if (locationStyle == null) {
locationStyle = new Rectangle(-1, -1, -1, -1);
blackboard.put(LocationStyleContent.ID, locationStyle);
}
FontStyle fontStyle = (FontStyle) blackboard.get(FontStyleContent.ID);
if (fontStyle == null) {
fontStyle = new FontStyle();
blackboard.put(FontStyleContent.ID, fontStyle);
}
this.backgroundColour = legendStyle.backgroundColor;
this.foregroundColour = legendStyle.foregroundColor;
this.fontColour = legendStyle.fontColor;
this.isRounded = legendStyle.isRoundedRectangle;
this.horizontalMargin = 5;
this.verticalMargin = 5;
this.horizontalSpacing = 3;
this.verticalSpacing = 3;
this.indentSize = 5;
this.boxHeight = legendStyle.boxWidth;
this.boxWidth = legendStyle.boxWidth;
this.maxHeight = legendStyle.legendHeight;
this.maxWidth = legendStyle.legendWidth;
locationStyle.x = legendStyle.xPos;
locationStyle.y = legendStyle.yPos;
final ViewportGraphics graphics = context.getGraphics();
GC gc = graphics.getGraphics(GC.class);
if (gc != null) {
gc.setAntialias(SWT.ON);
}
final int rowHeight = Math.max(boxHeight, graphics.getFontHeight()); // space allocated to
// each layer
Font oldFont = fontStyle.getFont();
int fontHeight = rowHeight < 12 ? 8 : rowHeight - 8;
Font font = new Font(oldFont.getName(), fontStyle.getFont().getStyle(), fontHeight);
if (font != null) {
graphics.setFont(font);
} else {
graphics.setFont(fontStyle.getFont());
}
List<Map<ILayer, FeatureTypeStyle[]>> layers = new ArrayList<Map<ILayer, FeatureTypeStyle[]>>();
int longestRow = 0; // used to calculate the width of the graphic