]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/model/Node.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.debug.graphical / src / org / simantics / debug / graphical / model / Node.java
index 8aa0319705d06abc3e73a4904d0dcae09d780cd2..95dd6379ebea0ed4ab4c5f78171b202ec851b0fa 100644 (file)
-package org.simantics.debug.graphical.model;\r
-\r
-import java.awt.Color;\r
-import java.awt.Font;\r
-import java.awt.Graphics2D;\r
-import java.awt.font.FontRenderContext;\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Point2D;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-public class Node {\r
-    public static final Font FONT = new Font("Arial", Font.PLAIN, 12);\r
-    public static final FontRenderContext FRC = \r
-            new FontRenderContext(new AffineTransform(), true, true);\r
-    public static final Rectangle2D MAX_BOUNDS = FONT.getMaxCharBounds(FRC);\r
-    public static final double FONT_HEIGHT = MAX_BOUNDS.getHeight();\r
-    \r
-    public static double PADDING = 3.0;\r
-    \r
-    NodeData data;       \r
-    Content content;\r
-    \r
-    double x;\r
-    double y;\r
-    \r
-    double radiusX;\r
-    double radiusY;\r
-    \r
-    // for layouter\r
-    public double forceX, forceY;\r
-    \r
-    public Node(NodeData data) {\r
-        this.data = data;\r
-    }\r
-\r
-    public void setContent(Content content) {\r
-        this.content = content;\r
-        this.radiusX = content.radiusX;\r
-        this.radiusY = content.radiusY;\r
-    }\r
-    \r
-    public NodeData getData() {\r
-        return data;\r
-    }\r
-    \r
-    public void setPos(double x, double y) {\r
-        this.x = x;\r
-        this.y = y;\r
-    }\r
-    \r
-    public void render(Graphics2D g) {\r
-        Rectangle2D rect = new Rectangle2D.Double(x-radiusX, y-radiusY, 2*radiusX, 2*radiusY);\r
-        g.setColor(new Color(200, 200, 255));\r
-        g.fill(rect);\r
-        g.setColor(Color.BLACK);\r
-        \r
-        if(content != null)\r
-            content.render(g, x, y);\r
-        \r
-        g.draw(rect);\r
-    }\r
-    \r
-    public Point2D clipLineFromCenter(double targetX, double targetY) {\r
-        targetX -= x;\r
-        targetY -= y;\r
-        if(radiusX * Math.abs(targetY) < radiusY * Math.abs(targetX)) {\r
-            return new Point2D.Double(\r
-                    x+Math.signum(targetX)*radiusX, \r
-                    y+targetY * radiusX / Math.abs(targetX));\r
-        }\r
-        else {\r
-            return new Point2D.Double(                     \r
-                    x+targetX * radiusY / Math.abs(targetY),\r
-                    y+Math.signum(targetY)*radiusY);\r
-        }\r
-    }\r
-    \r
-    public boolean pick(double px, double py) {\r
-        return Math.abs(px - x) <= radiusX && Math.abs(py - y) <= radiusY; \r
-    }\r
-\r
-    public double getX() {\r
-        return x;\r
-    }\r
-    \r
-    public double getY() {\r
-        return y;\r
-    }\r
-    \r
-    public double getMinX() {\r
-        return x - radiusX;\r
-    }\r
-    \r
-    public double getMinY() {\r
-        return y - radiusY;\r
-    }\r
-    \r
-    public double getMaxX() {\r
-        return x + radiusX;\r
-    }\r
-    \r
-    public double getMaxY() {\r
-        return y + radiusY;\r
-    }\r
-}\r
+package org.simantics.debug.graphical.model;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.font.FontRenderContext;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+public class Node {
+    public static final Font FONT = new Font("Arial", Font.PLAIN, 12);
+    public static final FontRenderContext FRC = 
+            new FontRenderContext(new AffineTransform(), true, true);
+    public static final Rectangle2D MAX_BOUNDS = FONT.getMaxCharBounds(FRC);
+    public static final double FONT_HEIGHT = MAX_BOUNDS.getHeight();
+    
+    public static double PADDING = 3.0;
+    
+    NodeData data;       
+    Content content;
+    
+    double x;
+    double y;
+    
+    double radiusX;
+    double radiusY;
+    
+    // for layouter
+    public double forceX, forceY;
+    
+    public Node(NodeData data) {
+        this.data = data;
+    }
+
+    public void setContent(Content content) {
+        this.content = content;
+        this.radiusX = content.radiusX;
+        this.radiusY = content.radiusY;
+    }
+    
+    public NodeData getData() {
+        return data;
+    }
+    
+    public void setPos(double x, double y) {
+        this.x = x;
+        this.y = y;
+    }
+    
+    public void render(Graphics2D g) {
+        Rectangle2D rect = new Rectangle2D.Double(x-radiusX, y-radiusY, 2*radiusX, 2*radiusY);
+        g.setColor(new Color(200, 200, 255));
+        g.fill(rect);
+        g.setColor(Color.BLACK);
+        
+        if(content != null)
+            content.render(g, x, y);
+        
+        g.draw(rect);
+    }
+    
+    public Point2D clipLineFromCenter(double targetX, double targetY) {
+        targetX -= x;
+        targetY -= y;
+        if(radiusX * Math.abs(targetY) < radiusY * Math.abs(targetX)) {
+            return new Point2D.Double(
+                    x+Math.signum(targetX)*radiusX, 
+                    y+targetY * radiusX / Math.abs(targetX));
+        }
+        else {
+            return new Point2D.Double(                     
+                    x+targetX * radiusY / Math.abs(targetY),
+                    y+Math.signum(targetY)*radiusY);
+        }
+    }
+    
+    public boolean pick(double px, double py) {
+        return Math.abs(px - x) <= radiusX && Math.abs(py - y) <= radiusY; 
+    }
+
+    public double getX() {
+        return x;
+    }
+    
+    public double getY() {
+        return y;
+    }
+    
+    public double getMinX() {
+        return x - radiusX;
+    }
+    
+    public double getMinY() {
+        return y - radiusY;
+    }
+    
+    public double getMaxX() {
+        return x + radiusX;
+    }
+    
+    public double getMaxY() {
+        return y + radiusY;
+    }
+}