X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2Fnodes%2FNetworkDrawingNode.java;h=71ccb781a1f1a0b0bf74df1d14430a5937a6e6db;hb=985b0e7fb25091941011286a135731ad44809633;hp=b2c157184f07cf0c96b9eb342b3dc438f7cf53b8;hpb=02ecca5e61d2eb17de40cc058be678b414aaad00;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/NetworkDrawingNode.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/NetworkDrawingNode.java index b2c15718..71ccb781 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/NetworkDrawingNode.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/NetworkDrawingNode.java @@ -134,9 +134,13 @@ public class NetworkDrawingNode extends G2DNode { while (nodeIter.hasNext()) { if (end == null) { start = nodeIter.next(); + if (!nodeIter.hasNext()) { + break; + } } else { start = end; } + end = nodeIter.next(); createEdge(start, end); @@ -163,13 +167,14 @@ public class NetworkDrawingNode extends G2DNode { * String str = formatValue(val); */ // TODO: fix scale - double scale = 100000; -// double scale = 1; - double startLat = ModelledCRS.yToLatitude(start.getY() / scale); - double startLon = ModelledCRS.xToLongitude(start.getX() / scale); + double scaleY = getTransform().getScaleY(); + double scaleX = getTransform().getScaleX(); + + double startLat = ModelledCRS.yToLatitude(-start.getY() / scaleY); + double startLon = ModelledCRS.xToLongitude(start.getX() / scaleX); - double endLat = ModelledCRS.yToLatitude(end.getY() / scale); - double endLon = ModelledCRS.xToLongitude(end.getX() / scale); + double endLat = ModelledCRS.yToLatitude(-end.getY() / scaleY); + double endLon = ModelledCRS.xToLongitude(end.getX() / scaleX); double[] startCoords = new double[] { startLon, startLat }; double[] endCoords = new double[] { endLon, endLat }; @@ -179,7 +184,7 @@ public class NetworkDrawingNode extends G2DNode { @Override public void perform(WriteGraph graph) throws DatabaseException { - builder.create(graph, startCoords, endCoords, padding / scale); + builder.create(graph, startCoords, endCoords, 1 / padding); } });