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;
glm = context.get(GraphSynchronizationHints.GRAPH_LAYER_MANAGER);
}
- public static Optional<Resource> create(WriteGraph graph, Resource diagramResource, double[] start, double startElevation, double[] end, double endElevation, double padding) throws DatabaseException {
+ public static Optional<Resource> create(WriteGraph graph, Resource diagramResource, double[] start, double startElevation, double[] end, double endElevation, double[] detailedGeometryCoords, double padding) throws DatabaseException {
Collection<Resource> vertices = graph.syncRequest(new ObjectsWithType(diagramResource, Layer0.getInstance(graph).ConsistsOf, DistrictNetworkResource.getInstance(graph).Vertex));
double halfPadding = padding / 2;
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<Resource> 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<Resource> 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
}
// 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);
return 0;
}
- public void create(WriteGraph graph, double[] start, double startElevation, double[] end, double endElevation, double padding) throws DatabaseException {
-
- Optional<Resource> 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<Resource> 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());
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<ResourceVertex> vertices = (List<ResourceVertex>) result;
for (ResourceVertex vertx : vertices) {
Rectangle2D existing = new Rectangle2D.Double(vertx.coords[0] - halfPadding, vertx.coords[1] - halfPadding, padding, padding);
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 {