Skip to content

SlopeTextIndicator JSON

roosit edited this page Oct 16, 2026 · 1 revision

SlopeTextIndicator JSON

Up | Code | Русский

Purpose

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.

Two save modes

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. For Slope, 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.

Common indicator wrapper

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

Real mixel state

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.

Template state

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.

Properties

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:

  • font is a flat object: name (string), style (number: 0 plain, 1 bold, 2 italic), size (1..999) and a nested color (r, g, b, a, 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.
  • measurement is a composite property with the children system, format, distance, altitude, because the indicator declares the kinds DISTANCE and ALTITUDE.
    • system.value is an index: 0 from global settings, 1 metric, 2 imperial, 3 nautical, 4 mixed.
    • format.value is the index of the unit label format: 0 full, 1 normal, 2 short, 3 symbol. Although MeasurementProperty declares NORMAL as the default, the real initial value in the state is 0 (full).
    • distance.value is a string with the DistanceUnit name (MM, CM, M, KM, IN, FT, YD, MI, NM); in a template with system 0 it is "MM" (the first item of the list), and the value is not used until a system is selected.
    • altitude.value is an index: 0 meters, 1 feet.
  • textTemplate is an object with template (string) and vars (variable name → format). The "Short" and "Detailed" skins change only template.

Examples

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"
        }
      }
    }
  }
}

Compatibility

  • 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 the makeText(...) arguments in render(); 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_groups table, which supplies the section data, is not part of the indicator JSON (see SlopeGroupAtom).

Clone this wiki locally