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.TransientCacheListener;
-import org.simantics.db.common.request.ResourceRead;
import org.simantics.db.exception.DatabaseException;
import org.simantics.layer0.Layer0;
import org.simantics.scenegraph.INode;
public class ArrowLengthStyle extends ThrottledStyleBase<Double> {
private static final Double PENDING = Double.NaN;
- private static final Double ONE = 1.0;
@Override
public Double calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
// Prevent PendingVariableExceptions from coming through
boolean wasSynchronous = graph.setSynchronous(true);
try {
- Double length = ONE;
if (ds.arrowLengthProperty.isPresent()) {
- length = Simantics.applySCLRead(graph, ds.arrowLengthProperty.get(), groupItem);
- // System.out.println("read thickness: " + thickness + " : " + ds.arrowLengthProperty);
- if (length == null) {
- length = ONE;
- } else {
- length = length * ds.arrowLengthGain + ds.arrowLengthBias;
- }
+ Double length = Simantics.applySCLRead(graph, ds.arrowLengthProperty.get(), groupItem);
+ return length != null ? length * ds.arrowLengthGain + ds.arrowLengthBias : null;
+ }
+ else {
+ return null;
}
-
- return length;
}
finally {
graph.setSynchronous(wasSynchronous);
for (INode nn : n.getNodes())
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);
- }
- }
-
}