]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/TextPainter.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / impl / TextPainter.java
index 0ee4d3a8b604ba34ac8114453d02e4feae5d353b..8b6002efbc23707d26a96ed18b6a1db747dd8c99 100644 (file)
@@ -1,79 +1,79 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.g2d.element.handler.impl;\r
-\r
-import java.awt.Color;\r
-import java.awt.Font;\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-import org.simantics.g2d.element.ElementUtils;\r
-import org.simantics.g2d.element.IElement;\r
-import org.simantics.g2d.element.SceneGraphNodeKey;\r
-import org.simantics.g2d.element.handler.InternalSize;\r
-import org.simantics.g2d.element.handler.SceneGraph;\r
-import org.simantics.g2d.element.handler.Text;\r
-import org.simantics.scenegraph.Node;\r
-import org.simantics.scenegraph.g2d.G2DParentNode;\r
-import org.simantics.scenegraph.g2d.nodes.TextNode;\r
-import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
-\r
-/**\r
- * @author Toni Kalajainen\r
- */\r
-public class TextPainter implements SceneGraph {\r
-\r
-    /**\r
-     * \r
-     */\r
-    private static final long serialVersionUID = -4156239790629253738L;\r
-    \r
-    static final Font FONT = Font.decode("Arial 6");\r
-\r
-    public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");\r
-\r
-    @Override\r
-    public void cleanup(IElement e) {\r
-        Node node = e.removeHint(SG_NODE);\r
-        if (node != null)\r
-            node.remove();\r
-    }\r
-\r
-    @Override\r
-    public void init(IElement e, G2DParentNode parent) {\r
-        TextNode node = (TextNode) e.getHint(SG_NODE);\r
-        if (node == null) {\r
-            node = parent.addNode(TextNode.class);\r
-            e.setHint(SG_NODE, node);\r
-        }\r
-\r
-        Color bc = ElementUtils.getTextColor(e, Color.BLACK);\r
-        InternalSize b = e.getElementClass().getSingleItem(InternalSize.class);\r
-        Rectangle2D r = b.getBounds(e, null);\r
-        if (r ==  null)\r
-            return;\r
-        Text t = e.getElementClass().getAtMostOneItemOfClass(Text.class);\r
-        if (t == null)\r
-            return;\r
-        String text = t.getText(e);\r
-        if (text == null)\r
-            return;\r
-        AffineTransform at = ElementUtils.getTransform(e);\r
-        \r
-        node.setFont(FONT);\r
-        node.setColor(bc);\r
-        node.setBounds(r);\r
-        node.setText(text);\r
-        node.setTransform(at);\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.g2d.element.handler.impl;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.g2d.element.ElementUtils;
+import org.simantics.g2d.element.IElement;
+import org.simantics.g2d.element.SceneGraphNodeKey;
+import org.simantics.g2d.element.handler.InternalSize;
+import org.simantics.g2d.element.handler.SceneGraph;
+import org.simantics.g2d.element.handler.Text;
+import org.simantics.scenegraph.Node;
+import org.simantics.scenegraph.g2d.G2DParentNode;
+import org.simantics.scenegraph.g2d.nodes.TextNode;
+import org.simantics.utils.datastructures.hints.IHintContext.Key;
+
+/**
+ * @author Toni Kalajainen
+ */
+public class TextPainter implements SceneGraph {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -4156239790629253738L;
+    
+    static final Font FONT = Font.decode("Arial 6");
+
+    public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE");
+
+    @Override
+    public void cleanup(IElement e) {
+        Node node = e.removeHint(SG_NODE);
+        if (node != null)
+            node.remove();
+    }
+
+    @Override
+    public void init(IElement e, G2DParentNode parent) {
+        TextNode node = (TextNode) e.getHint(SG_NODE);
+        if (node == null) {
+            node = parent.addNode(TextNode.class);
+            e.setHint(SG_NODE, node);
+        }
+
+        Color bc = ElementUtils.getTextColor(e, Color.BLACK);
+        InternalSize b = e.getElementClass().getSingleItem(InternalSize.class);
+        Rectangle2D r = b.getBounds(e, null);
+        if (r ==  null)
+            return;
+        Text t = e.getElementClass().getAtMostOneItemOfClass(Text.class);
+        if (t == null)
+            return;
+        String text = t.getText(e);
+        if (text == null)
+            return;
+        AffineTransform at = ElementUtils.getTransform(e);
+        
+        node.setFont(FONT);
+        node.setColor(bc);
+        node.setBounds(r);
+        node.setText(text);
+        node.setTransform(at);
+    }
+
+}