]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network/src/org/simantics/district/network/profile/DNElementColorStyle.java
Add support for gradients in dynamic visualisations
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / profile / DNElementColorStyle.java
index fe0a1fe7f2ebce8bbbfdec501fce0a0032b6e544..9bcae2e5f42e907231694ca559d7b68e64184416 100644 (file)
@@ -3,7 +3,6 @@ package org.simantics.district.network.profile;
 import java.awt.Color;
 import java.util.Map;
 
-import org.simantics.Simantics;
 import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
@@ -40,7 +39,6 @@ public class DNElementColorStyle extends ThrottledStyleBase<Color> {
         DynamicVisualisation dv = graph.syncRequest(new RuntimeDynamicVisualisationsRequest(runtimeDiagram),
                 TransientCacheAsyncListener.instance());
 
-        DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheAsyncListener.instance());
         // Prevent PendingVariableExceptions from coming through
         boolean wasSynchronous = graph.setSynchronous(true);
         try {
@@ -72,7 +70,7 @@ public class DNElementColorStyle extends ThrottledStyleBase<Color> {
                                         // here we do the adjusting according to spec in #15038
                                         double adjustedValue = possibleValue.doubleValue() * dcc.getVariableGain() + dcc.getVariableBias();
                                         DynamicColorMap defaultColorMap = dcc.getDefaultColorMap();
-                                        Color color = defaultColorMap.getColor(adjustedValue, dcc.getDefaultMin(), dcc.getDefaultMax());
+                                        Color color = defaultColorMap.getColor(adjustedValue, dv.getColorBarOptions().isUseGradients(), dcc.getDefaultMin(), dcc.getDefaultMax());
                                         return color;
                                     } else {
                                         LOGGER.warn("No value for {}", attribute.getURI(graph));
@@ -91,20 +89,6 @@ public class DNElementColorStyle extends ThrottledStyleBase<Color> {
                     }
                 }
             }
-                   
-            // the old implementation here
-                       if (ds.elementColoringFunction.isPresent()) {
-                               if (DEBUG)
-                                       System.out.print("elementColoringFunction: " + ds.elementColoringFunction + "(" + groupItem + "): ");
-                               Double t = Simantics.applySCLRead(graph, ds.elementColoringFunction.get(), groupItem);
-                               if (DEBUG)
-                                       System.out.print(t);
-                               if (t != null) {
-                                       Color result = ds.coloringGradient.get(t);
-                                       //System.out.println("color(" + t + "): " + result);
-                                       return result;
-                               }
-                       }
                }
                finally {
                        graph.setSynchronous(wasSynchronous);