]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RoutePoint.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.diagram.connection / src / org / simantics / diagram / connection / RoutePoint.java
diff --git a/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RoutePoint.java b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RoutePoint.java
new file mode 100644 (file)
index 0000000..70450e9
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************\r
+ * Copyright (c) 2011 Association for Decentralized Information Management in\r
+ * 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.diagram.connection;\r
+\r
+import gnu.trove.map.hash.THashMap;\r
+\r
+import java.util.Comparator;\r
+\r
+public abstract class RoutePoint {\r
+    \r
+    public static final Comparator<RoutePoint> X_COMPARATOR = new Comparator<RoutePoint>() {\r
+        @Override\r
+        public int compare(RoutePoint a, RoutePoint b) {\r
+            return Double.compare(a.x, b.x);\r
+        }\r
+    };\r
+    \r
+    public static final Comparator<RoutePoint> Y_COMPARATOR = new Comparator<RoutePoint>() {\r
+        @Override\r
+        public int compare(RoutePoint a, RoutePoint b) {\r
+            return Double.compare(a.y, b.y);\r
+        }\r
+    };\r
+    \r
+    double x;\r
+    double y;\r
+\r
+    public RoutePoint() {\r
+    }\r
+    \r
+    public RoutePoint(double x, double y) {\r
+        this.x = x;\r
+        this.y = y;\r
+    }\r
+    \r
+    public double getX() {\r
+        return x;\r
+    }\r
+    \r
+    public double getY() {\r
+        return y;\r
+    }\r
+\r
+    void removeFromOther(RouteLine routeLine) {\r
+    }\r
+\r
+    public boolean isNear(double x2, double y2, double tolerance) {\r
+        double dx = x2-x;\r
+        double dy = y2-y;\r
+        \r
+        return dx*dx + dy*dy <= tolerance*tolerance;\r
+    }\r
+\r
+       abstract RoutePoint copy(THashMap<Object, Object> map);\r
+       \r
+       \r
+       public void setX(double x) {\r
+               this.x = x;\r
+       }\r
+       \r
+       public void setY(double y) {\r
+               this.y = y;\r
+       }\r
+}\r