]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/BranchPointNode.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / g2d / nodes / BranchPointNode.java
index f1e5b2e25c7661cf2669cd57f97866c87dd6ece0..39db0e60c76749acf942d1f482096ef6c247769e 100644 (file)
-/*******************************************************************************\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.scenegraph.g2d.nodes;\r
-\r
-import java.awt.BasicStroke;\r
-import java.awt.Color;\r
-import java.awt.Graphics2D;\r
-import java.awt.Shape;\r
-import java.awt.Stroke;\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Ellipse2D;\r
-import java.awt.geom.Line2D;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-import org.simantics.scenegraph.g2d.G2DNode;\r
-import org.simantics.scenegraph.utils.NodeUtil;\r
-\r
-public class BranchPointNode extends G2DNode {\r
-    private static final long serialVersionUID = -5838113741617205901L;\r
-\r
-//    public static final Shape SHAPE = new Ellipse2D.Double(-.5, -.5, 1, 1);\r
-//    public static final Shape SHAPE2 = new Rectangle2D.Double(-.3, -.3, .6, .6);\r
-    public static final Shape SHAPE = new Ellipse2D.Double(-.5, -.5, 1, 1);\r
-    public static final Shape SHAPE2 = new Rectangle2D.Double(-.5, -.5, 1, 1);\r
-\r
-    public static final Stroke STROKE = new BasicStroke(0.1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);\r
-\r
-    Integer degree = 0;\r
-    // 0 == any, 1 == horizontal, 2 == vertical\r
-    Byte direction = 0;\r
-\r
-    @SyncField("degree")\r
-    public void setDegree(int degree) {\r
-        this.degree = degree;\r
-    }\r
-\r
-    @SyncField("direction")\r
-    public void setDirection(byte direction) {\r
-        this.direction = direction;\r
-    }\r
-\r
-    @Override\r
-    public void render(Graphics2D g) {\r
-        AffineTransform oldTransform = g.getTransform();\r
-        if (transform != null)\r
-            g.transform(transform);\r
-\r
-        try {\r
-            renderBranchpoint(g);\r
-        } finally {\r
-            g.setTransform(oldTransform);\r
-        }\r
-    }\r
-\r
-    private void renderBranchpoint(Graphics2D g) {\r
-        boolean selected = NodeUtil.isSelected(this, 2);\r
-        if (degree <= 2) {\r
-            if (selected) {\r
-                g.setPaint(Color.GREEN);\r
-                g.fill(SHAPE2);\r
-                g.setPaint(Color.BLACK);\r
-                g.setStroke(STROKE);\r
-                g.draw(SHAPE2);\r
-            } else {\r
-                //g.setPaint(new Color(128,128,128,64));\r
-                g.setPaint(Color.LIGHT_GRAY);\r
-                g.fill(SHAPE2);\r
-            }\r
-        } else {\r
-            if (selected) {\r
-                g.setPaint(Color.GREEN);\r
-                //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);\r
-                g.fill(SHAPE);\r
-                g.setPaint(Color.BLACK);\r
-                g.setStroke(STROKE);\r
-                g.draw(SHAPE);\r
-            } else {\r
-                g.setPaint(Color.BLACK);\r
-                //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);\r
-                g.fill(SHAPE);\r
-            }\r
-        }\r
-\r
-        if (direction != 0) {\r
-            g.setStroke(STROKE);\r
-            g.setColor(degree <= 2 ? Color.BLACK : (selected ? Color.BLACK : Color.GREEN));\r
-            if (direction == 1) {\r
-                // Horizontal\r
-                g.draw(new Line2D.Double(-.5, 0, .5, 0));\r
-            } else if (direction == 2) {\r
-                // Vertical\r
-                g.draw(new Line2D.Double(0, -.5, 0, .5));\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return super.toString() + " [degree=" + degree + "]";\r
-    }\r
-\r
-    @Override\r
-    public Rectangle2D getBoundsInLocal() {\r
-        Shape shp = SHAPE;\r
-        if (degree <= 2) {\r
-            shp = SHAPE2;\r
-        }\r
-        return shp.getBounds2D();\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.scenegraph.g2d.nodes;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.scenegraph.g2d.G2DNode;
+import org.simantics.scenegraph.utils.NodeUtil;
+
+public class BranchPointNode extends G2DNode {
+    private static final long serialVersionUID = -5838113741617205901L;
+
+//    public static final Shape SHAPE = new Ellipse2D.Double(-.5, -.5, 1, 1);
+//    public static final Shape SHAPE2 = new Rectangle2D.Double(-.3, -.3, .6, .6);
+    public static final Shape SHAPE = new Ellipse2D.Double(-.5, -.5, 1, 1);
+    public static final Shape SHAPE2 = new Rectangle2D.Double(-.5, -.5, 1, 1);
+
+    public static final Stroke STROKE = new BasicStroke(0.1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
+
+    Integer degree = 0;
+    // 0 == any, 1 == horizontal, 2 == vertical
+    Byte direction = 0;
+
+    @SyncField("degree")
+    public void setDegree(int degree) {
+        this.degree = degree;
+    }
+
+    @SyncField("direction")
+    public void setDirection(byte direction) {
+        this.direction = direction;
+    }
+
+    @Override
+    public void render(Graphics2D g) {
+        AffineTransform oldTransform = g.getTransform();
+        if (transform != null)
+            g.transform(transform);
+
+        try {
+            renderBranchpoint(g);
+        } finally {
+            g.setTransform(oldTransform);
+        }
+    }
+
+    private void renderBranchpoint(Graphics2D g) {
+        boolean selected = NodeUtil.isSelected(this, 2);
+        if (degree <= 2) {
+            if (selected) {
+                g.setPaint(Color.GREEN);
+                g.fill(SHAPE2);
+                g.setPaint(Color.BLACK);
+                g.setStroke(STROKE);
+                g.draw(SHAPE2);
+            } else {
+                //g.setPaint(new Color(128,128,128,64));
+                g.setPaint(Color.LIGHT_GRAY);
+                g.fill(SHAPE2);
+            }
+        } else {
+            if (selected) {
+                g.setPaint(Color.GREEN);
+                //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+                g.fill(SHAPE);
+                g.setPaint(Color.BLACK);
+                g.setStroke(STROKE);
+                g.draw(SHAPE);
+            } else {
+                g.setPaint(Color.BLACK);
+                //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+                g.fill(SHAPE);
+            }
+        }
+
+        if (direction != 0) {
+            g.setStroke(STROKE);
+            g.setColor(degree <= 2 ? Color.BLACK : (selected ? Color.BLACK : Color.GREEN));
+            if (direction == 1) {
+                // Horizontal
+                g.draw(new Line2D.Double(-.5, 0, .5, 0));
+            } else if (direction == 2) {
+                // Vertical
+                g.draw(new Line2D.Double(0, -.5, 0, .5));
+            }
+        }
+    }
+
+    @Override
+    public String toString() {
+        return super.toString() + " [degree=" + degree + "]";
+    }
+
+    @Override
+    public Rectangle2D getBoundsInLocal() {
+        Shape shp = SHAPE;
+        if (degree <= 2) {
+            shp = SHAPE2;
+        }
+        return shp.getBounds2D();
+    }
+}