X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2FDNEdgeBuilder.java;h=92a6187b59c7975fb70d4789c0e14eb88bcc686a;hb=1c4f571d010b7439e006e411f3661a50ee6a4400;hp=7ed99c363be31a83dd139534f08b71be812b33d3;hpb=d4d53a3987be0c2b771c8093b7e8c2286738a6c8;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DNEdgeBuilder.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DNEdgeBuilder.java index 7ed99c36..92a6187b 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DNEdgeBuilder.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DNEdgeBuilder.java @@ -1,7 +1,6 @@ package org.simantics.district.network.ui; import java.awt.geom.Rectangle2D; -import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Optional; @@ -46,7 +45,7 @@ public class DNEdgeBuilder { glm = context.get(GraphSynchronizationHints.GRAPH_LAYER_MANAGER); } - public static Optional create(WriteGraph graph, Resource diagramResource, double[] start, double startElevation, double[] end, double endElevation, double padding) throws DatabaseException { + public static Optional create(WriteGraph graph, Resource diagramResource, double[] start, double startElevation, double[] end, double endElevation, double[] detailedGeometryCoords, double padding) throws DatabaseException { Collection vertices = graph.syncRequest(new ObjectsWithType(diagramResource, Layer0.getInstance(graph).ConsistsOf, DistrictNetworkResource.getInstance(graph).Vertex)); double halfPadding = padding / 2; @@ -60,11 +59,10 @@ public class DNEdgeBuilder { Envelope e = new Envelope(x1, x2, y1, y2); vv.insert(e, new ResourceVertex(vertex, coords, false)); } - return create(graph, vv, diagramResource, null, start, startElevation, end, endElevation, padding, false); + return create(graph, vv, diagramResource, null, start, startElevation, end, endElevation, detailedGeometryCoords, padding, false); } - public static Optional create(WriteGraph graph, Quadtree vertices, Resource diagramResource, Resource mapping, double[] start, double startElevation, double[] end, double endElevation, double padding, boolean writeElevationToEdgeFromPoints) throws DatabaseException { - + public static Optional create(WriteGraph graph, Quadtree vertices, Resource diagramResource, Resource mapping, double[] start, double startElevation, double[] end, double endElevation, double[] detailedGeometryCoords, double padding, boolean writeElevationToEdgeFromPoints) throws DatabaseException { DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); // 2. Add vertices @@ -76,7 +74,7 @@ public class DNEdgeBuilder { } // 1. Get diagram edge to construct - Resource edge = getOrCreateEdge(graph, diagramResource, mapping); + Resource edge = getOrCreateEdge(graph, diagramResource, mapping, detailedGeometryCoords); if (writeElevationToEdgeFromPoints) { graph.claimLiteral(edge, DN.Edge_HasElevation, calculateElevationFromVertices(graph, startVertex, endVertex), Bindings.DOUBLE); @@ -108,9 +106,8 @@ public class DNEdgeBuilder { return 0; } - public void create(WriteGraph graph, double[] start, double startElevation, double[] end, double endElevation, double padding) throws DatabaseException { - - Optional edge = create(graph, diagramResource, start, startElevation, end, endElevation, padding); + public void create(WriteGraph graph, double[] start, double startElevation, double[] end, double endElevation, double[] detailedGeometryCoords, double padding) throws DatabaseException { + Optional edge = create(graph, diagramResource, start, startElevation, end, endElevation, detailedGeometryCoords, padding); // 7. Put the element on all the currently active layers if possible. if (glm != null) { putOnActiveLayer(graph, edge.get()); @@ -135,7 +132,8 @@ public class DNEdgeBuilder { double y2= coords[1] + halfPadding; Envelope e = new Envelope(x1, x2, y1, y2); - List result = qtree.query(e); + List result = qtree.query(e); + @SuppressWarnings("unchecked") List vertices = (List) result; for (ResourceVertex vertx : vertices) { Rectangle2D existing = new Rectangle2D.Double(vertx.coords[0] - halfPadding, vertx.coords[1] - halfPadding, padding, padding); @@ -155,8 +153,8 @@ public class DNEdgeBuilder { return vertex; } - private static Resource getOrCreateEdge(WriteGraph graph, Resource diagramResource, Resource mapping) throws DatabaseException { - return DistrictNetworkUtil.createEdge(graph, diagramResource, mapping); + private static Resource getOrCreateEdge(WriteGraph graph, Resource diagramResource, Resource mapping, double[] detailedGeometryCoords) throws DatabaseException { + return DistrictNetworkUtil.createEdge(graph, diagramResource, mapping, detailedGeometryCoords); } public static class ResourceVertex {