addMarkerText method

void addMarkerText (int xs, int ys)

Adds a text to the polyline in the polyline's color from attrPyA.MARKER_TEXT, if present, at the screen position xs, ys. If the text is appended right of the polyline it requires that the user extended polyAttrPyA.INSETX by the length of the text in pixels.

Implementation

void addMarkerText(int xs, int ys) {
  if (polylineMarker != null) polylineMarker.remove();
  if (attr[PyA.MARKER_TEXT] == null || attr[PyA.MARKER_TEXT].isEmpty) return;
  polylineMarker = TextElement();
  polylineMarker.text = attr[PyA.MARKER_TEXT];
  int fontsize = int.parse(attr[PyA.MARKER_FONTSIZE]);
  SVG.setAttr(polylineMarker, {
    "x": "${xs + 8}",
    "y": "${ys + fontsize ~/ 4}",
    SVG.FONT_SIZE: "${fontsize}",
    SVG.FILL: attr[PyA.STROKE],
    SVG.STROKE: "none",
  });
  polylineContainer.append(polylineMarker);
}