]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java
Dynamic Visualisations view improvements & profile refactoring
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / profile / DiagramSettingsRequest.java
diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java
deleted file mode 100644 (file)
index eac9ce0..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.simantics.district.network.profile;
-
-import org.simantics.databoard.Bindings;
-import org.simantics.db.ReadGraph;
-import org.simantics.db.Resource;
-import org.simantics.db.common.request.ResourceRead;
-import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.layer0.variable.Variable;
-import org.simantics.db.layer0.variable.Variables;
-import org.simantics.diagram.stubs.DiagramResource;
-import org.simantics.district.network.ontology.DistrictNetworkResource;
-import org.simantics.scl.runtime.function.Function1;
-
-/**
- * @author Tuukka Lehtonen
- */
-public class DiagramSettingsRequest extends ResourceRead<DiagramSettings> {
-
-       public DiagramSettingsRequest(Resource runtimeDiagram) {
-               super(runtimeDiagram);
-       }
-
-       @SuppressWarnings("unchecked")
-    @Override
-       public DiagramSettings perform(ReadGraph graph) throws DatabaseException {
-               DiagramResource DIA = DiagramResource.getInstance(graph);
-               DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
-
-               Function1<Resource, Double> arrowLengthProperty = null;
-               double arrowLengthGain = 1;
-               double arrowLengthBias = 0;
-
-               Resource diagram = graph.getPossibleObject(resource, DIA.RuntimeDiagram_HasConfiguration);
-               if (diagram != null) {
-                       Variable dv = Variables.getPossibleVariable(graph, diagram);
-
-                       Resource alp = graph.getPossibleObject(diagram, DN.Diagram_arrowLengthProperty);
-                       //System.out.println("alp: " + NameUtils.getURIOrSafeNameInternal(graph, alp));
-                       if (alp != null) {
-                               Variable alpv = Variables.getPossibleVariable(graph, alp);
-                               if (alpv != null) {
-                                       //System.out.println("alpv: " + alpv.getURI(graph));
-                                       arrowLengthProperty = alpv.getPropertyValue(graph, DN.Edge_ArrowLengthProperty_value);
-                               }
-
-                               arrowLengthGain =
-                                               safeDoubleProperty(graph, alp, DN.Edge_ArrowLengthProperty_gain, 1)
-                                               * safeDoubleProperty(graph, diagram, DN.Diagram_arrowLengthGain, 1);
-                               arrowLengthBias =
-                                               safeDoubleProperty(graph, alp, DN.Edge_ArrowLengthProperty_bias, 0)
-                                               + safeDoubleProperty(graph, diagram, DN.Diagram_arrowLengthBias, 0);
-                       }
-
-               }
-
-               DiagramSettings ds = new DiagramSettings( arrowLengthProperty, arrowLengthGain, arrowLengthBias);
-               //System.out.println("new diagram settings: " + ds);
-               return ds;
-       }
-
-       private static float safeFloatProperty(ReadGraph graph, Resource r, Resource property, float defaultValue) throws DatabaseException {
-               Float d = graph.getPossibleRelatedValue(r, property, Bindings.FLOAT);
-               return d != null ? d : defaultValue;
-       }
-
-       private static double safeDoubleProperty(ReadGraph graph, Resource r, Resource property, double defaultValue) throws DatabaseException {
-               Double d = graph.getPossibleRelatedValue(r, property, Bindings.DOUBLE);
-               return d != null ? d : defaultValue;
-       }
-
-       private static float limit(float min, float max, float value) {
-               return Math.max(min, Math.min(value,  max));
-       }
-
-       @SuppressWarnings("unused")
-       private static double limit(double min, double max, double value) {
-               return Math.max(min, Math.min(value,  max));
-       }
-
-}