Repository navigation
SpeedTextIndicator JSON
This page describes the saved (persisted) format of the speedText indicator in a project, in Mixel, and in templates. For the user guide to manual .vttp editing, see the page Speed Text JSON.
The indicator layer is saved in two modes:
-
toJSON(false)is the real Mixel state: the sensor is written assourceIdandsensorId, and the layer hassizeandpositionInParent. -
toJSON(true)is the template state: the sensor'ssourceIdandsensorIdkeys are not written (the object is empty), andmaketis written instead ofsizeandpositionInParent. When a template is loaded, a suitable project speed sensor is picked automatically for theSpeedproperty.
The other properties are written the same way in both modes.
{
"name": "com.velitask.plagin.official.speedText",
"data": {
"properties": {}
}
}| Part | Value |
|---|---|
| plugin uid | com.velitask.plagin.official |
| indicator name | speedText |
Besides properties, data holds the common layer fields (visibility, transparency, nested layers, etc.); they do not belong to the indicator and are not described here.
The shape of size and positionInParent is defined by the current runtime, so it is shown in abbreviated form. The sourceId and sensorId numbers in the example are arbitrary.
{
"name": "com.velitask.plagin.official.speedText",
"data": {
"size": { "...": "layer size state" },
"positionInParent": { "...": "layer position state" },
"properties": {
"Speed": {
"sourceId": { "value": 1 },
"sensorId": { "value": 3 }
},
"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 }, "speed": { "value": "KMH" } },
"textTemplate": { "template": "{currNum} {currUnit}", "vars": { "currNum": "%.1f", "currUnit": "%s" } }
}
}
}{
"name": "com.velitask.plagin.official.speedText",
"data": {
"maket": { "preset": "auto" },
"properties": {
"Speed": {},
"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 }, "speed": { "value": "KMH" } },
"textTemplate": { "template": "{currNum} {currUnit}", "vars": { "currNum": "%.1f", "currUnit": "%s" } }
}
}
}The values are the initial values from the code. When a template is written in the toJSON(true) mode, maket is the proportional preset with the fractions x, y, w, h; auto and fill are also accepted when reading.
The row order matches defineProperties().
| JSON key | Java property | SDK type | Meaning for the user | Default |
|---|---|---|---|---|
Speed |
mSpeed |
SpeedAtomProperty |
Speed sensor. | Empty selection: {} in a template. |
font |
mText |
FontColorProperty |
Text font and color. | Dialog, plain, 48, white. |
textAlign |
mTextAlign |
TextAlignProperty |
Text alignment in the layer. |
{"value":4} (CENTER). |
measurement |
mUnits |
MeasurementProperty |
Measurement system, format, and speed unit. |
system 0, format 0, speed "KMH". |
textTemplate |
mTemplate |
TextTemplateProperty |
Line template with two variables. |
{currNum} {currUnit}. |
Value formats:
-
SpeedhassourceIdandsensorId, each of the form{"value": <long>}; in a template the object is empty. -
fontis a flat object:name(string),style(0plain,1bold,2italic),size(integer 1-999),color(r,g,b,ain the range 0-255). -
textAlignis{"value": 0..8}:0TOP_LEFT,1TOP_CENTER,2TOP_RIGHT,3CENTER_LEFT,4CENTER,5CENTER_RIGHT,6BOTTOM_LEFT,7BOTTOM_CENTER,8BOTTOM_RIGHT. A value out of range is treated asCENTER_LEFT. -
measurementis a composite property without aunitkey. The child keys in order:system,format,speed.
| Key | Type | Values |
|---|---|---|
system |
{"value": int} |
0 from global settings, 1 metric, 2 imperial, 3 nautical, 4 mixed |
format |
{"value": int} |
0 full, 1 normal, 2 short, 3 symbol |
speed |
{"value": string} |
SpeedUnit name: KMH, MPS, MPH, KNOTS, FPS
|
The allowed units depend on system: for metric, KMH, MPS; for imperial, MPH, FPS; for nautical, KNOTS, MPS; for mixed, all five. A name that is not in the allowed list is read as the first unit of the list. Choosing system from 1 to 3 sets the default unit (KMH, MPH, KNOTS); if the saved unit differs from it, the system automatically switches to "mixed" (4). While system is 0, speed is not used: the unit is taken from the general application settings.
The initial state of format is index 0 (full format), although the property's getDefault() returns "normal" (NORMAL).
-
textTemplatehastemplate(string) andvars(the format of each variable:currNum,currUnit). The values are passed tomakeTextin the ordercurrNum,currUnit.
The compact skin changes only template to {currNum}{currUnit}.
Knots, short format, compact text:
{
"measurement": { "system": { "value": 3 }, "format": { "value": 2 }, "speed": { "value": "KNOTS" } },
"textTemplate": { "template": "{currNum}{currUnit}", "vars": { "currNum": "%.1f", "currUnit": "%s" } }
}Here system.value = 3 selects the nautical system, speed is knots, and format.value = 2 is the short label (kn).
-
VelitaskPlagin.getUID()(com.velitask.plagin.official) must not be changed without migrating saved projects. -
Indicator.getName()(speedText) must not be changed without migration. - Property names (
Speed,font,textAlign,measurement,textTemplate) must not be renamed without migration: loading goes by names. - Template variable names (
currNum,currUnit) and the order of values inmakeTextare part of the saved format. - Renaming a property is more dangerous than changing the order: the order mostly affects the UI.