]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Result filtering for multidimensional variables
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 9 Dec 2011 09:08:21 +0000 (09:08 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 9 Dec 2011 09:08:21 +0000 (09:08 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@23470 ac1ea38d-2e2b-0410-8846-a27921b304fc

38 files changed:
org.simantics.jfreechart.ontology/graph.tg
org.simantics.jfreechart.ontology/graph/JFreeChart.pgraph
org.simantics.jfreechart.ontology/src/org/simantics/sysdyn/JFreeChartResource.java
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/ChartViewpoints.pgraph
org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/adapters.xml
org.simantics.sysdyn.ui/icons/chart_line.png [new file with mode: 0644]
org.simantics.sysdyn.ui/icons/chart_pie.png [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ChartImager.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ChartLabeler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Charts.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/AbstractChartNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/BarChartNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/LineChartNode.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ChartNode.java with 60% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/PieChartNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractAxis.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryAxis.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryDataset.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryPlot.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ChartComposite.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ChartUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/JFreeChart.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/PieDataset.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/PiePlot.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYDataset.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/graphexplorer/SeriesLabelDecorationRule.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RVIModifier.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarGeneralPropertiesTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarSeriesPropertyComposite.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarSeriesTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieGeneralPropertiesTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieSeriesPropertyComposite.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieSeriesTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/SeriesPropertyComposite.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynResult.java

index 923bca85a1f8bc413b51ab2edb6e0cd985239c0a..f85899a232d244cf84dc745dbf95352b9274630c 100644 (file)
Binary files a/org.simantics.jfreechart.ontology/graph.tg and b/org.simantics.jfreechart.ontology/graph.tg differ
index e6a3a70ce52c904104936fa332de8a30642225f0..4611e693c7400fedc398739e4aa91256581865e3 100644 (file)
@@ -62,6 +62,7 @@ JFREE.Axis <T L0.Entity
     >-- JFREE.Axis.visibleTickMarks --> L0.Boolean <R L0.HasProperty : L0.FunctionalRelation
     >-- JFREE.Axis.visibleAxisLine --> L0.Boolean <R L0.HasProperty : L0.FunctionalRelation
     >-- JFREE.Axis.visibleLabel --> L0.Boolean <R L0.HasProperty : L0.FunctionalRelation
+    >-- JFREE.Axis.rotateLabelDegrees --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
     
 JFREE.CategoryAxis <T JFREE.Axis
 JFREE.ValueAxis <T JFREE.Axis
@@ -87,6 +88,8 @@ JFREE.PieDataset <T JFREE.Dataset
 JFREE.Series <T L0.Entity
     >-- JFREE.color
     >-- JFREE.variableRVI --> L0.String <R L0.HasProperty
+    >-- JFREE.variableFilter --> L0.StringArray <R L0.HasProperty
+    >-- JFREE.Series.rangeList --> L0.List <R L0.HasProperty : L0.FunctionalRelation
     >-- JFREE.Series.lineWidth --> L0.Integer <R L0.HasProperty : L0.FunctionalRelation
     >-- JFREE.Series.exploded --> L0.Boolean <R L0.HasProperty : L0.FunctionalRelation
     >-- JFREE.Series.time --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
index add59f77256fd90c23bfb3cee315ea4a127a55bc..3b89a5cfd8c78c3471bcda01b686b1e6451069a6 100644 (file)
@@ -13,6 +13,8 @@ public class JFreeChartResource {
     public final Resource Axis_max_Inverse;\r
     public final Resource Axis_min;\r
     public final Resource Axis_min_Inverse;\r
+    public final Resource Axis_rotateLabelDegrees;\r
+    public final Resource Axis_rotateLabelDegrees_Inverse;\r
     public final Resource Axis_visibleAxisLine;\r
     public final Resource Axis_visibleAxisLine_Inverse;\r
     public final Resource Axis_visibleLabel;\r
@@ -69,6 +71,8 @@ public class JFreeChartResource {
     public final Resource Series_exploded_Inverse;\r
     public final Resource Series_lineWidth;\r
     public final Resource Series_lineWidth_Inverse;\r
+    public final Resource Series_rangeList;\r
+    public final Resource Series_rangeList_Inverse;\r
     public final Resource Series_time;\r
     public final Resource Series_time_Inverse;\r
     public final Resource StackedBarRenderer;\r
@@ -87,6 +91,8 @@ public class JFreeChartResource {
     public final Resource subtitles_Inverse;\r
     public final Resource title;\r
     public final Resource title_Inverse;\r
+    public final Resource variableFilter;\r
+    public final Resource variableFilter_Inverse;\r
     public final Resource variableRVI;\r
     public final Resource variableRVI_Inverse;\r
     public final Resource visible;\r
@@ -98,6 +104,8 @@ public class JFreeChartResource {
         public static final String Axis_max_Inverse = "http://www.simantics.org/JFreeChart-1.0/Axis/max/Inverse";\r
         public static final String Axis_min = "http://www.simantics.org/JFreeChart-1.0/Axis/min";\r
         public static final String Axis_min_Inverse = "http://www.simantics.org/JFreeChart-1.0/Axis/min/Inverse";\r
+        public static final String Axis_rotateLabelDegrees = "http://www.simantics.org/JFreeChart-1.0/Axis/rotateLabelDegrees";\r
+        public static final String Axis_rotateLabelDegrees_Inverse = "http://www.simantics.org/JFreeChart-1.0/Axis/rotateLabelDegrees/Inverse";\r
         public static final String Axis_visibleAxisLine = "http://www.simantics.org/JFreeChart-1.0/Axis/visibleAxisLine";\r
         public static final String Axis_visibleAxisLine_Inverse = "http://www.simantics.org/JFreeChart-1.0/Axis/visibleAxisLine/Inverse";\r
         public static final String Axis_visibleLabel = "http://www.simantics.org/JFreeChart-1.0/Axis/visibleLabel";\r
@@ -154,6 +162,8 @@ public class JFreeChartResource {
         public static final String Series_exploded_Inverse = "http://www.simantics.org/JFreeChart-1.0/Series/exploded/Inverse";\r
         public static final String Series_lineWidth = "http://www.simantics.org/JFreeChart-1.0/Series/lineWidth";\r
         public static final String Series_lineWidth_Inverse = "http://www.simantics.org/JFreeChart-1.0/Series/lineWidth/Inverse";\r
+        public static final String Series_rangeList = "http://www.simantics.org/JFreeChart-1.0/Series/rangeList";\r
+        public static final String Series_rangeList_Inverse = "http://www.simantics.org/JFreeChart-1.0/Series/rangeList/Inverse";\r
         public static final String Series_time = "http://www.simantics.org/JFreeChart-1.0/Series/time";\r
         public static final String Series_time_Inverse = "http://www.simantics.org/JFreeChart-1.0/Series/time/Inverse";\r
         public static final String StackedBarRenderer = "http://www.simantics.org/JFreeChart-1.0/StackedBarRenderer";\r
@@ -172,6 +182,8 @@ public class JFreeChartResource {
         public static final String subtitles_Inverse = "http://www.simantics.org/JFreeChart-1.0/subtitles/Inverse";\r
         public static final String title = "http://www.simantics.org/JFreeChart-1.0/title";\r
         public static final String title_Inverse = "http://www.simantics.org/JFreeChart-1.0/title/Inverse";\r
+        public static final String variableFilter = "http://www.simantics.org/JFreeChart-1.0/variableFilter";\r
+        public static final String variableFilter_Inverse = "http://www.simantics.org/JFreeChart-1.0/variableFilter/Inverse";\r
         public static final String variableRVI = "http://www.simantics.org/JFreeChart-1.0/variableRVI";\r
         public static final String variableRVI_Inverse = "http://www.simantics.org/JFreeChart-1.0/variableRVI/Inverse";\r
         public static final String visible = "http://www.simantics.org/JFreeChart-1.0/visible";\r
@@ -193,6 +205,8 @@ public class JFreeChartResource {
         Axis_max_Inverse = getResourceOrNull(graph, URIs.Axis_max_Inverse);\r
         Axis_min = getResourceOrNull(graph, URIs.Axis_min);\r
         Axis_min_Inverse = getResourceOrNull(graph, URIs.Axis_min_Inverse);\r
+        Axis_rotateLabelDegrees = getResourceOrNull(graph, URIs.Axis_rotateLabelDegrees);\r
+        Axis_rotateLabelDegrees_Inverse = getResourceOrNull(graph, URIs.Axis_rotateLabelDegrees_Inverse);\r
         Axis_visibleAxisLine = getResourceOrNull(graph, URIs.Axis_visibleAxisLine);\r
         Axis_visibleAxisLine_Inverse = getResourceOrNull(graph, URIs.Axis_visibleAxisLine_Inverse);\r
         Axis_visibleLabel = getResourceOrNull(graph, URIs.Axis_visibleLabel);\r
@@ -249,6 +263,8 @@ public class JFreeChartResource {
         Series_exploded_Inverse = getResourceOrNull(graph, URIs.Series_exploded_Inverse);\r
         Series_lineWidth = getResourceOrNull(graph, URIs.Series_lineWidth);\r
         Series_lineWidth_Inverse = getResourceOrNull(graph, URIs.Series_lineWidth_Inverse);\r
+        Series_rangeList = getResourceOrNull(graph, URIs.Series_rangeList);\r
+        Series_rangeList_Inverse = getResourceOrNull(graph, URIs.Series_rangeList_Inverse);\r
         Series_time = getResourceOrNull(graph, URIs.Series_time);\r
         Series_time_Inverse = getResourceOrNull(graph, URIs.Series_time_Inverse);\r
         StackedBarRenderer = getResourceOrNull(graph, URIs.StackedBarRenderer);\r
@@ -267,6 +283,8 @@ public class JFreeChartResource {
         subtitles_Inverse = getResourceOrNull(graph, URIs.subtitles_Inverse);\r
         title = getResourceOrNull(graph, URIs.title);\r
         title_Inverse = getResourceOrNull(graph, URIs.title_Inverse);\r
+        variableFilter = getResourceOrNull(graph, URIs.variableFilter);\r
+        variableFilter_Inverse = getResourceOrNull(graph, URIs.variableFilter_Inverse);\r
         variableRVI = getResourceOrNull(graph, URIs.variableRVI);\r
         variableRVI_Inverse = getResourceOrNull(graph, URIs.variableRVI_Inverse);\r
         visible = getResourceOrNull(graph, URIs.visible);\r
index bb966445e3f773f746ed721182c85d1deed584d4..0b7d2e4293b215d42314ab4c70818c16ddd2ece7 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
index c916c172c41d4f73ba88999b156fc526b6c427d3..44b844d02636a0b905d9ed69193987822a15bbf7 100644 (file)
@@ -18,6 +18,7 @@ CBC.AxisChildRule : VP.ChildRule
 CBC.VariableChildRule : VP.ChildRule\r
 CBC.SeriesLabelRule : VP.LabelRule\r
 CBC.AxisLabelRule : VP.LabelRule\r
+CBC.SeriesLabelDecorationRule : VP.LabelDecorationRule\r
 \r
 CBC\r
     @VP.customChildRule JFREE.Chart CBC.AxisChildRule\r
@@ -29,6 +30,9 @@ CBC
     @VP.customLabelRule             JFREE.Axis          CBC.AxisLabelRule\r
     @VP.customLabelRule             JFREE.Series        CBC.SeriesLabelRule\r
     \r
+CBC\r
+    @VP.customLabelDecorationRule   JFREE.Series        CBC.SeriesLabelDecorationRule \r
+    \r
 CBC\r
     @VP.dropActionContribution JFREE.Axis CAC.Actions.SeriesDropAction 1.0    \r
     @VP.dropActionContribution JFREE.Series CAC.Actions.SeriesDropAction 1.0      \r
@@ -57,7 +61,8 @@ BSAC = SYSDYN.BarSeriesActionContext : VP.BrowseContext
 \r
 BSBC.SeriesChildRule : VP.ChildRule\r
 BSBC.SeriesLabelRule : VP.LabelRule\r
-\r
+BSBC.SeriesLabelDecorationRule : VP.LabelDecorationRule\r
+    \r
 BSBC\r
     @VP.customChildRule JFREE.Chart BSBC.SeriesChildRule\r
         JFREE.Series\r
@@ -65,6 +70,9 @@ BSBC
 BSBC        \r
     @VP.customLabelRule             JFREE.Series        BSBC.SeriesLabelRule\r
     \r
+BSBC\r
+    @VP.customLabelDecorationRule   JFREE.Series        BSBC.SeriesLabelDecorationRule     \r
+    \r
 //BSBC\r
 //    @VP.dropActionContribution JFREE.Series BSAC.Actions.SeriesDropAction 1.0      \r
     \r
@@ -85,7 +93,8 @@ PSAC = SYSDYN.PieSeriesActionContext : VP.BrowseContext
 \r
 PSBC.SeriesChildRule : VP.ChildRule\r
 PSBC.SeriesLabelRule : VP.LabelRule\r
-\r
+PSBC.SeriesLabelDecorationRule : VP.LabelDecorationRule\r
+    \r
 PSBC\r
     @VP.customChildRule JFREE.Chart PSBC.SeriesChildRule\r
         JFREE.Series\r
@@ -93,6 +102,9 @@ PSBC
 PSBC        \r
     @VP.customLabelRule             JFREE.Series        PSBC.SeriesLabelRule\r
     \r
+PSBC\r
+    @VP.customLabelDecorationRule   JFREE.Series        PSBC.SeriesLabelDecorationRule     \r
+    \r
 //PSBC\r
 //    @VP.dropActionContribution JFREE.Series PSAC.Actions.SeriesDropAction 1.0      \r
     \r
index c8ad7f0f64be6a2ea31e5acdfc610223226f92a2..e0b54e36d2da542d99966f70ac9f23daa71adade 100644 (file)
@@ -21,6 +21,7 @@ public class SysdynResource {
     public final Resource BarSeriesActionContext_Actions;\r
     public final Resource BarSeriesBrowseContext;\r
     public final Resource BarSeriesBrowseContext_SeriesChildRule;\r
+    public final Resource BarSeriesBrowseContext_SeriesLabelDecorationRule;\r
     public final Resource BarSeriesBrowseContext_SeriesLabelRule;\r
     public final Resource BasicExperiment;\r
     public final Resource Bottom;\r
@@ -58,6 +59,7 @@ public class SysdynResource {
     public final Resource ChartAxisAndVariablesBrowseContext;\r
     public final Resource ChartAxisAndVariablesBrowseContext_AxisChildRule;\r
     public final Resource ChartAxisAndVariablesBrowseContext_AxisLabelRule;\r
+    public final Resource ChartAxisAndVariablesBrowseContext_SeriesLabelDecorationRule;\r
     public final Resource ChartAxisAndVariablesBrowseContext_SeriesLabelRule;\r
     public final Resource ChartAxisAndVariablesBrowseContext_VariableChildRule;\r
     public final Resource Cloud;\r
@@ -190,6 +192,7 @@ public class SysdynResource {
     public final Resource PieSeriesActionContext_Actions;\r
     public final Resource PieSeriesBrowseContext;\r
     public final Resource PieSeriesBrowseContext_SeriesChildRule;\r
+    public final Resource PieSeriesBrowseContext_SeriesLabelDecorationRule;\r
     public final Resource PieSeriesBrowseContext_SeriesLabelRule;\r
     public final Resource PlaybackExperiment;\r
     public final Resource Polarity;\r
@@ -303,6 +306,7 @@ public class SysdynResource {
         public static final String BarSeriesActionContext_Actions = "http://www.simantics.org/Sysdyn-1.1/BarSeriesActionContext/Actions";\r
         public static final String BarSeriesBrowseContext = "http://www.simantics.org/Sysdyn-1.1/BarSeriesBrowseContext";\r
         public static final String BarSeriesBrowseContext_SeriesChildRule = "http://www.simantics.org/Sysdyn-1.1/BarSeriesBrowseContext/SeriesChildRule";\r
+        public static final String BarSeriesBrowseContext_SeriesLabelDecorationRule = "http://www.simantics.org/Sysdyn-1.1/BarSeriesBrowseContext/SeriesLabelDecorationRule";\r
         public static final String BarSeriesBrowseContext_SeriesLabelRule = "http://www.simantics.org/Sysdyn-1.1/BarSeriesBrowseContext/SeriesLabelRule";\r
         public static final String BasicExperiment = "http://www.simantics.org/Sysdyn-1.1/BasicExperiment";\r
         public static final String Bottom = "http://www.simantics.org/Sysdyn-1.1/Bottom";\r
@@ -340,6 +344,7 @@ public class SysdynResource {
         public static final String ChartAxisAndVariablesBrowseContext = "http://www.simantics.org/Sysdyn-1.1/ChartAxisAndVariablesBrowseContext";\r
         public static final String ChartAxisAndVariablesBrowseContext_AxisChildRule = "http://www.simantics.org/Sysdyn-1.1/ChartAxisAndVariablesBrowseContext/AxisChildRule";\r
         public static final String ChartAxisAndVariablesBrowseContext_AxisLabelRule = "http://www.simantics.org/Sysdyn-1.1/ChartAxisAndVariablesBrowseContext/AxisLabelRule";\r
+        public static final String ChartAxisAndVariablesBrowseContext_SeriesLabelDecorationRule = "http://www.simantics.org/Sysdyn-1.1/ChartAxisAndVariablesBrowseContext/SeriesLabelDecorationRule";\r
         public static final String ChartAxisAndVariablesBrowseContext_SeriesLabelRule = "http://www.simantics.org/Sysdyn-1.1/ChartAxisAndVariablesBrowseContext/SeriesLabelRule";\r
         public static final String ChartAxisAndVariablesBrowseContext_VariableChildRule = "http://www.simantics.org/Sysdyn-1.1/ChartAxisAndVariablesBrowseContext/VariableChildRule";\r
         public static final String Cloud = "http://www.simantics.org/Sysdyn-1.1/Cloud";\r
@@ -472,6 +477,7 @@ public class SysdynResource {
         public static final String PieSeriesActionContext_Actions = "http://www.simantics.org/Sysdyn-1.1/PieSeriesActionContext/Actions";\r
         public static final String PieSeriesBrowseContext = "http://www.simantics.org/Sysdyn-1.1/PieSeriesBrowseContext";\r
         public static final String PieSeriesBrowseContext_SeriesChildRule = "http://www.simantics.org/Sysdyn-1.1/PieSeriesBrowseContext/SeriesChildRule";\r
+        public static final String PieSeriesBrowseContext_SeriesLabelDecorationRule = "http://www.simantics.org/Sysdyn-1.1/PieSeriesBrowseContext/SeriesLabelDecorationRule";\r
         public static final String PieSeriesBrowseContext_SeriesLabelRule = "http://www.simantics.org/Sysdyn-1.1/PieSeriesBrowseContext/SeriesLabelRule";\r
         public static final String PlaybackExperiment = "http://www.simantics.org/Sysdyn-1.1/PlaybackExperiment";\r
         public static final String Polarity = "http://www.simantics.org/Sysdyn-1.1/Polarity";\r
@@ -595,6 +601,7 @@ public class SysdynResource {
         BarSeriesActionContext_Actions = getResourceOrNull(graph, URIs.BarSeriesActionContext_Actions);\r
         BarSeriesBrowseContext = getResourceOrNull(graph, URIs.BarSeriesBrowseContext);\r
         BarSeriesBrowseContext_SeriesChildRule = getResourceOrNull(graph, URIs.BarSeriesBrowseContext_SeriesChildRule);\r
+        BarSeriesBrowseContext_SeriesLabelDecorationRule = getResourceOrNull(graph, URIs.BarSeriesBrowseContext_SeriesLabelDecorationRule);\r
         BarSeriesBrowseContext_SeriesLabelRule = getResourceOrNull(graph, URIs.BarSeriesBrowseContext_SeriesLabelRule);\r
         BasicExperiment = getResourceOrNull(graph, URIs.BasicExperiment);\r
         Bottom = getResourceOrNull(graph, URIs.Bottom);\r
@@ -632,6 +639,7 @@ public class SysdynResource {
         ChartAxisAndVariablesBrowseContext = getResourceOrNull(graph, URIs.ChartAxisAndVariablesBrowseContext);\r
         ChartAxisAndVariablesBrowseContext_AxisChildRule = getResourceOrNull(graph, URIs.ChartAxisAndVariablesBrowseContext_AxisChildRule);\r
         ChartAxisAndVariablesBrowseContext_AxisLabelRule = getResourceOrNull(graph, URIs.ChartAxisAndVariablesBrowseContext_AxisLabelRule);\r
+        ChartAxisAndVariablesBrowseContext_SeriesLabelDecorationRule = getResourceOrNull(graph, URIs.ChartAxisAndVariablesBrowseContext_SeriesLabelDecorationRule);\r
         ChartAxisAndVariablesBrowseContext_SeriesLabelRule = getResourceOrNull(graph, URIs.ChartAxisAndVariablesBrowseContext_SeriesLabelRule);\r
         ChartAxisAndVariablesBrowseContext_VariableChildRule = getResourceOrNull(graph, URIs.ChartAxisAndVariablesBrowseContext_VariableChildRule);\r
         Cloud = getResourceOrNull(graph, URIs.Cloud);\r
@@ -764,6 +772,7 @@ public class SysdynResource {
         PieSeriesActionContext_Actions = getResourceOrNull(graph, URIs.PieSeriesActionContext_Actions);\r
         PieSeriesBrowseContext = getResourceOrNull(graph, URIs.PieSeriesBrowseContext);\r
         PieSeriesBrowseContext_SeriesChildRule = getResourceOrNull(graph, URIs.PieSeriesBrowseContext_SeriesChildRule);\r
+        PieSeriesBrowseContext_SeriesLabelDecorationRule = getResourceOrNull(graph, URIs.PieSeriesBrowseContext_SeriesLabelDecorationRule);\r
         PieSeriesBrowseContext_SeriesLabelRule = getResourceOrNull(graph, URIs.PieSeriesBrowseContext_SeriesLabelRule);\r
         PlaybackExperiment = getResourceOrNull(graph, URIs.PlaybackExperiment);\r
         Polarity = getResourceOrNull(graph, URIs.Polarity);\r
index dd09c0f4659173ac518da891fd9968ded34c0a68..336f926863365dd4e98f0f37231631fa489f6661 100644 (file)
@@ -10,5 +10,5 @@
         VTT Technical Research Centre of Finland - initial API and implementation\r
  -->\r
 
-<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r     <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-0.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r\r               <resource\r                      uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-1.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-0.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <resource uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.InputFactory" />                       \r       </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />            \r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowConnectionFactory">\r            <graph/>\r        </type>                       \r                       \r               <resource uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r   </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-0.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-0.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-0.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r       <!-- ModelBrowser2 -->\r \r       <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.VariableChildRule"/>  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>           \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>                          \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisLabelRule"/> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>                               \r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/OpenWorkbook"\r            class="org.simantics.sysdyn.ui.browser.actions.OpenWorkbookAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewSharedFunctionLibraryAction" />            \r    </target>         \r    \r   <target interface="org.simantics.db.layer0.adapter.DropActionFactory">\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/AxisDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisDropAction" />            \r    </target>     \r  \r  <!-- PROFILES -->\r    <target interface="org.simantics.scenegraph.profile.Style">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/SimulationPlaybackStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.SimulationPlaybackStyle">\r        </resource>\r                <resource uri="http://www.simantics.org/Sysdyn-0.0/IssueStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.IssueDecorationStyle">\r        </resource>\r    </target>\r    \r  <!-- Charts -->\r    <target interface="org.simantics.sysdyn.ui.trend.chart.IJFreeChart">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/Chart"\r            class="org.simantics.sysdyn.ui.trend.chart.JFreeChart">\r            <graph />\r            <this />\r        </type>\r    </target>  \r    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IDataset">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.XYDataset">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryDataset">\r            <graph />\r            <this />\r        </type>        \r        <type uri="http://www.simantics.org/JFreeChart-1.0/PieDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.PieDataset">\r            <graph />\r            <this />\r        </type>          \r    </target>\r    \r     <target interface="org.simantics.sysdyn.ui.trend.chart.ITitle">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/TextTitle"\r            class="org.simantics.sysdyn.ui.trend.chart.TextTitle">\r            <graph />\r            <this />\r        </type>\r    </target>\r    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IAxis">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/NumberAxis"\r            class="org.simantics.sysdyn.ui.trend.chart.NumberAxis">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryAxis"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryAxis">\r            <graph />\r            <this />\r        </type>        \r    </target>\r       \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IPlot">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYPlot"\r            class="org.simantics.sysdyn.ui.trend.chart.XYPlot">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryPlot"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryPlot">\r            <graph />\r            <this />\r        </type>      \r        <type uri="http://www.simantics.org/JFreeChart-1.0/PiePlot"\r            class="org.simantics.sysdyn.ui.trend.chart.PiePlot">\r            <graph />\r            <this />\r        </type>               \r    </target>\r    \r     <target interface="org.simantics.sysdyn.ui.trend.chart.IRenderer">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/BarRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.BarRenderer">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/StackedBarRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.StackedBarRenderer">\r            <graph />\r            <this />\r        </type>        \r    </target>    \r       \r
+<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r     <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-0.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r\r               <resource\r                      uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-1.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-0.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <resource uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.InputFactory" />                       \r       </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />            \r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowConnectionFactory">\r            <graph/>\r        </type>                       \r                       \r               <resource uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r   </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-0.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-0.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-0.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r       <!-- ModelBrowser2 -->\r \r       <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.VariableChildRule"/>  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>           \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>                          \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisLabelRule"/> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>       \r                     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>       \r                                               \r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/OpenWorkbook"\r            class="org.simantics.sysdyn.ui.browser.actions.OpenWorkbookAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewSharedFunctionLibraryAction" />            \r    </target>         \r    \r   <target interface="org.simantics.db.layer0.adapter.DropActionFactory">\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/AxisDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisDropAction" />            \r    </target>     \r  \r  <!-- PROFILES -->\r    <target interface="org.simantics.scenegraph.profile.Style">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/SimulationPlaybackStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.SimulationPlaybackStyle">\r        </resource>\r                <resource uri="http://www.simantics.org/Sysdyn-0.0/IssueStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.IssueDecorationStyle">\r        </resource>\r    </target>\r    \r  <!-- Charts -->\r    <target interface="org.simantics.sysdyn.ui.trend.chart.IJFreeChart">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/Chart"\r            class="org.simantics.sysdyn.ui.trend.chart.JFreeChart">\r            <graph />\r            <this />\r        </type>\r    </target>  \r    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IDataset">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.XYDataset">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryDataset">\r            <graph />\r            <this />\r        </type>        \r        <type uri="http://www.simantics.org/JFreeChart-1.0/PieDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.PieDataset">\r            <graph />\r            <this />\r        </type>          \r    </target>\r    \r     <target interface="org.simantics.sysdyn.ui.trend.chart.ITitle">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/TextTitle"\r            class="org.simantics.sysdyn.ui.trend.chart.TextTitle">\r            <graph />\r            <this />\r        </type>\r    </target>\r    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IAxis">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/NumberAxis"\r            class="org.simantics.sysdyn.ui.trend.chart.NumberAxis">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryAxis"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryAxis">\r            <graph />\r            <this />\r        </type>        \r    </target>\r       \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IPlot">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYPlot"\r            class="org.simantics.sysdyn.ui.trend.chart.XYPlot">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryPlot"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryPlot">\r            <graph />\r            <this />\r        </type>      \r        <type uri="http://www.simantics.org/JFreeChart-1.0/PiePlot"\r            class="org.simantics.sysdyn.ui.trend.chart.PiePlot">\r            <graph />\r            <this />\r        </type>               \r    </target>\r    \r     <target interface="org.simantics.sysdyn.ui.trend.chart.IRenderer">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/BarRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.BarRenderer">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/StackedBarRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.StackedBarRenderer">\r            <graph />\r            <this />\r        </type>        \r    </target>    \r       \r
 </adapters>
\ No newline at end of file
diff --git a/org.simantics.sysdyn.ui/icons/chart_line.png b/org.simantics.sysdyn.ui/icons/chart_line.png
new file mode 100644 (file)
index 0000000..85020f3
Binary files /dev/null and b/org.simantics.sysdyn.ui/icons/chart_line.png differ
diff --git a/org.simantics.sysdyn.ui/icons/chart_pie.png b/org.simantics.sysdyn.ui/icons/chart_pie.png
new file mode 100644 (file)
index 0000000..fe00fa0
Binary files /dev/null and b/org.simantics.sysdyn.ui/icons/chart_pie.png differ
index 6cc2a412ee301b3f4e0b221f128f6fbe93b3a2e1..10948a1c2dda24fe0bb2f8697addde2c3f81102d 100644 (file)
@@ -14,20 +14,31 @@ package org.simantics.sysdyn.ui.browser.contributions;
 import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.simantics.browsing.ui.swt.ImagerContributor;\r
 import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.browser.nodes.ChartNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractChartNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.BarChartNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.LineChartNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.PieChartNode;\r
 \r
 /**\r
- * Provides image for {@link ChartNode} in model browser\r
+ * Provides image for {@link LineChartNode} in model browser\r
  * @author Teemu Lempinen\r
  *\r
  */\r
-public class ChartImager extends ImagerContributor<ChartNode> {\r
+public class ChartImager extends ImagerContributor<AbstractChartNode<Resource>> {\r
 \r
     @Override\r
-    public ImageDescriptor getDescriptor(ReadGraph graph, ChartNode input) throws DatabaseException {\r
-        return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_organisation.png"));\r
+    public ImageDescriptor getDescriptor(ReadGraph graph, AbstractChartNode<Resource> input) throws DatabaseException {\r
+        if(input instanceof BarChartNode)\r
+            return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_bar.png"));\r
+        else if(input instanceof PieChartNode)\r
+            return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_pie.png"));\r
+        else\r
+            return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_line.png"));\r
+\r
+        \r
     }\r
 \r
 }\r
index 671d1b74297b0cc93b6ab55afca1bca2ac63b5b5..1301ab5f880d6e22ada48347c15b3aa83fee64f5 100644 (file)
@@ -13,19 +13,21 @@ package org.simantics.sysdyn.ui.browser.contributions;
 \r
 import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
 import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.Layer0;\r
-import org.simantics.sysdyn.ui.browser.nodes.ChartNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractChartNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.LineChartNode;\r
 \r
 /**\r
- * Provides label for {@link ChartNode} in model browser\r
+ * Provides label for {@link LineChartNode} in model browser\r
  * @author Teemu Lempinen\r
  *\r
  */\r
-public class ChartLabeler extends LabelerContributor<ChartNode> {\r
+public class ChartLabeler extends LabelerContributor<AbstractChartNode<Resource>> {\r
 \r
     @Override\r
-    public String getLabel(ReadGraph graph, ChartNode chart) throws DatabaseException {\r
+    public String getLabel(ReadGraph graph, AbstractChartNode<Resource> chart) throws DatabaseException {\r
         String name = graph.getPossibleRelatedValue(chart.data, Layer0.getInstance(graph).HasLabel);\r
         return name == null ? "Chart (no label)" : name;\r
     }\r
index 766aec6b0c48f7f46d4d9b644d3c97ea6c5708ed..90707af4abfce862165c2530dff70b4f08881544 100644 (file)
@@ -19,11 +19,14 @@ import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributo
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.PossibleObjectWithType;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
-import org.simantics.sysdyn.ui.browser.nodes.ChartNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.BarChartNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.LineChartNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ChartsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.PieChartNode;\r
 \r
 /**\r
  * Class for creating chart nodes for model browser\r
@@ -34,12 +37,24 @@ public class Charts extends ViewpointContributor<ChartsFolder> {
 \r
     @Override\r
     public Collection<?> getContribution(ReadGraph graph, ChartsFolder folder) throws DatabaseException {\r
+        Layer0 l0 = Layer0.getInstance(graph);\r
+        JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+        \r
         ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
         for(Resource chart : graph.syncRequest(\r
                 new ObjectsWithType(folder.data,\r
-                        Layer0.getInstance(graph).ConsistsOf, \r
-                        JFreeChartResource.getInstance(graph).Chart))) {\r
-            result.add(new ChartNode(chart));\r
+                        l0.ConsistsOf, \r
+                        jfree.Chart))) {\r
+            Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.Plot));\r
+            if(plot != null) {\r
+                if(graph.isInstanceOf(plot, jfree.XYPlot)) {\r
+                    result.add(new LineChartNode(chart));\r
+                } else if(graph.isInstanceOf(plot, jfree.CategoryPlot)) {\r
+                    result.add(new BarChartNode(chart));\r
+                } else if(graph.isInstanceOf(plot, jfree.PiePlot)) {\r
+                    result.add(new PieChartNode(chart));\r
+                }\r
+            }\r
         }\r
         return result;\r
     }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/AbstractChartNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/AbstractChartNode.java
new file mode 100644 (file)
index 0000000..61eb185
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import java.util.Iterator;\r
+\r
+import org.eclipse.core.runtime.IAdaptable;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
+import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.RemoverUtil;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+\r
+public abstract class AbstractChartNode<T> extends AbstractNode<Resource> implements IDropTargetNode, IDeletableNode {\r
+\r
+    public AbstractChartNode(Resource data) {\r
+        super(data);\r
+    }\r
+\r
+\r
+    /**\r
+     * Add variable to this chart, if the dropped element(s) can be adapted to a {@link Variable} \r
+     */\r
+    @Override\r
+    public void drop(Object data) {\r
+        IStructuredSelection selection = (IStructuredSelection)data;\r
+        Iterator<?> iterator = selection.iterator();\r
+        while(iterator.hasNext()) {\r
+            Object o = iterator.next();\r
+            if(o instanceof IAdaptable) {\r
+                Variable v = (Variable) ((IAdaptable)o).getAdapter(Variable.class);\r
+                if(v != null) {\r
+                    addVariableToChart(v);\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+\r
+    /**\r
+     * Adds a variable to this chart and map it to the first rangeAxis\r
+     * @param variable\r
+     */\r
+    protected abstract void addVariableToChart(final Variable variable);\r
+\r
+    @Override\r
+    public void delete() throws DeleteException {\r
+        try {\r
+            SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+                @Override\r
+                public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+                    RemoverUtil.remove(graph, data);\r
+                }\r
+            });\r
+        } catch (DatabaseException e) {\r
+            ExceptionUtils.logAndShowError(e);\r
+        }    \r
+\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/BarChartNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/BarChartNode.java
new file mode 100644 (file)
index 0000000..91fe6d6
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.PossibleObjectWithType;\r
+import org.simantics.db.common.request.SingleObjectWithType;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+/**\r
+ * Bar chart node\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class BarChartNode extends AbstractChartNode<Resource> {\r
+\r
+    public BarChartNode(Resource data) {\r
+        super(data);\r
+    }\r
+    \r
+    \r
+    /**\r
+     * Adds a variable to this chart\r
+     * @param variable\r
+     */\r
+    @Override\r
+    protected void addVariableToChart(final Variable variable) {\r
+\r
+        SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+            @Override\r
+            public void perform(WriteGraph graph) throws DatabaseException {\r
+                Layer0 l0 = Layer0.getInstance(graph);\r
+                JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+\r
+                Resource plot = graph.syncRequest(new SingleObjectWithType(data, l0.ConsistsOf, jfree.Plot));\r
+                if(plot == null)\r
+                    return;\r
+\r
+                Resource dataset = graph.syncRequest(new PossibleObjectWithType(plot, l0.ConsistsOf, jfree.Dataset));\r
+                \r
+                if(dataset == null)\r
+                    return;\r
+                \r
+                // Create the series and attach it to the dataset\r
+                String rvi = Variables.getRVI(graph, variable);\r
+                ChartUtils.createSeries(graph, dataset, rvi);\r
+            }\r
+        });\r
+    }\r
+\r
+}\r
similarity index 60%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ChartNode.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/LineChartNode.java
index a4db841d9b0f5b079ae3d93d865dfd810777a8de..1aa188f6e741519ba4796edad8d68e935022e7c2 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.browser.nodes;\r
 \r
-import java.util.Iterator;\r
-\r
-import org.eclipse.core.runtime.IAdaptable;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.simantics.browsing.ui.common.node.AbstractNode;\r
-import org.simantics.browsing.ui.common.node.DeleteException;\r
-import org.simantics.browsing.ui.common.node.IDeletableNode;\r
-import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.SingleObjectWithType;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.ListUtils;\r
-import org.simantics.db.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.utils.ui.ExceptionUtils;\r
 \r
 /**\r
- * Node representing a chart\r
+ * Node representing a  line chart\r
  * @author Teemu Lempinen\r
  *\r
  */\r
-public class ChartNode extends AbstractNode<Resource> implements IDropTargetNode, IDeletableNode {\r
+public class LineChartNode extends AbstractChartNode<Resource> {\r
 \r
-    public ChartNode(Resource data) {\r
+    public LineChartNode(Resource data) {\r
         super(data);\r
     }\r
 \r
-    /**\r
-     * Add variable to this chart, if the dropped element(s) can be adapted to a {@link Variable} \r
-     */\r
-    @Override\r
-    public void drop(Object data) {\r
-        IStructuredSelection selection = (IStructuredSelection)data;\r
-        Iterator<?> iterator = selection.iterator();\r
-        while(iterator.hasNext()) {\r
-            Object o = iterator.next();\r
-            if(o instanceof IAdaptable) {\r
-                Variable v = (Variable) ((IAdaptable)o).getAdapter(Variable.class);\r
-                if(v != null) {\r
-                    addVariableToChart(v);\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-\r
     /**\r
      * Adds a variable to this chart and map it to the first rangeAxis\r
      * @param variable\r
      */\r
-    private void addVariableToChart(final Variable variable) {\r
+    @Override\r
+    protected void addVariableToChart(final Variable variable) {\r
 \r
         SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
 \r
@@ -102,19 +73,4 @@ public class ChartNode extends AbstractNode<Resource> implements IDropTargetNode
         });\r
     }\r
 \r
-    @Override\r
-    public void delete() throws DeleteException {\r
-        try {\r
-            SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
-                @Override\r
-                public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
-                    RemoverUtil.remove(graph, data);\r
-                }\r
-            });\r
-        } catch (DatabaseException e) {\r
-            ExceptionUtils.logAndShowError(e);\r
-        }    \r
-\r
-    }\r
-\r
 }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/PieChartNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/PieChartNode.java
new file mode 100644 (file)
index 0000000..82f2750
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.PossibleObjectWithType;\r
+import org.simantics.db.common.request.SingleObjectWithType;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+/**\r
+ * Node for pie charts\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class PieChartNode extends AbstractChartNode<Resource> {\r
+\r
+    public PieChartNode(Resource data) {\r
+        super(data);\r
+    }\r
+\r
+    /**\r
+     * Adds a variable to this chart\r
+     * @param variable\r
+     */\r
+    @Override\r
+    protected void addVariableToChart(final Variable variable) {\r
+        SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+            @Override\r
+            public void perform(WriteGraph graph) throws DatabaseException {\r
+                Layer0 l0 = Layer0.getInstance(graph);\r
+                JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+\r
+                Resource plot = graph.syncRequest(new SingleObjectWithType(data, l0.ConsistsOf, jfree.Plot));\r
+                if(plot == null)\r
+                    return;\r
+\r
+                Resource dataset = graph.syncRequest(new PossibleObjectWithType(plot, l0.ConsistsOf, jfree.Dataset));\r
+                \r
+                if(dataset == null)\r
+                    return;\r
+                \r
+                // Create the series and attach it to the dataset\r
+                String rvi = Variables.getRVI(graph, variable);\r
+                Resource series = ChartUtils.createSeries(graph, dataset, rvi);\r
+                graph.claimLiteral(series, jfree.Series_exploded, false);\r
+            }\r
+        });        \r
+    }\r
+\r
+}\r
index 3f6e7bf114da810201d20cdb7fb5db607d655ae7..9d04cab34c73e5780601904ee6fbaea70b9129ed 100644 (file)
@@ -33,7 +33,7 @@ public abstract class AbstractAxis implements IAxis {
     protected String label;\r
     protected Boolean tMarksVisible, tLabelsVisible, labelVisible, lineVisible;\r
     protected Color color;\r
-    protected Double min, max;\r
+    protected Double min, max, rotate;\r
 \r
     /**\r
      *\r
@@ -53,6 +53,7 @@ public abstract class AbstractAxis implements IAxis {
             color = c == null ? null : G2DUtils.getColor(graph, c);\r
             min = graph.getPossibleRelatedValue(axisResource, jfree.Axis_min, Bindings.DOUBLE);\r
             max = graph.getPossibleRelatedValue(axisResource, jfree.Axis_max, Bindings.DOUBLE);\r
+            rotate = graph.getPossibleRelatedValue(axisResource, jfree.Axis_rotateLabelDegrees, Bindings.DOUBLE);\r
         } catch (DatabaseException e) {\r
             e.printStackTrace();\r
         }\r
index d31e8ea79163fcf7e18aeb41befaf572443b2693..bd58da1e0acbb1678351098c17d5e13a1ba3d5b1 100644 (file)
@@ -12,6 +12,7 @@
 package org.simantics.sysdyn.ui.trend.chart;\r
 \r
 import org.jfree.chart.axis.Axis;\r
+import org.jfree.chart.axis.CategoryLabelPositions;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 \r
@@ -30,6 +31,12 @@ public class CategoryAxis extends AbstractAxis {
     @Override\r
     public Axis getAxis() {\r
         axis = new org.jfree.chart.axis.CategoryAxis();\r
+        \r
+        if(rotate != null && rotate > 0) {\r
+            ((org.jfree.chart.axis.CategoryAxis)axis).setCategoryLabelPositions(\r
+                    CategoryLabelPositions.createUpRotationLabelPositions(Math.toRadians(rotate)));\r
+        }\r
+        \r
         return super.getAxis();\r
     }\r
 \r
index d87627c04a7382fa57e0ee60638628c8d24cebc4..98416d0f46a073edc6d33738df56150628995721 100644 (file)
@@ -37,6 +37,8 @@ import org.simantics.modeling.ModelingResources;
 import org.simantics.operation.Layer0X;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.adapter.SysdynVariableProperties;\r
+import org.simantics.sysdyn.adapter.VariableRVIUtils;\r
+import org.simantics.sysdyn.manager.SysdynDataSet;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
 /**\r
@@ -122,39 +124,61 @@ public class CategoryDataset extends AbstractDataset {
                             try {\r
                                 // Get a variable for the series\r
                                 Variable v = Variables.getVariable(graph, realizationURI + rvi);\r
-\r
+                                \r
                                 // Get values\r
-                                double[] va = v.getPossiblePropertyValue(graph, SysdynVariableProperties.VALUES , Bindings.DOUBLE_ARRAY);\r
-\r
-                                if(va == null || va.length == 0)\r
-                                    continue;\r
-\r
-                                // Time\r
-                                Double time = graph.getPossibleRelatedValue(r, jfree.Series_time, Bindings.DOUBLE);\r
-\r
-                                if(time == null)\r
-                                    time = v.getPossiblePropertyValue(graph, SysdynVariableProperties.TIME, Bindings.DOUBLE);\r
-\r
-                                // Value\r
-                                Double value = null;\r
-                                if(time == null) {\r
-                                    value = va[va.length - 1];\r
-                                } else {\r
-                                    double[] ta = v.getPossiblePropertyValue(graph, SysdynVariableProperties.TIMES , Bindings.DOUBLE_ARRAY);\r
-                                    for(int i = 0; i < ta.length; i++) {\r
-                                        double t = ta[i];\r
-                                        if(time <= t) {\r
-                                            value = va[i]; \r
-                                            break;\r
-                                        }\r
+                                Object object =  v.getPossiblePropertyValue(graph, SysdynVariableProperties.ACTIVE_DATASETS , Bindings.VARIANT);\r
+                                if(object == null || !(object instanceof ArrayList<?>))\r
+                                    return series;\r
+                                \r
+                                ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
+                                \r
+                                for(Object o : (ArrayList<?>)object) {\r
+                                    if(o instanceof SysdynDataSet)\r
+                                        datasets.add((SysdynDataSet)o);\r
+                                }\r
+                                \r
+                                String[] filter = graph.getPossibleRelatedValue(r, jfree.variableFilter);\r
+                                if(filter != null) {\r
+                                    ArrayList<SysdynDataSet> result2 = VariableRVIUtils.getDataset(datasets, filter);\r
+                                    if(result2 != null) {\r
+                                        datasets = result2;\r
                                     }\r
-\r
-                                    if(value == null)\r
+                                }\r
+                                \r
+                                for(SysdynDataSet dataset : datasets) {\r
+                                    double[] va = dataset.values;\r
+                                    \r
+                                    \r
+                                    if(va == null || va.length == 0)\r
+                                        continue;\r
+\r
+                                    // Time\r
+                                    Double time = graph.getPossibleRelatedValue(r, jfree.Series_time, Bindings.DOUBLE);\r
+\r
+                                    if(time == null)\r
+                                        time = v.getPossiblePropertyValue(graph, SysdynVariableProperties.TIME, Bindings.DOUBLE);\r
+\r
+                                    // Value\r
+                                    Double value = null;\r
+                                    if(time == null) {\r
                                         value = va[va.length - 1];\r
+                                    } else {\r
+                                        double[] ta = dataset.times;\r
+                                        for(int i = 0; i < ta.length; i++) {\r
+                                            double t = ta[i];\r
+                                            if(time <= t) {\r
+                                                value = va[i]; \r
+                                                break;\r
+                                            }\r
+                                        }\r
+\r
+                                        if(value == null)\r
+                                            value = va[va.length - 1];\r
+                                    }\r
+                                    String label = graph.getPossibleRelatedValue(r, Layer0.getInstance(graph).HasLabel); // Called to refresh paints when label changes\r
+                                    String name = dataset.name;\r
+                                    series.add(new TempSeries(label == null || label.isEmpty() ? name : label, "Current", value));\r
                                 }\r
-                                String label = graph.getPossibleRelatedValue(r, Layer0.getInstance(graph).HasLabel); // Called to refresh paints when label changes\r
-                                String name = v.getName(graph);\r
-                                series.add(new TempSeries(label == null || label.isEmpty() ? name : label, "Current", value));\r
                             } catch (MissingVariableException e) {\r
                                 // Do nothing, if variable was not found. Move on to the next series\r
                             }\r
@@ -165,7 +189,6 @@ public class CategoryDataset extends AbstractDataset {
 \r
             }, listener);\r
         }\r
-//        System.out.println("RETURNING CATEGORY DATASET" + dataset);\r
         return dataset;\r
     }\r
 \r
@@ -197,7 +220,6 @@ public class CategoryDataset extends AbstractDataset {
                     for(int i = 0; i < series.size(); i++) {\r
                         TempSeries s = series.get(i);\r
                         dataset.addValue(s.value, s.series, s.name);\r
-//                        System.out.println("Added " + s.name + ": " + s.value + " to " + dataset);\r
                     }\r
                 }\r
             });\r
index 51679325a31c3d9b3d2090e1c0f0e0072d4dda75..60a0092502bb48ac8ffb61b103a888a487788d5f 100644 (file)
@@ -47,8 +47,9 @@ public class CategoryPlot extends AbstractPlot {
 \r
     @Override\r
     public Plot getPlot() {\r
-        plot = new org.jfree.chart.plot.CategoryPlot(null, null, null, null);\r
-        \r
+        if(plot == null) {\r
+            plot = new org.jfree.chart.plot.CategoryPlot(null, null, null, null);\r
+        }        \r
         /* Support using multiple axis, but prefer using only one domain and \r
          * one range axis\r
          */\r
index 9e374b88a844bf0f8de05cc8e1a702d88466cdc0..446a53323888e4257d38af7a880ddd43ec72d058 100644 (file)
@@ -22,11 +22,12 @@ import org.eclipse.swt.events.DisposeListener;
 import org.eclipse.swt.widgets.Composite;\r
 import org.jfree.chart.ChartPanel;\r
 import org.jfree.chart.JFreeChart;\r
+import org.simantics.db.AsyncReadGraph;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.util.Simantics;\r
-import org.simantics.db.procedure.SyncListener;\r
+import org.simantics.db.procedure.AsyncListener;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.ui.SimanticsUI;\r
@@ -43,7 +44,7 @@ public class ChartComposite extends Composite {
     private Frame frame;\r
     private ChartPanel panel;\r
     private Composite composite;\r
-    IJFreeChart chart;\r
+    private IJFreeChart chart;\r
 \r
     /**\r
      * A new ChartComposite with a definition in chartResourceURI\r
@@ -101,60 +102,58 @@ public class ChartComposite extends Composite {
         GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
         frame = SWT_AWT.new_Frame(composite);\r
 \r
-        try {\r
-            // Add a listener displaying the contents of the chart. Chart is re-drawn if the definition changes\r
-            Simantics.getSession().syncRequest(new Read<JFreeChart>() {\r
+        // Add a listener displaying the contents of the chart. Chart is re-drawn if the definition changes\r
+        Simantics.getSession().asyncRequest(new Read<JFreeChart>() {\r
 \r
-                @Override\r
-                public JFreeChart perform(ReadGraph graph) throws DatabaseException {\r
-                    // Adapt chartResource to a chart (XY, pie, bar, ...)\r
-                    if(graph.isInstanceOf(chartResource, JFreeChartResource.getInstance(graph).Chart)) {\r
-                        if(chart != null)\r
-                            chart.dispose();\r
-                        chart = graph.adapt(chartResource, IJFreeChart.class);\r
-                        return chart.getChart();\r
-                    } else {\r
-                        return null;\r
-                    }\r
+            @Override\r
+            public JFreeChart perform(ReadGraph graph) throws DatabaseException {\r
+                // Adapt chartResource to a chart (XY, pie, bar, ...)\r
+                if(graph.isInstanceOf(chartResource, JFreeChartResource.getInstance(graph).Chart)) {\r
+                    if(chart != null)\r
+                        chart.dispose();\r
+                    chart = graph.adapt(chartResource, IJFreeChart.class);\r
+                    return chart.getChart();\r
+                } else {\r
+                    return null;\r
                 }\r
+            }\r
 \r
-            } , new SyncListener<JFreeChart>() {\r
+        } , new AsyncListener<JFreeChart>() {\r
 \r
-                @Override\r
-                public boolean isDisposed() {\r
-                    return composite.isDisposed();\r
-                }\r
+            @Override\r
+            public boolean isDisposed() {\r
+                return composite.isDisposed();\r
+            }\r
 \r
-                @Override\r
-                public void execute(ReadGraph graph, JFreeChart chart) throws DatabaseException {\r
-                    if(chart == null)\r
-                        return;\r
-                    // Display the result chart\r
-                    composite.getDisplay().asyncExec(new RunnableWithObject(chart) {\r
-\r
-                        @Override\r
-                        public void run() {\r
-                            if(composite.isDisposed())\r
-                                return;\r
-                            if(panel != null)\r
-                                frame.remove(panel);\r
-                            composite.layout();\r
-                            panel = new ChartPanel((JFreeChart)getObject(), false, true, true, true, true);\r
-                            frame.add(panel);\r
-                            frame.repaint();\r
-                            frame.validate();\r
-                        }\r
-                    });\r
-                }\r
+            @Override\r
+            public void execute(AsyncReadGraph graph, JFreeChart chart) {\r
+                if(chart == null)\r
+                    return;\r
+                // Display the result chart\r
+                composite.getDisplay().asyncExec(new RunnableWithObject(chart) {\r
+\r
+                    @Override\r
+                    public void run() {\r
+                        if(composite.isDisposed())\r
+                            return;\r
+                        if(panel != null)\r
+                            frame.remove(panel);\r
+                        composite.layout();\r
+                        JFreeChart chart = (JFreeChart)getObject();\r
+                        panel = new ChartPanel(chart, false, true, true, true, true);\r
+                        frame.add(panel);\r
+                        frame.repaint();\r
+                        frame.validate();\r
+                    }\r
+                });\r
+            }\r
 \r
-                @Override\r
-                public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {\r
-                    throwable.printStackTrace();\r
-                }\r
-            });\r
-        } catch (DatabaseException e) {\r
-            e.printStackTrace();\r
-        }\r
+            @Override\r
+            public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+                throwable.printStackTrace();\r
+\r
+            }\r
+        });\r
     }\r
 \r
 }\r
index 6aa3ac6fe32ab85de892f5e5619307e8a707eba9..32081bbeb0c96c4ac9fe04a6a8dfed892cd124dd 100644 (file)
@@ -3,13 +3,17 @@ package org.simantics.sysdyn.ui.trend.chart;
 import java.util.ArrayList;\r
 import java.util.UUID;\r
 \r
+import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.request.PossibleActiveExperiment;\r
+import org.simantics.db.layer0.request.PossibleModel;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.operation.Layer0X;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
 \r
 /**\r
@@ -115,4 +119,30 @@ public class ChartUtils {
         return series;\r
     }\r
 \r
+    /**\r
+     * Find the current realization uri\r
+     * \r
+     * @param graph ReadGraph\r
+     * @param chartComponent A resource from a chart (consistsOf relation in a chart)\r
+     * @return current realization uri\r
+     * @throws DatabaseException\r
+     */\r
+    public static String getCurrentRealizationURI(ReadGraph graph, Resource chartComponent) throws DatabaseException {\r
+        // Find the model where the chart is located\r
+        Resource model = graph.syncRequest(new PossibleModel(chartComponent)); \r
+        if(model == null)\r
+            return null;\r
+        \r
+        // Find the variable realization of the current experiment\r
+        String realizationURI = null;\r
+        Resource realization = graph.syncRequest(new PossibleActiveExperiment(model));\r
+        if (realization == null) {\r
+            Layer0X L0X = Layer0X.getInstance(graph);\r
+            realization = graph.getPossibleObject(model, L0X.HasBaseRealization);\r
+        }\r
+        if (realization != null)\r
+            realizationURI = graph.getURI(realization);\r
+        \r
+        return realizationURI;        \r
+    }\r
 }\r
index 87aa81ceb87e364c8819289ed264d05602dfe30a..830ff222692e4f34005796c95756f7bb36f2a737 100644 (file)
@@ -11,6 +11,7 @@
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.trend.chart;\r
 \r
+import java.lang.reflect.InvocationTargetException;\r
 import java.util.Collection;\r
 \r
 import javax.swing.SwingUtilities;\r
@@ -24,6 +25,7 @@ import org.simantics.db.common.request.PossibleObjectWithType;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.utils.RunnableWithObject;\r
 \r
 /**\r
  * Class representing a complete JFreeChart.Chart\r
@@ -74,25 +76,30 @@ public class JFreeChart implements IJFreeChart {
     public org.jfree.chart.JFreeChart getChart() {\r
         if(plot == null)\r
             return null;\r
-        jfreechart = new org.jfree.chart.JFreeChart(plot.getPlot());\r
-\r
-        SwingUtilities.invokeLater(new Runnable() {\r
-            \r
-            @Override\r
-            public void run() {\r
-                // setVisible does not work in TextTitle, have to use this workaround \r
-                org.jfree.chart.title.TextTitle  t = (org.jfree.chart.title.TextTitle)title.getTitle();\r
-                if(t.isVisible())\r
-                    jfreechart.setTitle(t);\r
-\r
-                if(legendVisible != null && !legendVisible) {\r
-                    for(Object title : jfreechart.getSubtitles()) {\r
-                        if(title instanceof LegendTitle)\r
-                            ((LegendTitle)title).setVisible(legendVisible);\r
+\r
+        try {\r
+            SwingUtilities.invokeAndWait(new RunnableWithObject(plot) {\r
+                @Override\r
+                public void run() {\r
+                    jfreechart = new org.jfree.chart.JFreeChart(plot.getPlot());\r
+                    org.jfree.chart.title.TextTitle  t = (org.jfree.chart.title.TextTitle)title.getTitle();\r
+                    if(t.isVisible())\r
+                        jfreechart.setTitle(t);\r
+\r
+                    if(legendVisible != null && !legendVisible) {\r
+                        for(Object title : jfreechart.getSubtitles()) {\r
+                            if(title instanceof LegendTitle) {\r
+                                jfreechart.removeLegend();\r
+                            }\r
+                        }\r
                     }\r
                 }\r
-            }\r
-        });\r
+            });\r
+        } catch (InterruptedException e) {\r
+            e.printStackTrace();\r
+        } catch (InvocationTargetException e) {\r
+            e.printStackTrace();\r
+        }\r
         return jfreechart;\r
     }\r
 \r
index b7956d2ae6256f6e91139f1314cf2b4b9bf48a99..da1b61a1b98b689153475cc3a1af153c03a78bbd 100644 (file)
@@ -38,6 +38,8 @@ import org.simantics.modeling.ModelingResources;
 import org.simantics.operation.Layer0X;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.adapter.SysdynVariableProperties;\r
+import org.simantics.sysdyn.adapter.VariableRVIUtils;\r
+import org.simantics.sysdyn.manager.SysdynDataSet;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
 /**\r
@@ -84,34 +86,7 @@ public class PieDataset extends AbstractDataset {
             Resource seriesList = graph.getPossibleObject(resource, jfree.Dataset_seriesList);\r
             if(seriesList != null) {\r
                 this.seriesList = ListUtils.toList(graph, seriesList);\r
-\r
-                colorMap = new HashMap<String, Color>();\r
-                explodedMap = new HashMap<String, Boolean>();\r
-\r
-                for(Resource r : this.seriesList) {\r
-                    String rvi = graph.getPossibleRelatedValue(r, jfree.variableRVI);\r
-                    if(rvi == null)\r
-                        continue;\r
-\r
-                    try {\r
-                        Variable v = Variables.getVariable(graph, realizationURI + rvi);\r
-                        if(v != null) {\r
-                            String name = v.getName(graph);\r
-                            graph.getPossibleRelatedValue(r, l0.HasLabel); // Called to refresh paints when label changes\r
-                            // Get visual properties\r
-                            Resource c = graph.getPossibleObject(r, jfree.color);\r
-                            Color color = c == null ? null : G2DUtils.getColor(graph, c);\r
-                            colorMap.put(name, color);\r
-                            Boolean exploded = graph.getPossibleRelatedValue(r, jfree.Series_exploded, Bindings.BOOLEAN);\r
-                            explodedMap.put(name, exploded);\r
-                        }\r
-                    } catch (MissingVariableException e) {\r
-                        // Invalid or missing rvi, skip this series\r
-                        continue;\r
-                    }\r
-                }\r
             }\r
-\r
         } catch (DatabaseException e) {\r
             e.printStackTrace();\r
         }\r
@@ -156,6 +131,10 @@ public class PieDataset extends AbstractDataset {
                     ArrayList<TempSeries> series = new ArrayList<TempSeries>();\r
                     // Get properties for all series\r
                     if(seriesList != null) {\r
+\r
+                        colorMap = new HashMap<String, Color>();\r
+                        explodedMap = new HashMap<String, Boolean>();\r
+\r
                         for(Resource r : seriesList) {\r
                             String label = graph.getPossibleRelatedValue(r, Layer0.getInstance(graph).HasLabel);\r
                             String rvi = graph.getPossibleRelatedValue(r, jfree.variableRVI);\r
@@ -163,39 +142,69 @@ public class PieDataset extends AbstractDataset {
                                 continue;\r
 \r
                             try {\r
+                                // Get visual properties\r
+                                Resource c = graph.getPossibleObject(r, jfree.color);\r
+                                Color color = c == null ? null : G2DUtils.getColor(graph, c);\r
+                                Boolean exploded = graph.getPossibleRelatedValue(r, jfree.Series_exploded, Bindings.BOOLEAN);\r
+\r
                                 // Get a variable for the series\r
                                 Variable v = Variables.getVariable(graph, realizationURI + rvi);\r
+\r
                                 // Get values\r
-                                double[] va = v.getPossiblePropertyValue(graph, SysdynVariableProperties.VALUES , Bindings.DOUBLE_ARRAY);\r
-\r
-                                if(va == null || va.length == 0)\r
-                                    continue;\r
-\r
-                                // Time\r
-                                Double time = graph.getPossibleRelatedValue(r, jfree.Series_time, Bindings.DOUBLE);\r
-\r
-                                if(time == null)\r
-                                    time = v.getPossiblePropertyValue(graph, SysdynVariableProperties.TIME, Bindings.DOUBLE);\r
-\r
-                                // Value\r
-                                Double value = null;\r
-                                if(time == null) {\r
-                                    value = va[va.length - 1];\r
-                                } else {\r
-                                    double[] ta = v.getPossiblePropertyValue(graph, SysdynVariableProperties.TIMES , Bindings.DOUBLE_ARRAY);\r
-                                    for(int i = 0; i < ta.length; i++) {\r
-                                        double t = ta[i];\r
-                                        if(time <= t) {\r
-                                            value = va[i]; \r
-                                            break;\r
-                                        }\r
+                                Object object =  v.getPossiblePropertyValue(graph, SysdynVariableProperties.ACTIVE_DATASETS , Bindings.VARIANT);\r
+                                if(object == null || !(object instanceof ArrayList<?>))\r
+                                    return series;\r
+\r
+                                ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
+\r
+                                for(Object o : (ArrayList<?>)object) {\r
+                                    if(o instanceof SysdynDataSet)\r
+                                        datasets.add((SysdynDataSet)o);\r
+                                }\r
+\r
+                                String[] filter = graph.getPossibleRelatedValue(r, jfree.variableFilter);\r
+                                if(filter != null) {\r
+                                    ArrayList<SysdynDataSet> result2 = VariableRVIUtils.getDataset(datasets, filter);\r
+                                    if(result2 != null) {\r
+                                        datasets = result2;\r
                                     }\r
+                                }\r
+\r
+                                for(SysdynDataSet dataset : datasets) {\r
+                                    double[] va = dataset.values;\r
+\r
+                                    if(va == null || va.length == 0)\r
+                                        continue;\r
+\r
+                                    // Time\r
+                                    Double time = graph.getPossibleRelatedValue(r, jfree.Series_time, Bindings.DOUBLE);\r
 \r
-                                    if(value == null)\r
+                                    if(time == null)\r
+                                        time = v.getPossiblePropertyValue(graph, SysdynVariableProperties.TIME, Bindings.DOUBLE);\r
+\r
+                                    // Value\r
+                                    Double value = null;\r
+                                    if(time == null) {\r
                                         value = va[va.length - 1];\r
-                                }\r
+                                    } else {\r
+                                        double[] ta = dataset.times;\r
+                                        for(int i = 0; i < ta.length; i++) {\r
+                                            double t = ta[i];\r
+                                            if(time <= t) {\r
+                                                value = va[i]; \r
+                                                break;\r
+                                            }\r
+                                        }\r
 \r
-                                series.add(new TempSeries(label == null || label.isEmpty() ? v.getName(graph) : label, value));\r
+                                        if(value == null)\r
+                                            value = va[va.length - 1];\r
+                                    }\r
+\r
+                                    String name = label == null || label.isEmpty() ? dataset.name : label;\r
+                                    colorMap.put(name, color);\r
+                                    explodedMap.put(name, exploded);\r
+                                    series.add(new TempSeries(name, value));\r
+                                }\r
                             } catch (MissingVariableException e) {\r
                                 // Do nothing, if variable was not found. Move on to the next series\r
                             }\r
index b3b07e4977c91b204abe7cf6f4eb1a829d04cc75..62da880447ce480a171dbe432650d1afc5e78e75 100644 (file)
@@ -14,11 +14,11 @@ package org.simantics.sysdyn.ui.trend.chart;
 import java.awt.Color;\r
 import java.util.HashMap;\r
 \r
-import javax.swing.SwingUtilities;\r
-\r
 import org.jfree.chart.plot.DefaultDrawingSupplier;\r
 import org.jfree.chart.plot.Plot;\r
 import org.jfree.data.general.Dataset;\r
+import org.jfree.data.general.DatasetChangeEvent;\r
+import org.jfree.data.general.DatasetChangeListener;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 \r
@@ -31,6 +31,8 @@ import org.simantics.db.Resource;
 public class PiePlot extends AbstractPlot {\r
 \r
     org.jfree.chart.plot.PiePlot plot;\r
+    org.jfree.data.general.PieDataset pieDataset;\r
+    DatasetChangeListener listener;\r
 \r
     public PiePlot(ReadGraph graph, Resource resource) {\r
         super(graph, resource);\r
@@ -39,39 +41,83 @@ public class PiePlot extends AbstractPlot {
     @Override\r
     public Plot getPlot() {\r
         if(plot == null) {\r
-            plot = new org.jfree.chart.plot.PiePlot();\r
+            plot = new MyPiePlot();\r
         }\r
 \r
         if(!datasets.isEmpty()) {\r
             // We assume that a pie plot has only one dataset\r
-            IDataset ds = datasets.get(0);\r
-            final Dataset dataset = ((PieDataset)ds).getDataset();\r
-            final HashMap<String, Color> colorMap = ((PieDataset)ds).getColorMap();\r
-            final HashMap<String, Boolean> explodedMap = ((PieDataset)ds).getExplodedMap();\r
-            if(dataset instanceof org.jfree.data.general.PieDataset) {\r
-                SwingUtilities.invokeLater(new Runnable() {\r
-\r
-                    @Override\r
-                    public void run() {\r
-                        plot.clearSectionPaints(true);\r
-                        plot.setDrawingSupplier(new DefaultDrawingSupplier());\r
-\r
-                        org.jfree.data.general.PieDataset pieDataset = (org.jfree.data.general.PieDataset)dataset;\r
-                        plot.setDataset(pieDataset);\r
-\r
-                        for(String name : colorMap.keySet())\r
-                            plot.setSectionPaint(name, colorMap.get(name));\r
-\r
-                        for(String name : explodedMap.keySet()) {\r
-                            Boolean exploded = explodedMap.get(name);\r
-                            if(Boolean.TRUE.equals(exploded))\r
-                                plot.setExplodePercent(name, 0.3);\r
-                        }                     \r
-                    }\r
-                });\r
+            final IDataset ds = datasets.get(0);\r
+            Dataset dataset = ((PieDataset)ds).getDataset();\r
+\r
+            plot.clearSectionPaints(true);\r
+            plot.setDrawingSupplier(new DefaultDrawingSupplier());\r
+\r
+            if(pieDataset != null && listener != null) {\r
+                pieDataset.removeChangeListener(listener);\r
             }\r
+            \r
+            pieDataset = (org.jfree.data.general.PieDataset)dataset;\r
+            plot.setDataset(pieDataset);\r
+            \r
+            listener = new DatasetChangeListener() {\r
+                \r
+                @Override\r
+                public void datasetChanged(DatasetChangeEvent event) {\r
+                    HashMap<String, Color> colorMap = ((PieDataset)ds).getColorMap();\r
+                    HashMap<String, Boolean> explodedMap = ((PieDataset)ds).getExplodedMap();\r
+                    \r
+                    for(Object o : plot.getDataset().getKeys()) {\r
+                        if(o instanceof Comparable) {\r
+                            Comparable<?> key = (Comparable<?>)o;\r
+                            if(explodedMap.containsKey(key) && explodedMap.get(key)) {\r
+                                plot.setExplodePercent(key, 0.3);\r
+\r
+                            } else {\r
+                                plot.setExplodePercent(key, 0);\r
+                            }\r
+                        }\r
+                    }\r
+                    \r
+                    for(String name : explodedMap.keySet()) {\r
+                        Boolean exploded = explodedMap.get(name);\r
+                        if(Boolean.TRUE.equals(exploded))\r
+                            plot.setExplodePercent(name, 0.3);\r
+                    } \r
+                    \r
+                    plot.setDrawingSupplier(new DefaultDrawingSupplier());\r
+\r
+                    for(String name : colorMap.keySet())\r
+                        plot.setSectionPaint(name, colorMap.get(name));\r
+                }\r
+            };\r
+            \r
+            pieDataset.addChangeListener(listener);\r
         }\r
         return plot;\r
     }\r
 \r
+    /**\r
+     * Pie plot class with a stricter equals condition\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class MyPiePlot extends org.jfree.chart.plot.PiePlot {\r
+\r
+        private static final long serialVersionUID = -5917620061541212934L;\r
+\r
+        @Override\r
+        public boolean equals(Object obj) {\r
+            boolean result = super.equals(obj);\r
+            if(result == true) {\r
+                org.jfree.chart.plot.PiePlot that = (org.jfree.chart.plot.PiePlot) obj;\r
+                if (this.getDataset() != that.getDataset()) {\r
+                    return false; // Normally plot does not check this. We need this to properly update the charts\r
+                }\r
+            }\r
+\r
+            return result;\r
+        }\r
+\r
+    }\r
+\r
 }\r
index 1246412d0303ed6ca178abee802fab024a061af5..a9d6ce8088e4dc499a6ed289d3cf914c727abac6 100644 (file)
@@ -44,6 +44,7 @@ import org.simantics.modeling.ModelingResources;
 import org.simantics.operation.Layer0X;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.adapter.SysdynVariableProperties;\r
+import org.simantics.sysdyn.adapter.VariableRVIUtils;\r
 import org.simantics.sysdyn.manager.SysdynDataSet;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
@@ -146,26 +147,37 @@ public class XYDataset extends AbstractDataset {
                             try {\r
                                 // Get visual properties\r
                                 Integer width = graph.getPossibleRelatedValue(r, jfree.Series_lineWidth, Bindings.INTEGER);\r
+                                if(width == null) width = 1;\r
+\r
                                 Resource c = graph.getPossibleObject(r, jfree.color);\r
                                 Color color = c == null ? null : G2DUtils.getColor(graph, c);\r
 \r
                                 // Get a variable for the series\r
                                 Variable v = Variables.getVariable(graph, realizationURI + rvi);\r
 \r
-                                if(width == null) width = 1;\r
+                                \r
                                 // Get values\r
-//                                double[] va = v.getPossiblePropertyValue(graph, SysdynVariableProperties.VALUES , Bindings.DOUBLE_ARRAY);\r
-\r
-\r
                                 Object object =  v.getPossiblePropertyValue(graph, SysdynVariableProperties.ACTIVE_DATASETS , Bindings.VARIANT);\r
                                 if(object == null || !(object instanceof ArrayList<?>))\r
                                     return series;\r
-                                ArrayList<?> datasets = (ArrayList<?>)object;\r
-                                for(Object o : datasets) {\r
-                                    if(!(o instanceof SysdynDataSet))\r
-                                        continue;\r
+                                \r
+                                ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
 \r
-                                    SysdynDataSet dataset = (SysdynDataSet)o;\r
+                                for(Object o : (ArrayList<?>)object) {\r
+                                    if(o instanceof SysdynDataSet)\r
+                                        datasets.add((SysdynDataSet)o);\r
+                                }\r
+                                \r
+                                \r
+                                String[] filter = graph.getPossibleRelatedValue(r, jfree.variableFilter);\r
+                                if(filter != null) {\r
+                                    ArrayList<SysdynDataSet> result2 = VariableRVIUtils.getDataset(datasets, filter);\r
+                                    if(result2 != null) {\r
+                                        datasets = result2;\r
+                                    }\r
+                                }\r
+                                \r
+                                for(SysdynDataSet dataset : datasets) {\r
                                     double[] va = dataset.values;\r
 \r
                                     // Get domain axis values (time OR other variable) \r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/graphexplorer/SeriesLabelDecorationRule.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/graphexplorer/SeriesLabelDecorationRule.java
new file mode 100644 (file)
index 0000000..1aebcdb
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.trend.chart.graphexplorer;\r
+\r
+import org.eclipse.jface.resource.FontDescriptor;\r
+import org.simantics.browsing.ui.content.LabelDecorator;\r
+import org.simantics.browsing.ui.model.labeldecorators.LabelDecorationRule;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+public class SeriesLabelDecorationRule implements LabelDecorationRule {\r
+\r
+    @Override\r
+    public boolean isCompatible(Class<?> contentType) {\r
+        return contentType.equals(Resource.class);\r
+    }\r
+\r
+    @Override\r
+    public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException {\r
+        Resource resource = AdaptionUtils.adaptToSingle(content, Resource.class);\r
+        JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+\r
+        if (resource != null && graph.isInstanceOf(resource, jfree.Series)) {\r
+            final String[] filter = graph.getPossibleRelatedValue(resource, jfree.variableFilter, Bindings.STRING_ARRAY);\r
+            if(filter != null) {\r
+                return new LabelDecorator.Stub() {\r
+                    @Override\r
+                    public String decorateLabel(String label, String column, int itemIndex) {\r
+                        label += " [";\r
+                        for(int i = 0; i < filter.length; i++) {\r
+                            label += filter[i];\r
+                            if(i < filter.length - 1)\r
+                                label += ", ";\r
+                        }\r
+                        label += "]";\r
+                        return label;\r
+                    }\r
+\r
+                    @SuppressWarnings("unchecked")\r
+                    @Override\r
+                    public <F> F decorateFont(F font, String column, int itemIndex) {\r
+                        return (F) ((FontDescriptor) font);\r
+                    }\r
+                };\r
+            }\r
+        }\r
+        return null;\r
+    }\r
+\r
+}\r
index b17a4935d93d5bca3e5419bba9055106ceda1ca6..9a667b8e8894ac4e8f0d06b3ce334e2724dcc8a7 100644 (file)
@@ -98,10 +98,12 @@ public class RVIModifier extends TextModifyListenerImpl<Resource> {
     \r
 \r
     @Override\r
-    public void applyText(WriteGraph graph, Resource issue, String text) throws DatabaseException {\r
+    public void applyText(WriteGraph graph, Resource resource, String text) throws DatabaseException {\r
         if(active) {\r
             text = "/" + text.replace('.', '/');\r
-            graph.claimLiteral(issue, JFreeChartResource.getInstance(graph).variableRVI, text, Bindings.STRING);\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+            graph.claimLiteral(resource, jfree.variableRVI, text, Bindings.STRING);\r
+            graph.deny(resource, jfree.variableFilter);\r
         }\r
     }\r
 \r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java
new file mode 100644 (file)
index 0000000..40cbade
--- /dev/null
@@ -0,0 +1,320 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.trend.chart.properties;\r
+\r
+import java.util.Iterator;\r
+import java.util.LinkedHashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.ScrolledComposite;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedCombo;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ComboModifyListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.RunnableWithObject;\r
+import org.simantics.utils.datastructures.Quad;\r
+import org.simantics.utils.datastructures.Triple;\r
+\r
+/**\r
+ * Composite for range controls in chart series properties\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class RangeComposite extends Composite implements Widget {\r
+\r
+    private Composite composite;\r
+    \r
+    public RangeComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) {\r
+        super(parent, style);\r
+        support.register(this);\r
+        GridLayoutFactory.fillDefaults().spacing(3, 0).margins(3, 3).applyTo(this);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(this);\r
+        composite = this;\r
+    }\r
+\r
+    @Override\r
+    public void setInput(final ISessionContext context, final Object input) {\r
+        if(composite == null || composite.isDisposed())\r
+            return;\r
+\r
+        final Resource series = AdaptionUtils.adaptToSingle(input, Resource.class);\r
+\r
+        /*\r
+         *  Listen to the enumerations assigned to the variable in this series.\r
+         *  Listener is needed because the user can change the variableRVI for the series\r
+         *  and that changes the options for range\r
+         */\r
+        context.getSession().asyncRequest(new Read<LinkedHashMap<String, Resource>>() {\r
+\r
+            @Override\r
+            public LinkedHashMap<String, Resource> perform(ReadGraph graph) throws DatabaseException {\r
+                JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+                SysdynResource sr = SysdynResource.getInstance(graph);\r
+\r
+                String realizationURI = ChartUtils.getCurrentRealizationURI(graph, series);\r
+                String rvi = graph.getPossibleRelatedValue(series, jfree.variableRVI);\r
+                if(rvi == null)\r
+                    return null;\r
+                \r
+                try {\r
+                    // Find the variable for the current variableRVI\r
+                    Variable v = Variables.getVariable(graph, realizationURI + rvi.trim());\r
+                    Resource variable = v.getRepresents(graph);\r
+                    \r
+                    // Return the enumerations assigned to that variable\r
+                    Resource arrayIndexes = graph.getPossibleObject(variable, sr.HasArrayIndexes);\r
+                    if(arrayIndexes != null) {\r
+                        LinkedHashMap<String, Resource> result = new LinkedHashMap<String, Resource>();\r
+                        for(Resource enumeration : OrderedSetUtils.toList(graph, arrayIndexes)) {\r
+                            String enumerationName = NameUtils.getSafeName(graph, enumeration);\r
+                            result.put(enumerationName, enumeration);\r
+                        }\r
+                        return result;\r
+                    }\r
+                } catch (DatabaseException e) {\r
+                    // No variable was found, return null\r
+                }\r
+                return null;\r
+            }\r
+\r
+        }, new Listener<LinkedHashMap<String, Resource>>() {\r
+\r
+            @Override\r
+            public void execute(LinkedHashMap<String, Resource> result) {\r
+                if(isDisposed())\r
+                    return;\r
+\r
+                // Always modify the composite, even with null result\r
+                composite.getDisplay().asyncExec(new RunnableWithObject(result) {\r
+                    @Override\r
+                    public void run() {\r
+                        if(composite == null || composite.isDisposed())\r
+                            return;\r
+\r
+                        // Remove all content (even with null result)\r
+                        for(Control child : composite.getChildren())\r
+                            child.dispose();\r
+\r
+                        if(getObject() == null)\r
+                            return;\r
+\r
+                        // New widgetSupport for the combos\r
+                        WidgetSupportImpl support = new WidgetSupportImpl();\r
+\r
+                        Label label;\r
+                        TrackedCombo combo;\r
+                        LinkedHashMap<?, ?> result = (LinkedHashMap<?, ?>)getObject();\r
+                        Iterator<?> iterator = result.keySet().iterator();\r
+                        \r
+                        // For each array index (enumeration), create a label and a combo \r
+                        int index = 0;\r
+                        while(iterator.hasNext()) {\r
+                            Object key = iterator.next();\r
+                            Composite c = new Composite(composite, SWT.NONE);\r
+                            GridDataFactory.fillDefaults().applyTo(c);\r
+                            GridLayoutFactory.fillDefaults().applyTo(c);\r
+                            \r
+                            label = new Label(c, SWT.NONE);\r
+                            label.setText((String)key);\r
+                            GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.END).applyTo(label);\r
+\r
+                            combo = new TrackedCombo(c, support, SWT.READ_ONLY);\r
+                            combo.setItemFactory(new RangeItemFactory(index, (Resource)result.get(key)));\r
+                            combo.setSelectionFactory(new RangeSelectionFactory(index));\r
+                            combo.addModifyListener(new RangeModifyListener(index, result.size()));\r
+                            GridDataFactory.fillDefaults().applyTo(combo.getWidget());\r
+                            index++;\r
+                        }\r
+                        \r
+                        // Set the width of the combo \r
+                        GridLayout gl = (GridLayout)composite.getLayout();\r
+                        gl.numColumns = index;\r
+                        \r
+                        // Set input for the combos\r
+                        support.fireInput(context, input);\r
+                        \r
+                        /*\r
+                         *  Find out if this composite is located in a scrolled composite. \r
+                         *  If it is, resize the scrolled composite\r
+                         */\r
+                        Composite previousParent = composite.getParent();\r
+                        for(int i = 0; i < 5; i++) {\r
+                            if(previousParent.getParent() instanceof ScrolledComposite) {\r
+                                previousParent.layout();\r
+                                ScrolledComposite sc = (ScrolledComposite) previousParent.getParent();\r
+                                Point size = previousParent.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
+                                sc.setMinSize(size);\r
+                                break;\r
+                            }\r
+                            previousParent = previousParent.getParent();\r
+                        }\r
+                    }\r
+                });                    \r
+            }\r
+\r
+            @Override\r
+            public void exception(Throwable t) {\r
+                t.printStackTrace();\r
+            }\r
+\r
+            @Override\r
+            public boolean isDisposed() {\r
+                return composite == null || composite.isDisposed();\r
+            }\r
+        });\r
+    }\r
+\r
+    /**\r
+     * \r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class RangeSelectionFactory extends ReadFactoryImpl<Resource, String> {\r
+\r
+        int index;\r
+\r
+        /**\r
+         * \r
+         * @param index Index of the enumeration in the variable\r
+         */\r
+        public RangeSelectionFactory(int index) {\r
+            this.index = index;\r
+        }\r
+\r
+        public Object getIdentity(Object inputContents) {\r
+            return new Triple<Object, Integer, Class<?>>(inputContents, index, getClass());\r
+        }\r
+\r
+        @Override\r
+        public String perform(ReadGraph graph, Resource series) throws DatabaseException {\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+            String[] filter = graph.getPossibleRelatedValue(series, jfree.variableFilter, Bindings.STRING_ARRAY);\r
+            \r
+            /*\r
+             * If no filter was found or the index is not applicable, return "All"\r
+             */\r
+            if(filter == null)\r
+                return "All";\r
+            else if(filter.length < index)\r
+                return "All";\r
+            else\r
+                return filter[index];\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * RangeItemFactory finds all inexes of a given enumeration \r
+     * and adds "Sum" and "All" to the returned indexes\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class RangeItemFactory extends ReadFactoryImpl<Resource, Map<String, Object>> {\r
+\r
+        private int index;\r
+        private Resource enumeration;\r
+\r
+        /**\r
+         * \r
+         * @param index Index of the enumeration in the variable\r
+         * @param enumeration The enumeration\r
+         */\r
+        public RangeItemFactory(int index, Resource enumeration) {\r
+            this.index = index;\r
+            this.enumeration = enumeration;\r
+        }\r
+\r
+        public Object getIdentity(Object inputContents) {\r
+            return new Quad<Object, Integer, Resource, Class<?>>(inputContents, index, enumeration, getClass());\r
+        }\r
+        @Override\r
+        public Map<String, Object> perform(ReadGraph graph, Resource series) throws DatabaseException {\r
+            SysdynResource sr = SysdynResource.getInstance(graph);\r
+            LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>();\r
+            Resource enumerationIndexes = graph.getPossibleObject(enumeration, sr.HasEnumerationIndexes);\r
+            List<Resource> indexes = OrderedSetUtils.toList(graph, enumerationIndexes);\r
+            // First add "All" and "Sum", then all of the enumeration indexes in order\r
+            result.put("All", "All");\r
+            result.put("Sum", "Sum");\r
+            for(Resource index : indexes) {\r
+                String name = NameUtils.getSafeName(graph, index);\r
+                result.put(name, name);\r
+            }\r
+            return result;\r
+        }\r
+    }\r
+\r
+    /**\r
+     * RangeModifyListener for modifying a range filter in chart series \r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class RangeModifyListener  extends ComboModifyListenerImpl<Resource> {\r
+        \r
+        private int index, size;\r
+\r
+        /**\r
+         * \r
+         * @param index Index of the modified range filter\r
+         * @param size Size of the whole filter (for situations where there is no filter)\r
+         */\r
+        public RangeModifyListener(int index, int size) {\r
+            this.index = index;\r
+            this.size = size;\r
+        }\r
+\r
+        @Override\r
+        public void applyText(WriteGraph graph, Resource series, String text) throws DatabaseException {\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+            String[] filter = graph.getPossibleRelatedValue(series, jfree.variableFilter, Bindings.STRING_ARRAY);\r
+            \r
+            // If there is no filter, create a default filter with all indexes "All"\r
+            if(filter == null) {\r
+                filter = new String[size];\r
+                for(int i = 0; i < filter.length; i++) {\r
+                    filter[i] = "All";\r
+                }\r
+            }\r
+            \r
+            // Modify the filter index\r
+            filter[index] = text;\r
+            graph.claimLiteral(series, jfree.variableFilter, filter, Bindings.STRING_ARRAY);\r
+        }\r
+    }\r
+}\r
index 8d4d6e34d7f10415cb6a0090d42429d9d22d6863..d2ed2907395f07dc9ca5e9b1b68f9f5dcdd14b35 100644 (file)
@@ -20,12 +20,24 @@ import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;\r
 import org.eclipse.swt.widgets.Group;\r
 import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Spinner;\r
 import org.eclipse.ui.IWorkbenchSite;\r
 import org.simantics.browsing.ui.swt.widgets.Button;\r
 import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
 import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListener;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TrackedModifyEvent;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.PossibleObjectWithType;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
@@ -35,6 +47,8 @@ import org.simantics.sysdyn.ui.trend.chart.properties.BooleanSelectionListener;
 import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.TitleFactory;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.TitleModifier;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.TrackedSpinner;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
 \r
 /**\r
  * General properties of a bar chart\r
@@ -48,6 +62,7 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor {
     private Button hgrid, htitle, hlegend;\r
     private TrackedText name, title;\r
     private Combo type;\r
+    private TrackedSpinner angle;\r
 \r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {    \r
@@ -121,9 +136,108 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor {
         hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true));\r
         hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend));\r
 \r
+        Composite angleComposite = new Composite(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(angleComposite);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).applyTo(angleComposite);\r
+        // Line width\r
+        label = new Label(angleComposite, SWT.NONE);\r
+        label.setText("Label angle:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+\r
+        angle = new TrackedSpinner(angleComposite, support, SWT.BORDER);\r
+        angle.setSelectionFactory(new AngleSelectionFactory());\r
+        angle.addModifyListener(new AngleModifyListener());\r
+        angle.setMinimum(0);\r
+        angle.setMaximum(90);\r
+        angle.getWidget().setIncrement(5);\r
+        GridDataFactory.fillDefaults().applyTo(angle.getWidget());\r
+\r
         sc.setContent(composite);\r
         Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
         sc.setMinSize(size);\r
     }\r
 \r
+    /**\r
+     * ModifyListener for the angle {@link TrackedSpinner}\r
+     * \r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class AngleModifyListener implements TextModifyListener, Widget {\r
+\r
+        private ISessionContext context;\r
+        private Object lastInput = null;\r
+\r
+        @Override\r
+        public void modifyText(TrackedModifyEvent e) {\r
+            if(context == null)\r
+                return;\r
+\r
+            // Get the text value from spinner and associated resource (input)\r
+            Spinner spinner = (Spinner)e.getWidget();\r
+            final String textValue = spinner.getText();\r
+            final Object input = lastInput;\r
+\r
+            try {\r
+                context.getSession().syncRequest(new WriteRequest() {\r
+\r
+                    @Override\r
+                    public void perform(WriteGraph graph) throws DatabaseException {\r
+                        JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+                        Layer0 l0 = Layer0.getInstance(graph);\r
+\r
+                        Resource chart = AdaptionUtils.adaptToSingle(input, Resource.class);\r
+                        Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.CategoryPlot));\r
+                        Resource domainAxis = graph.getPossibleObject(plot, jfree.Plot_domainAxis);\r
+\r
+                        try {\r
+                            // usually reliable, since the spinner does all the checks\r
+                            Double value = Double.parseDouble(textValue); \r
+                            graph.claimLiteral(domainAxis, jfree.Axis_rotateLabelDegrees, value, Bindings.DOUBLE);\r
+                        } catch (NumberFormatException e) {\r
+                            graph.claimLiteral(domainAxis, jfree.Axis_rotateLabelDegrees, 0.0, Bindings.DOUBLE);\r
+                        }\r
+                    }\r
+\r
+                });\r
+            } catch (DatabaseException e1) {\r
+                e1.printStackTrace();\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public void setInput(ISessionContext context, Object parameter) {\r
+            this.context = context;\r
+            lastInput = parameter;\r
+        }\r
+\r
+    }\r
+\r
+    /**\r
+     * Class for setting the value for angle {@link TrackedSpinner}\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class AngleSelectionFactory extends ReadFactoryImpl<Resource, Integer>   {\r
+\r
+        @Override\r
+        public Integer perform(ReadGraph graph, Resource chart) throws DatabaseException {\r
+            Double angle = 0.0;\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+            Layer0 l0 = Layer0.getInstance(graph);\r
+            Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.CategoryPlot));\r
+            if(plot != null) {\r
+                Resource domainAxis = graph.getPossibleObject(plot, jfree.Plot_domainAxis);\r
+                if(domainAxis != null) {\r
+                    Double value = graph.getPossibleRelatedValue(domainAxis, jfree.Axis_rotateLabelDegrees);\r
+                    if(value != null)\r
+                        angle = value;\r
+                }\r
+            }\r
+            return angle.intValue();\r
+\r
+        }\r
+\r
+    }\r
+\r
 }\r
index 3b463a7ea2e74f0e6ca75daba1d12732c2eaf229..7ccbbc4a96e3bfb0d0cba711c296e3d825ca72c0 100644 (file)
@@ -25,6 +25,7 @@ import org.simantics.layer0.Layer0;
 import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.RVIFactory;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.RVIModifier;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.RangeComposite;\r
 \r
 /**\r
  * Composite for modifying properties of a series in a bar chart\r
@@ -35,7 +36,7 @@ public class BarSeriesPropertyComposite extends Composite {
     \r
     private TrackedText variable, label;\r
     \r
-    public BarSeriesPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) {\r
+    public BarSeriesPropertyComposite(Composite parent, final ISessionContext context, WidgetSupport support, int style) {\r
         super(parent, style);\r
         \r
         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this);\r
@@ -51,6 +52,15 @@ public class BarSeriesPropertyComposite extends Composite {
         variable.setColorProvider(new JFreeChartPropertyColorProvider(this.variable.getResourceManager()));\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(this.variable.getWidget());\r
 \r
+        // Range\r
+        label = new Label(this, SWT.NONE);\r
+        label.setText("Range:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        \r
+        RangeComposite rangeComposite = new RangeComposite(this, context, support, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeComposite);\r
+        \r
+        \r
         // Label to be displayed in chart for this series\r
         label = new Label(this, SWT.NONE);\r
         label.setText("Label:");\r
index 4dd81ff10e7711c623576b83e70217b99de32bec..6196c3537469e8d1c2e152a18ca8b5470342392d 100644 (file)
@@ -59,6 +59,7 @@ public class BarSeriesTab extends LabelPropertyTabContributor implements Widget
     private WidgetSupportImpl additionalSupport;\r
     private Button add, remove;\r
     private Resource chartResource;\r
+    private BarSeriesPropertyComposite spc;\r
 \r
 \r
     public BarSeriesTab() {\r
@@ -120,19 +121,18 @@ public class BarSeriesTab extends LabelPropertyTabContributor implements Widget
         if(resource == null)\r
             return;\r
 \r
-\r
         for(Control child : propertyContainer.getChildren()) {\r
             child.dispose();\r
         }\r
-        BarSeriesPropertyComposite spc = new BarSeriesPropertyComposite(propertyContainer, context, additionalSupport, SWT.NONE);\r
+        spc = new BarSeriesPropertyComposite(propertyContainer, context, additionalSupport, SWT.NONE);\r
+\r
+        additionalSupport.fireInput(context, selection);\r
+\r
         propertyContainer.setContent(spc);\r
         Point size = spc.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
         propertyContainer.setMinSize(size);\r
-\r
-        additionalSupport.fireInput(context, selection);\r
     }\r
 \r
-\r
     /**\r
      * SelectionListener for adding a new variable to a plot\r
      * @author Teemu Lempinen\r
@@ -164,8 +164,7 @@ public class BarSeriesTab extends LabelPropertyTabContributor implements Widget
 \r
             if(dataset != null) {\r
                 // Create series with no rvi\r
-                Resource series = ChartUtils.createSeries(graph, dataset, null);\r
-                graph.claimLiteral(series, jfree.Series_exploded, false);\r
+                ChartUtils.createSeries(graph, dataset, null);\r
             }\r
         }\r
     }\r
index 2bfe94b9c9b749b38fce3a750d32315c509f63fa..3900631f6f6a80eb7b67d4abe08a422fa09819bc 100644 (file)
@@ -116,7 +116,7 @@ public class PieGeneralPropertiesTab extends LabelPropertyTabContributor {
         hlegend.setText("Legend");\r
         hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true));\r
         hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend));\r
-\r
+        \r
         sc.setContent(composite);\r
         Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
         sc.setMinSize(size);\r
index 642f070d764905d9093bd521a410fd19cebc89a8..1e8786c4c733697d341042b6e346834045396449 100644 (file)
@@ -30,6 +30,7 @@ import org.simantics.sysdyn.ui.trend.chart.properties.ColorPicker;
 import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.RVIFactory;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.RVIModifier;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.RangeComposite;\r
 \r
 /**\r
  * Composite containing the properties of a series\r
@@ -56,6 +57,15 @@ public class PieSeriesPropertyComposite extends Composite {
         variable.setColorProvider(new JFreeChartPropertyColorProvider(this.variable.getResourceManager()));\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(this.variable.getWidget());\r
 \r
+        // Range\r
+        label = new Label(this, SWT.NONE);\r
+        label.setText("Range:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        \r
+        RangeComposite rangeComposite = new RangeComposite(this, context, support, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeComposite);\r
+        \r
+        \r
         // Label to be displayed in chart for this series\r
         label = new Label(this, SWT.NONE);\r
         label.setText("Label:");\r
index 96a5fd40e9baaeeaa231d28374517eeeaafd4a15..d05e5d28e154727151472eb3405ae4ed7aa427a6 100644 (file)
@@ -28,10 +28,12 @@ import org.simantics.browsing.ui.swt.SingleSelectionInputSource;
 import org.simantics.browsing.ui.swt.widgets.Button;\r
 import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
 import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.PossibleObjectWithType;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
@@ -50,12 +52,13 @@ import org.simantics.utils.datastructures.ArrayMap;
  * @author Teemu Lempinen\r
  *\r
  */\r
-public class PieSeriesTab extends LabelPropertyTabContributor {\r
+public class PieSeriesTab extends LabelPropertyTabContributor implements Widget {\r
 \r
     private GraphExplorerComposite explorer;\r
     private ScrolledComposite propertyContainer;\r
     private WidgetSupportImpl additionalSupport;\r
     private Button add, remove;\r
+    private Resource chartResource;\r
 \r
     public PieSeriesTab() {\r
         additionalSupport = new WidgetSupportImpl();\r
@@ -63,6 +66,7 @@ public class PieSeriesTab extends LabelPropertyTabContributor {
 \r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, final ISessionContext context, WidgetSupport support) {\r
+        support.register(this);\r
         Composite composite = new Composite(body, SWT.NONE);\r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
         GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite);\r
@@ -142,18 +146,24 @@ public class PieSeriesTab extends LabelPropertyTabContributor {
 \r
         @Override\r
         public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
-            if(input == null)\r
-                return;\r
             JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
             Layer0 l0 = Layer0.getInstance(graph);\r
-            Resource dataset;\r
-            if(graph.isInstanceOf(input, jfree.Series)) {\r
-                dataset = graph.getPossibleObject(input, l0.PartOf);\r
-                if(dataset != null) {\r
-                    // Create series with no rvi\r
-                    Resource series = ChartUtils.createSeries(graph, dataset, null);\r
-                    graph.claimLiteral(series, jfree.Series_exploded, false);\r
+            Resource dataset = null;\r
+            if(input == null) {\r
+                if(chartResource != null) {\r
+                    Resource plot = graph.syncRequest(new PossibleObjectWithType(chartResource, l0.ConsistsOf, jfree.Plot));\r
+                    if(plot != null)\r
+                        dataset = graph.syncRequest(new PossibleObjectWithType(plot, l0.ConsistsOf, jfree.Dataset));\r
                 }\r
+            } else {\r
+                if(graph.isInstanceOf(input, jfree.Series)) {\r
+                    dataset = graph.getPossibleObject(input, l0.PartOf);\r
+                }\r
+            }\r
+            if(dataset != null) {\r
+                // Create series with no rvi\r
+                Resource series = ChartUtils.createSeries(graph, dataset, null);\r
+                graph.claimLiteral(series, jfree.Series_exploded, false);\r
             }\r
         }\r
     }\r
@@ -192,6 +202,10 @@ public class PieSeriesTab extends LabelPropertyTabContributor {
             }\r
         }\r
     }\r
-\r
+    \r
+    @Override\r
+    public void setInput(ISessionContext context, Object input) {\r
+        chartResource = AdaptionUtils.adaptToSingle(input, Resource.class);\r
+    }\r
 \r
 }\r
index 4b09224c5f9503b48a295ffb66fa99d51accb34c..f0568510ba4143f26e3d125e44b397166ba2c66f 100644 (file)
@@ -38,6 +38,7 @@ import org.simantics.sysdyn.ui.trend.chart.properties.ColorPicker;
 import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.RVIFactory;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.RVIModifier;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.RangeComposite;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.TrackedSpinner;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
@@ -68,6 +69,14 @@ public class SeriesPropertyComposite extends Composite {
         variable.setColorProvider(new JFreeChartPropertyColorProvider(this.variable.getResourceManager()));\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(this.variable.getWidget());\r
 \r
+        // Range\r
+        label = new Label(this, SWT.NONE);\r
+        label.setText("Range:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        \r
+        RangeComposite rangeComposite = new RangeComposite(this, context, support, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeComposite);\r
+        \r
         // Label to be displayed in chart for this series \r
         label = new Label(this, SWT.NONE);\r
         label.setText("Label:");\r
index 32a0bc2bcfb7886e30e0386a87a533029fd6d868..c5f050858806097fef51416a47f7a0849480068f 100644 (file)
@@ -11,6 +11,7 @@
  *******************************************************************************/\r
 package org.simantics.sysdyn.adapter;\r
 \r
+import java.util.ArrayList;\r
 import java.util.HashMap;\r
 import java.util.LinkedHashMap;\r
 import java.util.List;\r
@@ -25,6 +26,7 @@ import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.SysdynDataSet;\r
 \r
 /**\r
  * Utils for finding all active rvis for a single variable. A variable can have multiple \r
@@ -43,7 +45,7 @@ import org.simantics.sysdyn.SysdynResource;
  *\r
  */\r
 public class VariableRVIUtils {\r
-    \r
+\r
     /**\r
      * Recursive function for finding number format and label for the set of rvis. (rvis.put("Variable[1]", "Variable[index1]");\r
      * At the end of the recursive calls, rvis contains all possible combinations of enumeration indexes that are\r
@@ -101,7 +103,7 @@ public class VariableRVIUtils {
             }\r
         }\r
     }\r
-    \r
+\r
     /**\r
      * Resolves and replaces all overridden enumerations in enumerations -list\r
      * \r
@@ -159,11 +161,11 @@ public class VariableRVIUtils {
      */\r
     public static HashMap<String, String> getActiveRVIs(ReadGraph graph, Variable variable) throws DatabaseException {\r
         HashMap<String, String> rvis = new LinkedHashMap<String, String>();\r
-        \r
+\r
         SysdynResource sr = SysdynResource.getInstance(graph);\r
-        \r
+\r
         String rvi = Variables.getRVI(graph, variable);\r
-        \r
+\r
         Resource r = variable.getPropertyValue(graph, Variables.REPRESENTS);\r
 \r
         Resource arrayIndexes = graph.getPossibleObject(r, sr.HasArrayIndexes);\r
@@ -180,8 +182,156 @@ public class VariableRVIUtils {
             else\r
                 rvis.put(rvi, rvi);\r
         }\r
-        \r
+\r
         return rvis;\r
     }\r
 \r
+    \r
+    /**\r
+     * Filters a list of datasets of a single variable with a given filter. Filter should contain \r
+     * as many entries as the variable has enumerations. If the variable is Var[Enum1, Enum2, Enum3]\r
+     * the filter length should be 3.\r
+     * \r
+     * Allowed filter entries are All, Sum and a name of an index.\r
+     * \r
+     * Example filtering for variable Var[Enum1, Enum2, Enum3] where all enumerations have indexes {1, 2}\r
+     * \r
+     * filter: {All, Sum, 1}\r
+     * \r
+     * Filters are applied from back to front\r
+     * \r
+     * 1 1 1\r
+     * 1 1 2    \r
+     * 1 2 1    1 1 1    \r
+     * 1 2 2 => 1 2 1 => 1 SUM(1 1, 2 1)\r
+     * 2 1 1    2 1 1    2 SUM(1 1, 2 1)\r
+     * 2 1 2    2 2 1    \r
+     * 2 2 1    \r
+     * 2 2 2    \r
+     * \r
+     * @param datasets List of SysdynDatasets for a single multidimensional variable\r
+     * @param filter filter for the datasets\r
+     * @return filtered list of SysdynDatasets\r
+     */\r
+    public static ArrayList<SysdynDataSet> getDataset(ArrayList<SysdynDataSet> datasets, String[] filter) {\r
+        // If all filters are "All", no filtering is required.\r
+        boolean doFiltering = false;\r
+        for(String f : filter) {\r
+            if(!f.equalsIgnoreCase("All")) {\r
+                // One of the filters is not All -> do filtering\r
+                doFiltering = true;\r
+                break;\r
+            }\r
+        }\r
+        \r
+        if(doFiltering == false)\r
+            return datasets;\r
+                \r
+        // Start filtering with the complete set of datasets\r
+        ArrayList<SysdynDataSet> result = datasets;\r
+        \r
+        // Go through the filter from end to start\r
+        for(int i = filter.length - 1; i >= 0; i--) {\r
+            // Get the current filter\r
+            String currentFilter = filter[i].trim();\r
+            \r
+            ArrayList<SysdynDataSet> tempResult = new ArrayList<SysdynDataSet>();\r
+            HashMap<String, SysdynDataSet> sums = new HashMap<String, SysdynDataSet>();\r
+            for(SysdynDataSet dataset : result) {\r
+                String tempIndexes = dataset.name.substring(dataset.name.indexOf('[') + 1, dataset.name.indexOf(']'));\r
+                String[] indexes = tempIndexes.split(",");\r
+                if(currentFilter.equals("All")) {\r
+                    /*\r
+                     *  If the filter is "All", all datasets \r
+                     *  are kept for the next filtering\r
+                     */\r
+                    tempResult.add(dataset);\r
+                } else if(currentFilter.equals(indexes[i].trim())) {\r
+                    /*\r
+                     *  If the filter equals the index of the dataset\r
+                     *  at the same location, the dataset is kept for the next filtering\r
+                     *  \r
+                     *  e.g. \r
+                     *  dataset = Var[index3, index1, index2]\r
+                     *  filter = {All, index1, ALL}\r
+                     *  i = 1 (from 0 to 2)\r
+                     *  \r
+                     *  dataset's index and filter match at location 1 (the middle index)\r
+                     */\r
+                    tempResult.add(dataset);\r
+                }  else if(currentFilter.equals("Sum")) {\r
+                    /*\r
+                     * Whenever Sum is used as the filter, all datasets having the\r
+                     * same indexes before the sum filter location are summed. \r
+                     * \r
+                     * e.g.\r
+                     * filter = {1, 1, SUM}\r
+                     * 1, 1, 1    \r
+                     * 1, 1, 2 => 1, 1, SUM(1, 1, 1; 1, 1, 2)\r
+                     * 1, 2, 1    1, 2, SUM(1, 2, 1; 1, 2, 2)\r
+                     * 1, 2, 2    \r
+                     */\r
+                    \r
+                    // Find the preceding range (e.g. index1index2index2)\r
+                    String rangeBefore = "";\r
+                    for(int j = 0; j < i; j++)\r
+                        rangeBefore += indexes[j].trim();\r
+                    \r
+                    // Find if there are any datasets for that preceding range in sums\r
+                    SysdynDataSet sum = sums.get(rangeBefore);\r
+                    if(sum != null) {\r
+                        // A sum dataset was found. Add values from this dataset to the sum dataset\r
+                        for(int j = 0; j < sum.values.length; j++)\r
+                            sum.values[j] = sum.values[j] + dataset.values[j];\r
+                    } else {\r
+                        // The first occurence of this preceding range, create a new dataset for the sum\r
+                        \r
+                        // Copy times and values\r
+                        double[] times = new double[dataset.times.length];\r
+                        for(int j = 0; j < dataset.times.length; j++)\r
+                            times[j] = dataset.times[j];\r
+                        double[] values = new double[dataset.values.length];\r
+                        for(int j = 0; j < dataset.values.length; j++)\r
+                            values[j] = dataset.values[j];\r
+                        \r
+                        // Create the dataset and add it to both tempResult and sums map\r
+                        SysdynDataSet newDataset = new SysdynDataSet(dataset.name, dataset.result, times, values);\r
+                        tempResult.add(newDataset);\r
+                        sums.put(rangeBefore, newDataset);\r
+                        \r
+                        // Modify the name of the dataset by adding "Sum" to the current index location.\r
+                        String name = newDataset.name.substring(0, newDataset.name.indexOf('[') + 1);\r
+                        for(int j = 0; j < indexes.length; j++) {\r
+                            if(j < i)\r
+                                // Indexes before "Sum" stay the same\r
+                                name += indexes[j].trim();\r
+                            else if(j >= i)\r
+                                // Current "Sum" index  and indexes after "Sum" are copied from filter\r
+                                name += filter[j].trim();\r
+\r
+                            if(j < indexes.length - 1)\r
+                                name += ", ";\r
+                        }\r
+                        name += "]";\r
+                        \r
+                        // Replace the sum dataset's name\r
+                        newDataset.name = name;\r
+                    }\r
+                        \r
+                } else {\r
+                    // Discard the series\r
+                }\r
+            }\r
+            \r
+            /*\r
+             *  Replace result list with the filtered results and move on to next\r
+             *  filter index or return the list \r
+             */\r
+            result.clear();\r
+            for(SysdynDataSet dataset : tempResult)\r
+                result.add(dataset);\r
+        }\r
+        return result;\r
+    }\r
+    \r
 }\r
index 9fbacbb3aceca83c76bdd16317eccd357d7d1a77..d0771f50cfee1bd3602845663c8374d0c7c356cc 100644 (file)
@@ -235,7 +235,6 @@ public class SysdynResult {
 \r
             } catch (AccessorConstructionException e) {\r
                 // Variable was not found\r
-                System.err.println("Variable "+variable+" is not available in the history.");\r
             } catch (AccessorException e) {\r
                 // Unable to read data from file\r
                 e.printStackTrace();\r