parse method

void parse(
  1. XmlElement rootElement
)

Parses XML attributes to configure this symbol rendering instruction.

Processes XML attributes such as symbol ID, bitmap source, positioning, rotation, and other styling parameters from the theme definition.

rootElement XML element containing the symbol instruction attributes

Implementation

void parse(XmlElement rootElement) {
  for (var element in rootElement.attributes) {
    String name = element.name.toString();
    String value = element.value;
    if (Renderinstruction.SRC == name) {
      bitmapSrc = value;
    } else if (Renderinstruction.DISPLAY == name) {
      display = MapDisplay.values.firstWhere((e) => e.toString().toLowerCase().contains(value));
    } else if (Renderinstruction.PRIORITY == name) {
      priority = int.parse(value);
    } else if (Renderinstruction.DY == name) {
      setDy(double.parse(value));
    } else if (Renderinstruction.SCALE == name) {
      setScaleFromValue(value);
    } else if (Renderinstruction.ID == name) {
      id = value;
    } else if (Renderinstruction.SYMBOL_HEIGHT == name) {
      setBitmapHeight(XmlUtils.parseNonNegativeInteger(name, value));
    } else if (Renderinstruction.SYMBOL_PERCENT == name) {
      setBitmapPercent(XmlUtils.parseNonNegativeInteger(name, value));
    } else if (Renderinstruction.SYMBOL_SCALING == name) {
      // no-op
    } else if (Renderinstruction.SYMBOL_WIDTH == name) {
      setBitmapWidth(XmlUtils.parseNonNegativeInteger(name, value));
    } else if (Renderinstruction.POSITION == name) {
      positioning = MapPositioning.values.firstWhere((e) => e.toString().toLowerCase().contains(value));
    } else {
      throw Exception("Parsing problems $name=$value");
    }
  }
}