Repository navigation
SpeedometerIndicator JSON
This page describes the persisted format of the speedometer indicator in a project, in Mixel and in templates. For the user instructions on manually editing .vttp, see the page Speedometer JSON.
The indicator layer is saved in two modes:
-
toJSON(false)— the real Mixel state: the sensor is written assourceIdandsensorId, and the layer hassizeandpositionInParent. -
toJSON(true)— the template state: the sensor does not write thesourceIdandsensorIdkeys (the object is empty), andmaketis written instead ofsizeandpositionInParent. When a template is loaded, a suitable project sensor is selected automatically for theDistanceproperty.
The other properties (speedScale, colors, font, text template, background) are written identically in both modes.
The layer name is built from the plugin uid and the indicator name:
{
"name": "com.velitask.plagin.official.speedometer",
"data": {
"properties": {}
}
}Stable parts:
| Part | Value |
|---|---|
| plugin uid | com.velitask.plagin.official |
| indicator name | speedometer |
Besides properties, data contains the common layer fields (visibility, transparency, nested layers, etc.); they do not belong to the indicator and are not described here.
In a real Mixel the layer has size and positionInParent; the exact shape of their State fields is determined by the current runtime, so it is shown below in abbreviated form. The sensor stores the project source and sensor identifiers.
{
"name": "com.velitask.plagin.official.speedometer",
"data": {
"size": { "...": "layer size state" },
"positionInParent": { "...": "layer position state" },
"properties": {
"Distance": {
"sourceId": { "value": 1 },
"sensorId": { "value": 2 }
},
"speedScale": { "value": 2 },
"font": { "name": "Dialog", "style": 0, "size": 120, "color": { "r": 255, "g": 255, "b": 255, "a": 255 } },
"textTemplate": { "template": "{curr}", "vars": { "curr": "%.0f" } },
"scaleColor": { "r": 255, "g": 255, "b": 255, "a": 255 },
"arrowFillColor": { "r": 204, "g": 88, "b": 84, "a": 255 },
"arrowStrokeColor": { "r": 255, "g": 255, "b": 255, "a": 255 },
"tailColor": { "r": 103, "g": 136, "b": 166, "a": 178 },
"background": {
"color": { "r": 204, "g": 204, "b": 204, "a": 255 },
"transparency": {}
}
}
}
}The sourceId and sensorId numbers in the example are illustrative.
In a template, maket is written instead of size and positionInParent (when a template of a layer with a parent is written, it is the proportional preset with the fractions x, y, w, h; when reading, auto and fill are also accepted). The Distance property is empty.
{
"name": "com.velitask.plagin.official.speedometer",
"data": {
"maket": { "preset": "auto" },
"properties": {
"Distance": {},
"speedScale": { "value": 2 },
"font": { "name": "Dialog", "style": 0, "size": 120, "color": { "r": 255, "g": 255, "b": 255, "a": 255 } },
"textTemplate": { "template": "{curr}", "vars": { "curr": "%.0f" } },
"scaleColor": { "r": 255, "g": 255, "b": 255, "a": 255 },
"arrowFillColor": { "r": 204, "g": 88, "b": 84, "a": 255 },
"arrowStrokeColor": { "r": 255, "g": 255, "b": 255, "a": 255 },
"tailColor": { "r": 103, "g": 136, "b": 166, "a": 178 },
"background": {
"color": { "r": 204, "g": 204, "b": 204, "a": 255 },
"transparency": {}
}
}
}
}The values in the example are the initial values from the code. An untouched property may be written as an empty object: for example, the initial transparency has no saved value and returns 80 through getDefault(), so it gives {} when written; when reading, a missing key gives the same value 80.
The row order matches defineProperties().
| JSON key | Java property | SDK type | User meaning | Default |
|---|---|---|---|---|
Distance |
mDistance |
DistanceSensorProperty |
The distance sensor whose atom the speed is taken from. | Empty selection: {} in a template. |
speedScale |
mSpeedScale |
EnumArrayProperty<SpeedScale> |
Maximum of the scale. |
{"value":2} (160 km/h). |
font |
mText |
FontColorProperty |
Font and color of the number in the center. | Dialog, plain, 120, white. |
textTemplate |
mTemplate |
TextTemplateProperty |
Template of the number in the center. |
{curr}, format %.0f. |
scaleColor |
mScaleColor |
ColorProperty |
Color of the scale ticks and numbers. |
255, 255, 255, 255. |
arrowFillColor |
mArrowFillColor |
ColorProperty |
Needle fill. |
204, 88, 84, 255. |
arrowStrokeColor |
mArrowStrokeColor |
ColorProperty |
Stroke of the needle and the center dot. |
255, 255, 255, 255. |
tailColor |
mTailColor |
ColorProperty |
Color of the filled sector behind the needle. |
103, 136, 166, 178. |
background |
mBackground |
TransparentColorProperty |
Background color and its transparency. | Color 204, 204, 204, 255, transparency 80. |
Value formats:
-
Distance—sourceIdandsensorId, each of the form{"value": <long>}; in a template the object is empty. -
speedScale— the index of aSpeedScalevariant.
value |
Scale |
|---|---|
0 |
40 km/h |
1 |
80 km/h |
2 |
160 km/h |
3 |
320 km/h |
-
font— a flat object:name(string),style(0plain,1bold,2italic),size(integer 1–999) andcolor(r,g,b,ain the range 0–255). -
textTemplate—template(string) andvars(the format of each variable). There is one variable:curr. - Color properties — a flat object
r,g,b,a(0–255). -
background— a composite property: the nestedcolor(an objectr,g,b,a) andtransparency({"value": 0..100}; 0 is opaque, 100 is fully transparent). Background opacity when drawing:(100 - transparency) / 100.
The night skin is the only registered one. It rewrites the properties font (color only), background (color and transparency), scaleColor, arrowFillColor, arrowStrokeColor and tailColor; the text template does not change.
The values of the night skin, written as property states:
{
"font": { "name": "Dialog", "style": 0, "size": 120, "color": { "r": 170, "g": 170, "b": 170, "a": 255 } },
"scaleColor": { "r": 136, "g": 136, "b": 136, "a": 255 },
"arrowFillColor": { "r": 85, "g": 43, "b": 42, "a": 255 },
"arrowStrokeColor": { "r": 170, "g": 170, "b": 170, "a": 255 },
"tailColor": { "r": 51, "g": 68, "b": 85, "a": 170 },
"background": {
"color": { "r": 17, "g": 17, "b": 17, "a": 255 },
"transparency": { "value": 33 }
}
}-
VelitaskPlagin.getUID()(com.velitask.plagin.official) must not be changed without migrating saved projects. -
Indicator.getName()(speedometer) must not be changed without a migration. - The property names (
Distance,speedScale,font,textTemplate,scaleColor,arrowFillColor,arrowStrokeColor,tailColor,background) must not be renamed without a migration: loading goes by names. - The order of the
SpeedScaleelements defines thespeedScale.valuevalue: reordering or inserting in the middle changes the meaning of already saved projects. - Renaming a property is more dangerous than changing the order: the order mostly affects the interface, while the state is loaded by names.