Color borderColor = ElementUtils.getBorderColor(e, Color.BLACK);\r
String text = ElementUtils.getText(e);\r
AffineTransform at = ElementUtils.getTransform(e);\r
+ Alignment hAlign = ElementUtils.getHintOrDefault(e, ElementHints.KEY_HORIZONTAL_ALIGN, horizontalAlignment);\r
node.init(text, font, color, originX, originY, 0.235);\r
node.setBackgroundColor(fillColor);\r
node.setBorderColor(borderColor);\r
- node.setHorizontalAlignment((byte) horizontalAlignment.ordinal());\r
+ node.setHorizontalAlignment((byte) hAlign.ordinal());\r
node.setPadding(paddingX, paddingY);\r
node.setBorderWidth((float) borderWidth);\r
node.setEditable(editable);\r
import java.util.Collection;\r
\r
import org.simantics.db.Resource;\r
+import org.simantics.diagram.elements.TextNode;\r
import org.simantics.g2d.element.ElementClass;\r
import org.simantics.g2d.element.ElementHints;\r
import org.simantics.g2d.element.ElementUtils;\r
private IHintListener hoverHintListener;\r
\r
public ValveSceneGraph() {\r
- super(0, VALVE_SIZE + 3.0, Alignment.CENTER);\r
+// super(0, VALVE_SIZE + 3.0, Alignment.CENTER); // Move with affine transformation in init()\r
+ super(0, 0, Alignment.CENTER);\r
}\r
@Override\r
public void init(IElement e, G2DParentNode parent) {\r
Boolean hover = e.getHint(ElementHints.KEY_HOVER); \r
node.setHover(hover != null ? hover : false);\r
\r
- if(at != null)\r
+ if(at != null) {\r
node.setTransform(at);\r
\r
+ // Use affinetransform to move the name of the valve below the valve symbol\r
+ TextNode name = (TextNode) e.getHint(SG_NODE);\r
+ if(name != null) {\r
+ AffineTransform at2 = (AffineTransform) at.clone();\r
+ at2.translate(0, VALVE_SIZE + 3.0);\r
+ name.setTransform(at2);\r
+ }\r
+ }\r
+\r
hoverHintListener = new IHintListener() {\r
\r
@Override\r