--- /dev/null
+/*******************************************************************************\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