Skip to content

SpeedTextIndicator JSON

roosit edited this page Nov 15, 2026 · 2 revisions

SpeedTextIndicator JSON

Up | Code | Русский

Purpose

This page describes the persisted format of the speedText indicator in a project, in Mixel and in templates. For the user instructions on manually editing .vttp, see the page Speed Text JSON.

Two save modes

The indicator layer is saved in two modes:

  • toJSON(false): the real Mixel state: the sensor is written as sourceId and sensorId, and the layer has size and positionInParent.
  • toJSON(true): the template state: the sensor does not write the sourceId and sensorId keys (the object is empty), and maket is written instead of size and positionInParent. When a template is loaded, suitable project sensors are selected automatically for the Speed and Distance properties.

The other properties are written identically in both modes.

Common indicator wrapper

{
  "name": "com.velitask.plagin.official.speedText",
  "data": {
    "properties": {}
  }
}
Part Value
plugin uid com.velitask.plagin.official
indicator name speedText

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.

Real mixel state

The shape of size and positionInParent is determined 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 }
      },
      "Distance": {
        "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 }, "speed": { "value": "KMH" } },
      "textTemplate": { "template": "{currNum} {currUnit}", "vars": { "currNum": "%.1f", "currUnit": "%s" } }
    }
  }
}

Template state

{
  "name": "com.velitask.plagin.official.speedText",
  "data": {
    "maket": { "preset": "auto" },
    "properties": {
      "Speed": {},
      "Distance": {},
      "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, maket in the toJSON(true) mode is the proportional preset with the shares x, y, w, h; auto and fill are also accepted on reading.

Properties

The order of the rows matches defineProperties().

JSON key Java property SDK type User meaning Default
Speed mSpeed SpeedAtomProperty The speed sensor. An empty choice: {} in the template.
Distance mDistance DistanceSensorProperty The fallback distance sensor ("Distance"): the speed is taken from it if the Speed sensor is not selected. An empty choice: {} in the template.
font mText FontColorProperty The font and the color of the text. Dialog, plain, 48, white.
textAlign mTextAlign TextAlignProperty The alignment of the text in the layer. {"value":4} (CENTER).
measurement mUnits MeasurementProperty The measurement system, the format and the speed unit. system 0, format 0, speed "KMH".
textTemplate mTemplate TextTemplateProperty A string template with two variables. {currNum} {currUnit}.

Value formats:

  • Speed and Distance: sourceId and sensorId, each of the form {"value": <long>}; in a template the object is empty.
  • font: a flat object: name (string), style (0 plain, 1 bold, 2 italic), size (an integer 1-999), color (r, g, b, a in the range 0-255).
  • textAlign: {"value": 0..8}: 0 TOP_LEFT, 1 TOP_CENTER, 2 TOP_RIGHT, 3 CENTER_LEFT, 4 CENTER, 5 CENTER_RIGHT, 6 BOTTOM_LEFT, 7 BOTTOM_CENTER, 8 BOTTOM_RIGHT. A value out of range is treated as CENTER_LEFT.
  • measurement: a composite property without a unit key. 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} the 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 outside 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 (the full format), although getDefault() of the property returns "normal" (NORMAL).

  • textTemplate: template (a string) and vars (the format of each variable: currNum, currUnit). The values are passed to makeText in the order currNum, currUnit.

The compact skin changes only template to {currNum}{currUnit}.

Examples

Knots, the short format, a 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 selects knots, and format.value = 2 selects the short caption (kn).

Compatibility

  • VelitaskPlagin.getUID() (com.velitask.plagin.official) must not be changed without a migration of the saved projects.
  • Indicator.getName() (speedText) must not be changed without a migration.
  • The property names (Speed, Distance, font, textAlign, measurement, textTemplate) must not be renamed without a migration: loading goes by names.
  • The names of the template variables (currNum, currUnit) and the order of the values in makeText are part of the saved format.
  • Renaming a property is more dangerous than changing the order: the order mostly affects the interface.

Clone this wiki locally