addSelectionIcon method
Adds a selection rectangle at xs, ys
of polylineContainer
If xs
is null, the last rectangle is redrawn if there was one.
Implementation
void addSelectionIcon(int xs, int ys) {
if (selectionIcon != null) {
selectionIcon.remove(); // already there
}
if (xs == null) {
if (xselectionIcon != null && yselectionIcon != null) // redraw last
{
xs = xselectionIcon;
ys = yselectionIcon;
} else {
if (xsLast != null && ysLast != null) {
xs = xsLast;
ys = ysLast;
} else {
return; // no valid coordinates
}
}
}
int width = int.parse(attr[PyA.SELECTION_ICON_WIDTH]), height = width;
// PyA.SELECTION_ICON_OUTSIDE is false e.g. for integrals
if (attr[PyA.SELECTION_ICON_OUTSIDE] == Utils.TRUE &&
xs > dataAreaWidth - insetx ~/ 2) {
xs = dataAreaWidth -
width; // make sure icon remains visible inside data area
}
xselectionIcon = xs + 2;
yselectionIcon = ys - height ~/ 2;
String stroke = attr[PyA.STROKE], fill = "white";
if (isSelected) {
fill = attr[PyA.STROKE];
}
selectionIcon = RectElement();
SVG.setAttr(selectionIcon, {
"x": "$xselectionIcon",
"y": "$yselectionIcon",
"width": "$width",
"height": "$height",
SVG.STROKE: "$stroke",
SVG.FILL: "$fill"
});
polylineContainer.append(selectionIcon);
}