DN.VertexSizeStyle : DIA.Style
DN.EdgeThicknessStyle : DIA.Style
DN.HideStyle : DIA.Style
+DN.VertexSymbolStyle : DIA.Style
+
+// Function for dynamic selection of symbols for a vertex
+// The input of the function is a DN.Vertex
+// The output of the function should be SVG
+DN.HasSymbolFunction <R L0.HasProperty
+ <-- DIA.ProfileEntry
+ --> L0.ExternalValue
+ ==> "Resource -> <ReadGraph> String"
public final Resource HasSpatialRefSystem_Inverse;
public final Resource HasStartVertex;
public final Resource HasStartVertex_Inverse;
+ public final Resource HasSymbolFunction;
+ public final Resource HasSymbolFunction_Inverse;
public final Resource HideStyle;
public final Resource Images;
public final Resource Images_MapImage;
public final Resource VertexMappingParameterType;
public final Resource VertexScalePropertyParameterType;
public final Resource VertexSizeStyle;
+ public final Resource VertexSymbolStyle;
public final Resource Vertex_HasAddress;
public final Resource Vertex_HasAddress_Inverse;
public final Resource Vertex_HasDeltaPressure;
public static final String HasSpatialRefSystem_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasSpatialRefSystem/Inverse";
public static final String HasStartVertex = "http://www.simantics.org/DistrictNetwork-1.0/HasStartVertex";
public static final String HasStartVertex_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasStartVertex_Inverse";
+ public static final String HasSymbolFunction = "http://www.simantics.org/DistrictNetwork-1.0/HasSymbolFunction";
+ public static final String HasSymbolFunction_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasSymbolFunction/Inverse";
public static final String HideStyle = "http://www.simantics.org/DistrictNetwork-1.0/HideStyle";
public static final String Images = "http://www.simantics.org/DistrictNetwork-1.0/Images";
public static final String Images_MapImage = "http://www.simantics.org/DistrictNetwork-1.0/Images/MapImage";
public static final String VertexMappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/VertexMappingParameterType";
public static final String VertexScalePropertyParameterType = "http://www.simantics.org/DistrictNetwork-1.0/VertexScalePropertyParameterType";
public static final String VertexSizeStyle = "http://www.simantics.org/DistrictNetwork-1.0/VertexSizeStyle";
+ public static final String VertexSymbolStyle = "http://www.simantics.org/DistrictNetwork-1.0/VertexSymbolStyle";
public static final String Vertex_HasAddress = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasAddress";
public static final String Vertex_HasAddress_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasAddress/Inverse";
public static final String Vertex_HasDeltaPressure = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasDeltaPressure";
HasSpatialRefSystem_Inverse = getResourceOrNull(graph, URIs.HasSpatialRefSystem_Inverse);
HasStartVertex = getResourceOrNull(graph, URIs.HasStartVertex);
HasStartVertex_Inverse = getResourceOrNull(graph, URIs.HasStartVertex_Inverse);
+ HasSymbolFunction = getResourceOrNull(graph, URIs.HasSymbolFunction);
+ HasSymbolFunction_Inverse = getResourceOrNull(graph, URIs.HasSymbolFunction_Inverse);
HideStyle = getResourceOrNull(graph, URIs.HideStyle);
Images = getResourceOrNull(graph, URIs.Images);
Images_MapImage = getResourceOrNull(graph, URIs.Images_MapImage);
VertexMappingParameterType = getResourceOrNull(graph, URIs.VertexMappingParameterType);
VertexScalePropertyParameterType = getResourceOrNull(graph, URIs.VertexScalePropertyParameterType);
VertexSizeStyle = getResourceOrNull(graph, URIs.VertexSizeStyle);
+ VertexSymbolStyle = getResourceOrNull(graph, URIs.VertexSymbolStyle);
Vertex_HasAddress = getResourceOrNull(graph, URIs.Vertex_HasAddress);
Vertex_HasAddress_Inverse = getResourceOrNull(graph, URIs.Vertex_HasAddress_Inverse);
Vertex_HasDeltaPressure = getResourceOrNull(graph, URIs.Vertex_HasDeltaPressure);
Export-Package: org.simantics.district.network.ui,
org.simantics.district.network.ui.adapters,
org.simantics.district.network.ui.breakdown,
- org.simantics.district.network.ui.function
+ org.simantics.district.network.ui.function,
+ org.simantics.district.network.ui.nodes
Require-Bundle: org.eclipse.e4.ui.model.workbench;bundle-version="1.1.100.v20150407-1430",
org.eclipse.swt,
org.simantics.g2d,
import org.simantics.g2d.diagram.handler.PickRequest;
import org.simantics.g2d.diagram.participant.AbstractDiagramParticipant;
import org.simantics.g2d.element.IElement;
-import org.simantics.scenegraph.g2d.G2DNode;
+import org.simantics.scenegraph.Node;
import org.simantics.scenegraph.g2d.G2DParentNode;
import org.simantics.utils.datastructures.hints.IHintContext.Key;
import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
boolean changed = false;
for (IElement sn : snap) {
- G2DNode node = sn.getHint(DistrictNetworkVertexElement.KEY_DN_VERTEX_NODE);
+ Node node = sn.getHint(DistrictNetworkVertexElement.KEY_DN_VERTEX_NODE);
if (node instanceof DistrictNetworkVertexNode) {
if (((DistrictNetworkVertexNode) node).hover(false) && !changed) {
changed = true;
}
for (IElement elem : pickables) {
- G2DNode node = elem.getHint(DistrictNetworkVertexElement.KEY_DN_VERTEX_NODE);
+ Node node = elem.getHint(DistrictNetworkVertexElement.KEY_DN_VERTEX_NODE);
if (node instanceof DistrictNetworkVertexNode) {
if (((DistrictNetworkVertexNode) node).hover(true) && !changed) {
changed = true;
import org.simantics.g2d.element.handler.SceneGraph;
import org.simantics.g2d.element.handler.impl.DefaultTransform;
import org.simantics.g2d.element.handler.impl.SimpleElementLayers;
+import org.simantics.scenegraph.INode;
import org.simantics.scenegraph.g2d.G2DParentNode;
+import org.simantics.scenegraph.g2d.nodes.SVGNode;
import org.simantics.utils.datastructures.hints.IHintContext.Key;
import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
public static final Key KEY_DN_VERTEX = new KeyOf(DistrictNetworkVertex.class, "DN_VERTEX");
public static final Key KEY_DN_VERTEX_NODE = new SceneGraphNodeKey(DistrictNetworkVertexNode.class, "DN_VERTEX_NODE");
+ public static final Key KEY_DN_VERTEX_SYMBOL_NODE = new SceneGraphNodeKey(SVGNode.class, "DN_VERTEX_SYMBOL_NODE");
public static final ElementClass CLASS =
ElementClass.compile(
if (node == null) {
node = parent.addNode(ElementUtils.generateNodeId(vertexElement), DistrictNetworkVertexNode.class);
vertexElement.setHint(KEY_DN_VERTEX_NODE, node);
+
+ SVGNode symbol = node.addNode(ElementUtils.generateNodeId(vertexElement), SVGNode.class);
+ vertexElement.setHint(KEY_DN_VERTEX_SYMBOL_NODE, symbol);
}
+
node.setVertex(vertex);
node.setColor(ElementUtils.getAdditionalColor(vertexElement, Color.BLUE));
@Override
public void cleanup(IElement edge) {
- ElementUtils.removePossibleNode(edge, KEY_DN_VERTEX_NODE);
+ ElementUtils.removePossibleNode(edge, KEY_DN_VERTEX_SYMBOL_NODE);
+ INode node = ElementUtils.removePossibleNode(edge, KEY_DN_VERTEX_NODE);
+ if (node != null)
+ node.getParent().remove();
+
edge.removeHint(KEY_DN_VERTEX_NODE);
+ edge.removeHint(KEY_DN_VERTEX_SYMBOL_NODE);
}
}
import org.simantics.district.network.ModelledCRS;
import org.simantics.district.network.ui.adapters.DistrictNetworkVertex;
+import org.simantics.scenegraph.INode;
import org.simantics.scenegraph.ISelectionPainterNode;
import org.simantics.scenegraph.g2d.G2DNode;
+import org.simantics.scenegraph.g2d.G2DParentNode;
+import org.simantics.scenegraph.g2d.nodes.SVGNode;
import org.simantics.scenegraph.utils.GeometryUtils;
import org.simantics.scenegraph.utils.NodeUtil;
-public class DistrictNetworkVertexNode extends G2DNode implements ISelectionPainterNode {
+public class DistrictNetworkVertexNode extends G2DParentNode implements ISelectionPainterNode {
//private static final Logger LOGGER = LoggerFactory.getLogger(DistrictNetworkVertexNode.class);
if (changeColor)
g2d.setColor(newColor);
g2d.fill(toDraw);
-
+
// Reset settings
if (changeColor)
g2d.setColor(oldColor);
if (oaaHint != null)
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);
+
+ // Render SVG symbol
+ for (INode nn : getNodes()) {
+ ((G2DNode)nn).setTransform(new AffineTransform(toDraw.getWidth(), 0.0, 0.0, toDraw.getHeight(), toDraw.getCenterX(), toDraw.getCenterY()));
+ ((G2DNode)nn).render(g2d);
+ }
+
if (ot != null)
g2d.setTransform(ot);
}
return color;
}
+ @PropertySetter(value = "SVG")
+ public void setSVG(String value) {
+ for (INode nn : this.getNodes())
+ if (nn instanceof SVGNode)
+ ((SVGNode)nn).setData(value);
+ }
+
+
@PropertySetter(value = "size")
public void setSize(Double size) {
boolean changed = false;
<resource uri="http://www.simantics.org/DistrictNetwork-1.0/HideStyle"
class="org.simantics.district.network.profile.HideStyle">
</resource>
+ <resource uri="http://www.simantics.org/DistrictNetwork-1.0/VertexSymbolStyle"
+ class="org.simantics.district.network.profile.VertexSymbolStyle">
+ </resource>
</target>
<target interface="org.simantics.scenegraph.profile.Group">
<type
--- /dev/null
+package org.simantics.district.network.profile;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.diagram.profile.StyleBase;
+import org.simantics.district.network.ontology.DistrictNetworkResource;
+import org.simantics.scenegraph.INode;
+import org.simantics.scenegraph.g2d.G2DSceneGraph;
+import org.simantics.scenegraph.g2d.nodes.SingleElementNode;
+import org.simantics.scenegraph.profile.EvaluationContext;
+import org.simantics.scenegraph.profile.common.ProfileVariables;
+import org.simantics.scl.runtime.function.Function;
+
+public class VertexSymbolStyle extends StyleBase<String> {
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public String calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
+ DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+ Resource symbolFunctionResource = graph.getPossibleObject(entry, DN.HasSymbolFunction);
+ if (symbolFunctionResource == null)
+ return null;
+
+ Function symbolFunction = (Function) graph.getPossibleValue2(symbolFunctionResource, null);
+ if (symbolFunction == null)
+ return null;
+
+ return (String) symbolFunction.apply(graph, entry);
+ }
+
+ @Override
+ public void applyStyleForNode(EvaluationContext observer, INode node, String value) {
+ SingleElementNode n = (SingleElementNode) node;
+ for (INode nn : n.getNodes())
+ ProfileVariables.claimNodeProperty(nn, "SVG", value, observer);
+ }
+
+ @Override
+ protected void cleanupStyleForNode(EvaluationContext evaluationContext, INode node) {
+ ((G2DSceneGraph)node.getRootNode()).clearPending(node);
+ SingleElementNode n = (SingleElementNode) node;
+ for (INode nn : n.getNodes())
+ ProfileVariables.claimNodeProperty(nn, "SVG", null, evaluationContext);
+ }
+
+}
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Semantum Oy
Require-Bundle: org.simantics.layer0,
- org.simantics.district.network.ontology;bundle-version="1.0.0"
+ org.simantics.district.network.ontology;bundle-version="1.0.0",
+ org.simantics.diagram.ontology;bundle-version="2.2.0"
Automatic-Module-Name: fi.vtt.apros.district.route.ontology
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.simantics.district.route.ontology