X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fprofile%2FEdgeThicknessStyle.java;h=b305c39148bd284bfea3b96ee1cbf6221226e198;hb=fa8b6523f7dc37c548f0bdd614e74b71a624c276;hp=45b55549333848a94c3d808fbfe4e824e94af877;hpb=3354c578fb8e65421d0fdb123310232ccdc597cf;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeThicknessStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeThicknessStyle.java index 45b55549..b305c391 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeThicknessStyle.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeThicknessStyle.java @@ -5,36 +5,43 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener; import org.simantics.db.exception.DatabaseException; -import org.simantics.diagram.profile.StyleBase; import org.simantics.scenegraph.INode; import org.simantics.scenegraph.g2d.G2DSceneGraph; import org.simantics.scenegraph.g2d.nodes.ConnectionNode; import org.simantics.scenegraph.profile.EvaluationContext; import org.simantics.scenegraph.profile.common.ProfileVariables; -public class EdgeThicknessStyle extends StyleBase { +public class EdgeThicknessStyle extends ThrottledStyleBase { private static final Double PENDING = Double.NaN; private static final Double ONE = 1.0; @Override - public Double calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException { + public Double calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException { DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheAsyncListener.instance()); - Double thickness = ONE; - if (ds.edgeThicknessProperty.isPresent()) { - thickness = Simantics.applySCLRead(graph, ds.edgeThicknessProperty.get(), groupItem); -// System.out.println("read thickness: " + thickness + " : " + ds.edgeThicknessProperty); - if (thickness == null) { - thickness = ONE; - } else { - thickness = thickness * ds.edgeThicknessGain + ds.edgeThicknessBias; + // Prevent PendingVariableExceptions from coming through + boolean wasSynchronous = graph.setSynchronous(true); + try { + Double thickness = ONE; + if (ds.edgeThicknessProperty.isPresent()) { + thickness = Simantics.applySCLRead(graph, ds.edgeThicknessProperty.get(), groupItem); + // System.out.println("read thickness: " + thickness + " : " + ds.edgeThicknessProperty); + if (thickness == null) { + thickness = ONE; + } else { + thickness = thickness * ds.edgeThicknessGain + ds.edgeThicknessBias; + } } + + return thickness; + } + finally { + graph.setSynchronous(wasSynchronous); } - return thickness; } @Override - public void applyStyleForNode(EvaluationContext observer, INode node, Double value) { + public void applyThrottledStyleForNode(EvaluationContext observer, INode node, Double value) { // System.out.println("apply: " + node + " : " + value); ConnectionNode n = (ConnectionNode) node; if (value == PENDING) {