X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Fg2d%2Fnodes%2FFlagNode.java;h=598e130091391303febf5b14cbe039e4bda3ef2e;hp=4468996fb81d57e995bcc0c34162feb94e672cd8;hb=6b0f2d47b9137d0f92e30b50175195ee878485bc;hpb=c486ef9e73c4c4e1ca0392bfba326641fde35e2e diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/FlagNode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/FlagNode.java index 4468996fb..598e13009 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/FlagNode.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/FlagNode.java @@ -49,7 +49,7 @@ public class FlagNode extends G2DNode { 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; @@ -66,6 +66,7 @@ public class FlagNode extends G2DNode { 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(); @@ -85,8 +86,8 @@ public class FlagNode extends G2DNode { 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; @@ -101,6 +102,7 @@ public class FlagNode extends G2DNode { this.textArea = textArea; this.hAlign = (byte) hAlign; this.vAlign = (byte) vAlign; + this.font = font; resetCaches(); } @@ -165,8 +167,7 @@ public class FlagNode extends G2DNode { } // Paint flag text - Font f = FONT; - g.setFont(f); + g.setFont(font); g.setColor(textColor); AffineTransform orig = g.getTransform(); @@ -240,7 +241,7 @@ public class FlagNode extends G2DNode { 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) @@ -254,7 +255,7 @@ public class FlagNode extends G2DNode { 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