]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/profile/TextGridStyle.java
Better support for ontological profiles
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / profile / TextGridStyle.java
index d660d47a5be007f7e33acd9349c820cd1d1c7615..54972155d8d69579294e4d6e49718a453e14e66d 100644 (file)
@@ -94,7 +94,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                String name = graph.getPossibleRelatedValue(config, getPropertyRelation(graph,element), Bindings.STRING);
                return name;
        }
-       
+
        public AffineTransform getTransform(INode node, AffineTransform parentTransform, Rectangle2D elementBounds, int location, boolean up) {
                return getTransform(parentTransform, elementBounds, location, up);
        }
@@ -110,7 +110,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                at.scale(0.15, 0.15);
 
                return at;
-               
+
        }
 
        protected String rowId() {
@@ -161,7 +161,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
 
                        String value2 = result != null ? result.getText2() : null;
                        String value3 = result != null ? result.getText3() : null;
-                       
+
                        double spacing = result.getSpacing();
 
                        final Function1<String, String> modifier = result != null ? result.getModifier() : null;
@@ -209,7 +209,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                        node.setCache(1, row, result);
 
                        boolean isConnection = _node instanceof ConnectionNode;
-                       
+
                        Rectangle2D elementBounds = isConnection ? EMPTY_BOUNDS : NodeUtil.getLocalElementBounds(_node);
                        if(elementBounds == null) {
                                new Exception("Cannot get local element bounds for node " + _node.toString()).printStackTrace();
@@ -225,14 +225,14 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                        Vec2d offset = result.getOffset();
 
                        Point2D[] cellOffsets = getCellOffsets();
-                       
+
                        AffineTransform at1 = new AffineTransform(at);
                        at1.translate(cellOffsets[0].getX(),cellOffsets[0].getY());
                        AffineTransform at2 = new AffineTransform(at);
                        at2.translate(cellOffsets[1].getX()+spacing,cellOffsets[1].getY());
                        AffineTransform at3 = new AffineTransform(at);
                        at3.translate(cellOffsets[2].getX()+spacing,cellOffsets[2].getY());
-                       
+
                        at1.translate(offset.x, offset.y);
                        at2.translate(offset.x, offset.y);
                        at3.translate(offset.x, offset.y);
@@ -251,7 +251,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                                node.setHorizontalAlignment(2, row, (byte) getAlignment(2).ordinal());
                                node.setHorizontalAlignment(3, row, (byte) getAlignment(3).ordinal());
                        }
-                       
+
                        Alignment[] verticalAlignments = result.getVerticalAlignments();
                        if(verticalAlignments != null) {
                                node.setVerticalAlignment(1, row, (byte) verticalAlignments[0].ordinal());
@@ -266,11 +266,13 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                        node.setZIndex(3000);
 
                        org.simantics.common.color.Color color = result.getColor();
-                       java.awt.Color awtColor = color != null ? Colors.awt(color) : Color.DARK_GRAY;
+                       Color awtColor = color != null ? Colors.awt(color) : Color.DARK_GRAY;
+                       Color bgColor = getBackgroundColor();
+                       Font font = getFont();
 
-                       setTextNodeData(node, 1, row, value, FONT, awtColor, BACKGROUND_COLOR);
-                       setTextNodeData(node, 2, row, value2, result.getPending(), FONT, awtColor, BACKGROUND_COLOR);
-                       setTextNodeData(node, 3, row, value3, FONT, awtColor, BACKGROUND_COLOR);
+                       setTextNodeData(node, 1, row, value, font, awtColor, bgColor);
+                       setTextNodeData(node, 2, row, value2, result.getPending(), font, awtColor, bgColor);
+                       setTextNodeData(node, 3, row, value3, font, awtColor, bgColor);
 
                        node.setEditable(1, row, false);
                        node.setForceEventListening(2, row, true);
@@ -309,7 +311,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
 
                        node.setInputValidator(2, row, validator);
                        node.setTranslator(translator);
-                       
+
                        node.setRVI(2, row, rvi);
 
                        postProcessNode(node, row);
@@ -336,6 +338,14 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                node.setPending(x, y, pending);
        }
 
+       protected Font getFont() {
+               return FONT;
+       }
+
+       protected Color getBackgroundColor() {
+               return BACKGROUND_COLOR;
+       }
+
        protected Alignment getAlignment(int column) {
                switch(column) {
                case 1: return Alignment.TRAILING;