createPointShape method

GeometryElement createPointShape (int mxs, int mys, String shape)

Creates a point shape for the screen position mxs, mys with the geometric form shape.

Implementation

GeometryElement createPointShape(int mxs, int mys, String shape) {
  GeometryElement pointShape;
  String stroke = attr[PyA.POINT_LIST_STROKE], fill = "white";
  if (stroke == null) {
    stroke = attr[PyA.STROKE]; // use polyline stroke
  }
  if (shape == POLYLINE_POINT_SHAPE_SQUARE_EMPTY) {
    int width = 8, height = width;
    pointShape = RectElement();
    SVG.setAttr(pointShape, {
      "x": "${mxs + width / ~2}", // center the square
      "y": "${mys + height / ~2}",
      "width": "$width",
      "height": "$height",
      SVG.STROKE: "$stroke",
      SVG.FILL: "$fill"
    });
  } else if (shape == POLYLINE_POINT_SHAPE_CIRCLE_EMPTY) {
    int radius = 6;
    pointShape = CircleElement();
    SVG.setAttr(pointShape, {
      "cx": "${mxs}",
      "cy": "${mys}",
      "r": "$radius",
      SVG.STROKE: "$stroke",
      SVG.FILL: "$fill"
    });
  }
  return pointShape;
}