]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.charts/src/org/simantics/charts/query/ChartDataQuery.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / query / ChartDataQuery.java
index 5636f6aa9b960fe3c5541970de667f0ad16212dd..cb56225033ec953dde7b65adc08ab6de42379092 100644 (file)
@@ -1,88 +1,88 @@
-package org.simantics.charts.query;\r
-\r
-import java.util.Arrays;\r
-\r
-import org.simantics.charts.ontology.ChartResource;\r
-import org.simantics.charts.ui.ChartData;\r
-import org.simantics.charts.ui.ChartData.ItemKey;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.NamedResource;\r
-import org.simantics.db.common.request.ObjectsWithType;\r
-import org.simantics.db.common.request.ResourceRead;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.trend.configuration.TrendItem;\r
-import org.simantics.trend.configuration.YAxisMode;\r
-\r
-public class ChartDataQuery extends ResourceRead<ChartData> {\r
-\r
-    public ChartDataQuery(Resource resource) {\r
-        super(resource);\r
-    }\r
-\r
-    @Override\r
-    public ChartData perform(ReadGraph g) throws DatabaseException {\r
-        Resource chart = resource;\r
-        ChartData data = new ChartData();\r
-\r
-        Layer0 L0 = Layer0.getInstance(g);\r
-        ChartResource CHART = ChartResource.getInstance(g);\r
-\r
-        data.name = g.getPossibleRelatedValue(chart, L0.HasName, Bindings.STRING);\r
-\r
-        Resource am = g.getPossibleObject(chart, CHART.Chart_YAxisMode);\r
-        if ( CHART.YAxisMode_SingleAxis.equals(am) ) data.axisMode = YAxisMode.SingleAxis;\r
-        else if ( CHART.YAxisMode_MultiAxis.equals(am) ) data.axisMode = YAxisMode.MultiAxis;\r
-        else {\r
-            data.axisMode = YAxisMode.SingleAxis;\r
-        }\r
-\r
-        Double increment = g.getPossibleRelatedAdapter(chart, CHART.Chart_TimeWindowIncrement, Double.class);\r
-        if ( increment!=null ) data.timeIncrement = increment;\r
-        Double length = g.getPossibleRelatedAdapter(chart, CHART.Chart_TimeWindowLength, Double.class);\r
-        if ( length !=null ) data.timeLength = length;\r
-        Double start = g.getPossibleRelatedAdapter(chart, CHART.Chart_TimeWindowStart, Double.class);\r
-        if ( start!=null ) data.timeStart = start;\r
-\r
-        Boolean showMilestones = g.getPossibleRelatedValue(chart, CHART.Chart_ShowMilestones, Bindings.BOOLEAN);\r
-        if ( showMilestones!=null ) data.showMilestones = showMilestones;\r
-        Boolean showGrid = g.getPossibleRelatedValue(chart, CHART.Chart_showGrid, Bindings.BOOLEAN);\r
-        if ( showGrid!=null ) data.showGrid = showGrid;\r
-        Boolean trackExperimentTime = g.getPossibleRelatedValue(chart, CHART.Chart_trackExperimentTime, Bindings.BOOLEAN);\r
-        if ( trackExperimentTime!=null ) data.trackExperimentTime = trackExperimentTime;\r
-\r
-        for (Resource chartItem : g.syncRequest(new ObjectsWithType(chart, L0.ConsistsOf, CHART.Chart_Item))) {\r
-            TrendItem ti = g.syncRequest(new TrendItemQuery(chartItem));\r
-            NamedResource nr = new NamedResource(ti.label, chartItem);\r
-            ItemKey key = new ItemKey(ti.renderer, ti.index, nr);\r
-            data.allItems.put(key, ti);\r
-            Boolean hidden = g.getPossibleRelatedValue(chartItem, CHART.Chart_Item_hidden, Bindings.BOOLEAN);\r
-            if (Boolean.TRUE.equals(hidden))\r
-                data.hiddenItems.add(key);\r
-        }\r
-\r
-        float[] bgColor = g.getPossibleRelatedValue(chart, CHART.Chart_backgroundColor, Bindings.FLOAT_ARRAY);\r
-        if (bgColor != null && bgColor.length >= 3) {\r
-            int len = bgColor.length;\r
-            if (len >= 6) {\r
-                data.backgroundGradient = true;\r
-                data.backgroundColor1 = Arrays.copyOfRange(bgColor, 0, 3);\r
-                data.backgroundColor2 = Arrays.copyOfRange(bgColor, 3, 6);\r
-            } else if (len >= 3) {\r
-                data.backgroundGradient = false;\r
-                data.backgroundColor1 = Arrays.copyOfRange(bgColor, 0, 3);\r
-                data.backgroundColor2 = data.backgroundColor1;\r
-            }\r
-        }\r
-\r
-        float[] gridColor = g.getPossibleRelatedValue(chart, CHART.Chart_gridColor, Bindings.FLOAT_ARRAY);\r
-        if (gridColor != null && gridColor.length >= 3) {\r
-            data.gridColor = gridColor;\r
-        }\r
-\r
-        return data;\r
-    }\r
-\r
-}\r
+package org.simantics.charts.query;
+
+import java.util.Arrays;
+
+import org.simantics.charts.ontology.ChartResource;
+import org.simantics.charts.ui.ChartData;
+import org.simantics.charts.ui.ChartData.ItemKey;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.NamedResource;
+import org.simantics.db.common.request.ObjectsWithType;
+import org.simantics.db.common.request.ResourceRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+import org.simantics.trend.configuration.TrendItem;
+import org.simantics.trend.configuration.YAxisMode;
+
+public class ChartDataQuery extends ResourceRead<ChartData> {
+
+    public ChartDataQuery(Resource resource) {
+        super(resource);
+    }
+
+    @Override
+    public ChartData perform(ReadGraph g) throws DatabaseException {
+        Resource chart = resource;
+        ChartData data = new ChartData();
+
+        Layer0 L0 = Layer0.getInstance(g);
+        ChartResource CHART = ChartResource.getInstance(g);
+
+        data.name = g.getPossibleRelatedValue(chart, L0.HasName, Bindings.STRING);
+
+        Resource am = g.getPossibleObject(chart, CHART.Chart_YAxisMode);
+        if ( CHART.YAxisMode_SingleAxis.equals(am) ) data.axisMode = YAxisMode.SingleAxis;
+        else if ( CHART.YAxisMode_MultiAxis.equals(am) ) data.axisMode = YAxisMode.MultiAxis;
+        else {
+            data.axisMode = YAxisMode.SingleAxis;
+        }
+
+        Double increment = g.getPossibleRelatedAdapter(chart, CHART.Chart_TimeWindowIncrement, Double.class);
+        if ( increment!=null ) data.timeIncrement = increment;
+        Double length = g.getPossibleRelatedAdapter(chart, CHART.Chart_TimeWindowLength, Double.class);
+        if ( length !=null ) data.timeLength = length;
+        Double start = g.getPossibleRelatedAdapter(chart, CHART.Chart_TimeWindowStart, Double.class);
+        if ( start!=null ) data.timeStart = start;
+
+        Boolean showMilestones = g.getPossibleRelatedValue(chart, CHART.Chart_ShowMilestones, Bindings.BOOLEAN);
+        if ( showMilestones!=null ) data.showMilestones = showMilestones;
+        Boolean showGrid = g.getPossibleRelatedValue(chart, CHART.Chart_showGrid, Bindings.BOOLEAN);
+        if ( showGrid!=null ) data.showGrid = showGrid;
+        Boolean trackExperimentTime = g.getPossibleRelatedValue(chart, CHART.Chart_trackExperimentTime, Bindings.BOOLEAN);
+        if ( trackExperimentTime!=null ) data.trackExperimentTime = trackExperimentTime;
+
+        for (Resource chartItem : g.syncRequest(new ObjectsWithType(chart, L0.ConsistsOf, CHART.Chart_Item))) {
+            TrendItem ti = g.syncRequest(new TrendItemQuery(chartItem));
+            NamedResource nr = new NamedResource(ti.label, chartItem);
+            ItemKey key = new ItemKey(ti.renderer, ti.index, nr);
+            data.allItems.put(key, ti);
+            Boolean hidden = g.getPossibleRelatedValue(chartItem, CHART.Chart_Item_hidden, Bindings.BOOLEAN);
+            if (Boolean.TRUE.equals(hidden))
+                data.hiddenItems.add(key);
+        }
+
+        float[] bgColor = g.getPossibleRelatedValue(chart, CHART.Chart_backgroundColor, Bindings.FLOAT_ARRAY);
+        if (bgColor != null && bgColor.length >= 3) {
+            int len = bgColor.length;
+            if (len >= 6) {
+                data.backgroundGradient = true;
+                data.backgroundColor1 = Arrays.copyOfRange(bgColor, 0, 3);
+                data.backgroundColor2 = Arrays.copyOfRange(bgColor, 3, 6);
+            } else if (len >= 3) {
+                data.backgroundGradient = false;
+                data.backgroundColor1 = Arrays.copyOfRange(bgColor, 0, 3);
+                data.backgroundColor2 = data.backgroundColor1;
+            }
+        }
+
+        float[] gridColor = g.getPossibleRelatedValue(chart, CHART.Chart_gridColor, Bindings.FLOAT_ARRAY);
+        if (gridColor != null && gridColor.length >= 3) {
+            data.gridColor = gridColor;
+        }
+
+        return data;
+    }
+
+}