From: niemisto Date: Mon, 18 Jun 2012 11:22:58 +0000 (+0000) Subject: Changed sysdyn to use new routing mode X-Git-Tag: simantics-1.7~25 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=8c093887681f9dbc2d0108e0e7540f7dc8726472;p=simantics%2Fsysdyn.git Changed sysdyn to use new routing mode refs #3279 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@25199 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowArrowLineStyle.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowArrowLineStyle.java index 885b75b5..47120e94 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowArrowLineStyle.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowArrowLineStyle.java @@ -15,7 +15,6 @@ import java.awt.Color; import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.awt.geom.Path2D; -import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.StringTokenizer; @@ -39,16 +38,13 @@ public class FlowArrowLineStyle implements ILineEndStyle, Serializable { protected Path2D path; protected double lineEndLength; - protected Rectangle2D bounds = new Rectangle2D.Double(); - - public FlowArrowLineStyle(String desc, Rectangle2D bounds) { + public FlowArrowLineStyle(String desc) { this.type = ArrowType.None; this.lineEndLength = 0.0; double l = length; double w = width; double s = space; - this.bounds = bounds; StringTokenizer tokenizer = new StringTokenizer(desc); if (tokenizer.hasMoreTokens()) { @@ -80,23 +76,6 @@ public class FlowArrowLineStyle implements ILineEndStyle, Serializable { public void render(Graphics2D g, double x, double y, int dir) { if (type == ArrowType.None || path == null) return; - // Calculate coordinates to the border of the terminal - switch(dir) { - case 0: - x = bounds.getMinX(); - break; - case 1: - y = bounds.getMinY(); - break; - case 2: - x = bounds.getMaxX(); - break; - case 3: - y = bounds.getMaxY(); - break; - default: - return; - } AffineTransform old = g.getTransform(); g.translate(x, y); g.rotate(dir*Math.PI*0.5); @@ -116,20 +95,6 @@ public class FlowArrowLineStyle implements ILineEndStyle, Serializable { @Override public double getLineEndLength(int direction) { - switch(direction) { - case 0: - lineEndLength = bounds.getWidth() / 2.0; - break; - case 1: - lineEndLength = bounds.getHeight() / 2.0; - break; - case 2: - lineEndLength = bounds.getWidth() / 2.0; - break; - case 3: - lineEndLength = bounds.getHeight() / 2.0; - break; - } return lineEndLength; } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java index df190df7..e30d2578 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java @@ -234,7 +234,7 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { // Expand bounds by 4mm to make the connections enter the terminals // at a straight angle and from a distance instead of coming in // "horizontally". - GeometryUtils.expandRectangle(bounds, 4); + //GeometryUtils.expandRectangle(bounds, 4); minx = bounds.getMinX(); miny = bounds.getMinY(); @@ -271,14 +271,9 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { direction = 0xf; //System.out.println("load line style: " + NameUtils.getSafeLabel(graph, attachmentRelation)); - ILineEndStyle endStyle = loadLineEndStyle(graph, te, attachmentRelation, new Rectangle2D.Double( - bounds.getX(), - bounds.getY(), - bounds.getWidth(), - bounds.getHeight()) - ); - - RouteTerminal routeTerminal = rg.addTerminal(x, y, minx, miny, maxx, maxy, direction, endStyle); + ILineEndStyle endStyle = loadLineEndStyle(graph, te, attachmentRelation); + + RouteTerminal routeTerminal = rg.addBigTerminal(/*x, y,*/ minx, miny, maxx, maxy, /*direction,*/ endStyle); routeTerminal.setData( RouteGraphConnection.serialize(graph, connector) ); nodes.add( connector ); @@ -377,20 +372,17 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { return null; } - public ILineEndStyle loadLineEndStyle(ReadGraph graph, IElement te, Resource attachmentRelation, Rectangle2D bounds) + public ILineEndStyle loadLineEndStyle(ReadGraph graph, IElement te, Resource attachmentRelation) throws DatabaseException { ILineEndStyle style; // TODO: change bounds according to terminal type: Very small rectangle for Valves, Text box size for Stocks and Clouds if(te.getElementClass().containsClass(ValveSceneGraph.class)) { - GeometryUtils.expandRectangle(bounds, -4); - style = new FlowArrowLineStyle("none 0 0 0", bounds); + style = new FlowArrowLineStyle("none 0 0 0"); } else { if (graph.isSubrelationOf(attachmentRelation, DIA.HasHeadConnector)) { - GeometryUtils.expandRectangle(bounds, -2.5); - style = new FlowArrowLineStyle("fill 2 2 -1.5", bounds); + style = new FlowArrowLineStyle("fill 2 2 0"); } else { - GeometryUtils.expandRectangle(bounds, -4); - style = new FlowArrowLineStyle("none 0 0 0", bounds); + style = new FlowArrowLineStyle("none 0 0 0"); } } return style;