Skip to content

DistanceTextIndicator JSON

roosit edited this page Oct 16, 2026 · 1 revision

DistanceTextIndicator JSON

Up | Code | Русский

Purpose

This page describes the saved (persisted) format of the distanceText indicator in a project, in Mixel, and in templates. For the user guide to manual .vttp editing, see the page Distance Text JSON.

Two save modes

The indicator layer is saved in two modes:

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

The other properties are written the same way in both modes.

Common indicator wrapper

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

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.

Real mixel state

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.distanceText",
  "data": {
    "size": { "...": "layer size state" },
    "positionInParent": { "...": "layer position state" },
    "properties": {
      "Distance": {
        "sourceId": { "value": 1 },
        "sensorId": { "value": 2 }
      },
      "valueText": { "name": "Dialog", "style": 0, "size": 48, "color": { "r": 255, "g": 255, "b": 255, "a": 255 } },
      "unitFont": { "name": "Dialog", "style": 0, "size": 28 },
      "textAlign": { "value": 4 },
      "measurement": { "system": { "value": 0 }, "format": { "value": 0 }, "distance": { "value": "MM" } },
      "textTemplate": {
        "template": "{currNum} {currUnit} of {fullNum} {fullUnit}",
        "vars": { "currNum": "%.2f", "currUnit": "%s", "fullNum": "%.0f", "fullUnit": "%s" }
      }
    }
  }
}

Template state

{
  "name": "com.velitask.plagin.official.distanceText",
  "data": {
    "maket": { "preset": "auto" },
    "properties": {
      "Distance": {},
      "valueText": { "name": "Dialog", "style": 0, "size": 48, "color": { "r": 255, "g": 255, "b": 255, "a": 255 } },
      "unitFont": { "name": "Dialog", "style": 0, "size": 28 },
      "textAlign": { "value": 4 },
      "measurement": { "system": { "value": 0 }, "format": { "value": 0 }, "distance": { "value": "MM" } },
      "textTemplate": {
        "template": "{currNum} {currUnit} of {fullNum} {fullUnit}",
        "vars": { "currNum": "%.2f", "currUnit": "%s", "fullNum": "%.0f", "fullUnit": "%s" }
      }
    }
  }
}

The values are the initial values from the code. The default template string comes from the plugin localization, so it depends on the UI language (in the Russian locale it is "из", in the English one of). 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.

Properties

The row order matches defineProperties().

JSON key Java property SDK type Meaning for the user Default
Distance mDistanceSensor DistanceSensorProperty Distance sensor. Empty selection: {} in a template.
valueText mValueText FontColorProperty Text font and color ("Value font"). Dialog, plain, 48, white.
unitFont mUnitFont FontProperty Unit font ("Unit font"); not used in render(). Dialog, plain, 28.
textAlign mTextAlign TextAlignProperty Text alignment in the layer. {"value":4} (CENTER).
measurement mUnits MeasurementProperty Measurement system, format, and distance unit. system 0, format 0, distance "MM".
textTemplate mTemplate TextTemplateProperty Line template with four variables. {currNum} {currUnit} of {fullNum} {fullUnit}.

Value formats:

  • Distance has sourceId and sensorId, each of the form {"value": <long>}; in a template the object is empty.
  • valueText and unitFont are a flat font object: name (string), style (0 plain, 1 bold, 2 italic), size (integer 1-999); valueText additionally has color (r, g, b, a in the range 0-255).
  • textAlign is {"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 is a composite property without a unit key. The child keys in order: system, format, distance.
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
distance {"value": string} DistanceUnit name: MM, CM, M, KM, IN, FT, YD, MI, NM

The allowed units depend on system: for metric, KM, M, CM, MM; for imperial, MI, YD, FT, IN; for nautical, NM, YD, FT; for mixed, all nine. 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 (KM, MI, NM); if the saved unit differs from it, the system automatically switches to "mixed" (4). While system is 0, distance is not used: the unit is picked automatically to fit the value.

The initial state of format is index 0 (full format), although the property's getDefault() returns "normal" (NORMAL).

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

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

Examples

Metric system, meters, symbol format, compact text:

{
  "measurement": { "system": { "value": 1 }, "format": { "value": 3 }, "distance": { "value": "M" } },
  "textTemplate": { "template": "{currNum} {currUnit}", "vars": { "currNum": "%.0f", "currUnit": "%s", "fullNum": "%.0f", "fullUnit": "%s" } }
}

Here system.value = 1 selects the metric system, distance is meters, and format.value = 3 is the symbol label (m).

Compatibility

  • VelitaskPlagin.getUID() (com.velitask.plagin.official) must not be changed without migrating saved projects.
  • Indicator.getName() (distanceText) must not be changed without migration.
  • Property names (Distance, valueText, unitFont, textAlign, measurement, textTemplate) must not be renamed without migration: loading goes by names.
  • Template variable names (currNum, currUnit, fullNum, fullUnit) and the order of values in makeText are part of the saved format.
  • Renaming a property is more dangerous than changing the order: the order mostly affects the UI.

Clone this wiki locally