X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.diagram.connection%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fconnection%2FRouteGraph.java;fp=bundles%2Forg.simantics.diagram.connection%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fconnection%2FRouteGraph.java;h=feaefeb69d15a251e46f8b2a7eb31dfd4460206b;hp=1905cfe2b2c172969e2883a5659a0d807a106761;hb=2b0fe692f116091f8d65da664174c92591a077b8;hpb=043ed4538f5bdc16d299bc40c2dd8285a3120f9b diff --git a/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteGraph.java b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteGraph.java index 1905cfe2b..feaefeb69 100644 --- a/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteGraph.java +++ b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteGraph.java @@ -45,6 +45,13 @@ public class RouteGraph implements Serializable { boolean isSimpleConnection; boolean needsUpdate = false; + public void updateTerminals() { + boolean changed = false; + for(RouteTerminal terminal : terminals) + changed |= terminal.updateDynamicPosition(); + if(changed) update(); + } + /** * Adds a route line to the graph. * @param isHorizontal true, if the line is horizontal @@ -78,21 +85,31 @@ public class RouteGraph implements Serializable { * * @param style Tells what kind of line end is drawn * to the connection. + * @param position a provider for a dynamic position for the terminal or + * null if terminal position is not dynamic * @return The new terminal. */ + public RouteTerminal addTerminal(double x, double y, + double minX, double minY, + double maxX, double maxY, + int allowedDirections, + ILineEndStyle style, RouteTerminalPosition position) { + return addTerminal(x, y, minX, minY, maxX, maxY, allowedDirections, style, null, position); + } + public RouteTerminal addTerminal(double x, double y, double minX, double minY, double maxX, double maxY, int allowedDirections, ILineEndStyle style) { - return addTerminal(x, y, minX, minY, maxX, maxY, allowedDirections, style, null); - + return addTerminal(x, y, minX, minY, maxX, maxY, allowedDirections, style, null, null); } + public RouteTerminal addTerminal(double x, double y, double minX, double minY, double maxX, double maxY, int allowedDirections, - ILineEndStyle style, ILineEndStyle dynamicStyle) { + ILineEndStyle style, ILineEndStyle dynamicStyle, RouteTerminalPosition position) { if(CHECK_PARAMERS) { if(allowedDirections > 0x1f) throw new IllegalArgumentException("Illegal allowedDirection flags."); @@ -102,7 +119,7 @@ public class RouteGraph implements Serializable { if(style == null) style = PlainLineEndStyle.INSTANCE; RouteTerminal terminal = new RouteTerminal(x, y, minX, minY, - maxX, maxY, allowedDirections, false, style); + maxX, maxY, allowedDirections, false, style, position); terminal.setDynamicStyle(dynamicStyle); terminals.add(terminal); return terminal; @@ -124,7 +141,7 @@ public class RouteGraph implements Serializable { 0.5*(minX+maxX), 0.5*(minY+maxY), minX, minY, maxX, maxY, - 0xf, true, style); + 0xf, true, style, null); terminal.setDynamicStyle(dynamicStyle); terminals.add(terminal); @@ -142,7 +159,7 @@ public class RouteGraph implements Serializable { ILineEndStyle style) { return addTerminal(x, y, bounds.getMinX(), bounds.getMinY(), bounds.getMaxX(), bounds.getMaxY(), - allowedDirections, style); + allowedDirections, style, null); } /** @@ -152,7 +169,7 @@ public class RouteGraph implements Serializable { RouteTerminal newTerminal = addTerminal(terminal.x, terminal.y, terminal.getMinX(), terminal.getMinY(), terminal.getMaxX(), terminal.getMaxY(), - terminal.getAllowedDirections(), terminal.getStyle(), terminal.getDynamicStyle()); + terminal.getAllowedDirections(), terminal.getStyle(), terminal.getDynamicStyle(), terminal.getDynamicPosition()); newTerminal.setData(terminal.getData()); return terminal; } @@ -166,7 +183,7 @@ public class RouteGraph implements Serializable { double maxX, double maxY, int allowedDirections) { return addTerminal(x, y, minX, minY, maxX, maxY, allowedDirections, - PlainLineEndStyle.INSTANCE); + PlainLineEndStyle.INSTANCE, null); } /**