package org.simantics.district.network.profile;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.simantics.Simantics;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
-import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
+import org.simantics.db.common.procedure.adapter.TransientCacheListener;
+import org.simantics.db.common.request.ResourceRead;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
import org.simantics.scenegraph.INode;
import org.simantics.scenegraph.g2d.G2DSceneGraph;
import org.simantics.scenegraph.g2d.nodes.ConnectionNode;
@Override
public Double calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
- DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheAsyncListener.instance());
+ Resource diagram = graph.getSingleObject(groupItem, Layer0.getInstance(graph).PartOf);
+ Set<Resource> edgesToUse = graph.syncRequest(new MidBranchEdgeSetRequest(diagram), TransientCacheListener.instance());
+ if (!edgesToUse.contains(groupItem))
+ return null;
+
+ DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheListener.instance());
// Prevent PendingVariableExceptions from coming through
boolean wasSynchronous = graph.setSynchronous(true);
try {
ProfileVariables.claimNodeProperty(nn, "arrowLength", null, evaluationContext);
}
+ private static final class MidBranchEdgeSetRequest extends ResourceRead<Set<Resource>> {
+ private MidBranchEdgeSetRequest(Resource resource) {
+ super(resource);
+ }
+
+ @Override
+ public Set<Resource> perform(ReadGraph graph) throws DatabaseException {
+ List<Resource> edges = Simantics.applySCL("Simantics/District/Algorithm", "midBranchEdges", graph, resource);
+ return new HashSet<>(edges);
+ }
+ }
+
}