-/*******************************************************************************\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.io.Serializable;\r
-\r
-public class RouteLink extends RoutePoint implements Serializable {\r
-\r
- private static final long serialVersionUID = 1446230300676765986L;\r
-\r
- RouteLine a;\r
- RouteLine b;\r
-\r
- /**\r
- * Default constructor for copy-method\r
- */\r
- private RouteLink() {\r
- }\r
- \r
- RouteLink(RouteLine a, RouteLine b) {\r
- this.a = a;\r
- this.b = b;\r
- a.addPoint(this);\r
- b.addPoint(this);\r
- }\r
- \r
- void removeFromOther(RouteLine other) {\r
- if(a == other)\r
- b.points.remove(this);\r
- else\r
- a.points.remove(this);\r
- }\r
-\r
- public RouteLine getA() {\r
- return a;\r
- }\r
- \r
- public RouteLine getB() {\r
- return b;\r
- }\r
-\r
- public void setA(RouteLine rl) {\r
- this.a = rl;\r
- rl.addPoint(this);\r
- if(b.isTransient())\r
- b.terminal.line = rl;\r
- }\r
- \r
- public void setB(RouteLine rl) {\r
- this.b = rl;\r
- rl.addPoint(this);\r
- if(a.isTransient())\r
- a.terminal.line = rl;\r
- }\r
-\r
- public RouteLine getOther(RouteLine line) {\r
- if(a == line)\r
- return b;\r
- else\r
- return a;\r
- }\r
-\r
- public void replace(RouteLine rl1, RouteLine rl2) {\r
- if(a == rl1)\r
- setA(rl2);\r
- else if(b == rl1)\r
- setB(rl2);\r
- }\r
-\r
- @Override\r
- RouteLink copy(THashMap<Object, Object> map) {\r
- RouteLink copy = (RouteLink)map.get(this);\r
- if(copy == null) {\r
- copy = new RouteLink();\r
- map.put(this, copy);\r
- copy.a = a.copy(map);\r
- copy.b = b.copy(map); \r
- copy.x = x;\r
- copy.y = y;\r
- }\r
- return copy;\r
- }\r
- \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2011 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.diagram.connection;
+
+import gnu.trove.map.hash.THashMap;
+
+import java.io.Serializable;
+
+public class RouteLink extends RoutePoint implements Serializable {
+
+ private static final long serialVersionUID = 1446230300676765986L;
+
+ RouteLine a;
+ RouteLine b;
+
+ /**
+ * Default constructor for copy-method
+ */
+ private RouteLink() {
+ }
+
+ RouteLink(RouteLine a, RouteLine b) {
+ this.a = a;
+ this.b = b;
+ a.addPoint(this);
+ b.addPoint(this);
+ }
+
+ void removeFromOther(RouteLine other) {
+ if(a == other)
+ b.points.remove(this);
+ else
+ a.points.remove(this);
+ }
+
+ public RouteLine getA() {
+ return a;
+ }
+
+ public RouteLine getB() {
+ return b;
+ }
+
+ public void setA(RouteLine rl) {
+ this.a = rl;
+ rl.addPoint(this);
+ if(b.isTransient())
+ b.terminal.line = rl;
+ }
+
+ public void setB(RouteLine rl) {
+ this.b = rl;
+ rl.addPoint(this);
+ if(a.isTransient())
+ a.terminal.line = rl;
+ }
+
+ public RouteLine getOther(RouteLine line) {
+ if(a == line)
+ return b;
+ else
+ return a;
+ }
+
+ public void replace(RouteLine rl1, RouteLine rl2) {
+ if(a == rl1)
+ setA(rl2);
+ else if(b == rl1)
+ setB(rl2);
+ }
+
+ @Override
+ RouteLink copy(THashMap<Object, Object> map) {
+ RouteLink copy = (RouteLink)map.get(this);
+ if(copy == null) {
+ copy = new RouteLink();
+ map.put(this, copy);
+ copy.a = a.copy(map);
+ copy.b = b.copy(map);
+ copy.x = x;
+ copy.y = y;
+ }
+ return copy;
+ }
+
+}