Skip to content

ImageIndicator JSON

roosit edited this page Oct 16, 2026 · 1 revision

ImageIndicator JSON

Up | Code | Русский

Purpose

This page describes the persisted format of the image indicator in a project, in a Mixel and in templates. For the user instruction on manual .vttp editing see the page Image JSON.

Two save modes

The indicator is saved in two modes:

  • toJSON(false) is the real state of a Mixel: the selected image source, the current property values, and the size and position of the layer.
  • toJSON(true) is a template: property values without a binding to a project and the description of the layer placement (maket). ImageSourceProperty.toJSON(true) returns an empty object, so the selected source does not get into a template.

Common indicator wrapper

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

Real mixel state

In a real Mixel the size and position of the layer are stored next to properties. The exact form of these State fields depends on the current runtime, so an abbreviated structure is shown; the properties are shown in full.

{
  "name": "com.velitask.plagin.official.image",
  "data": {
    "size": { "...": "layer size state" },
    "positionInParent": { "...": "layer position state" },
    "properties": {
      "imageSource": {"sourceId": {"value": 7}},
      "adaptive": {"value": false},
      "fit": {"value": 0},
      "border": {
        "lineColor": {"r": 255, "g": 255, "b": 255, "a": 255},
        "thickness": {},
        "style": {"value": 0},
        "dashPattern": {"value": ""},
        "cornerRadius": {}
      }
    }
  }
}

sourceId is the identifier of the source inside the project; 0 or a missing key means "no source selected".

Template state

In a template, maket is written instead of size and positionInParent. When a template is exported from the application, the layer is written with a proportional maket (preset: "proportional" with the fractions x, y, w, h); by hand you can set auto: the placement is taken from defineMaket(...) - the bottom right corner, a margin of 50 on the right and at the bottom, a size of 480×270. There is no source in a template: imageSource is an empty object.

{
  "name": "com.velitask.plagin.official.image",
  "data": {
    "maket": { "preset": "auto" },
    "properties": {
      "imageSource": {},
      "adaptive": {"value": false},
      "fit": {"value": 0},
      "border": {
        "lineColor": {"r": 255, "g": 255, "b": 255, "a": 255},
        "thickness": {},
        "style": {"value": 0},
        "dashPattern": {"value": ""},
        "cornerRadius": {}
      }
    }
  }
}

Properties

The order of the rows matches defineProperties().

JSON key Java property SDK type Meaning for the user Default
imageSource mImage ImageSourceProperty The selected image of the project. Not selected; {} in a template.
adaptive mAdaptive BooleanProperty Pick the source automatically by the current time. false
fit mFit FitModeProperty How the image fits into the layer. 0 (COVER)
border mBorder BorderProperty A border around the image. White, thickness 1, solid, radius 0.

imageSource

Key Values Meaning
sourceId.value integer, 0 means not selected Identifier of the image source in the project. Saved only in the real state.

Only sources of the "image" type are allowed. With adaptive = false the saved sourceId is used; with adaptive = true it is the image source of the project whose time interval contains the current time (if there are several, the one that started later wins). Sources have no sensorId key.

adaptive

BooleanProperty is saved as {"value": true|false}.

fit

FitModeProperty (EnumArrayProperty<FitMode>) saves the index of the FitMode element as {"value": N}.

value FitMode Behavior
0 COVER Fill the layer keeping proportions; the excess is cropped.
1 CONTAIN Fit entirely; margins are possible.
2 FILL Stretch over the whole layer without keeping proportions.
3 NONE Own size, centered.

An index out of range is read as 0.

border

BorderProperty is a composite property: LineProperty plus a corner radius. Each child key is stored as a separate object.

Key SDK type Format Default Meaning
lineColor ColorProperty {"r","g","b","a"}, each 0..255 white 255,255,255,255 Border color (a is opacity, 255 is opaque).
thickness ThicknessProperty {"value": N} 1 Thickness in pixels, range 0..50; 0 means no border.
style EnumArrayProperty<LineStyle> {"value": N} 0 (SOLID) Line style: 0 SOLID, 1 DASH, 2 DOT, 3 DASH_DOT, 4 DASH_DOT_DOT, 5 LONG_DASH, 6 SHORT_DASH, 7 CUSTOM.
dashPattern StringProperty {"value": "12,6"} "" Dash pattern for CUSTOM.
cornerRadius CornerRadiusProperty {"value": N} 0 Corner radius in pixels, range 0..500.

ImageIndicator.render() uses only lineColor, thickness and cornerRadius; style and dashPattern are saved and edited but do not affect drawing. The ranges are applied when a value is set from the interface; when JSON is read, the value is not clamped to the range. For thickness and cornerRadius the default value (1 and 0) is written in a template as an empty object {} (the value key is absent); when loaded, such an object gives the default value. In the real state of a Mixel, {"value": N} is written after the value has been changed.

The "Framed" and "Rounded" skins change only lineColor (white), thickness (4 / 0) and cornerRadius (0 / 30).

Examples

A logo without a border, fitted entirely:

{
  "name": "com.velitask.plagin.official.image",
  "data": {
    "maket": { "preset": "auto" },
    "properties": {
      "imageSource": {},
      "adaptive": {"value": false},
      "fit": {"value": 1},
      "border": {
        "lineColor": {"r": 255, "g": 255, "b": 255, "a": 255},
        "thickness": {"value": 0},
        "style": {"value": 0},
        "dashPattern": {"value": ""},
        "cornerRadius": {}
      }
    }
  }
}

Compatibility

  • VelitaskPlagin.getUID() (com.velitask.plagin.official) must not be changed without a migration of saved projects.
  • Indicator.getName() (image) must not be changed without a migration.
  • The names of the properties (imageSource, adaptive, fit, border) must not be renamed without a migration: loading goes by names, and renaming is more dangerous than reordering.
  • The names of the child keys of border are defined by the SDK and must also stay stable.
  • The indexes of fit and style are the ordinals of the constants of FitMode and LineStyle; the order of the constants must not be changed.

Clone this wiki locally