X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fprofile%2FArrowLengthStyle.java;h=2e8c3458164770959409e9aa7fce6f87b2276532;hb=7d92384ac5455e67e69c02bff9a53e1f0cc256b2;hp=3b0524d406f6fe9c9a01d20df10e6587017c6b92;hpb=7977ea8081aed5396b820c26bcaf354ca878db21;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java index 3b0524d4..2e8c3458 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java @@ -1,10 +1,16 @@ 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; @@ -18,7 +24,12 @@ public class ArrowLengthStyle extends ThrottledStyleBase { @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 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 { @@ -61,4 +72,16 @@ public class ArrowLengthStyle extends ThrottledStyleBase { ProfileVariables.claimNodeProperty(nn, "arrowLength", null, evaluationContext); } + private static final class MidBranchEdgeSetRequest extends ResourceRead> { + private MidBranchEdgeSetRequest(Resource resource) { + super(resource); + } + + @Override + public Set perform(ReadGraph graph) throws DatabaseException { + List edges = Simantics.applySCL("Simantics/District/Algorithm", "midBranchEdges", graph, resource); + return new HashSet<>(edges); + } + } + }