addBGRectangle_ method
Adds a rectangle to the legend container legendArea with covers the same
space as the current legendArea size.
This will make the legend area visible to the user.
deltay
defines the current rectangle height (to which rectbordersize is added).
The following attributes from the legend attributes will apply: BG_OPACITY, BG_COLOR.
Implementation
void addBGRectangle_(int deltay) {
if (bgRectangle != null) {
bgRectangle.remove(); // remove the one from the last draw
}
bgRectangle = new RectElement();
int rectX = 0; // rel.to legendArea, rectY, rectWidth, rectHeight;
int rectY = 0; // rel.to legendArea, rectY, rectWidth, rectHeight;
// int rectWidth = legendArea.getBBox().width.round();
// at the very first call rendering is not complete, so use arbitrary value
// This could be made better: TODO number of text chars times "font-size"
int rectWidth = int.parse(attrMap[LEGEND_ID][LegA.BG_WIDTH]);
if (rectWidth == 0) return;
int rectHeight = int.parse(attrMap[LEGEND_ID][LegA.BG_HEIGTH]);
bgRectangle.attributes[SVG.X] = "$rectX";
bgRectangle.attributes[SVG.Y] = "$rectY";
bgRectangle.attributes[SVG.WIDTH] = "$rectWidth";
bgRectangle.attributes[SVG.HEIGHT] = "$rectHeight";
bgRectangle.attributes[SVG.FILL] = attrMap[LEGEND_ID][LegA.BG_COLOR];
bgRectangle.attributes[SVG.FILL_OPACITY] =
attrMap[LEGEND_ID][LegA.BG_OPACITY];
legendContainer.append(bgRectangle);
}