Repository navigation
SlopeTextIndicator JSON
This page describes the persisted format of the slopeText ("Slope Text") indicator in a project, a Mixel and templates. For the user guide on editing .vttp by hand, see Slope Text JSON.
The indicator is saved in two modes:
-
toJSON(false)is the real Mixel state: it contains the selected source/sensor, the current property values, and the layer size and position. -
toJSON(true)is the template state: it contains only the values that can be carried between projects. ForSlope, the source and sensor are not written and the object stays empty{}; when the indicator is added from a template, the runtime picks the slope sensor automatically.
The layer identifier is built from the plugin uid and the indicator name:
{
"name": "com.velitask.plagin.official.slopeText",
"data": {
"properties": {}
}
}Stable parts:
| Part | Value |
|---|---|
| plugin uid | com.velitask.plagin.official |
| indicator name | slopeText |
In a real Mixel, next to properties the runtime stores the layer geometry: size, position and binding to the parent. The exact shape of these State fields depends on the current runtime, so they are shown in abbreviated form.
{
"name": "com.velitask.plagin.official.slopeText",
"data": {
"size": { "...": "layer size state" },
"positionInParent": { "...": "layer position state" },
"properties": {
"Slope": {
"sourceId": { "value": 1 },
"sensorId": { "value": 2 }
},
"font": {
"name": "Dialog",
"style": 0,
"size": 48,
"color": { "r": 255, "g": 255, "b": 255, "a": 255 }
},
"textAlign": { "value": 4 },
"measurement": {
"system": { "value": 0 },
"format": { "value": 0 },
"distance": { "value": "MM" },
"altitude": { "value": 0 }
},
"textTemplate": {
"template": "{type} {pc}% ({curr}{currUnit} / {length}{lengthUnit})",
"vars": { "...": "see the section \"Template state\"" }
}
}
}
}The sourceId and sensorId values are identifiers from a specific project.
A template uses maket, and Slope stays empty. This is the real output of toJSON(true) for a freshly created indicator; the template string is given for the English locale (the value comes from localization).
{
"name": "com.velitask.plagin.official.slopeText",
"data": {
"maket": { "preset": "auto" },
"properties": {
"Slope": {},
"font": {
"name": "Dialog",
"style": 0,
"size": 48,
"color": { "r": 255, "g": 255, "b": 255, "a": 255 }
},
"textAlign": { "value": 4 },
"measurement": {
"system": { "value": 0 },
"format": { "value": 0 },
"distance": { "value": "MM" },
"altitude": { "value": 0 }
},
"textTemplate": {
"template": "{type} {pc}% ({curr}{currUnit} / {length}{lengthUnit})",
"vars": {
"type": "%s",
"typec": "%s",
"pc": "%.1f",
"curr": "%.3f",
"currUnit": "%s",
"length": "%.2f",
"lengthUnit": "%s",
"height": "%.0f",
"heightUnit": "%s",
"ele": "%.0f",
"eleUnit": "%s",
"eleCurr": "%.1f",
"up": "%.0f",
"down": "%.0f"
}
}
}
}
}The indicator declares no figures.
The order of rows matches defineProperties().
| JSON key | Java property | SDK type | User meaning | Default |
|---|---|---|---|---|
Slope |
mSlope |
SlopeAtomProperty |
The slope sensor ("Slope"). | Empty selection: {} in a template. |
font |
mText |
FontColorProperty |
Text font and color ("Font"). |
Dialog, style 0, size 48, white. |
textAlign |
mTextAlign |
TextAlignProperty |
Text alignment ("Text Alignment"). |
4 (center), range 0..8. |
measurement |
mUnits |
MeasurementProperty |
Units of distance and altitude ("Units"). | system 0, format 0, distance "MM", altitude 0. |
textTemplate |
mTemplate |
TextTemplateProperty |
A text template with slope variables ("Text Template"). |
{type} {pc}% ({curr}{currUnit} / {length}{lengthUnit}) (English locale). |
State formats:
-
fontis a flat object:name(string),style(number:0plain,1bold,2italic),size(1..999) and a nestedcolor(r,g,b,a,0..255). -
textAlignis{ "value": 0..8 }:0top left,1top center,2top right,3center left,4center,5center right,6bottom left,7bottom center,8bottom right. -
measurementis a composite property with the childrensystem,format,distance,altitude, because the indicator declares the kindsDISTANCEandALTITUDE.-
system.valueis an index:0from global settings,1metric,2imperial,3nautical,4mixed. -
format.valueis the index of the unit label format:0full,1normal,2short,3symbol. AlthoughMeasurementPropertydeclaresNORMALas the default, the real initial value in the state is0(full). -
distance.valueis a string with theDistanceUnitname (MM,CM,M,KM,IN,FT,YD,MI,NM); in a template with system0it is"MM"(the first item of the list), and the value is not used until a system is selected. -
altitude.valueis an index:0meters,1feet.
-
-
textTemplateis an object withtemplate(string) andvars(variable name → format). The "Short" and "Detailed" skins change onlytemplate.
A short label with the type and percent, metric system, output in the top left:
{
"name": "com.velitask.plagin.official.slopeText",
"data": {
"maket": { "preset": "auto" },
"properties": {
"Slope": {},
"font": {
"name": "Dialog",
"style": 1,
"size": 64,
"color": { "r": 255, "g": 255, "b": 255, "a": 255 }
},
"textAlign": { "value": 0 },
"measurement": {
"system": { "value": 1 },
"format": { "value": 2 },
"distance": { "value": "KM" },
"altitude": { "value": 0 }
},
"textTemplate": {
"template": "{typec} {pc}%",
"vars": {
"type": "%s",
"typec": "%s",
"pc": "%.1f",
"curr": "%.3f",
"currUnit": "%s",
"length": "%.2f",
"lengthUnit": "%s",
"height": "%.0f",
"heightUnit": "%s",
"ele": "%.0f",
"eleUnit": "%s",
"eleCurr": "%.1f",
"up": "%.0f",
"down": "%.0f"
}
}
}
}
}-
VelitaskPlagin.getUID()(com.velitask.plagin.official) must not be changed without a migration of saved projects. -
Indicator.getName()(slopeText) must not be changed without a migration. - Property names (
Slope,font,textAlign,measurement,textTemplate) and template variable names must not be renamed without a migration. - The order of variables in
defineVars()matches the order of themakeText(...)arguments inrender(); reordering them without changing the call at the same time would shift the values. - The order of properties mostly affects the UI, while loading of the persisted state goes by name; renaming is more dangerous than reordering.
- The
slope_groupstable, which supplies the section data, is not part of the indicator JSON (see SlopeGroupAtom).