--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry exported="true" kind="lib" path="lib/hsqldb-2.3.4.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/gt-epsg-hsql-16.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-pool-1.5.4.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/core-0.26.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/GeographicLib-Java-1.44.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/gt-metadata-16.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/gt-opengis-16.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/gt-referencing-16.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/jai_core-1.1.3.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/jgridshift-1.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/jsr-275-1.0-beta-2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/jts-1.13.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.simantics.district.geotools</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics Geotools
+Bundle-SymbolicName: org.simantics.district.geotools
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.simantics.district.geotools.Activator
+Require-Bundle: org.eclipse.core.runtime
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: lib/commons-pool-1.5.4.jar,
+ lib/core-0.26.jar,
+ lib/GeographicLib-Java-1.44.jar,
+ lib/gt-metadata-16.0.jar,
+ lib/gt-opengis-16.0.jar,
+ lib/gt-referencing-16.0.jar,
+ lib/jai_core-1.1.3.jar,
+ lib/jgridshift-1.0.jar,
+ lib/jsr-275-1.0-beta-2.jar,
+ lib/jts-1.13.jar,
+ .,
+ lib/gt-epsg-hsql-16.0.jar,
+ lib/hsqldb-2.3.4.jar
+Export-Package: org.geotools.geometry,
+ org.geotools.referencing,
+ org.opengis.geometry,
+ org.opengis.referencing,
+ org.opengis.referencing.crs,
+ org.opengis.referencing.operation
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ lib/commons-pool-1.5.4.jar,\
+ lib/core-0.26.jar,\
+ lib/GeographicLib-Java-1.44.jar,\
+ lib/gt-metadata-16.0.jar,\
+ lib/gt-opengis-16.0.jar,\
+ lib/gt-referencing-16.0.jar,\
+ lib/jai_core-1.1.3.jar,\
+ lib/jgridshift-1.0.jar,\
+ lib/jsr-275-1.0-beta-2.jar,\
+ lib/jts-1.13.jar,\
+ lib/gt-epsg-hsql-16.0.jar,\
+ lib/hsqldb-2.3.4.jar
--- /dev/null
+package org.simantics.district.geotools;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
DN.HasMapping <R L0.HasProperty : DN.MappingParameterType
L0.HasLabel "Mapping"
+DN.Edge.HasLength <R L0.HasProperty : SEL.GenericParameterType
+ L0.HasLabel "Length"
+ L0.HasRange L0.Double
+ L0.readOnly true
+
DN.Edge.HasDiameter <R L0.HasProperty : SEL.GenericParameterType
L0.HasLabel "Diameter"
L0.HasRange L0.Double
ACTIONS.NewDNDiagram : MOD.NewComposite
MOD.NewComposite.HasCompositeType DN.Composite
- MOD.NewComposite.HasDefaultName "NewDNComposite"
+ MOD.NewComposite.HasDefaultName "NewNetworkDiagram"
IMAGES = DN.Images : L0.Library
public final Resource EdgeMappingParameterType;
public final Resource Edge_HasDiameter;
public final Resource Edge_HasDiameter_Inverse;
+ public final Resource Edge_HasLength;
+ public final Resource Edge_HasLength_Inverse;
public final Resource Edge_HasOuterDiameter;
public final Resource Edge_HasOuterDiameter_Inverse;
public final Resource Functions;
public static final String EdgeMappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/EdgeMappingParameterType";
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_HasLength = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasLength";
+ public static final String Edge_HasLength_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasLength/Inverse";
public static final String Edge_HasOuterDiameter = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasOuterDiameter";
public static final String Edge_HasOuterDiameter_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasOuterDiameter/Inverse";
public static final String Functions = "http://www.simantics.org/DistrictNetwork-1.0/Functions";
EdgeMappingParameterType = getResourceOrNull(graph, URIs.EdgeMappingParameterType);
Edge_HasDiameter = getResourceOrNull(graph, URIs.Edge_HasDiameter);
Edge_HasDiameter_Inverse = getResourceOrNull(graph, URIs.Edge_HasDiameter_Inverse);
+ Edge_HasLength = getResourceOrNull(graph, URIs.Edge_HasLength);
+ Edge_HasLength_Inverse = getResourceOrNull(graph, URIs.Edge_HasLength_Inverse);
Edge_HasOuterDiameter = getResourceOrNull(graph, URIs.Edge_HasOuterDiameter);
Edge_HasOuterDiameter_Inverse = getResourceOrNull(graph, URIs.Edge_HasOuterDiameter_Inverse);
Functions = getResourceOrNull(graph, URIs.Functions);
import org.simantics.modeling.ModelingUtils;
import org.simantics.modeling.adapters.NewCompositeActionFactory;
import org.simantics.modeling.typicals.TypicalUtil;
+import org.simantics.operation.Layer0X;
import org.simantics.scl.reflection.annotations.SCLValue;
import org.simantics.ui.workbench.action.DefaultActions;
import org.simantics.utils.ui.SWTUtils;
graph.claim(diagram, DN.EdgeDefaultMapping, dialog.getDefaultEdgeMapping());
graph.claim(diagram, DN.VertexDefaultMapping, dialog.getDefaultVertexMapping());
graph.claim(diagram, DN.HasSpatialRefSystem, dialog.getCRS());
+
+ // Generated name prefix from composite name
+ String compositeName = graph.getRelatedValue2(composite, Layer0.getInstance(graph).HasName, Bindings.STRING);
+ graph.claimLiteral(diagram, Layer0X.getInstance(graph).HasGeneratedNamePrefix, "N" + compositeName.substring(compositeName.length() - 1, compositeName.length()));
}
});
DefaultActions.asyncPerformDefaultAction(Simantics.getSession(), composite, false, false, true);
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Collection;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.district.network.ModelledCRS;
import org.simantics.district.network.ontology.DistrictNetworkResource;
-import org.simantics.district.network.ui.adapters.DistrictNetworkVertexElement;
-import org.simantics.district.network.ui.nodes.DistrictNetworkVertexNode;
import org.simantics.g2d.canvas.Hints;
import org.simantics.g2d.diagram.participant.pointertool.TranslateMode;
import org.simantics.g2d.element.ElementUtils;
import org.simantics.g2d.element.IElement;
-import org.simantics.g2d.element.handler.Move;
public class DNTranslateMode extends TranslateMode {
@Override
protected boolean commit() {
- for (IElement el : elementsToReallyTranslate) {
- Move move = el.getElementClass().getAtMostOneItemOfClass(Move.class);
- if (move != null) {
- Point2D oldPos = move.getPosition(el);
- move.moveTo(el, oldPos.getX() + dx, oldPos.getY() + dy);
- }
- }
try {
Simantics.getSession().syncRequest(new WriteRequest() {
@Override
DiagramResource DIA = DiagramResource.getInstance(graph);
for (IElement e : elementsToReallyTranslate) {
- DistrictNetworkVertexNode node = e.getHint(DistrictNetworkVertexElement.KEY_DN_VERTEX_NODE);
- Rectangle2D bounds = node.getBounds();
Object obj = ElementUtils.getObject(e);
if (obj instanceof Resource) {
+
Resource res = (Resource) obj;
+
+ // Read current location from graph
+ double[] currentCoords = graph.getRelatedValue2(res, DIA.HasLocation);
+
+ double x = ModelledCRS.longitudeToX(currentCoords[0]);
+ double y = ModelledCRS.latitudeToY(currentCoords[1]);
+
AffineTransform at = ElementUtils.getLocalTransform(e, new AffineTransform());
if (graph.isInstanceOf(res, DN.Vertex)) {
- double x = at.getTranslateX();
- double y = at.getTranslateY();
-
- double lat = ModelledCRS.yToLatitude(y / at.getScaleY());
- double lon = ModelledCRS.xToLongitude(x / at.getScaleX());
+ double lat = ModelledCRS.yToLatitude(y + (dy / at.getScaleY()));
+ double lon = ModelledCRS.xToLongitude(x + (dx / at.getScaleX()));
// write to db
double[] coords = new double[] { lon, lat };
import org.simantics.db.common.utils.OrderedSetUtils;
import org.simantics.db.exception.DatabaseException;
import org.simantics.diagram.stubs.DiagramResource;
-import org.simantics.diagram.synchronization.graph.AddElement;
import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;
import org.simantics.diagram.synchronization.graph.layer.GraphLayer;
import org.simantics.diagram.synchronization.graph.layer.IGraphLayerUtil;
import org.simantics.district.network.ontology.DistrictNetworkResource;
import org.simantics.layer0.Layer0;
+import org.simantics.operation.Layer0X;
public class DistrictNetworkUtil {
OrderedSetUtils.add(graph, composite, edge);
graph.claim(composite, L0.ConsistsOf, L0.PartOf, edge);
- AddElement.claimFreshElementName(graph, composite, edge);
+ claimFreshElementName(graph, composite, edge);
return edge;
}
OrderedSetUtils.add(graph, composite, vertex);
graph.claim(composite, L0.ConsistsOf, L0.PartOf, vertex);
- AddElement.claimFreshElementName(graph, composite, vertex);
+ claimFreshElementName(graph, composite, vertex);
// We need to put GraphLayer to newLayers so...
for (Resource layer : graph.getObjects(composite, DiagramResource.getInstance(graph).HasLayer)) {
graph.claim(endVertexEdge, DN.HasEndVertex, master);
}
OrderedSetUtils.remove(graph, composite, slave);
+ // Remove ConsistsOf statement
+ graph.deny(composite, Layer0.getInstance(graph).ConsistsOf, slave);
}
return master;
}
return crsClass.calculateDistance(startCoords, endCoords);
}
+
+ public static final String claimFreshElementName(WriteGraph graph, Resource diagram, Resource element) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ DiagramResource DIA = DiagramResource.getInstance(graph);
+ // Get name prefix from diagram
+ String namePrefix = graph.getPossibleRelatedValue2(diagram, Layer0X.getInstance(graph).HasGeneratedNamePrefix);
+ if (namePrefix == null)
+ namePrefix = "";
+ // Give running name to element and increment the counter attached to the diagram.
+ Long l = graph.getPossibleRelatedValue(diagram, DIA.HasModCount, Bindings.LONG);
+ if (l == null)
+ l = Long.valueOf(0L);
+ String name = namePrefix + l.toString();
+ graph.claimLiteral(element, L0.HasName, name, Bindings.STRING);
+ graph.claimLiteral(diagram, DIA.HasModCount, ++l, Bindings.LONG);
+ return name;
+ }
}