static transient final BasicStroke STROKE = new BasicStroke(0.25f, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER);
- final transient Font FONT = Font.decode("Arial 12");
+ public final static Font DEFAULT_FONT = Font.decode("Arial 12");
protected boolean visible;
protected Rectangle2D textArea;
protected byte hAlign;
protected byte vAlign;
+ protected Font font = DEFAULT_FONT;
private transient final Point2D origin = new Point2D.Double();
private transient final Point2D xa = new Point2D.Double();
return visible;
}
- @SyncField({"visible", "flagShape", "flagText", "stroke", "border", "fill", "textColor", "width", "height", "direction", "beakAngle", "textSize", "hAlign", "vAlign"})
- public void init(Shape flagShape, String[] flagText, Stroke stroke, Color border, Color fill, Color textColor, float width, float height, double direction, float beakAngle, Rectangle2D textArea, int hAlign, int vAlign) {
+ @SyncField({"visible", "flagShape", "flagText", "stroke", "border", "fill", "textColor", "width", "height", "direction", "beakAngle", "textSize", "hAlign", "vAlign", "font"})
+ public void init(Shape flagShape, String[] flagText, Stroke stroke, Color border, Color fill, Color textColor, float width, float height, double direction, float beakAngle, Rectangle2D textArea, int hAlign, int vAlign, Font font) {
this.visible = true;
this.flagShape = flagShape;
this.flagText = flagText;
this.textArea = textArea;
this.hAlign = (byte) hAlign;
this.vAlign = (byte) vAlign;
+ this.font = font;
resetCaches();
}
}
// Paint flag text
- Font f = FONT;
- g.setFont(f);
+ g.setFont(font);
g.setColor(textColor);
AffineTransform orig = g.getTransform();
System.out.println("transform: " + g.getTransform());
}
- FontMetrics fm = g.getFontMetrics(f);
+ FontMetrics fm = g.getFontMetrics(font);
double fontHeight = fm.getHeight();
if (textLayout == null || (float) scale != lastViewScale)
textHeight = 0;
for (int i = 0; i < flagText.length; ++i) {
String txt = flagText[i].isEmpty() ? " " : flagText[i];
- textLayout[i] = new TextLayout(txt, f, frc);
+ textLayout[i] = new TextLayout(txt, font, frc);
rects[i] = textLayout[i].getBounds();
// If the bb height is not overridden with the font height