import java.lang.reflect.InvocationTargetException;
import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import org.apache.commons.csv.CSVRecord;
import org.simantics.databoard.Bindings;
import org.simantics.db.Resource;
import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.ObjectsWithType;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.request.Write;
+import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.district.imports.DistrictImportUtils;
import org.simantics.district.network.DistrictNetworkUtil;
import org.simantics.district.network.ontology.DistrictNetworkResource;
import org.simantics.district.network.ui.DNEdgeBuilder;
-import org.simantics.maps.MapScalingTransform;
+import org.simantics.district.network.ui.DNEdgeBuilder.ResourceVertex;
+import org.simantics.layer0.Layer0;
import org.simantics.utils.ui.ExceptionUtils;
public class CSVImportWizard extends Wizard implements IImportWizard {
public CSVImportWizard() {
setWindowTitle("Import CSV data");
+ setNeedsProgressMonitor(true);
}
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- monitor.beginTask("Importing CSV", 1000);
try {
Path csvFile = model.getSource();
char delim = model.getDelimiter();
List<CSVRecord> rows = DistrictImportUtils.readRows(csvFile, delim, -1);
+ monitor.beginTask("Importing CSV", rows.size());
// Path wktFile = model.getWKTFile();
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+ Collection<Resource> vertices = graph.syncRequest(new ObjectsWithType(model.getParentDiagram(), Layer0.getInstance(graph).ConsistsOf, DistrictNetworkResource.getInstance(graph).Vertex));
+ List<ResourceVertex> vv = new ArrayList<>(vertices.size());
+ for (Resource vertex : vertices) {
+ double[] existingCoords = graph.getRelatedValue2(vertex, DiagramResource.getInstance(graph).HasLocation, Bindings.DOUBLE_ARRAY);
+ vv.add(new ResourceVertex(vertex, existingCoords));
+ }
+
for (int k = 1; k < rows.size(); k++) {
CSVRecord row = rows.get(k);
if (model.isVertexImport()) {
String xCoords = row.get(xCoordColumnIndex);
String yCoords = row.get(yCoordColumnIndex);
- double xCoord = - Double.parseDouble(xCoords); // make negative for now
+ double xCoord = Double.parseDouble(xCoords);
double yCoord = Double.parseDouble(yCoords);
double z = 0;
DirectPosition res = actualTransform.transform(sourcePos, targetPos);
coords = res.getCoordinate();
} else {
- coords = new double[] { xCoord / MapScalingTransform.getScaleX(), yCoord / MapScalingTransform.getScaleY() };
+ coords = new double[] { xCoord, yCoord };
}
- Resource vertex = DistrictNetworkUtil.createVertex(graph, model.getParentDiagram(), new double[] { coords[1], -coords[0]}, model.getComponentMappings().get(mappingValue));
+ Resource vertex = DistrictNetworkUtil.createVertex(graph, model.getParentDiagram(), coords, model.getComponentMappings().get(mappingValue));
writeStringValue(graph, row, idColumn, vertex, DN.HasId);
String endXCoords = row.get(endXCoordColumnIndex);
String endYCoords = row.get(endYCoordColumnIndex);
- double startXCoord = - Double.parseDouble(startXCoords); // make negative
+ double startXCoord = Double.parseDouble(startXCoords); // make negative
double startYCoord = Double.parseDouble(startYCoords);
- double endXCoord = - Double.parseDouble(endXCoords); // make negative
+ double endXCoord = Double.parseDouble(endXCoords); // make negative
double endYCoord = Double.parseDouble(endYCoords);
double[] startCoords;
DirectPosition endRes = actualTransform.transform(endSourcePos, endTargetPos);
endCoords = endRes.getCoordinate();
} else {
- startCoords = new double[] { startXCoord / MapScalingTransform.getScaleX(), startYCoord / MapScalingTransform.getScaleY() };
- endCoords = new double[] { endXCoord / MapScalingTransform.getScaleX(), endYCoord / MapScalingTransform.getScaleY() };
+ startCoords = new double[] { startXCoord , startYCoord };
+ endCoords = new double[] { endXCoord , endYCoord };
}
-
- Resource edge = DNEdgeBuilder.create(graph, model.getParentDiagram(), model.getComponentMappings().get(mappingValue), new double[] { startCoords[1], -startCoords[0]}, new double[] { endCoords[1], -endCoords[0]}, padding);
+
+ Resource edge = DNEdgeBuilder.create(graph, vv, model.getParentDiagram(), model.getComponentMappings().get(mappingValue), startCoords, endCoords, padding);
writeStringValue(graph, row, idColumn, edge, DN.HasId);
writeValue(graph, row, diameterColumnIndex, edge, DN.Edge_HasDiameter);
} catch (MismatchedDimensionException | TransformException | DatabaseException e) {
throw new DatabaseException(e);
}
+ monitor.worked(1);
}
}
});
DN.DistrictProfile.entry1
L0.HasLabel "Id"
@DIA.groupStyleProfileEntry DN.ComponentIdStyle DN.Groups.ElementGroup
+ DN.DistrictProfile.entry2
+ L0.HasLabel "Edge Node Styling"
+ @DIA.groupStyleProfileEntry DN.EdgeNodeStyle DN.Groups.ElementGroup
DN.Groups : L0.Library
"""
"String -> Variable -> <ReadGraph> (String, String, String)"
@G2D.fontProperty DIA.TextElement.font "Arial" 30 G2D.FontStyle.normal_font_style
+
+//DN.EdgeNodeGroup : DIA.Group
+
+//DN.Profiles : L0.Library
+
+DN.EdgeNodeStyle : DIA.Style
+
+// Templates
+
+//groupStyleEntry : L0.Template
+// @template %subject %style %group
+// %subject : DIA.GroupStyleProfileEntry
+// DIA.ProfileEntry.HasStyle %style
+// DIA.ProfileEntry.HasGroup %group
+
+
+//DN.Profiles.EdgeNodeStyle
+// L0.HasLabel "Edge Node Style"
+// @groupStyleEntry DN.EdgeNodeStyle DN.EdgeNodeGroup
public final Resource DistrictProfile;
public final Resource DistrictProfile_entry;
public final Resource DistrictProfile_entry1;
+ public final Resource DistrictProfile_entry2;
public final Resource EPSG_4326;
public final Resource Edge;
public final Resource EdgeDefaultMapping;
public final Resource EdgeDefaultMapping_Inverse;
public final Resource EdgeMappingParameterType;
+ public final Resource EdgeNodeStyle;
public final Resource Edge_HasDiameter;
public final Resource Edge_HasDiameter_Inverse;
public final Resource Edge_HasFlowArea;
public static final String DistrictProfile = "http://www.simantics.org/DistrictNetwork-1.0/DistrictProfile";
public static final String DistrictProfile_entry = "http://www.simantics.org/DistrictNetwork-1.0/DistrictProfile/entry";
public static final String DistrictProfile_entry1 = "http://www.simantics.org/DistrictNetwork-1.0/DistrictProfile/entry1";
+ public static final String DistrictProfile_entry2 = "http://www.simantics.org/DistrictNetwork-1.0/DistrictProfile/entry2";
public static final String EPSG_4326 = "http://www.simantics.org/DistrictNetwork-1.0/EPSG_4326";
public static final String Edge = "http://www.simantics.org/DistrictNetwork-1.0/Edge";
public static final String EdgeDefaultMapping = "http://www.simantics.org/DistrictNetwork-1.0/EdgeDefaultMapping";
public static final String EdgeDefaultMapping_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/EdgeDefaultMapping/Inverse";
public static final String EdgeMappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/EdgeMappingParameterType";
+ public static final String EdgeNodeStyle = "http://www.simantics.org/DistrictNetwork-1.0/EdgeNodeStyle";
public static final String Edge_HasDiameter = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasDiameter";
public static final String Edge_HasDiameter_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasDiameter/Inverse";
public static final String Edge_HasFlowArea = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasFlowArea";
DistrictProfile = getResourceOrNull(graph, URIs.DistrictProfile);
DistrictProfile_entry = getResourceOrNull(graph, URIs.DistrictProfile_entry);
DistrictProfile_entry1 = getResourceOrNull(graph, URIs.DistrictProfile_entry1);
+ DistrictProfile_entry2 = getResourceOrNull(graph, URIs.DistrictProfile_entry2);
EPSG_4326 = getResourceOrNull(graph, URIs.EPSG_4326);
Edge = getResourceOrNull(graph, URIs.Edge);
EdgeDefaultMapping = getResourceOrNull(graph, URIs.EdgeDefaultMapping);
EdgeDefaultMapping_Inverse = getResourceOrNull(graph, URIs.EdgeDefaultMapping_Inverse);
EdgeMappingParameterType = getResourceOrNull(graph, URIs.EdgeMappingParameterType);
+ EdgeNodeStyle = getResourceOrNull(graph, URIs.EdgeNodeStyle);
Edge_HasDiameter = getResourceOrNull(graph, URIs.Edge_HasDiameter);
Edge_HasDiameter_Inverse = getResourceOrNull(graph, URIs.Edge_HasDiameter_Inverse);
Edge_HasFlowArea = getResourceOrNull(graph, URIs.Edge_HasFlowArea);
package org.simantics.district.network.ui;
import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import org.simantics.databoard.Bindings;
import org.simantics.db.Resource;
}
public static Resource create(WriteGraph graph, Resource diagramResource, double[] start, double[] end, double padding) throws DatabaseException {
- return create(graph, diagramResource, null, start, end, padding);
+ Collection<Resource> vertices = graph.syncRequest(new ObjectsWithType(diagramResource, Layer0.getInstance(graph).ConsistsOf, DistrictNetworkResource.getInstance(graph).Vertex));
+ List<ResourceVertex> vv = new ArrayList<>(vertices.size());
+ for (Resource vertex : vertices) {
+ double[] existingCoords = graph.getRelatedValue2(vertex, DiagramResource.getInstance(graph).HasLocation, Bindings.DOUBLE_ARRAY);
+ vv.add(new ResourceVertex(vertex, existingCoords));
+ }
+ return create(graph, vv, diagramResource, null, start, end, padding);
}
- public static Resource create(WriteGraph graph, Resource diagramResource, Resource mapping, double[] start, double[] end, double padding) throws DatabaseException {
+ public static Resource create(WriteGraph graph, Collection<ResourceVertex> vertices, Resource diagramResource, Resource mapping, double[] start, double[] end, double padding) throws DatabaseException {
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
Resource edge = getOrCreateEdge(graph, diagramResource, mapping);
// 2. Add vertices
- Collection<Resource> vertices = graph.syncRequest(new ObjectsWithType(diagramResource, Layer0.getInstance(graph).ConsistsOf, DistrictNetworkResource.getInstance(graph).Vertex));
- Resource startVertex = getOrCreateVertex(graph, diagramResource, vertices, start, padding);
- Resource endVertex = getOrCreateVertex(graph, diagramResource, vertices, end, padding);
+ Resource startVertex = getOrCreateVertex(graph, diagramResource, vertices, start, padding, null);
+ Resource endVertex = getOrCreateVertex(graph, diagramResource, vertices, end, padding, startVertex);
graph.claim(edge, DN.HasStartVertex, startVertex);
graph.claim(edge, DN.HasEndVertex, endVertex);
// We need to put GraphLayer to newLayers so...
- for (Resource layer : graph.getObjects(diagramResource, DiagramResource.getInstance(graph).HasLayer)) {
- IGraphLayerUtil layerUtil = graph.adapt(graph.getSingleObject(layer, Layer0.getInstance(graph).InstanceOf), IGraphLayerUtil.class);
-
- GraphLayer gl = layerUtil.loadLayer(graph, layer);
- gl.forEachTag(tag -> {
- DiagramGraphUtil.tag(graph, startVertex, tag, true);
- DiagramGraphUtil.tag(graph, endVertex, tag, true);
- });
- }
-
+// for (Resource layer : graph.getObjects(diagramResource, DiagramResource.getInstance(graph).HasLayer)) {
+// IGraphLayerUtil layerUtil = graph.adapt(graph.getSingleObject(layer, Layer0.getInstance(graph).InstanceOf), IGraphLayerUtil.class);
+//
+// GraphLayer gl = layerUtil.loadLayer(graph, layer);
+// gl.forEachTag(tag -> {
+// DiagramGraphUtil.tag(graph, startVertex, tag, true);
+// DiagramGraphUtil.tag(graph, endVertex, tag, true);
+// });
+// }
+//
return edge;
}
public void create(WriteGraph graph, double[] start, double[] end, double padding) throws DatabaseException {
glm.putElementOnVisibleLayers(diagram, graph, res);
}
- private static Resource getOrCreateVertex(WriteGraph graph, Resource diagramResource, Collection<Resource> vertices, double[] coords, double padding) throws DatabaseException {
+ private static Resource getOrCreateVertex(WriteGraph graph, Resource diagramResource, Collection<ResourceVertex> vertices, double[] coords, double padding, Resource startVertex) throws DatabaseException {
Resource vertex = null;
double halfPadding = padding / 2;
double maxDistance = Double.MAX_VALUE;
- for (Resource vertx : vertices) {
- double[] existingCoords = graph.getRelatedValue2(vertx, DiagramResource.getInstance(graph).HasLocation, Bindings.DOUBLE_ARRAY);
- Rectangle2D existing = new Rectangle2D.Double(existingCoords[0] - halfPadding, existingCoords[1] - halfPadding, padding, padding);
+ for (ResourceVertex vertx : vertices) {
+ Rectangle2D existing = new Rectangle2D.Double(vertx.coords[0] - halfPadding, vertx.coords[1] - halfPadding, padding, padding);
Rectangle2D tobecreated = new Rectangle2D.Double(coords[0] - halfPadding, coords[1] - halfPadding, padding, padding);
if (existing.intersects(tobecreated)) {
- double dist = Math.sqrt((Math.pow(coords[0] - existingCoords[0], 2) + (Math.pow(coords[1] - existingCoords[1], 2))));
- if (dist <= maxDistance) {
- vertex = vertx;
+ double dist = Math.sqrt((Math.pow(coords[0] - vertx.coords[0], 2) + (Math.pow(coords[1] - vertx.coords[1], 2))));
+ if (dist <= maxDistance && !vertx.vertex.equals(startVertex)) {
+ vertex = vertx.vertex;
+ maxDistance = dist;
}
}
}
if (vertex == null) {
vertex = DistrictNetworkUtil.createVertex(graph, diagramResource, coords);
+ vertices.add(new ResourceVertex(vertex, coords));
}
return vertex;
}
return DistrictNetworkUtil.createEdge(graph, diagramResource, mapping);
}
+ public static class ResourceVertex {
+
+ final Resource vertex;
+ final double[] coords;
+
+ public ResourceVertex(Resource vertex, double[] coords) {
+ this.vertex = vertex;
+ this.coords = coords;
+ }
+ }
}
import org.simantics.g2d.participant.GridPainter;
import org.simantics.g2d.participant.PanZoomRotateHandler;
import org.simantics.g2d.participant.RenderingQualityInteractor;
+import org.simantics.g2d.participant.ZoomToAreaHandler;
import org.simantics.maps.MapScalingTransform;
import org.simantics.maps.eclipse.MapPainter;
import org.simantics.modeling.ui.diagramEditor.DiagramViewer;
ctx.add(new MapRulerPainter());
ctx.add(new BackgroundPainter());
}
+
+ protected void addViewManipulationParticipants(CanvasContext ctx) {
+ ctx.add(new DistrictPanZoomRotateHandler());
+ //ctx.add(new MousePanZoomInteractor());
+ //ctx.add(new MultitouchPanZoomRotateInteractor());
+ // ctx.add( new OrientationRestorer() );
+ ctx.add(new ZoomToAreaHandler());
+ }
+
}
--- /dev/null
+package org.simantics.district.network.ui;
+
+import org.simantics.g2d.participant.PanZoomRotateHandler;
+import org.simantics.scenegraph.g2d.events.MouseEvent.MouseWheelMovedEvent;
+import org.simantics.scenegraph.g2d.nodes.NavigationNode;
+
+public class DistrictPanZoomRotateHandler extends PanZoomRotateHandler {
+
+ public DistrictPanZoomRotateHandler() {
+ }
+
+ @Override
+ protected Class<? extends NavigationNode> getNavigationNodeClass() {
+ return DistrictNavigationNode.class;
+ }
+
+ public static class DistrictNavigationNode extends NavigationNode {
+
+ private static final long serialVersionUID = 5452897272925816875L;
+
+ @Override
+ public Double getZoomInLimit() {
+ return super.getZoomInLimit();
+ }
+
+ @Override
+ public Double getZoomOutLimit() {
+ return super.getZoomOutLimit();
+ }
+
+ @Override
+ public boolean mouseWheelMoved(MouseWheelMovedEvent me) {
+ if (navigationEnabled && zoomEnabled) {
+ double scroll = Math.min(0.9, -me.wheelRotation / 20.0);
+ double z = 1 - scroll;
+ double dx = (me.controlPosition.getX() - transform.getTranslateX()) / transform.getScaleX();
+ double dy = (me.controlPosition.getY() - transform.getTranslateY()) / transform.getScaleY();
+ dx = dx * (1 - z);
+ dy = dy * (1 - z);
+ double limitedScale = limitScaleFactor(z);
+ if (limitedScale != 1.0) {
+ translate(dx, dy);
+ scale(z, z);
+ transformChanged();
+ dropQuality();
+ repaint();
+ }
+ }
+ return false;
+ }
+
+ }
+}
@Override
public void load(ReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource edgeResource, IElement element) throws DatabaseException {
-
+ if (!graph.hasStatement(edgeResource))
+ return; // already deleted
+
Resource startVertex = graph.getSingleObject(edgeResource, DN.HasStartVertex);
Resource endVertex = graph.getSingleObject(edgeResource, DN.HasEndVertex);
@Override
public void load(ReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource vertexResource, IElement element) throws DatabaseException {
-
+ if (!graph.hasStatement(vertexResource))
+ return; // already deleted
+
double[] coords = graph.getRelatedValue(vertexResource, DIA.HasLocation);
DistrictNetworkVertex vertex = new DistrictNetworkVertex(coords);
private Color color;
+ private Double stroke;
+
@Override
public void init() {
}
g2d.setColor(color);
if (STROKE != null) {
if (scaleStroke && STROKE instanceof BasicStroke) {
- BasicStroke bs = GeometryUtils.scaleStroke(STROKE, (float) (1.0 / GeometryUtils.getScale(g2d.getTransform())));
+ double str;
+ if (stroke != null)
+ str = stroke;
+ else
+ str = 1.0;
+ BasicStroke bs = GeometryUtils.scaleStroke(STROKE, (float) (str / GeometryUtils.getScale(g2d.getTransform())));
g2d.setStroke(bs);
} else {
g2d.setStroke(STROKE);
public static Path2D calculatePath(DistrictNetworkEdge edge) {
// Convert to screen coordinates
double startX = ModelledCRS.longitudeToX(edge.getStartPoint().getX());
- double startY = ModelledCRS.latitudeToY(edge.getStartPoint().getY());
+ double startY = ModelledCRS.latitudeToY(-edge.getStartPoint().getY()); // Invert for Simantics
double endX = ModelledCRS.longitudeToX(edge.getEndPoint().getX());
- double endY = ModelledCRS.latitudeToY(edge.getEndPoint().getY());
+ double endY = ModelledCRS.latitudeToY(-edge.getEndPoint().getY());// Invert for Simantics
// render
Path2D path = new Path2D.Double();
return color;
}
+ @PropertySetter(value = "stroke")
+ public void setStroke(Double stroke) {
+ this.stroke = stroke / 100;
+ }
+
}
private static final long serialVersionUID = -2641639101400236719L;
private DistrictNetworkVertex vertex;
- private static final double left = -0.5;
- private static final double top = -0.5;
- private static final double width = 1;
- private static final double height = 1;
+ private static final double left = -0.25;
+ private static final double top = -0.25;
+ private static final double width = 0.5;
+ private static final double height = 0.5;
private static final Rectangle2D NORMAL = new Rectangle2D.Double(left, top, width, height);
private static final Rectangle2D HOVERED = new Rectangle2D.Double(left * 3, top * 3, width * 3, height * 3);
private Rectangle2D bounds;
+ private Double strokee;
+
@Override
public void init() {
setZIndex(2);
double scaleRecip = 1;
if (scaleStroke) {
double scale = GeometryUtils.getScale(g2d.getTransform());
-
+ double str;
+ if (strokee != null)
+ str = strokee;
+ else
+ str = 1.0;
//System.out.println("scale: " + scale);
scaleRecip = 1.0 / scale;
}
private static Point2D calculatePoint2D(DistrictNetworkVertex vertex) {
Point2D point= vertex.getPoint();
double x = ModelledCRS.longitudeToX(point.getX());
- double y = ModelledCRS.latitudeToY(point.getY());
+ double y = ModelledCRS.latitudeToY(-point.getY()); // Inverse because Simantics Diagram is inverted
// Apply the scaling
Point2D res = new Point2D.Double(x, y);
return color;
}
+ @PropertySetter(value = "stroke")
+ public void setStroke(Double stroke) {
+ this.strokee = stroke / 10;
+ }
}
double scaleY = getTransform().getScaleY();
double scaleX = getTransform().getScaleX();
- double startLat = ModelledCRS.yToLatitude(start.getY() / scaleY);
+ double startLat = ModelledCRS.yToLatitude(-start.getY() / scaleY);
double startLon = ModelledCRS.xToLongitude(start.getX() / scaleX);
- double endLat = ModelledCRS.yToLatitude(end.getY() / scaleY);
+ double endLat = ModelledCRS.yToLatitude(-end.getY() / scaleY);
double endLon = ModelledCRS.xToLongitude(end.getX() / scaleX);
double[] startCoords = new double[] { startLon, startLat };
import java.util.ArrayList;
import java.util.Collection;
-import javax.xml.bind.DataBindingException;
-
import org.simantics.Simantics;
import org.simantics.db.Resource;
import org.simantics.db.WriteGraph;
AffineTransform at = ElementUtils.getLocalTransform(e, new AffineTransform());
if (graph.isInstanceOf(res, DN.Vertex)) {
- double lat = ModelledCRS.yToLatitude(y + (dy / at.getScaleY()));
+ double lat = ModelledCRS.yToLatitude(y + (-dy / at.getScaleY()));
double lon = ModelledCRS.xToLongitude(x + (dx / at.getScaleX()));
// write to db
CommentMetadata cm = graph.getMetadata(CommentMetadata.class);
graph.addMetadata(cm.add("Translated " + transformed.size() + " "
+ (transformed.size() == 1 ? "element" : "elements")
- + " by (" + dx + "," + dy + ") mm."));
+ + " by (" + dx + "," + -dy + ") mm."));
}
}
});
org.simantics.db.layer0,
org.simantics.district.maps,
org.simantics.district.geotools;bundle-version="1.0.0",
- org.simantics.diagram
+ org.simantics.diagram,
+ org.simantics.scenegraph.profile;bundle-version="1.0.0"
Export-Package: org.simantics.district.network
<this />
</type>
</target>
+ <target interface="org.simantics.scenegraph.profile.Group">
+ <resource uri="http://www.simantics.org/DistrictNetwork-1.0/EdgeNodeGroup"
+ class="org.simantics.district.network.profile.EdgeNodeGroup">
+ <graph/>
+ </resource>
+ </target>
+ <target interface="org.simantics.scenegraph.profile.Style">
+ <resource uri="http://www.simantics.org/DistrictNetwork-1.0/EdgeNodeStyle"
+ class="org.simantics.district.network.profile.EdgeNodeStyle">
+ </resource>
+ </target>
</adapters>
\ No newline at end of file
()
else ()
()
+
+importJava "org.simantics.district.network.DistrictNetworkUtil" where
+ createVertex :: Resource -> Vector Double -> Resource -> <WriteGraph, Proc> Resource
+ createEdge :: Resource -> Resource -> <WriteGraph, Proc> Resource
+
public static Resource createEdge(WriteGraph graph, Resource composite) throws DatabaseException {
return createEdge(graph, composite, graph.getPossibleObject(composite, DistrictNetworkResource.getInstance(graph).EdgeDefaultMapping));
}
-
+
public static Resource createEdge(WriteGraph graph, Resource composite, Resource mapping) throws DatabaseException {
Layer0 L0 = Layer0.getInstance(graph);
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
graph.claim(composite, L0.ConsistsOf, L0.PartOf, edge);
claimFreshElementName(graph, composite, edge);
+
+ // We need to put GraphLayer to newLayers so...
+ for (Resource layer : graph.getObjects(composite, DiagramResource.getInstance(graph).HasLayer)) {
+ IGraphLayerUtil layerUtil = graph.adapt(graph.getSingleObject(layer, Layer0.getInstance(graph).InstanceOf), IGraphLayerUtil.class);
+
+ GraphLayer gl = layerUtil.loadLayer(graph, layer);
+ gl.forEachTag(tag -> {
+ DiagramGraphUtil.tag(graph, edge, tag, true);
+ });
+ }
+
return edge;
}
-
+
public static Resource createVertex(WriteGraph graph, Resource composite, double[] coords) throws DatabaseException {
Resource defaultVertexMapping = graph.getPossibleObject(composite, DistrictNetworkResource.getInstance(graph).VertexDefaultMapping);
return createVertex(graph, composite, coords, defaultVertexMapping);
}
-
+
public static Resource createVertex(WriteGraph graph, Resource composite, double[] coords, Resource mapping) throws DatabaseException {
Layer0 L0 = Layer0.getInstance(graph);
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);