1 package org.simantics.district.network.profile;
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.exception.DatabaseException;
6 import org.simantics.district.network.ontology.DistrictNetworkResource;
7 import org.simantics.scenegraph.INode;
8 import org.simantics.scenegraph.g2d.G2DSceneGraph;
9 import org.simantics.scenegraph.g2d.nodes.SingleElementNode;
10 import org.simantics.scenegraph.profile.EvaluationContext;
11 import org.simantics.scenegraph.profile.common.ProfileVariables;
12 import org.simantics.scl.runtime.function.Function;
14 public class VertexSymbolStyle extends ThrottledStyleBase<String> {
16 @SuppressWarnings({ "rawtypes", "unchecked" })
18 public String calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
19 DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
20 Resource symbolFunctionResource = graph.getPossibleObject(entry, DN.HasSymbolFunction);
21 if (symbolFunctionResource == null)
24 Function symbolFunction = (Function) graph.getPossibleValue2(symbolFunctionResource, null);
25 if (symbolFunction == null)
28 return (String) symbolFunction.apply(graph, entry);
32 public void applyThrottledStyleForNode(EvaluationContext observer, INode node, String value) {
33 SingleElementNode n = (SingleElementNode) node;
34 for (INode nn : n.getNodes())
35 ProfileVariables.claimNodeProperty(nn, "SVG", value, observer);
39 protected void cleanupStyleForNode(EvaluationContext evaluationContext, INode node) {
40 ((G2DSceneGraph)node.getRootNode()).clearPending(node);
41 SingleElementNode n = (SingleElementNode) node;
42 for (INode nn : n.getNodes())
43 ProfileVariables.claimNodeProperty(nn, "SVG", null, evaluationContext);