]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
two new chart types: bar and pie
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 7 Dec 2011 11:05:38 +0000 (11:05 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 7 Dec 2011 11:05:38 +0000 (11:05 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@23432 ac1ea38d-2e2b-0410-8846-a27921b304fc

56 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/ChartAxisAndVariablesViewpoint.pgraph [deleted file]
org.simantics.sysdyn.ontology/graph/ChartViewpoints.pgraph [new file with mode: 0644]
org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/adapters.xml
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewBarChartHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewPieChartHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewXYLineChartHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewChartHandler.java with 91% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/listeners/SysdynPlaybackExperimentListener.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/menu/PlaybackSliderContribution.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LabelPropertyTabContributor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractAxis.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractDataset.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractPlot.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractRenderer.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/BarRenderer.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryAxis.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryDataset.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryPlot.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ChartComposite.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ExtendedNumberAxis.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/IDataset.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/IJFreeChartComponent.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/IPlot.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/IRenderer.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/JFreeChart.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/NumberAxis.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/PieDataset.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/PiePlot.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/StackedBarRenderer.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/TextTitle.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/XYPlot.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/graphexplorer/AxisDropAction.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/graphexplorer/SeriesChildRule.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/graphexplorer/SeriesDropAction.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/TitleFactory.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/TitleModifier.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarGeneralPropertiesTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarSeriesPropertyComposite.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarSeriesTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieGeneralPropertiesTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieSeriesPropertyComposite.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieSeriesTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/AxisAndVariablesExplorerComposite.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/AxisAndVariablesExplorerComposite.java with 95% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/AxisPropertyComposite.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/AxisPropertyComposite.java with 91% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/SeriesPropertyComposite.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/SeriesPropertyComposite.java with 90% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineAxisAndVariablesTab.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/ChartAxisAndVariablesTab.java with 96% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineGeneralPropertiesTab.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/GeneralChartPropertiesTab.java with 82% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/viewUtils/SysdynDatasetSelectionListener.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/HistoryVariable.java

index 208c3be8761684b1014203c87be37fc57f2635fe..923bca85a1f8bc413b51ab2edb6e0cd985239c0a 100644 (file)
Binary files a/org.simantics.jfreechart.ontology/graph.tg and b/org.simantics.jfreechart.ontology/graph.tg differ
index d6f115d9514446844c2ec1c34888b127f52d5ec5..e6a3a70ce52c904104936fa332de8a30642225f0 100644 (file)
@@ -72,6 +72,7 @@ JFREE.NumberAxis <T JFREE.Axis
 //#####################################################################
 JFREE.Dataset <T L0.Entity
     >-- JFREE.Dataset.seriesList --> L0.List <R L0.HasProperty : L0.FunctionalRelation
+    >-- JFREE.Dataset.renderer --> JFREE.Renderer <R L0.HasProperty : L0.FunctionalRelation
     >-- JFREE.Dataset.mapToDomainAxis --> JFREE.Axis <R L0.HasProperty : L0.FunctionalRelation
     >-- JFREE.Dataset.mapToRangeAxis --> JFREE.Axis <R L0.HasProperty : L0.FunctionalRelation
 
@@ -84,10 +85,20 @@ JFREE.PieDataset <T JFREE.Dataset
 //#####################################################################
 
 JFREE.Series <T L0.Entity
-    >-- JFREE.variableRVI --> L0.String <R L0.HasProperty : L0.FunctionalRelation
-    >-- JFREE.Series.lineWidth --> L0.Integer <R L0.HasProperty : L0.FunctionalRelation
     >-- JFREE.color
+    >-- JFREE.variableRVI --> L0.String <R L0.HasProperty
+    >-- 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
+
+//#####################################################################
+// Renderers
+//#####################################################################
+
+JFREE.Renderer <T L0.Entity
 
+JFREE.BarRenderer <T JFREE.Renderer
+JFREE.StackedBarRenderer <T JFREE.Renderer
     
 //#####################################################################
 // Position
index 18073fac3adf0a401d5640e07a2de3d4e08d3b9d..add59f77256fd90c23bfb3cee315ea4a127a55bc 100644 (file)
@@ -21,6 +21,7 @@ public class JFreeChartResource {
     public final Resource Axis_visibleTickLabels_Inverse;\r
     public final Resource Axis_visibleTickMarks;\r
     public final Resource Axis_visibleTickMarks_Inverse;\r
+    public final Resource BarRenderer;\r
     public final Resource Bottom;\r
     public final Resource CategoryAxis;\r
     public final Resource CategoryDataset;\r
@@ -40,6 +41,8 @@ public class JFreeChartResource {
     public final Resource Dataset_mapToDomainAxis_Inverse;\r
     public final Resource Dataset_mapToRangeAxis;\r
     public final Resource Dataset_mapToRangeAxis_Inverse;\r
+    public final Resource Dataset_renderer;\r
+    public final Resource Dataset_renderer_Inverse;\r
     public final Resource Dataset_seriesList;\r
     public final Resource Dataset_seriesList_Inverse;\r
     public final Resource ImageTitle;\r
@@ -59,10 +62,16 @@ public class JFreeChartResource {
     public final Resource Plot_visibleGrid;\r
     public final Resource Plot_visibleGrid_Inverse;\r
     public final Resource Position;\r
+    public final Resource Renderer;\r
     public final Resource Right;\r
     public final Resource Series;\r
+    public final Resource Series_exploded;\r
+    public final Resource Series_exploded_Inverse;\r
     public final Resource Series_lineWidth;\r
     public final Resource Series_lineWidth_Inverse;\r
+    public final Resource Series_time;\r
+    public final Resource Series_time_Inverse;\r
+    public final Resource StackedBarRenderer;\r
     public final Resource TextTitle;\r
     public final Resource Title;\r
     public final Resource Title_position;\r
@@ -97,6 +106,7 @@ public class JFreeChartResource {
         public static final String Axis_visibleTickLabels_Inverse = "http://www.simantics.org/JFreeChart-1.0/Axis/visibleTickLabels/Inverse";\r
         public static final String Axis_visibleTickMarks = "http://www.simantics.org/JFreeChart-1.0/Axis/visibleTickMarks";\r
         public static final String Axis_visibleTickMarks_Inverse = "http://www.simantics.org/JFreeChart-1.0/Axis/visibleTickMarks/Inverse";\r
+        public static final String BarRenderer = "http://www.simantics.org/JFreeChart-1.0/BarRenderer";\r
         public static final String Bottom = "http://www.simantics.org/JFreeChart-1.0/Bottom";\r
         public static final String CategoryAxis = "http://www.simantics.org/JFreeChart-1.0/CategoryAxis";\r
         public static final String CategoryDataset = "http://www.simantics.org/JFreeChart-1.0/CategoryDataset";\r
@@ -116,6 +126,8 @@ public class JFreeChartResource {
         public static final String Dataset_mapToDomainAxis_Inverse = "http://www.simantics.org/JFreeChart-1.0/Dataset/mapToDomainAxis/Inverse";\r
         public static final String Dataset_mapToRangeAxis = "http://www.simantics.org/JFreeChart-1.0/Dataset/mapToRangeAxis";\r
         public static final String Dataset_mapToRangeAxis_Inverse = "http://www.simantics.org/JFreeChart-1.0/Dataset/mapToRangeAxis/Inverse";\r
+        public static final String Dataset_renderer = "http://www.simantics.org/JFreeChart-1.0/Dataset/renderer";\r
+        public static final String Dataset_renderer_Inverse = "http://www.simantics.org/JFreeChart-1.0/Dataset/renderer/Inverse";\r
         public static final String Dataset_seriesList = "http://www.simantics.org/JFreeChart-1.0/Dataset/seriesList";\r
         public static final String Dataset_seriesList_Inverse = "http://www.simantics.org/JFreeChart-1.0/Dataset/seriesList/Inverse";\r
         public static final String ImageTitle = "http://www.simantics.org/JFreeChart-1.0/ImageTitle";\r
@@ -135,10 +147,16 @@ public class JFreeChartResource {
         public static final String Plot_visibleGrid = "http://www.simantics.org/JFreeChart-1.0/Plot/visibleGrid";\r
         public static final String Plot_visibleGrid_Inverse = "http://www.simantics.org/JFreeChart-1.0/Plot/visibleGrid/Inverse";\r
         public static final String Position = "http://www.simantics.org/JFreeChart-1.0/Position";\r
+        public static final String Renderer = "http://www.simantics.org/JFreeChart-1.0/Renderer";\r
         public static final String Right = "http://www.simantics.org/JFreeChart-1.0/Right";\r
         public static final String Series = "http://www.simantics.org/JFreeChart-1.0/Series";\r
+        public static final String Series_exploded = "http://www.simantics.org/JFreeChart-1.0/Series/exploded";\r
+        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_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
         public static final String TextTitle = "http://www.simantics.org/JFreeChart-1.0/TextTitle";\r
         public static final String Title = "http://www.simantics.org/JFreeChart-1.0/Title";\r
         public static final String Title_position = "http://www.simantics.org/JFreeChart-1.0/Title/position";\r
@@ -183,6 +201,7 @@ public class JFreeChartResource {
         Axis_visibleTickLabels_Inverse = getResourceOrNull(graph, URIs.Axis_visibleTickLabels_Inverse);\r
         Axis_visibleTickMarks = getResourceOrNull(graph, URIs.Axis_visibleTickMarks);\r
         Axis_visibleTickMarks_Inverse = getResourceOrNull(graph, URIs.Axis_visibleTickMarks_Inverse);\r
+        BarRenderer = getResourceOrNull(graph, URIs.BarRenderer);\r
         Bottom = getResourceOrNull(graph, URIs.Bottom);\r
         CategoryAxis = getResourceOrNull(graph, URIs.CategoryAxis);\r
         CategoryDataset = getResourceOrNull(graph, URIs.CategoryDataset);\r
@@ -202,6 +221,8 @@ public class JFreeChartResource {
         Dataset_mapToDomainAxis_Inverse = getResourceOrNull(graph, URIs.Dataset_mapToDomainAxis_Inverse);\r
         Dataset_mapToRangeAxis = getResourceOrNull(graph, URIs.Dataset_mapToRangeAxis);\r
         Dataset_mapToRangeAxis_Inverse = getResourceOrNull(graph, URIs.Dataset_mapToRangeAxis_Inverse);\r
+        Dataset_renderer = getResourceOrNull(graph, URIs.Dataset_renderer);\r
+        Dataset_renderer_Inverse = getResourceOrNull(graph, URIs.Dataset_renderer_Inverse);\r
         Dataset_seriesList = getResourceOrNull(graph, URIs.Dataset_seriesList);\r
         Dataset_seriesList_Inverse = getResourceOrNull(graph, URIs.Dataset_seriesList_Inverse);\r
         ImageTitle = getResourceOrNull(graph, URIs.ImageTitle);\r
@@ -221,10 +242,16 @@ public class JFreeChartResource {
         Plot_visibleGrid = getResourceOrNull(graph, URIs.Plot_visibleGrid);\r
         Plot_visibleGrid_Inverse = getResourceOrNull(graph, URIs.Plot_visibleGrid_Inverse);\r
         Position = getResourceOrNull(graph, URIs.Position);\r
+        Renderer = getResourceOrNull(graph, URIs.Renderer);\r
         Right = getResourceOrNull(graph, URIs.Right);\r
         Series = getResourceOrNull(graph, URIs.Series);\r
+        Series_exploded = getResourceOrNull(graph, URIs.Series_exploded);\r
+        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_time = getResourceOrNull(graph, URIs.Series_time);\r
+        Series_time_Inverse = getResourceOrNull(graph, URIs.Series_time_Inverse);\r
+        StackedBarRenderer = getResourceOrNull(graph, URIs.StackedBarRenderer);\r
         TextTitle = getResourceOrNull(graph, URIs.TextTitle);\r
         Title = getResourceOrNull(graph, URIs.Title);\r
         Title_position = getResourceOrNull(graph, URIs.Title_position);\r
index acca8d8fa04c639e2af53d7facf25013f3d63094..bb966445e3f773f746ed721182c85d1deed584d4 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
diff --git a/org.simantics.sysdyn.ontology/graph/ChartAxisAndVariablesViewpoint.pgraph b/org.simantics.sysdyn.ontology/graph/ChartAxisAndVariablesViewpoint.pgraph
deleted file mode 100644 (file)
index 9d3c5e9..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-L0 = <http://www.simantics.org/Layer0-1.0>\r
-VP = <http://www.simantics.org/Viewpoint-1.1>\r
-PROJECT = <http://www.simantics.org/Project-1.1>\r
-MOD = <http://www.simantics.org/Modeling-1.1>\r
-IMAGE = <http://www.simantics.org/Image2-1.1>\r
-COLOR = <http://www.simantics.org/Color-1.0>\r
-ACT = <http://www.simantics.org/Action-1.0>\r
-JFREE = <http://www.simantics.org/JFreeChart-1.0>\r
-SYSDYN = <http://www.simantics.org/Sysdyn-1.1>\r
-\r
-CBC = SYSDYN.ChartAxisAndVariablesBrowseContext : VP.BrowseContext\r
-CAC = SYSDYN.ChartAxisAndVariablesActionContext : VP.BrowseContext\r
-\r
-CBC.AxisChildRule : VP.ChildRule\r
-CBC.VariableChildRule : VP.ChildRule\r
-CBC.SeriesLabelRule : VP.LabelRule\r
-CBC.AxisLabelRule : VP.LabelRule\r
-\r
-CBC\r
-    @VP.customChildRule JFREE.Chart CBC.AxisChildRule\r
-        JFREE.Axis : VP.ResourceNodeType\r
-    @VP.customChildRule JFREE.Axis CBC.VariableChildRule\r
-        JFREE.Series : VP.ResourceNodeType\r
-\r
-CBC        \r
-    @VP.customLabelRule             JFREE.Axis          CBC.AxisLabelRule\r
-    @VP.customLabelRule             JFREE.Series        CBC.SeriesLabelRule\r
-    \r
-CBC\r
-    @VP.dropActionContribution JFREE.Axis ACTIONS.SeriesDropAction 1.0    \r
-    @VP.dropActionContribution JFREE.Series ACTIONS.SeriesDropAction 1.0      \r
-    @VP.dropActionContribution JFREE.Axis ACTIONS.AxisDropAction 2.0    \r
-    @VP.dropActionContribution JFREE.Series ACTIONS.AxisDropAction 2.0          \r
-    \r
-CBC\r
-    VP.BrowseContext.HasVisualsContribution _ : VP.VisualsContribution\r
-        VP.VisualsContribution.HasNodeType JFREE.Chart\r
-        VP.VisualsContribution.HasRule VP.PassThruSorterRule     \r
-    VP.BrowseContext.HasVisualsContribution _ : VP.VisualsContribution\r
-        VP.VisualsContribution.HasNodeType JFREE.Axis\r
-        VP.VisualsContribution.HasRule VP.PassThruSorterRule\r
-   \r
-    \r
-ACTIONS = CAC.Actions : L0.Library\r
-ACTIONS.SeriesDropAction : ACT.DropAction    \r
-ACTIONS.AxisDropAction : ACT.DropAction    
\ No newline at end of file
diff --git a/org.simantics.sysdyn.ontology/graph/ChartViewpoints.pgraph b/org.simantics.sysdyn.ontology/graph/ChartViewpoints.pgraph
new file mode 100644 (file)
index 0000000..c916c17
--- /dev/null
@@ -0,0 +1,105 @@
+L0 = <http://www.simantics.org/Layer0-1.0>\r
+VP = <http://www.simantics.org/Viewpoint-1.1>\r
+PROJECT = <http://www.simantics.org/Project-1.1>\r
+MOD = <http://www.simantics.org/Modeling-1.1>\r
+IMAGE = <http://www.simantics.org/Image2-1.1>\r
+COLOR = <http://www.simantics.org/Color-1.0>\r
+ACT = <http://www.simantics.org/Action-1.0>\r
+JFREE = <http://www.simantics.org/JFreeChart-1.0>\r
+SYSDYN = <http://www.simantics.org/Sysdyn-1.1>\r
+\r
+///////////////////////////////////////////////\r
+// XY Line axis: axis and variables viewpoint\r
+///////////////////////////////////////////////\r
+CBC = SYSDYN.ChartAxisAndVariablesBrowseContext : VP.BrowseContext\r
+CAC = SYSDYN.ChartAxisAndVariablesActionContext : VP.BrowseContext\r
+\r
+CBC.AxisChildRule : VP.ChildRule\r
+CBC.VariableChildRule : VP.ChildRule\r
+CBC.SeriesLabelRule : VP.LabelRule\r
+CBC.AxisLabelRule : VP.LabelRule\r
+\r
+CBC\r
+    @VP.customChildRule JFREE.Chart CBC.AxisChildRule\r
+        JFREE.Axis : VP.ResourceNodeType\r
+    @VP.customChildRule JFREE.Axis CBC.VariableChildRule\r
+        JFREE.Series : VP.ResourceNodeType\r
+\r
+CBC        \r
+    @VP.customLabelRule             JFREE.Axis          CBC.AxisLabelRule\r
+    @VP.customLabelRule             JFREE.Series        CBC.SeriesLabelRule\r
+    \r
+CBC\r
+    @VP.dropActionContribution JFREE.Axis CAC.Actions.SeriesDropAction 1.0    \r
+    @VP.dropActionContribution JFREE.Series CAC.Actions.SeriesDropAction 1.0      \r
+    @VP.dropActionContribution JFREE.Axis CAC.Actions.AxisDropAction 2.0    \r
+    @VP.dropActionContribution JFREE.Series CAC.Actions.AxisDropAction 2.0          \r
+    \r
+CBC\r
+    VP.BrowseContext.HasVisualsContribution _ : VP.VisualsContribution\r
+        VP.VisualsContribution.HasNodeType JFREE.Chart\r
+        VP.VisualsContribution.HasRule VP.PassThruSorterRule     \r
+    VP.BrowseContext.HasVisualsContribution _ : VP.VisualsContribution\r
+        VP.VisualsContribution.HasNodeType JFREE.Axis\r
+        VP.VisualsContribution.HasRule VP.PassThruSorterRule\r
+   \r
+    \r
+CAC.Actions : L0.Library\r
+CAC.Actions.SeriesDropAction : ACT.DropAction    \r
+CAC.Actions.AxisDropAction : ACT.DropAction    \r
+\r
+\r
+///////////////////////////////////////////////\r
+// Bar chart: Variables viewpoint\r
+///////////////////////////////////////////////\r
+BSBC = SYSDYN.BarSeriesBrowseContext : VP.BrowseContext\r
+BSAC = SYSDYN.BarSeriesActionContext : VP.BrowseContext\r
+\r
+BSBC.SeriesChildRule : VP.ChildRule\r
+BSBC.SeriesLabelRule : VP.LabelRule\r
+\r
+BSBC\r
+    @VP.customChildRule JFREE.Chart BSBC.SeriesChildRule\r
+        JFREE.Series\r
+\r
+BSBC        \r
+    @VP.customLabelRule             JFREE.Series        BSBC.SeriesLabelRule\r
+    \r
+//BSBC\r
+//    @VP.dropActionContribution JFREE.Series BSAC.Actions.SeriesDropAction 1.0      \r
+    \r
+BSBC\r
+    VP.BrowseContext.HasVisualsContribution _ : VP.VisualsContribution\r
+        VP.VisualsContribution.HasNodeType JFREE.Chart\r
+        VP.VisualsContribution.HasRule VP.PassThruSorterRule\r
+   \r
+BSAC.Actions : L0.Library\r
+//BSAC.Actions.SeriesDropAction : ACT.DropAction    \r
+\r
+\r
+///////////////////////////////////////////////\r
+// Pie chart: Variables viewpoint\r
+///////////////////////////////////////////////\r
+PSBC = SYSDYN.PieSeriesBrowseContext : VP.BrowseContext\r
+PSAC = SYSDYN.PieSeriesActionContext : VP.BrowseContext\r
+\r
+PSBC.SeriesChildRule : VP.ChildRule\r
+PSBC.SeriesLabelRule : VP.LabelRule\r
+\r
+PSBC\r
+    @VP.customChildRule JFREE.Chart PSBC.SeriesChildRule\r
+        JFREE.Series\r
+\r
+PSBC        \r
+    @VP.customLabelRule             JFREE.Series        PSBC.SeriesLabelRule\r
+    \r
+//PSBC\r
+//    @VP.dropActionContribution JFREE.Series PSAC.Actions.SeriesDropAction 1.0      \r
+    \r
+PSBC\r
+    VP.BrowseContext.HasVisualsContribution _ : VP.VisualsContribution\r
+        VP.VisualsContribution.HasNodeType JFREE.Chart\r
+        VP.VisualsContribution.HasRule VP.PassThruSorterRule\r
+   \r
+PSAC.Actions : L0.Library\r
+//PSAC.Actions.SeriesDropAction : ACT.DropAction    \r
index 4ce26dbd916fb53a52efdd2d6fb74385ae9f7e13..c8ad7f0f64be6a2ea31e5acdfc610223226f92a2 100644 (file)
@@ -17,6 +17,11 @@ public class SysdynResource {
     public final Resource AuxiliarySymbol;\r
     public final Resource AvailableSharedFunctionLibraries;\r
     public final Resource AvailableVariableIndexes;\r
+    public final Resource BarSeriesActionContext;\r
+    public final Resource BarSeriesActionContext_Actions;\r
+    public final Resource BarSeriesBrowseContext;\r
+    public final Resource BarSeriesBrowseContext_SeriesChildRule;\r
+    public final Resource BarSeriesBrowseContext_SeriesLabelRule;\r
     public final Resource BasicExperiment;\r
     public final Resource Bottom;\r
     public final Resource Browser;\r
@@ -181,6 +186,11 @@ public class SysdynResource {
     public final Resource NormalExpression;\r
     public final Resource Orientation;\r
     public final Resource ParameterExpression;\r
+    public final Resource PieSeriesActionContext;\r
+    public final Resource PieSeriesActionContext_Actions;\r
+    public final Resource PieSeriesBrowseContext;\r
+    public final Resource PieSeriesBrowseContext_SeriesChildRule;\r
+    public final Resource PieSeriesBrowseContext_SeriesLabelRule;\r
     public final Resource PlaybackExperiment;\r
     public final Resource Polarity;\r
     public final Resource PolarityLocation;\r
@@ -289,6 +299,11 @@ public class SysdynResource {
         public static final String AuxiliarySymbol = "http://www.simantics.org/Sysdyn-1.1/AuxiliarySymbol";\r
         public static final String AvailableSharedFunctionLibraries = "http://www.simantics.org/Sysdyn-1.1/AvailableSharedFunctionLibraries";\r
         public static final String AvailableVariableIndexes = "http://www.simantics.org/Sysdyn-1.1/AvailableVariableIndexes";\r
+        public static final String BarSeriesActionContext = "http://www.simantics.org/Sysdyn-1.1/BarSeriesActionContext";\r
+        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_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
         public static final String Browser = "http://www.simantics.org/Sysdyn-1.1/Browser";\r
@@ -453,6 +468,11 @@ public class SysdynResource {
         public static final String NormalExpression = "http://www.simantics.org/Sysdyn-1.1/NormalExpression";\r
         public static final String Orientation = "http://www.simantics.org/Sysdyn-1.1/Orientation";\r
         public static final String ParameterExpression = "http://www.simantics.org/Sysdyn-1.1/ParameterExpression";\r
+        public static final String PieSeriesActionContext = "http://www.simantics.org/Sysdyn-1.1/PieSeriesActionContext";\r
+        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_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
         public static final String PolarityLocation = "http://www.simantics.org/Sysdyn-1.1/PolarityLocation";\r
@@ -571,6 +591,11 @@ public class SysdynResource {
         AuxiliarySymbol = getResourceOrNull(graph, URIs.AuxiliarySymbol);\r
         AvailableSharedFunctionLibraries = getResourceOrNull(graph, URIs.AvailableSharedFunctionLibraries);\r
         AvailableVariableIndexes = getResourceOrNull(graph, URIs.AvailableVariableIndexes);\r
+        BarSeriesActionContext = getResourceOrNull(graph, URIs.BarSeriesActionContext);\r
+        BarSeriesActionContext_Actions = getResourceOrNull(graph, URIs.BarSeriesActionContext_Actions);\r
+        BarSeriesBrowseContext = getResourceOrNull(graph, URIs.BarSeriesBrowseContext);\r
+        BarSeriesBrowseContext_SeriesChildRule = getResourceOrNull(graph, URIs.BarSeriesBrowseContext_SeriesChildRule);\r
+        BarSeriesBrowseContext_SeriesLabelRule = getResourceOrNull(graph, URIs.BarSeriesBrowseContext_SeriesLabelRule);\r
         BasicExperiment = getResourceOrNull(graph, URIs.BasicExperiment);\r
         Bottom = getResourceOrNull(graph, URIs.Bottom);\r
         Browser = getResourceOrNull(graph, URIs.Browser);\r
@@ -735,6 +760,11 @@ public class SysdynResource {
         NormalExpression = getResourceOrNull(graph, URIs.NormalExpression);\r
         Orientation = getResourceOrNull(graph, URIs.Orientation);\r
         ParameterExpression = getResourceOrNull(graph, URIs.ParameterExpression);\r
+        PieSeriesActionContext = getResourceOrNull(graph, URIs.PieSeriesActionContext);\r
+        PieSeriesActionContext_Actions = getResourceOrNull(graph, URIs.PieSeriesActionContext_Actions);\r
+        PieSeriesBrowseContext = getResourceOrNull(graph, URIs.PieSeriesBrowseContext);\r
+        PieSeriesBrowseContext_SeriesChildRule = getResourceOrNull(graph, URIs.PieSeriesBrowseContext_SeriesChildRule);\r
+        PieSeriesBrowseContext_SeriesLabelRule = getResourceOrNull(graph, URIs.PieSeriesBrowseContext_SeriesLabelRule);\r
         PlaybackExperiment = getResourceOrNull(graph, URIs.PlaybackExperiment);\r
         Polarity = getResourceOrNull(graph, URIs.Polarity);\r
         PolarityLocation = getResourceOrNull(graph, URIs.PolarityLocation);\r
index 658f0808f33b194f73ac2030d68132ac1e4bbc80..dd09c0f4659173ac518da891fd9968ded34c0a68 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    </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    </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    </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    </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    </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    </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
index fdc1a04b5b4f6dee2aaf114617c70bb4997d927c..b576aadeedfa3c127d22133c97b44423808bb212 100644 (file)
                </visibleWhen>\r
             </command>\r
             <command\r
-                  commandId="org.simantics.sysdyn.ui.newChart"\r
-                  id="org.simantics.sysdyn.ui.browser.newChart"\r
-                  label="Chart"\r
+                  commandId="org.simantics.sysdyn.ui.newXYLineChart"\r
+                  id="org.simantics.sysdyn.ui.browser.newXYLineChart"\r
+                  label="Line Chart"\r
+                  style="push">\r
+               <visibleWhen\r
+                     checkEnabled="true">\r
+                  <with\r
+                        variable="selection">\r
+                     <test\r
+                           args="org.simantics.sysdyn.ui.browser.nodes.ChartsFolder"\r
+                           property="org.simantics.sysdyn.ui.nodeClass">\r
+                     </test>\r
+                  </with>\r
+               </visibleWhen>\r
+            </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.newBarChart"\r
+                  id="org.simantics.sysdyn.ui.browser.newBarChart"\r
+                  label="Bar Chart"\r
+                  style="push">\r
+               <visibleWhen\r
+                     checkEnabled="true">\r
+                  <with\r
+                        variable="selection">\r
+                     <test\r
+                           args="org.simantics.sysdyn.ui.browser.nodes.ChartsFolder"\r
+                           property="org.simantics.sysdyn.ui.nodeClass">\r
+                     </test>\r
+                  </with>\r
+               </visibleWhen>\r
+            </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.newPieChart"\r
+                  id="org.simantics.sysdyn.ui.browser.newPieChart"\r
+                  label="Pie Chart"\r
                   style="push">\r
                <visibleWhen\r
                      checkEnabled="true">\r
             name="Chart Panel Orientation">\r
       </command>\r
       <command\r
-            defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewChartHandler"\r
-            id="org.simantics.sysdyn.ui.newChart"\r
-            name="New Chart">\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewXYLineChartHandler"\r
+            id="org.simantics.sysdyn.ui.newXYLineChart"\r
+            name="New XY Line Chart">\r
+      </command>\r
+      <command\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewBarChartHandler"\r
+            id="org.simantics.sysdyn.ui.newBarChart"\r
+            name="New Bar Chart">\r
+      </command>\r
+      <command\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewPieChartHandler"\r
+            id="org.simantics.sysdyn.ui.newPieChart"\r
+            name="New Pie Chart">\r
       </command>\r
    </extension>\r
    <extension\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewBarChartHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewBarChartHandler.java
new file mode 100644 (file)
index 0000000..3171cc7
--- /dev/null
@@ -0,0 +1,110 @@
+/*******************************************************************************\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.handlers.newComponents;\r
+\r
+import java.util.Collections;\r
+import java.util.UUID;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\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.common.utils.ListUtils;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.stubs.G2DResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.ChartsFolder;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+/**\r
+ * Handler for creating a new Bar Chart\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class NewBarChartHandler extends AbstractHandler {\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        \r
+        ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+\r
+        ChartsFolder node = AdaptionUtils.adaptToSingle(sel, ChartsFolder.class);\r
+        if (node == null)\r
+            return null;\r
+\r
+        final Resource model = node.data;        \r
+\r
+        SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+            @Override\r
+            public void perform(WriteGraph g) throws DatabaseException {\r
+                Layer0 l0 = Layer0.getInstance(g);\r
+                JFreeChartResource jfree = JFreeChartResource.getInstance(g);\r
+                G2DResource g2d = G2DResource.getInstance(g);\r
+\r
+                Resource jfreechart = GraphUtils.create2(g, jfree.Chart,\r
+                        l0.HasName, "BarChart" + UUID.randomUUID().toString(),\r
+                        l0.HasLabel, NameUtils.findFreshLabel(g, "Bar Chart", model),\r
+                        l0.PartOf, model,\r
+                        jfree.Chart_visibleBorder, true,\r
+                        jfree.Chart_borderWidth, 3,\r
+                        jfree.Chart_visibleLegend, false\r
+                        );\r
+                \r
+                g.claimLiteral(jfreechart, jfree.Chart_borderColor, g2d.Color, new float[] {0,0,0,1});\r
+\r
+                GraphUtils.create2(g, jfree.TextTitle,\r
+                        l0.HasName, "TextTitle" + UUID.randomUUID().toString(),\r
+                        l0.HasLabel, "Bar Chart Title",\r
+                        jfree.Title_position, jfree.Top,\r
+                        l0.PartOf, jfreechart);\r
+\r
+                Resource domainAxis = GraphUtils.create2(g, jfree.CategoryAxis,\r
+                        l0.HasName, "CategoryAxis" + UUID.randomUUID().toString());\r
+                \r
+                Resource rangeAxis = GraphUtils.create2(g, jfree.NumberAxis,\r
+                        l0.HasName, "NumberAxis" + UUID.randomUUID().toString());\r
+\r
+                Resource renderer = GraphUtils.create2(g, jfree.BarRenderer);\r
+                \r
+                Resource dataset = GraphUtils.create2(g, jfree.CategoryDataset,\r
+                        l0.HasName, "CategoryDataset" + UUID.randomUUID().toString(),\r
+                        jfree.Dataset_mapToDomainAxis, domainAxis,\r
+                        jfree.Dataset_mapToRangeAxis, rangeAxis,\r
+                        jfree.Dataset_seriesList, ListUtils.create(g, Collections.<Resource>emptyList()),\r
+                        jfree.Dataset_renderer, renderer);\r
+\r
+                GraphUtils.create2(g, jfree.CategoryPlot,\r
+                        l0.HasName, "Category plot" + UUID.randomUUID().toString(),\r
+                        l0.PartOf, jfreechart,\r
+                        jfree.Plot_domainAxis, domainAxis,\r
+                        jfree.Plot_rangeAxis, rangeAxis,\r
+                        jfree.Plot_rangeAxisList, ListUtils.create(g, Collections.singletonList(rangeAxis)),\r
+                        l0.ConsistsOf, dataset,\r
+                        l0.ConsistsOf, domainAxis,\r
+                        l0.ConsistsOf, rangeAxis);\r
+            }\r
+\r
+        });\r
+        \r
+        return null;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewPieChartHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewPieChartHandler.java
new file mode 100644 (file)
index 0000000..516e49f
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************\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.handlers.newComponents;\r
+\r
+import java.util.Collections;\r
+import java.util.UUID;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\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.common.utils.ListUtils;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.stubs.G2DResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.ChartsFolder;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+/**\r
+ * Handler for craeting a new Pie Chart\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class NewPieChartHandler extends AbstractHandler {\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        \r
+        ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+\r
+        ChartsFolder node = AdaptionUtils.adaptToSingle(sel, ChartsFolder.class);\r
+        if (node == null)\r
+            return null;\r
+\r
+        final Resource model = node.data;        \r
+\r
+        SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+            @Override\r
+            public void perform(WriteGraph g) throws DatabaseException {\r
+                Layer0 l0 = Layer0.getInstance(g);\r
+                JFreeChartResource jfree = JFreeChartResource.getInstance(g);\r
+                G2DResource g2d = G2DResource.getInstance(g);\r
+\r
+                Resource jfreechart = GraphUtils.create2(g, jfree.Chart,\r
+                        l0.HasName, "PieChart" + UUID.randomUUID().toString(),\r
+                        l0.HasLabel, NameUtils.findFreshLabel(g, "Pie Chart", model),\r
+                        l0.PartOf, model,\r
+                        jfree.Chart_visibleBorder, true,\r
+                        jfree.Chart_borderWidth, 3);\r
+                g.claimLiteral(jfreechart, jfree.Chart_borderColor, g2d.Color, new float[] {0,0,0,1});\r
+\r
+                GraphUtils.create2(g, jfree.TextTitle,\r
+                        l0.HasName, "TextTitle" + UUID.randomUUID().toString(),\r
+                        l0.HasLabel, "Pie Chart Title",\r
+                        jfree.Title_position, jfree.Top,\r
+                        l0.PartOf, jfreechart);\r
+                \r
+                Resource dataset = GraphUtils.create2(g, jfree.PieDataset,\r
+                        l0.HasName, "CategoryDataset" + UUID.randomUUID().toString(),\r
+                        jfree.Dataset_seriesList, ListUtils.create(g, Collections.<Resource>emptyList())\r
+                        );\r
+\r
+                GraphUtils.create2(g, jfree.PiePlot,\r
+                        l0.HasName, "PiePlot" + UUID.randomUUID().toString(),\r
+                        l0.PartOf, jfreechart,\r
+                        l0.ConsistsOf, dataset\r
+                        );\r
+            }\r
+\r
+        });\r
+        \r
+        return null;\r
+    }\r
+}\r
similarity index 91%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewChartHandler.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewXYLineChartHandler.java
index 85d44c57fa107d9a7c670c06f617f91ecffc19d7..46b44408d67c47727798d8090ec9e90100333962 100644 (file)
@@ -30,17 +30,16 @@ import org.simantics.diagram.stubs.G2DResource;
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
-import org.simantics.sysdyn.ui.browser.nodes.ChartNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ChartsFolder;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
 /**\r
- * Handler for creating a new {@link ChartNode} in model browser\r
+ * Handler for creating a new XYLineChart in model browser\r
  * @author Teemu Lempinen\r
  *\r
  */\r
-public class NewChartHandler extends AbstractHandler {\r
+public class NewXYLineChartHandler extends AbstractHandler {\r
 \r
     @Override\r
     public Object execute(ExecutionEvent event) throws ExecutionException {\r
@@ -77,11 +76,9 @@ public class NewChartHandler extends AbstractHandler {
                         l0.PartOf, jfreechart);\r
 \r
                 Resource domainAxis = GraphUtils.create2(g, jfree.NumberAxis,\r
-                        l0.HasName, "NumberAxis" + UUID.randomUUID().toString(),\r
-                        l0.HasLabel, "Domain");\r
+                        l0.HasName, "NumberAxis" + UUID.randomUUID().toString());\r
                 Resource rangeAxis = GraphUtils.create2(g, jfree.NumberAxis,\r
-                        l0.HasName, "NumberAxis" + UUID.randomUUID().toString(),\r
-                        l0.HasLabel, "Range");\r
+                        l0.HasName, "NumberAxis" + UUID.randomUUID().toString());\r
 \r
                 Resource dataset = GraphUtils.create2(g, jfree.XYDataset,\r
                         l0.HasName, "XYDataset" + UUID.randomUUID().toString(),\r
index 50bd04806a37d1a8fc479d3e04166be93d284490..8c678caca80bf870328d8c02e05c51596c69427d 100644 (file)
@@ -40,6 +40,12 @@ import org.simantics.sysdyn.manager.SysdynPlaybackExperiment;
 import org.simantics.sysdyn.ui.editor.DiagramViewer;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
+/**\r
+ * Listener for playback simulations. This listener activates and reverts the playback\r
+ * profile when a playback simlation is activated or disposed.\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class SysdynPlaybackExperimentListener implements IExperimentListener {\r
 \r
     private Resource model;\r
@@ -215,7 +221,8 @@ public class SysdynPlaybackExperimentListener implements IExperimentListener {
         Resource current = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);\r
         if(profile.equals(current)) return;\r
         \r
-        graph.deny(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile, null, current);\r
+        if(current != null)\r
+            graph.deny(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile, null, current);\r
         graph.claim(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile, null, profile);\r
 \r
         // Set this profile as the default profile for this diagram\r
index cdb54df42b4fba09f1a0123c30eb20a97f8958fc..f16927eb137d399c4d84a0f5ae1a12c6023467f6 100644 (file)
@@ -35,6 +35,13 @@ import org.simantics.sysdyn.SysdynResource;
 import org.simantics.sysdyn.manager.SysdynPlaybackExperiment;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
+/**\r
+ * Contribution to the main toolbar. PlaybackSliderContribution contains a slider\r
+ * that can be used to control the time in a playback experiment\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
 public class PlaybackSliderContribution extends ToolBarContributionItem {\r
 \r
     Runnable timeListener;\r
@@ -72,6 +79,7 @@ public class PlaybackSliderContribution extends ToolBarContributionItem {
                 e1.printStackTrace();\r
             }\r
 \r
+            // Separator ToolItem can contain a composite. Add a composite with a slider to this item\r
             ToolItem ti = new ToolItem(parent, SWT.SEPARATOR);\r
 \r
             Composite composite = new Composite(parent, SWT.NONE);\r
@@ -94,6 +102,8 @@ public class PlaybackSliderContribution extends ToolBarContributionItem {
 \r
             startTime = numbers[0];\r
             endTime = numbers[1];\r
+            \r
+            // Create a DesimalFormat for rounding the time\r
             final DecimalFormat format = new DecimalFormat();\r
             format.setMinimumFractionDigits(0);\r
             format.setMaximumFractionDigits(2);\r
@@ -101,6 +111,8 @@ public class PlaybackSliderContribution extends ToolBarContributionItem {
             symbols.setDecimalSeparator('.');\r
             symbols.setGroupingSeparator(' ');\r
             format.setDecimalFormatSymbols(symbols);\r
+            \r
+            // Selection listener for the slider\r
             s.addSelectionListener(new SelectionListener() {\r
 \r
                 @Override\r
@@ -122,6 +134,7 @@ public class PlaybackSliderContribution extends ToolBarContributionItem {
                 spe.removeTimeListener(timeListener);\r
             }\r
 \r
+            // Time listener for setting the time in the slider if the time is changed somewhere else\r
             timeListener = new Runnable() {\r
 \r
                 @Override\r
@@ -134,7 +147,7 @@ public class PlaybackSliderContribution extends ToolBarContributionItem {
                                 startTime = spe.getStartTime();\r
                                 endTime = spe.getEndTime();\r
                             }\r
-                            int value = (int) ((spe.getTime() - startTime) / (endTime - startTime) * 99);\r
+                            int value = (int) Math.round(((spe.getTime() - startTime) / (endTime - startTime) * 99));\r
                             s.setSelection(value);\r
                             label.setText(format.format(spe.getTime()));\r
                         }\r
index ad0a573f9cbf0457f996ce560a5038d3c29f2e14..35e7c35764a2089674cdca9eb0ef1a4a1a8ecca0 100644 (file)
@@ -33,75 +33,69 @@ import org.simantics.utils.datastructures.Callback;
 \r
 public abstract class LabelPropertyTabContributor extends PropertyTabContributorImpl {\r
 \r
-       private boolean isDisposed = false;\r
-       \r
-       \r
-       public void createControl(Composite parent, final IWorkbenchSite site, final ISessionContext context, final WidgetSupportImpl support) {\r
-               super.createControl(parent, site, context, support);\r
-               \r
-               // Add dispose listener to make sure name listening receives the correct isDisposed -value\r
-               parent.addDisposeListener(new DisposeListener() {\r
-                       \r
-                       @Override\r
-                       public void widgetDisposed(DisposeEvent e) {\r
-                               LabelPropertyTabContributor.this.dispose();\r
-                       }\r
-               });\r
-       }\r
-       \r
-       @Override\r
+    private boolean isDisposed = false;\r
+\r
+\r
+    public void createControl(Composite parent, final IWorkbenchSite site, final ISessionContext context, final WidgetSupportImpl support) {\r
+        super.createControl(parent, site, context, support);\r
+\r
+        // Add dispose listener to make sure name listening receives the correct isDisposed -value\r
+        parent.addDisposeListener(new DisposeListener() {\r
+\r
+            @Override\r
+            public void widgetDisposed(DisposeEvent e) {\r
+                LabelPropertyTabContributor.this.dispose();\r
+            }\r
+        });\r
+    }\r
+\r
+    @Override\r
     public void updatePartName(ISelection forSelection, final Callback<String> updateCallback) {\r
-       final Resource resource = AdaptionUtils.adaptToSingle(forSelection, Resource.class);\r
-       if(resource == null) {\r
-               updateCallback.run("Selection properties");\r
-               return;\r
-       }\r
-       \r
-       try {\r
-                       SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+        final Resource resource = AdaptionUtils.adaptToSingle(forSelection, Resource.class);\r
+        if(resource == null) {\r
+            updateCallback.run("Selection properties");\r
+            return;\r
+        }\r
+\r
+        SimanticsUI.getSession().asyncRequest(new Read<String>() {\r
 \r
-                               @Override\r
-                               public String perform(ReadGraph graph) throws DatabaseException {\r
-                                       Layer0 l0 = Layer0.getInstance(graph);\r
-                                       ModelingResources mr = ModelingResources.getInstance(graph);\r
-                                       Resource r = resource;\r
-                                       if(graph.hasStatement(r, mr.ElementToComponent)) {\r
-                                               r = graph.getSingleObject(r, mr.ElementToComponent);\r
-                                       }\r
-                                       String label = graph.getPossibleRelatedValue(r, l0.HasLabel);\r
-                                       if(label != null)\r
-                                               return label;\r
-                                       label = graph.getPossibleRelatedValue(r, l0.HasName);\r
-                                       if(label != null)\r
-                                               return label;\r
-                                       return "No name for selection";\r
-                               }\r
-                       }, new AsyncListener<String>() {\r
+            @Override\r
+            public String perform(ReadGraph graph) throws DatabaseException {\r
+                Layer0 l0 = Layer0.getInstance(graph);\r
+                ModelingResources mr = ModelingResources.getInstance(graph);\r
+                Resource r = resource;\r
+                if(graph.hasStatement(r, mr.ElementToComponent)) {\r
+                    r = graph.getSingleObject(r, mr.ElementToComponent);\r
+                }\r
+                String label = graph.getPossibleRelatedValue(r, l0.HasLabel);\r
+                if(label != null)\r
+                    return label;\r
+                label = graph.getPossibleRelatedValue(r, l0.HasName);\r
+                if(label != null)\r
+                    return label;\r
+                return "No name for selection";\r
+            }\r
+        }, new AsyncListener<String>() {\r
 \r
-                               @Override\r
-                               public void execute(AsyncReadGraph graph, String result) {\r
-                                       updateCallback.run(result);\r
-                               }\r
+            @Override\r
+            public void execute(AsyncReadGraph graph, String result) {\r
+                updateCallback.run(result);\r
+            }\r
 \r
-                               @Override\r
-                               public void exception(AsyncReadGraph graph, Throwable throwable) {\r
-                                       \r
-                               }\r
+            @Override\r
+            public void exception(AsyncReadGraph graph, Throwable throwable) {\r
 \r
-                               @Override\r
-                               public boolean isDisposed() {\r
-                                       return isDisposed;\r
-                               }\r
-                       });\r
-               } catch (DatabaseException e) {\r
-                       updateCallback.run("Selection error in LabelPropertyTabContributor");\r
-                       e.printStackTrace();\r
-               }\r
-               \r
+            }\r
+\r
+            @Override\r
+            public boolean isDisposed() {\r
+                return isDisposed;\r
+            }\r
+        });\r
     }\r
-    \r
+\r
     @Override\r
     protected void dispose() {\r
-       this.isDisposed = true;\r
+        this.isDisposed = true;\r
     }\r
 }\r
index d0f4851d2d2e338e40468a506f2efcba456e8fb5..1fb72a786be6438260cd661021644ee243429b14 100644 (file)
@@ -19,6 +19,7 @@ import java.util.List;
 import org.eclipse.jface.viewers.ISelection;\r
 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.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
@@ -32,9 +33,13 @@ import org.simantics.simulation.ontology.SimulationResource;
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;\r
-import org.simantics.sysdyn.ui.trend.chart.properties.ChartAxisAndVariablesTab;\r
 import org.simantics.sysdyn.ui.trend.chart.properties.ChartTab;\r
-import org.simantics.sysdyn.ui.trend.chart.properties.GeneralChartPropertiesTab;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.bar.BarGeneralPropertiesTab;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.bar.BarSeriesTab;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.pie.PieGeneralPropertiesTab;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.pie.PieSeriesTab;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.xyline.XYLineAxisAndVariablesTab;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.xyline.XYLineGeneralPropertiesTab;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
 /**\r
@@ -108,7 +113,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                         r = connection;\r
                 }\r
             }\r
-            \r
+\r
             // Independent variable\r
             if (backend.isInstanceOf(r, sr.IndependentVariable)) {\r
                 Resource activeExpression = backend.getPossibleObject(r, sr.HasActiveExpression);\r
@@ -153,7 +158,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                         "Additional Information"));\r
                 return tabs;\r
             }\r
-            \r
+\r
             // Input variable\r
             if (backend.isInstanceOf(r, sr.Input)) {\r
                 tabs.add(new ComparableTabContributor(\r
@@ -175,7 +180,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                         "Additional Information"));\r
                 return tabs;\r
             }\r
-            \r
+\r
             // Enumeration\r
             if (backend.isInstanceOf(r, sr.Enumeration)) {\r
                 Object s = AdaptionUtils.adaptToSingle(selection, ISelection.class);\r
@@ -188,7 +193,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                         s,\r
                         "Enumeration"));\r
             }\r
-            \r
+\r
             // Configuration and model. They both show the properties of the configuration\r
             if ( backend.isInstanceOf(r, sr.Configuration) || backend.isInstanceOf(r, sr.SysdynModel)) {\r
                 if(!backend.isInstanceOf(r, sr.SysdynModel))\r
@@ -201,7 +206,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                     r,\r
                                     "Model Properties"));\r
             }\r
-            \r
+\r
             // Module\r
             if (backend.isInstanceOf(r, sr.Module)){\r
                 tabs.add(new ComparableTabContributor(\r
@@ -221,7 +226,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                         "Outputs"));\r
                 return tabs;\r
             }\r
-            \r
+\r
             // Playback experiment\r
             if (backend.isInstanceOf(r, sr.PlaybackExperiment))\r
                 return Collections.singleton(\r
@@ -230,7 +235,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                 0,\r
                                 r,\r
                                 "Experiment Properties"));\r
-            \r
+\r
             // Default experiment\r
             if (backend.isInstanceOf(r, simu.Experiment))\r
                 return Collections.singleton(\r
@@ -239,7 +244,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                 0,\r
                                 r,\r
                                 "Experiment Properties"));\r
-            \r
+\r
             // Saved simulation result\r
             if (backend.isInstanceOf(r, sr.Result))\r
                 return Collections.singleton(\r
@@ -248,7 +253,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                 0,\r
                                 r,\r
                                 "Result Properties"));\r
-            \r
+\r
             // Dependency\r
             if (backend.isInstanceOf(r, sr.Dependency))\r
                 if (backend.hasStatement(r, sr.RefersTo))\r
@@ -267,7 +272,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                     diaConnection,\r
                                     "Dependency Properties"));\r
                 }\r
-            \r
+\r
             // Module symbol. Modules in modules-folder are actually symbol resources\r
             if (backend.isInheritedFrom(r, sr.ModuleSymbol)) {\r
                 // Find the component resource\r
@@ -311,22 +316,54 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
 \r
             // Chart\r
             if (backend.isInstanceOf(r, jfree.Chart)) {\r
-                tabs.add(new ComparableTabContributor(\r
-                        new GeneralChartPropertiesTab(),\r
-                        10,\r
-                        r,\r
-                        "General"));\r
-                tabs.add(new ComparableTabContributor(\r
-                        new ChartAxisAndVariablesTab(),\r
-                        9,\r
-                        r,\r
-                        "Axis and Variables"));\r
-                tabs.add(new ComparableTabContributor(\r
-                        new ChartTab(),\r
-                        1,\r
-                        r,\r
-                        "Chart"));\r
-                return tabs;\r
+\r
+                Collection<Resource> plots = backend.syncRequest(new ObjectsWithType(r, Layer0.getInstance(backend).ConsistsOf, jfree.Plot));\r
+                if(!plots.isEmpty()) {\r
+                    Resource plot = plots.iterator().next();\r
+\r
+                    if(backend.isInstanceOf(plot, jfree.XYPlot)) {\r
+                        tabs.add(new ComparableTabContributor(\r
+                                new XYLineGeneralPropertiesTab(),\r
+                                10,\r
+                                r,\r
+                                "General"));\r
+                        tabs.add(new ComparableTabContributor(\r
+                                new XYLineAxisAndVariablesTab(),\r
+                                9,\r
+                                r,\r
+                                "Axis and Variables"));\r
+                    } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
+                        tabs.add(new ComparableTabContributor(\r
+                                new BarGeneralPropertiesTab(),\r
+                                10,\r
+                                r,\r
+                                "General"));\r
+                        tabs.add(new ComparableTabContributor(\r
+                                new BarSeriesTab(),\r
+                                9,\r
+                                r,\r
+                                "Variables"));\r
+                    } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
+                        tabs.add(new ComparableTabContributor(\r
+                                new PieGeneralPropertiesTab(),\r
+                                10,\r
+                                r,\r
+                                "General"));\r
+                        tabs.add(new ComparableTabContributor(\r
+                                new PieSeriesTab(),\r
+                                9,\r
+                                r,\r
+                                "Variables"));\r
+                    }\r
+                    \r
+                    tabs.add(new ComparableTabContributor(\r
+                            new ChartTab(),\r
+                            1,\r
+                            r,\r
+                            "Chart"));\r
+                    return tabs;\r
+\r
+                } \r
             }\r
 \r
         } catch (ServiceException e) {\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractAxis.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractAxis.java
new file mode 100644 (file)
index 0000000..3f6e7bf
--- /dev/null
@@ -0,0 +1,86 @@
+/*******************************************************************************\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;\r
+\r
+import java.awt.Color;\r
+\r
+import org.jfree.chart.axis.Axis;\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.diagram.G2DUtils;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+\r
+/**\r
+ * Abstract axis class for all JFreeChart axis\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public abstract class AbstractAxis implements IAxis {\r
+\r
+    protected Axis axis;\r
+    protected String label;\r
+    protected Boolean tMarksVisible, tLabelsVisible, labelVisible, lineVisible;\r
+    protected Color color;\r
+    protected Double min, max;\r
+\r
+    /**\r
+     *\r
+     * @param graph ReadGraph\r
+     * @param axisResource resource of type JFreeChart.NumberAxis\r
+     */\r
+    public AbstractAxis(ReadGraph graph, Resource axisResource) {\r
+        try {\r
+            Layer0 l0 = Layer0.getInstance(graph);\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+            label = graph.getPossibleRelatedValue(axisResource, l0.HasLabel);\r
+            tMarksVisible = graph.getPossibleRelatedValue(axisResource, jfree.Axis_visibleTickMarks, Bindings.BOOLEAN);\r
+            tLabelsVisible = graph.getPossibleRelatedValue(axisResource, jfree.Axis_visibleTickLabels, Bindings.BOOLEAN);\r
+            labelVisible = graph.getPossibleRelatedValue(axisResource, jfree.Axis_visibleLabel, Bindings.BOOLEAN);\r
+            lineVisible = graph.getPossibleRelatedValue(axisResource, jfree.Axis_visibleAxisLine, Bindings.BOOLEAN);\r
+            Resource c = graph.getPossibleObject(axisResource, jfree.color);\r
+            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
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
+        }\r
+    }\r
+    \r
+    @Override\r
+    public void dispose() {\r
+        \r
+    }\r
+\r
+    @Override\r
+    public Axis getAxis() {\r
+        if(tMarksVisible != null && tMarksVisible == false)\r
+            axis.setTickMarksVisible(false);\r
+        if(tLabelsVisible != null && tLabelsVisible == false)\r
+            axis.setTickLabelsVisible(false);\r
+        if(lineVisible != null && lineVisible == false)\r
+            axis.setAxisLineVisible(false);\r
+        \r
+        if(color != null) {\r
+            axis.setAxisLinePaint(color);\r
+            axis.setLabelPaint(color);\r
+            axis.setTickLabelPaint(color);\r
+            axis.setTickMarkPaint(color);\r
+        }\r
+        // label exists and its visibility == null or true\r
+        if((labelVisible == null || labelVisible == true) && label != null)\r
+            axis.setLabel(label);\r
+        return axis;\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractDataset.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractDataset.java
new file mode 100644 (file)
index 0000000..31a9112
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************\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;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+\r
+\r
+/**\r
+ * Abstract dataset class for all JFreeChart datasets\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public abstract class AbstractDataset implements IDataset {\r
+\r
+    protected Resource resource;\r
+    \r
+    public AbstractDataset(ReadGraph graph, Resource resource) {\r
+        this.resource = resource;\r
+    }\r
+    \r
+    @Override\r
+    public void dispose() {\r
+        \r
+    }\r
+\r
+    @Override\r
+    public Resource getResource() {\r
+        return resource;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractPlot.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractPlot.java
new file mode 100644 (file)
index 0000000..e38b641
--- /dev/null
@@ -0,0 +1,119 @@
+/*******************************************************************************\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;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+\r
+import org.jfree.chart.axis.Axis;\r
+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.utils.ListUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+\r
+/**\r
+ * Abstract plot class for all JFreeChart plots\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public abstract class AbstractPlot implements IPlot {\r
+\r
+    protected Resource resource;\r
+    protected ArrayList<IAxis> ranges;\r
+    protected ArrayList<IAxis> domains;\r
+    protected ArrayList<IDataset> datasets;\r
+    protected HashMap<IDataset, IAxis> rangeMappings;\r
+    protected HashMap<IDataset, IAxis> domainMappings;\r
+    \r
+    public AbstractPlot(ReadGraph graph, Resource resource) {\r
+        this.resource = resource;\r
+        \r
+        try {\r
+            Layer0 l0 = Layer0.getInstance(graph);\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+\r
+            HashMap<Resource, IAxis> axisMap = new HashMap<Resource, IAxis>();\r
+            ranges = new ArrayList<IAxis>();\r
+\r
+            // Get all range axis\r
+            Resource rangeList = graph.getPossibleObject(resource, jfree.Plot_rangeAxisList);\r
+            if(rangeList != null) {\r
+                for(Resource axisResource : ListUtils.toList(graph, rangeList)) {\r
+                    IAxis axis = graph.adapt(axisResource, IAxis.class);\r
+                    if(axis.getAxis() instanceof Axis) {\r
+                        ranges.add(axis);\r
+                        axisMap.put(axisResource, axis);\r
+                    }\r
+                }\r
+            }\r
+            \r
+            // Get all domain axis\r
+            // There usually is only one domain axis, but this supports also multiple domain axis\r
+            domains = new ArrayList<IAxis>();\r
+            for(Resource axisResource : graph.syncRequest(new ObjectsWithType(resource, jfree.Plot_domainAxis, jfree.Axis))) {\r
+                IAxis axis = graph.adapt(axisResource, IAxis.class);\r
+                if(axis.getAxis() instanceof Axis) {\r
+                    domains.add(axis);\r
+                    axisMap.put(axisResource, axis);\r
+                }\r
+            }\r
+\r
+            // Get all datasets and map them to axis\r
+            datasets = new ArrayList<IDataset>();\r
+            rangeMappings = new HashMap<IDataset, IAxis>();\r
+            domainMappings = new HashMap<IDataset, IAxis>();\r
+            for(Resource datasetResource : graph.syncRequest(new ObjectsWithType(resource, l0.ConsistsOf, jfree.Dataset))) {\r
+                IDataset dataset = graph.adapt(datasetResource, IDataset.class);\r
+                if(dataset != null) {\r
+                    datasets.add(dataset);\r
+                    Resource axisResource = graph.getPossibleObject(datasetResource, jfree.Dataset_mapToRangeAxis);\r
+                    IAxis axis;\r
+                    if(axisMap.containsKey(axisResource)) {\r
+                        axis = axisMap.get(axisResource);\r
+                        rangeMappings.put(dataset, axis);\r
+                    }\r
+                    \r
+                    axisResource = graph.getPossibleObject(datasetResource, jfree.Dataset_mapToDomainAxis);\r
+                    if(axisMap.containsKey(axisResource)) {\r
+                        axis = axisMap.get(axisResource);\r
+                        domainMappings.put(dataset, axis);\r
+                    }\r
+                }\r
+            }\r
+            \r
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
+        }\r
+        \r
+    }\r
+    \r
+    @Override\r
+    public void dispose() {\r
+        for(IAxis axis : ranges)\r
+            axis.dispose();\r
+        \r
+        for(IAxis axis : domains)\r
+            axis.dispose();\r
+        \r
+        for(IDataset dataset : datasets)\r
+            dataset.dispose();\r
+    }\r
+\r
+    @Override\r
+    public Resource getResource() {\r
+        return resource;\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractRenderer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/AbstractRenderer.java
new file mode 100644 (file)
index 0000000..c38bd23
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************\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;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+\r
+/**\r
+ * Abstract renderer class for all JFreeChart renderers\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public abstract class AbstractRenderer implements IRenderer {\r
+\r
+    protected Resource resource;\r
+    \r
+    public AbstractRenderer(ReadGraph graph, Resource resource) {\r
+        this.resource = resource;\r
+    }\r
+    \r
+    @Override\r
+    public void dispose() {\r
+    }\r
+\r
+    @Override\r
+    public Resource getResource() {\r
+        return resource;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/BarRenderer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/BarRenderer.java
new file mode 100644 (file)
index 0000000..d708ac5
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************\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;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+\r
+\r
+/**\r
+ * Normal bar renderer\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class BarRenderer extends AbstractRenderer {\r
+\r
+    public BarRenderer(ReadGraph graph, Resource resource) {\r
+        super(graph, resource);\r
+    }\r
+\r
+    private org.jfree.chart.renderer.category.BarRenderer renderer;\r
+    \r
+    @Override\r
+    public org.jfree.chart.renderer.AbstractRenderer getRenderer() {\r
+        if(renderer == null)\r
+            renderer = new org.jfree.chart.renderer.category.BarRenderer();\r
+        return renderer;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryAxis.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryAxis.java
new file mode 100644 (file)
index 0000000..d31e8ea
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************\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;\r
+\r
+import org.jfree.chart.axis.Axis;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+\r
+/**\r
+ * Class representing a JFreeChart.CategoryAxis\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class CategoryAxis extends AbstractAxis {\r
+\r
+    public CategoryAxis(ReadGraph graph, Resource axisResource) {\r
+        super(graph, axisResource);\r
+    }\r
+\r
+    @Override\r
+    public Axis getAxis() {\r
+        axis = new org.jfree.chart.axis.CategoryAxis();\r
+        return super.getAxis();\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryDataset.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryDataset.java
new file mode 100644 (file)
index 0000000..d87627c
--- /dev/null
@@ -0,0 +1,248 @@
+/*******************************************************************************\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;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import javax.swing.SwingUtilities;\r
+\r
+import org.jfree.chart.plot.DefaultDrawingSupplier;\r
+import org.jfree.chart.renderer.AbstractRenderer;\r
+import org.jfree.chart.renderer.category.BarRenderer;\r
+import org.jfree.data.category.DefaultCategoryDataset;\r
+import org.jfree.data.general.Dataset;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.ListUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.exception.MissingVariableException;\r
+import org.simantics.db.layer0.request.PossibleActiveExperiment;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.operation.Layer0X;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.adapter.SysdynVariableProperties;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+/**\r
+ * Class representing a JFreeChart.CategoryDataset\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class CategoryDataset extends AbstractDataset {\r
+\r
+    private List<Resource> seriesList;\r
+    private String realizationURI;\r
+    private IRenderer renderer;\r
+    private DefaultCategoryDataset dataset;\r
+\r
+    public CategoryDataset(ReadGraph graph, Resource resource) {\r
+        super(graph, resource);\r
+\r
+        try {\r
+            Layer0 l0 = Layer0.getInstance(graph);\r
+            ModelingResources mr = ModelingResources.getInstance(graph);\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+\r
+            // Find the model where the chart is located\r
+            Resource model = resource;\r
+            do {\r
+                model = graph.getPossibleObject(model, l0.PartOf);\r
+            } while(model != null && !graph.isInstanceOf(model, mr.StructuralModel));\r
+\r
+            // Find the variable realization of the current experiment\r
+            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
+            if(realizationURI == null)\r
+                return; // No experiment -> No results\r
+\r
+            Resource seriesList = graph.getPossibleObject(resource, jfree.Dataset_seriesList);\r
+            if(seriesList != null)\r
+                this.seriesList = ListUtils.toList(graph, seriesList);\r
+                \r
+            Resource rendererResource = graph.getPossibleObject(resource, jfree.Dataset_renderer);\r
+            renderer = graph.adapt(rendererResource, IRenderer.class);\r
+            \r
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
+        }\r
+    }\r
+\r
+    private DatasetListener listener;\r
+    \r
+    @Override\r
+    public Dataset getDataset() {\r
+        \r
+        if(seriesList == null || seriesList.isEmpty())\r
+            return null;\r
+\r
+        if(dataset == null) {\r
+            dataset = new DefaultCategoryDataset();\r
+        }\r
+        \r
+        if(listener == null || listener.isDisposed()) {\r
+            listener = new DatasetListener();\r
+            SimanticsUI.getSession().asyncRequest(new Read<ArrayList<TempSeries>>() {\r
+\r
+                @Override\r
+                public ArrayList<TempSeries> perform(ReadGraph graph) throws DatabaseException {\r
+                    JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+\r
+                    ArrayList<TempSeries> series = new ArrayList<TempSeries>();\r
+                    // Get properties for all series\r
+                    if(seriesList != null) {\r
+                        for(Resource r : seriesList) {\r
+                            String rvi = graph.getPossibleRelatedValue(r, jfree.variableRVI);\r
+                            if(rvi == null)\r
+                                continue;\r
+\r
+                            try {\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
+                                    }\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 = 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
+                        }\r
+                    }\r
+                    return series;\r
+                }\r
+\r
+            }, listener);\r
+        }\r
+//        System.out.println("RETURNING CATEGORY DATASET" + dataset);\r
+        return dataset;\r
+    }\r
+\r
+    @Override\r
+    public AbstractRenderer getRenderer() {\r
+        return renderer.getRenderer();\r
+    }\r
+    \r
+    private class DatasetListener implements Listener<ArrayList<TempSeries>> {\r
+        private boolean disposed = false;\r
+        \r
+        public void dispose() {\r
+            disposed = true;\r
+        }\r
+\r
+        @Override\r
+        public void execute(final ArrayList<TempSeries> series) {\r
+            // Modify series in AWT thread to avoid synchronization problems\r
+            SwingUtilities.invokeLater(new Runnable() {\r
+\r
+                @Override\r
+                public void run() {\r
+\r
+                    // Remove all unused series\r
+                    dataset.clear();\r
+                    ((BarRenderer)getRenderer()).getPlot().setDrawingSupplier(new DefaultDrawingSupplier());\r
+                    \r
+                    // Add found series\r
+                    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
+        }\r
+\r
+        @Override\r
+        public void exception(Throwable t) {\r
+            t.printStackTrace();\r
+        }\r
+\r
+        @Override\r
+        public boolean isDisposed() {\r
+            return disposed;\r
+        }\r
+    };\r
+    \r
+    @Override\r
+    public void dispose() {\r
+        super.dispose();\r
+        if(listener != null) {\r
+            listener.dispose();\r
+            listener = null;\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Auxiliary class containing all information needed to define a single series\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class TempSeries {\r
+        public String name;\r
+        public String series;\r
+        public Double value;\r
+\r
+        public TempSeries(String name, String series, Double value) {\r
+            this.name = name;\r
+            this.series = series;\r
+            this.value = value;\r
+        }\r
+\r
+        @Override\r
+        public String toString() {\r
+            return "TempSeries: " + name + ", " + series + ", " + value;\r
+        }\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryPlot.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/CategoryPlot.java
new file mode 100644 (file)
index 0000000..5167932
--- /dev/null
@@ -0,0 +1,86 @@
+/*******************************************************************************\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;\r
+\r
+import org.jfree.chart.axis.CategoryAxis;\r
+import org.jfree.chart.axis.ValueAxis;\r
+import org.jfree.chart.plot.Plot;\r
+import org.jfree.chart.renderer.category.CategoryItemRenderer;\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
+\r
+/**\r
+ * Class representing a CategoryPlot for JFreeChart\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class CategoryPlot extends AbstractPlot {\r
+    \r
+    private org.jfree.chart.plot.CategoryPlot plot;\r
+    private Boolean visibleGrid;\r
+\r
+\r
+    public CategoryPlot(ReadGraph graph, Resource resource) {\r
+        super(graph, resource);\r
+        \r
+        try {\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+            // Visual properties\r
+            visibleGrid = graph.getPossibleRelatedValue(resource, jfree.Plot_visibleGrid);\r
+        } catch(DatabaseException e) {\r
+            e.printStackTrace();\r
+        }\r
+\r
+        \r
+    }\r
+\r
+    @Override\r
+    public Plot getPlot() {\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
+        for(int i = 0; i < ranges.size(); i++) {\r
+            plot.setRangeAxis(i, (ValueAxis)ranges.get(i).getAxis());\r
+        }\r
+        \r
+        for(int i = 0; i < domains.size(); i++) {\r
+            plot.setDomainAxis(i, (CategoryAxis)domains.get(i).getAxis());\r
+        }\r
+        \r
+        IAxis axis;\r
+        for(int i = 0; i < datasets.size(); i++) {\r
+            IDataset dataset = datasets.get(i);\r
+            org.jfree.data.category.CategoryDataset ds = (org.jfree.data.category.CategoryDataset)dataset.getDataset();\r
+            plot.setDataset(i, ds);\r
+//            System.out.println("setting dataset " + i + ": " + ds);\r
+            plot.setRenderer(i, (CategoryItemRenderer)dataset.getRenderer());\r
+            axis = rangeMappings.get(dataset);\r
+            if(axis != null && ranges.contains(axis))\r
+                plot.mapDatasetToRangeAxis(i, ranges.indexOf(axis));\r
+            axis = domainMappings.get(dataset);\r
+            if(axis != null && ranges.contains(axis))\r
+                plot.mapDatasetToDomainAxis(i, domains.indexOf(axis));\r
+        }\r
+\r
+        if(visibleGrid != null) {\r
+            plot.setRangeGridlinesVisible(visibleGrid);\r
+            plot.setDomainGridlinesVisible(false);\r
+        }\r
+        \r
+        return plot;\r
+    }\r
+\r
+}\r
index d6fe54450fb0b7c418d740c95bba4c4da8d71f5f..9e374b88a844bf0f8de05cc8e1a702d88466cdc0 100644 (file)
@@ -17,6 +17,8 @@ import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.awt.SWT_AWT;\r
+import org.eclipse.swt.events.DisposeEvent;\r
+import org.eclipse.swt.events.DisposeListener;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.jfree.chart.ChartPanel;\r
 import org.jfree.chart.JFreeChart;\r
@@ -41,6 +43,7 @@ public class ChartComposite extends Composite {
     private Frame frame;\r
     private ChartPanel panel;\r
     private Composite composite;\r
+    IJFreeChart chart;\r
 \r
     /**\r
      * A new ChartComposite with a definition in chartResourceURI\r
@@ -84,6 +87,16 @@ public class ChartComposite extends Composite {
      */\r
     private void CreateContent(final Resource chartResource) {\r
         composite = this;\r
+        \r
+        composite.addDisposeListener(new DisposeListener() {\r
+            \r
+            @Override\r
+            public void widgetDisposed(DisposeEvent e) {\r
+                if(chart != null)\r
+                    chart.dispose();                \r
+            }\r
+        });\r
+        \r
         GridLayoutFactory.fillDefaults().applyTo(composite);\r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
         frame = SWT_AWT.new_Frame(composite);\r
@@ -96,8 +109,10 @@ public class ChartComposite extends Composite {
                 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
-                        IJFreeChart c = graph.adapt(chartResource, IJFreeChart.class);\r
-                        return c.getChart();\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
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ExtendedNumberAxis.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ExtendedNumberAxis.java
new file mode 100644 (file)
index 0000000..329faad
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************\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;\r
+\r
+import org.jfree.data.Range;\r
+\r
+/**\r
+ * NumberAxis that supports adding only one bound, lower or upper.\r
+ * The standard NumberAxis disables auto adjusting if even one of the bounds is set\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class ExtendedNumberAxis  extends org.jfree.chart.axis.NumberAxis {\r
+    private static final long serialVersionUID = 3066266986472919998L;\r
+\r
+    private Double lower = null;\r
+    private Double upper = null;\r
+    /**\r
+     * Use own lower and upper bounds to support using only one of them\r
+     */\r
+    protected void autoAdjustRange() {\r
+        super.autoAdjustRange();\r
+        Range range = getRange();\r
+        Double lower = this.lower == null ? range.getLowerBound() : this.lower;\r
+        Double upper = this.upper == null ? range.getUpperBound() : this.upper;\r
+        if(lower > upper)\r
+            upper = lower + 1;\r
+        if(upper - lower < getAutoRangeMinimumSize())\r
+            upper = lower + getAutoRangeMinimumSize();\r
+        \r
+        setRange(new Range(lower, upper), false, false);\r
+\r
+    }\r
+\r
+    public void setLower(Double lower) {\r
+        this.lower = lower;\r
+    }\r
+\r
+    public void setUpper(Double upper) {\r
+        this.upper = upper;\r
+    }\r
+\r
+}\r
index cf53605c80d3062f056bdd4585e60eaa4d43879a..cf91dd710e5d80b3d2d8cd8dd95c026249b4575b 100644 (file)
@@ -13,6 +13,7 @@ package org.simantics.sysdyn.ui.trend.chart;
 \r
 import org.jfree.chart.renderer.AbstractRenderer;\r
 import org.jfree.data.general.Dataset;\r
+import org.simantics.db.Resource;\r
 \r
 /**\r
  * Interface for JFreeChart.Dataset type resource\r
@@ -36,4 +37,10 @@ public interface IDataset extends IJFreeChartComponent {
      */\r
     public AbstractRenderer getRenderer();\r
 \r
+    /**\r
+     * Returns the resource of this dataset\r
+     * \r
+     * @return\r
+     */\r
+    public Resource getResource();\r
 }\r
index 162c9e0bebd0413c34f819f174893c3d1f37f289..39b42e2e3663754e0559c59dd0c9d04f7ea33096 100644 (file)
@@ -24,10 +24,4 @@ public interface IJFreeChartComponent {
      */\r
     public void dispose();\r
     \r
-    /**\r
-     * Returns the disposed state of the component\r
-     * @return\r
-     */\r
-    public boolean isDisposed();\r
-\r
 }\r
index 7f92e86d769243a0ead44e49a3d63c9b06cea918..ec8386efba8c46d69047eb87d093228571128668 100644 (file)
@@ -12,6 +12,7 @@
 package org.simantics.sysdyn.ui.trend.chart;\r
 \r
 import org.jfree.chart.plot.Plot;\r
+import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
 \r
 /**\r
@@ -30,4 +31,11 @@ public interface IPlot extends IJFreeChartComponent {
      */\r
     public Plot getPlot();\r
     \r
+    /**\r
+     * Returns the resource of this plot\r
+     * \r
+     * @return\r
+     */\r
+    public Resource getResource();\r
+    \r
 }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/IRenderer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/IRenderer.java
new file mode 100644 (file)
index 0000000..df832a4
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************\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;\r
+\r
+import org.jfree.chart.renderer.AbstractRenderer;\r
+import org.simantics.db.Resource;\r
+\r
+/**\r
+ * Interface for JFreeChart.Renderer type resource\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public interface IRenderer extends IJFreeChartComponent {\r
+    \r
+    /**\r
+     * Returns the JFreeChart AbstractRenderer represented by the associated resource\r
+     * \r
+     * @return JFreeChart renderer\r
+     */\r
+    public AbstractRenderer getRenderer();\r
+    \r
+    /**\r
+     * Returns the resource of this renderer\r
+     * @return\r
+     */\r
+    public Resource getResource();\r
+\r
+}\r
index 87661ceb54c0862b1b86c5fb26140ec1a7970c35..661fdf48751e6cf6555639274bd59e0c98a7b4ce 100644 (file)
@@ -35,11 +35,10 @@ import org.simantics.sysdyn.JFreeChartResource;
 public class JFreeChart implements IJFreeChart {\r
 \r
     private org.jfree.chart.JFreeChart jfreechart;\r
-    private boolean disposed = false;\r
 \r
     private ITitle title;\r
     private Boolean legendVisible;\r
-    \r
+\r
     private HashMap<Resource, IPlot> plots;\r
     private IPlot firstPlot = null;\r
 \r
@@ -79,12 +78,12 @@ public class JFreeChart implements IJFreeChart {
         if(plots.size() == 0)\r
             return null;\r
         jfreechart = new org.jfree.chart.JFreeChart(firstPlot.getPlot());\r
-        \r
+\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
+\r
         if(legendVisible != null && !legendVisible) {\r
             for(Object title : jfreechart.getSubtitles()) {\r
                 if(title instanceof LegendTitle)\r
@@ -96,16 +95,10 @@ public class JFreeChart implements IJFreeChart {
 \r
     @Override\r
     public void dispose() {\r
-        disposed = true;\r
-\r
         // Call dispose to title and plots to disable their possible listeners\r
         title.dispose();\r
         for(IPlot plot : plots.values())\r
             plot.dispose();\r
     }\r
 \r
-    @Override\r
-    public boolean isDisposed() {\r
-        return disposed;\r
-    }\r
 }\r
index 57bb972167181bef6ae01014bd952318ba7c96a5..eda694fe3c67cbda578bba83b98f03f6b2c6aa80 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.trend.chart;\r
 \r
-import java.awt.Color;\r
-\r
 import org.jfree.chart.axis.Axis;\r
-import org.jfree.data.Range;\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.diagram.G2DUtils;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.sysdyn.JFreeChartResource;\r
 \r
 /**\r
  * Class representing a JFreeChart.NumberAxis\r
@@ -29,14 +21,7 @@ import org.simantics.sysdyn.JFreeChartResource;
  * @author Teemu Lempinen\r
  *\r
  */\r
-public class NumberAxis implements IAxis {\r
-\r
-    private MyNumberAxis axis;\r
-    private String label;\r
-    private boolean disposed;\r
-    private Boolean tMarksVisible, tLabelsVisible, labelVisible, lineVisible;\r
-    private Color color;\r
-    private Double min, max;\r
+public class NumberAxis extends AbstractAxis {\r
 \r
     /**\r
      *\r
@@ -44,95 +29,16 @@ public class NumberAxis implements IAxis {
      * @param axisResource resource of type JFreeChart.NumberAxis\r
      */\r
     public NumberAxis(ReadGraph graph, Resource axisResource) {\r
-\r
-        try {\r
-            Layer0 l0 = Layer0.getInstance(graph);\r
-            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
-            label = graph.getPossibleRelatedValue(axisResource, l0.HasLabel);\r
-            tMarksVisible = graph.getPossibleRelatedValue(axisResource, jfree.Axis_visibleTickMarks, Bindings.BOOLEAN);\r
-            tLabelsVisible = graph.getPossibleRelatedValue(axisResource, jfree.Axis_visibleTickLabels, Bindings.BOOLEAN);\r
-            labelVisible = graph.getPossibleRelatedValue(axisResource, jfree.Axis_visibleLabel, Bindings.BOOLEAN);\r
-            lineVisible = graph.getPossibleRelatedValue(axisResource, jfree.Axis_visibleAxisLine, Bindings.BOOLEAN);\r
-            Resource c = graph.getPossibleObject(axisResource, jfree.color);\r
-            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
-        } catch (DatabaseException e) {\r
-            e.printStackTrace();\r
-        }\r
+        super(graph, axisResource);\r
     }\r
 \r
 \r
     @Override\r
     public Axis getAxis() {\r
-        axis = new MyNumberAxis();\r
-\r
-        if(tMarksVisible != null && tMarksVisible == false)\r
-            axis.setTickMarksVisible(false);\r
-        if(tLabelsVisible != null && tLabelsVisible == false)\r
-            axis.setTickLabelsVisible(false);\r
-        if(lineVisible != null && lineVisible == false)\r
-            axis.setAxisLineVisible(false);\r
-        \r
-        if(color != null) {\r
-            axis.setAxisLinePaint(color);\r
-            axis.setLabelPaint(color);\r
-            axis.setTickLabelPaint(color);\r
-            axis.setTickMarkPaint(color);\r
-        }\r
-        // label exists and its visibility == null or true\r
-        if((labelVisible == null || labelVisible == true) && label != null)\r
-            axis.setLabel(label);\r
-        axis.setLower(min);\r
-        axis.setUpper(max);\r
-        return axis;\r
+        axis = new ExtendedNumberAxis();\r
+        ((ExtendedNumberAxis)axis).setLower(min);\r
+        ((ExtendedNumberAxis)axis).setUpper(max);\r
+        return super.getAxis();\r
     }\r
 \r
-    @Override\r
-    public void dispose() {\r
-        disposed = true;\r
-    }\r
-\r
-    @Override\r
-    public boolean isDisposed() {\r
-        return disposed;\r
-    }\r
-\r
-    /**\r
-     * NumberAxis that supports adding only one bound, lower or upper.\r
-     * The standard NumberAxis disables auto adjusting if even one of the bounds is set\r
-     * \r
-     * @author Teemu Lempinen\r
-     *\r
-     */\r
-    private class MyNumberAxis extends org.jfree.chart.axis.NumberAxis {\r
-        private static final long serialVersionUID = 3066266986472919998L;\r
-\r
-        private Double lower = null;\r
-        private Double upper = null;\r
-        /**\r
-         * Use own lower and upper bounds to support using only one of them\r
-         */\r
-        protected void autoAdjustRange() {\r
-            super.autoAdjustRange();\r
-            Range range = getRange();\r
-            Double lower = this.lower == null ? range.getLowerBound() : this.lower;\r
-            Double upper = this.upper == null ? range.getUpperBound() : this.upper;\r
-            if(lower > upper)\r
-                upper = lower + 1;\r
-            if(upper - lower < getAutoRangeMinimumSize())\r
-                upper = lower + getAutoRangeMinimumSize();\r
-            \r
-            setRange(new Range(lower, upper), false, false);\r
-\r
-        }\r
-\r
-        public void setLower(Double lower) {\r
-            this.lower = lower;\r
-        }\r
-\r
-        public void setUpper(Double upper) {\r
-            this.upper = upper;\r
-        }\r
-    }        \r
 }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/PieDataset.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/PieDataset.java
new file mode 100644 (file)
index 0000000..b7956d2
--- /dev/null
@@ -0,0 +1,287 @@
+/*******************************************************************************\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;\r
+\r
+import java.awt.Color;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+\r
+import javax.swing.SwingUtilities;\r
+\r
+import org.jfree.chart.renderer.AbstractRenderer;\r
+import org.jfree.data.general.Dataset;\r
+import org.jfree.data.general.DefaultPieDataset;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.ListUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.exception.MissingVariableException;\r
+import org.simantics.db.layer0.request.PossibleActiveExperiment;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.diagram.G2DUtils;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.operation.Layer0X;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.adapter.SysdynVariableProperties;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+/**\r
+ * Class representing a PieDataset in JFreeChart ontology\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class PieDataset extends AbstractDataset {\r
+\r
+    private List<Resource> seriesList;\r
+    private String realizationURI;\r
+    private DefaultPieDataset dataset;\r
+\r
+    private HashMap<String, Color> colorMap;\r
+    private HashMap<String, Boolean> explodedMap;\r
+\r
+    public PieDataset(ReadGraph graph, Resource resource) {\r
+        super(graph, resource);\r
+\r
+        try {\r
+            Layer0 l0 = Layer0.getInstance(graph);\r
+            ModelingResources mr = ModelingResources.getInstance(graph);\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+\r
+            // Find the model where the chart is located\r
+            Resource model = resource;\r
+            do {\r
+                model = graph.getPossibleObject(model, l0.PartOf);\r
+            } while(model != null && !graph.isInstanceOf(model, mr.StructuralModel));\r
+\r
+            // Find the variable realization of the current experiment\r
+            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
+            if(realizationURI == null)\r
+                return; // No experiment -> No results\r
+\r
+            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
+\r
+    }\r
+\r
+    /**\r
+     * Map of colors for different slices in a pie chart. Name \r
+     * indicates the key of the value.\r
+     * @return  Map of colors for different slices in a pie chart\r
+     */\r
+    public HashMap<String, Color> getColorMap() {\r
+        return colorMap;\r
+    }\r
+\r
+    /**\r
+     * Map of exploded statuses for slices in a pie chart. Name\r
+     * indicates the key of the slice.\r
+     * @return\r
+     */\r
+    public HashMap<String, Boolean> getExplodedMap() {\r
+        return explodedMap;\r
+    }\r
+\r
+    @Override\r
+    public Dataset getDataset() {\r
+        if(seriesList == null || seriesList.isEmpty())\r
+            return null;\r
+\r
+        if(dataset == null) {\r
+            dataset = new DefaultPieDataset();\r
+        }\r
+\r
+        if(listener == null) {\r
+            listener = new DatasetListener();\r
+            SimanticsUI.getSession().asyncRequest(new Read<ArrayList<TempSeries>>() {\r
+\r
+                @Override\r
+                public ArrayList<TempSeries> perform(ReadGraph graph) throws DatabaseException {\r
+                    JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+\r
+                    ArrayList<TempSeries> series = new ArrayList<TempSeries>();\r
+                    // Get properties for all series\r
+                    if(seriesList != null) {\r
+                        for(Resource r : seriesList) {\r
+                            String label = graph.getPossibleRelatedValue(r, Layer0.getInstance(graph).HasLabel);\r
+                            String rvi = graph.getPossibleRelatedValue(r, jfree.variableRVI);\r
+                            if(rvi == null)\r
+                                continue;\r
+\r
+                            try {\r
+                                // Get a variable for the series\r
+                                Variable v = Variables.getVariable(graph, realizationURI + rvi);\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
+                                    }\r
+\r
+                                    if(value == null)\r
+                                        value = va[va.length - 1];\r
+                                }\r
+\r
+                                series.add(new TempSeries(label == null || label.isEmpty() ? v.getName(graph) : label, value));\r
+                            } catch (MissingVariableException e) {\r
+                                // Do nothing, if variable was not found. Move on to the next series\r
+                            }\r
+                        }\r
+                    }\r
+                    return series;\r
+                }\r
+\r
+            }, listener);\r
+        }\r
+        return dataset;\r
+    }\r
+\r
+    private DatasetListener listener;\r
+\r
+    private class DatasetListener implements Listener<ArrayList<TempSeries>> {\r
+\r
+        private boolean disposed = false;\r
+\r
+        @Override\r
+        public void execute(final ArrayList<TempSeries> series) {\r
+            // Modify series in AWT thread to avoid synchronization problems\r
+            SwingUtilities.invokeLater(new Runnable() {\r
+\r
+                @Override\r
+                public void run() {\r
+                    // Remove all series\r
+                    dataset.clear();\r
+\r
+                    // Add found series\r
+                    for(int i = 0; i < series.size(); i++) {\r
+                        TempSeries s = series.get(i);\r
+                        dataset.setValue(s.name, s.value);\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 disposed;\r
+        }\r
+\r
+        public void dispose() {\r
+            disposed = true;\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public AbstractRenderer getRenderer() {\r
+        // No renderer for pie chart\r
+        return null;\r
+    }\r
+\r
+    @Override\r
+    public void dispose() {\r
+        super.dispose();\r
+        if(listener != null) {\r
+            listener.dispose();\r
+            listener = null;\r
+        }\r
+    }\r
+\r
+\r
+    /**\r
+     * Auxiliary class containing all information needed to define a single series\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class TempSeries {\r
+        public String name;\r
+        public Double value;\r
+\r
+        public TempSeries(String name, Double value) {\r
+            this.name = name;\r
+            this.value = value;\r
+        }\r
+\r
+        @Override\r
+        public String toString() {\r
+            return "TempSeries: " + name + ", " + value;\r
+        }\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/PiePlot.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/PiePlot.java
new file mode 100644 (file)
index 0000000..62cc00d
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************\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;\r
+\r
+import java.awt.Color;\r
+import java.util.HashMap;\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.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+\r
+/**\r
+ * Class representing a PiePlot in JFreeChart ontology\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class PiePlot extends AbstractPlot {\r
+\r
+    org.jfree.chart.plot.PiePlot plot;\r
+\r
+    public PiePlot(ReadGraph graph, Resource resource) {\r
+        super(graph, resource);\r
+    }\r
+\r
+    @Override\r
+    public Plot getPlot() {\r
+        if(plot == null) {\r
+            plot = new org.jfree.chart.plot.PiePlot();\r
+        }\r
+\r
+        if(!datasets.isEmpty()) {\r
+            // We assume that a pie plot has only one dataset\r
+            IDataset ds = datasets.get(0);\r
+            Dataset dataset = ((PieDataset)ds).getDataset();\r
+            if(dataset instanceof org.jfree.data.general.PieDataset) {\r
+                plot.clearSectionPaints(true);\r
+                plot.setDrawingSupplier(new DefaultDrawingSupplier());\r
+                plot.setDataset(null);\r
+                \r
+                org.jfree.data.general.PieDataset pieDataset = (org.jfree.data.general.PieDataset)dataset;\r
+                plot.setDataset(pieDataset);\r
+\r
+                HashMap<String, Color> colorMap = ((PieDataset)ds).getColorMap();\r
+                for(String name : colorMap.keySet())\r
+                    plot.setSectionPaint(name, colorMap.get(name));\r
+\r
+                HashMap<String, Boolean> explodedMap = ((PieDataset)ds).getExplodedMap();\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
+        return plot;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/StackedBarRenderer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/StackedBarRenderer.java
new file mode 100644 (file)
index 0000000..daf266b
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************\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;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+\r
+/**\r
+ * Stacked bar renderer\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class StackedBarRenderer extends AbstractRenderer {\r
+\r
+    public StackedBarRenderer(ReadGraph graph, Resource resource) {\r
+        super(graph, resource);\r
+    }\r
+\r
+    private org.jfree.chart.renderer.category.StackedBarRenderer renderer;\r
+    \r
+    @Override\r
+    public org.jfree.chart.renderer.AbstractRenderer getRenderer() {\r
+        if(renderer == null)\r
+            renderer = new org.jfree.chart.renderer.category.StackedBarRenderer();\r
+        return renderer;\r
+    }\r
+\r
+}\r
index 3fd7ede108200743d1d9777c0c4d57da8093d6f2..7386a862d1d7b2d99ef1bc5c830b37bc2c8b9357 100644 (file)
@@ -30,7 +30,6 @@ public class TextTitle implements ITitle {
     private org.jfree.chart.title.TextTitle textTitle;\r
     private RectangleEdge position;\r
     private String text;\r
-    private boolean disposed;\r
     private Boolean visible;\r
     \r
     public TextTitle(ReadGraph graph, Resource titleResource) {\r
@@ -83,12 +82,6 @@ public class TextTitle implements ITitle {
 \r
     @Override\r
     public void dispose() {\r
-        disposed = true;\r
-    }\r
-\r
-    @Override\r
-    public boolean isDisposed() {\r
-        return disposed;\r
     }\r
 \r
 }\r
index e87cae319d5c1bf4a6398d267dc7578db861a0ef..1246412d0303ed6ca178abee802fab024a061af5 100644 (file)
@@ -13,15 +13,20 @@ package org.simantics.sysdyn.ui.trend.chart;
 \r
 import java.awt.BasicStroke;\r
 import java.awt.Color;\r
+import java.awt.Stroke;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
 \r
 import javax.swing.SwingUtilities;\r
 \r
+import org.jfree.chart.plot.DefaultDrawingSupplier;\r
+import org.jfree.chart.plot.ValueMarker;\r
 import org.jfree.chart.renderer.AbstractRenderer;\r
+import org.jfree.chart.renderer.xy.AbstractXYItemRenderer;\r
 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;\r
 import org.jfree.data.general.Dataset;\r
 import org.jfree.data.xy.DefaultXYDataset;\r
+import org.jfree.ui.Layer;\r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
@@ -48,17 +53,15 @@ import org.simantics.ui.SimanticsUI;
  * @author Teemu Lempinen\r
  *\r
  */\r
-public class XYDataset implements IDataset {\r
+public class XYDataset extends AbstractDataset {\r
 \r
-    private boolean disposed;\r
     private XYLineAndShapeRenderer renderer;\r
     private double[] domainValues;\r
     private List<Resource> seriesList;\r
     private String realizationURI;\r
-    private Resource resource;\r
 \r
     public XYDataset(ReadGraph graph, final Resource datasetResource) {\r
-        this.resource = datasetResource;\r
+        super(graph, datasetResource);\r
 \r
         try {\r
             Layer0 l0 = Layer0.getInstance(graph);\r
@@ -110,7 +113,9 @@ public class XYDataset implements IDataset {
         }\r
     }\r
 \r
-    DefaultXYDataset dataset;\r
+    private DefaultXYDataset dataset;\r
+    private DataSetListener datasetListener;\r
+    private TimeListener timeListener;\r
 \r
     @Override\r
     public Dataset getDataset() {\r
@@ -120,6 +125,10 @@ public class XYDataset implements IDataset {
 \r
         if(dataset == null) {\r
             dataset = new DefaultXYDataset();\r
+        }   \r
+\r
+        if(datasetListener == null || datasetListener.isDisposed()) {\r
+            datasetListener = new DataSetListener();\r
             SimanticsUI.getSession().asyncRequest(new Read<ArrayList<TempSeries>>() {\r
 \r
                 @Override\r
@@ -147,7 +156,7 @@ public class XYDataset implements IDataset {
                                 // Get values\r
 //                                double[] va = v.getPossiblePropertyValue(graph, SysdynVariableProperties.VALUES , Bindings.DOUBLE_ARRAY);\r
 \r
-                                \r
+\r
                                 Object object =  v.getPossiblePropertyValue(graph, SysdynVariableProperties.ACTIVE_DATASETS , Bindings.VARIANT);\r
                                 if(object == null || !(object instanceof ArrayList<?>))\r
                                     return series;\r
@@ -155,10 +164,10 @@ public class XYDataset implements IDataset {
                                 for(Object o : datasets) {\r
                                     if(!(o instanceof SysdynDataSet))\r
                                         continue;\r
-                                    \r
+\r
                                     SysdynDataSet dataset = (SysdynDataSet)o;\r
                                     double[] va = dataset.values;\r
-                                    \r
+\r
                                     // Get domain axis values (time OR other variable) \r
                                     double[] ta;\r
                                     if(domainValues != null) {\r
@@ -203,58 +212,151 @@ public class XYDataset implements IDataset {
                     return series;\r
                 }\r
 \r
-            }, new Listener<ArrayList<TempSeries>>() {\r
-\r
-                @Override\r
-                public boolean isDisposed() {\r
-                    return disposed;\r
-                }\r
+            }, datasetListener); \r
+        }\r
 \r
+        if(timeListener == null || timeListener.isDisposed()) {\r
+            timeListener = new TimeListener(new ValueMarker(0.0));\r
+            SimanticsUI.getSession().asyncRequest(new Read<Double>() {\r
                 @Override\r
-                public void execute(final ArrayList<TempSeries> series) {\r
-                    // Modify series in AWT thread to avoid synchronization problems\r
-                    SwingUtilities.invokeLater(new Runnable() {\r
-                        \r
-                        @Override\r
-                        public void run() {\r
-                            // Remove all series\r
-                            for(int i = dataset.getSeriesCount() - 1; i >= 0; i-- ) {\r
-                                dataset.removeSeries(dataset.getSeriesKey(i));\r
+                public Double perform(ReadGraph graph) throws DatabaseException {\r
+                    JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+                    // Get properties for all series\r
+                    if(seriesList != null) {\r
+                        for(Resource r : seriesList) {\r
+                            String rvi = graph.getPossibleRelatedValue(r, jfree.variableRVI);\r
+                            if(rvi == null)\r
+                                continue;\r
+                            try {\r
+                                // Get a variable for the series\r
+                                Variable v = Variables.getVariable(graph, realizationURI + rvi);\r
+                                Double time = v.getPossiblePropertyValue(graph, SysdynVariableProperties.TIME , Bindings.DOUBLE);\r
+                                return time;\r
+                            } catch (MissingVariableException e) {\r
+                                // Do nothing, if variable was not found.\r
                             }\r
-                            \r
-                            // Add found series\r
-                            for(int i = 0; i < series.size(); i++) {\r
-                                TempSeries s = series.get(i);\r
-                                dataset.addSeries(s.name, s.values);\r
-                                getRenderer().setSeriesStroke(i, new BasicStroke((float)s.width));\r
-                                if(s.color != null)\r
-                                    getRenderer().setSeriesPaint(i, s.color);\r
-                            } \r
                         }\r
-                    });\r
+                    }\r
+                    return null;\r
                 }\r
 \r
+            }, timeListener);\r
+        }\r
+        return dataset;\r
+    }\r
+\r
+\r
+    private class DataSetListener implements Listener<ArrayList<TempSeries>> {\r
+\r
+        private boolean disposed = false;\r
+\r
+        public void dispose() {\r
+            disposed = true;\r
+        }\r
+\r
+        @Override\r
+        public boolean isDisposed() {\r
+            return disposed;\r
+        }\r
+\r
+        @Override\r
+        public void execute(final ArrayList<TempSeries> series) {\r
+            // Modify series in AWT thread to avoid synchronization problems\r
+            SwingUtilities.invokeLater(new Runnable() {\r
+\r
                 @Override\r
-                public void exception(Throwable t) {\r
-                    t.printStackTrace();\r
+                public void run() {\r
+                    ((AbstractXYItemRenderer)getRenderer()).getPlot().setDrawingSupplier(new DefaultDrawingSupplier());\r
+                    // Remove all series\r
+                    for(int i = dataset.getSeriesCount() - 1; i >= 0; i-- ) {\r
+                        dataset.removeSeries(dataset.getSeriesKey(i));\r
+                    }\r
+\r
+                    // Add found series\r
+                    for(int i = 0; i < series.size(); i++) {\r
+                        TempSeries s = series.get(i);\r
+                        dataset.addSeries(s.name, s.values);\r
+                        getRenderer().setSeriesStroke(i, new BasicStroke((float)s.width));\r
+                        getRenderer().setSeriesPaint(i, s.color);\r
+                    } \r
                 }\r
+            });\r
+        }\r
+\r
+        @Override\r
+        public void exception(Throwable t) {\r
+            t.printStackTrace();\r
+        }\r
+\r
+    }\r
+\r
+\r
+    private class TimeListener implements Listener<Double> {\r
+\r
+        private ValueMarker marker;\r
+        private boolean disposed = false;\r
 \r
+        public TimeListener(ValueMarker marker) {\r
+            this.marker = marker;\r
+        }\r
+\r
+        public void dispose() {\r
+            this.disposed = true;\r
+        }\r
+\r
+        @Override\r
+        public boolean isDisposed() {\r
+            return disposed;\r
+        }\r
+\r
+        @Override\r
+        public void execute(final Double time) {\r
+            // Modify in AWT thread to avoid synchronization problems\r
+            SwingUtilities.invokeLater(new Runnable() {\r
+\r
+                @Override\r
+                public void run() {\r
+                    org.jfree.chart.plot.XYPlot plot = ((AbstractXYItemRenderer)getRenderer()).getPlot();\r
+\r
+                    int i = 0;\r
+                    for(i = 0; i < plot.getDatasetCount(); i++) {\r
+                        if(plot.getDataset(i).equals(dataset))\r
+                            break;\r
+                    }\r
+\r
+                    plot.removeDomainMarker(marker);\r
+                    if(time != null) {\r
+                        Stroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,\r
+                                BasicStroke.JOIN_MITER, 10.0f, new float[] {5.0f, 3.0f, 1.0f, 3.0f}, 0.0f);\r
+                        marker = new ValueMarker(time, Color.red, dashStroke);\r
+                        plot.addDomainMarker(i, marker, Layer.FOREGROUND);\r
+                    }\r
+\r
+                }\r
             });\r
-            \r
-        } \r
-        return dataset;\r
+        }\r
+\r
+        @Override\r
+        public void exception(Throwable t) {\r
+            t.printStackTrace();\r
+        }\r
+\r
     }\r
 \r
     @Override\r
     public void dispose() {\r
-        disposed = true;\r
-    }\r
+        if(timeListener != null) {\r
+            timeListener.dispose();\r
+            timeListener = null;\r
+        }\r
 \r
-    @Override\r
-    public boolean isDisposed() {\r
-        return disposed;\r
+        if(datasetListener != null) {\r
+            datasetListener.dispose();\r
+            datasetListener = null;\r
+        }\r
     }\r
 \r
+\r
     /**\r
      * Auxiliary class containing all information needed to define a single series\r
      * @author Teemu Lempinen\r
index 59978204c3398b543498f2e30d7582e9c8e34c6e..a64f9cf16e8779245e93830789cbd32ba7843088 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.trend.chart;\r
 \r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-\r
 import org.jfree.chart.axis.ValueAxis;\r
 import org.jfree.chart.plot.Plot;\r
 import org.jfree.chart.renderer.xy.XYItemRenderer;\r
 import org.jfree.data.xy.XYDataset;\r
 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.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
 \r
 /**\r
@@ -32,126 +26,61 @@ import org.simantics.sysdyn.JFreeChartResource;
  * @author Teemu Lempinen\r
  *\r
  */\r
-public class XYPlot implements IPlot {\r
+public class XYPlot extends AbstractPlot {\r
 \r
     private org.jfree.chart.plot.XYPlot plot;\r
-    private ArrayList<IAxis> ranges;\r
-    private ArrayList<IAxis> domains;\r
-    private ArrayList<IDataset> datasets;\r
-    private HashMap<IDataset, IAxis> rangeMappings;\r
-    private HashMap<IDataset, IAxis> domainMappings;\r
-    private boolean disposed;\r
     private Boolean visibleGrid;\r
-    \r
+\r
+\r
     public XYPlot(ReadGraph graph, Resource plotResource) {\r
+        super(graph, plotResource);\r
 \r
         try {\r
-            Layer0 l0 = Layer0.getInstance(graph);\r
             JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
-\r
-            HashMap<Resource, IAxis> axisMap = new HashMap<Resource, IAxis>();\r
-            ranges = new ArrayList<IAxis>();\r
-\r
-            // Get all range axis\r
-            Resource rangeList = graph.getPossibleObject(plotResource, jfree.Plot_rangeAxisList);\r
-            if(rangeList != null) {\r
-                for(Resource axisResource : ListUtils.toList(graph, rangeList)) {\r
-                    IAxis axis = graph.adapt(axisResource, IAxis.class);\r
-                    if(axis.getAxis() instanceof ValueAxis) {\r
-                        ranges.add(axis);\r
-                        axisMap.put(axisResource, axis);\r
-                    }\r
-                }\r
-            }\r
-            \r
-            // Get all domain axis\r
-            // There usually is only one domain axis, but this supports also multiple domain axis\r
-            domains = new ArrayList<IAxis>();\r
-            for(Resource axisResource : graph.syncRequest(new ObjectsWithType(plotResource, jfree.Plot_domainAxis, jfree.Axis))) {\r
-                IAxis axis = graph.adapt(axisResource, IAxis.class);\r
-                if(axis.getAxis() instanceof ValueAxis) {\r
-                    domains.add(axis);\r
-                    axisMap.put(axisResource, axis);\r
-                }\r
-            }\r
-\r
-            // Get all datasets and map them to axis\r
-            datasets = new ArrayList<IDataset>();\r
-            rangeMappings = new HashMap<IDataset, IAxis>();\r
-            domainMappings = new HashMap<IDataset, IAxis>();\r
-            for(Resource datasetResource : graph.syncRequest(new ObjectsWithType(plotResource, l0.ConsistsOf, jfree.Dataset))) {\r
-                IDataset dataset = graph.adapt(datasetResource, IDataset.class);\r
-                if(dataset.getDataset() != null && dataset.getDataset() instanceof XYDataset) {\r
-                    datasets.add(dataset);\r
-                    Resource axisResource = graph.getPossibleObject(datasetResource, jfree.Dataset_mapToRangeAxis);\r
-                    IAxis axis;\r
-                    if(axisMap.containsKey(axisResource)) {\r
-                        axis = axisMap.get(axisResource);\r
-                        rangeMappings.put(dataset, axis);\r
-                    }\r
-                    \r
-                    axisResource = graph.getPossibleObject(datasetResource, jfree.Dataset_mapToDomainAxis);\r
-                    if(axisMap.containsKey(axisResource)) {\r
-                        axis = axisMap.get(axisResource);\r
-                        domainMappings.put(dataset, axis);\r
-                    }\r
-                }\r
-            }\r
-            \r
             // Visual properties\r
             visibleGrid = graph.getPossibleRelatedValue(plotResource, jfree.Plot_visibleGrid);\r
-            \r
-        } catch (DatabaseException e) {\r
+        } catch(DatabaseException e) {\r
             e.printStackTrace();\r
         }\r
+\r
     }\r
 \r
     @Override\r
     public Plot getPlot() {\r
+        if(plot == null)\r
+            plot = new org.jfree.chart.plot.XYPlot(null, null, null, null);\r
         \r
-        plot = new org.jfree.chart.plot.XYPlot(null, null, null, null);\r
+        plot.clearDomainAxes();\r
+        plot.clearRangeAxes();\r
 \r
         for(int i = 0; i < ranges.size(); i++) {\r
             plot.setRangeAxis(i, (ValueAxis)ranges.get(i).getAxis());\r
         }\r
-        \r
+\r
         for(int i = 0; i < domains.size(); i++) {\r
             plot.setDomainAxis(i, (ValueAxis)domains.get(i).getAxis());\r
         }\r
-        \r
+\r
+        IAxis axis;\r
         for(int i = 0; i < datasets.size(); i++) {\r
             IDataset dataset = datasets.get(i);\r
             plot.setDataset(i, (XYDataset)dataset.getDataset());\r
             plot.setRenderer(i, (XYItemRenderer)dataset.getRenderer());\r
-            plot.mapDatasetToRangeAxis(i, ranges.indexOf(rangeMappings.get(dataset)));\r
-            plot.mapDatasetToDomainAxis(i, domains.indexOf(domainMappings.get(dataset)));\r
+            axis = rangeMappings.get(dataset);\r
+            if(axis != null && ranges.contains(axis))\r
+                plot.mapDatasetToRangeAxis(i, ranges.indexOf(axis));\r
+            axis = domainMappings.get(dataset);\r
+            if(axis != null && ranges.contains(axis))\r
+                plot.mapDatasetToDomainAxis(i, domains.indexOf(axis));\r
         }\r
+\r
+        if(visibleGrid == null)\r
+            visibleGrid = true;\r
+\r
+        plot.setRangeGridlinesVisible(visibleGrid);\r
+        plot.setDomainGridlinesVisible(visibleGrid);\r
         \r
-        if(visibleGrid != null) {\r
-            plot.setRangeGridlinesVisible(visibleGrid);\r
-            plot.setDomainGridlinesVisible(visibleGrid);\r
-        }\r
         return plot;\r
     }\r
-    \r
-    @Override\r
-    public void dispose() {\r
-        disposed = true;\r
-        \r
-        // Dispose all axis and datasets\r
-        for(IAxis axis : ranges)\r
-            axis.dispose();\r
-        \r
-        for(IAxis axis : domains)\r
-            axis.dispose();\r
-        \r
-        for(IDataset dataset : datasets)\r
-            dataset.dispose();\r
-    }\r
-\r
-    @Override\r
-    public boolean isDisposed() {\r
-        return disposed;\r
-    }\r
 \r
 }\r
index 7d3872ccb632547bc07d8bcdb90fcc1c10b6091a..e6590aa0f64c439386ffac5f9f50b9af8d928211 100644 (file)
@@ -22,7 +22,7 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.DropActionFactory;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
-import org.simantics.sysdyn.ui.trend.chart.properties.AxisAndVariablesExplorerComposite;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.xyline.AxisAndVariablesExplorerComposite;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/graphexplorer/SeriesChildRule.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/graphexplorer/SeriesChildRule.java
new file mode 100644 (file)
index 0000000..a12f844
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************\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 java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.model.children.ChildRule;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\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.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+\r
+/**\r
+ * Child rule for obtaining series in a chart. \r
+ * Assumes that the chart has only one plot and that plot has only one dataset\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class SeriesChildRule implements ChildRule {\r
+\r
+    @Override\r
+    public boolean isCompatible(Class<?> contentType) {\r
+        return contentType.equals(Resource.class);\r
+    }\r
+\r
+    @Override\r
+    public Collection<?> getChildren(ReadGraph graph, Object parent) throws DatabaseException {\r
+        ArrayList<Resource> result = new ArrayList<Resource>();\r
+        if(!(parent instanceof Resource))\r
+            return result;\r
+        JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+        Layer0 l0 = Layer0.getInstance(graph);\r
+        /*\r
+         * 1. we assume that there is only one plot\r
+         * 2. we assume that the only plot has only one dataset\r
+         */\r
+        Resource plot = graph.syncRequest(new PossibleObjectWithType((Resource)parent, l0.ConsistsOf, jfree.Plot));\r
+        \r
+        Resource dataset = graph.syncRequest(new PossibleObjectWithType(plot, l0.ConsistsOf, jfree.Dataset));\r
+        \r
+        Resource seriesList = graph.getPossibleObject(dataset, jfree.Dataset_seriesList);\r
+        if(seriesList != null)\r
+            for(Resource series : ListUtils.toList(graph, seriesList)) {\r
+                result.add(series);\r
+            }\r
+        return result;\r
+    }\r
+    \r
+    @Override\r
+    public Collection<?> getParents(ReadGraph graph, Object child) throws DatabaseException {\r
+        return new ArrayList<Resource>();\r
+    }\r
+\r
+}\r
index e0bd0d6345512b032d6a9eb25f0244c37d7a96d2..241394bb6ada2da0a4695f875b2f4642d140ce27 100644 (file)
@@ -24,12 +24,12 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.DropActionFactory;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
-import org.simantics.sysdyn.ui.trend.chart.properties.ChartAxisAndVariablesTab;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.xyline.XYLineAxisAndVariablesTab;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
 /**\r
- * Drop action for explorer in {@link ChartAxisAndVariablesTab}. This action is used for dropping \r
+ * Drop action for explorer in {@link XYLineAxisAndVariablesTab}. This action is used for dropping \r
  * both series on axis or another sries\r
  * \r
  * @author Teemu Lempinen\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/TitleFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/TitleFactory.java
new file mode 100644 (file)
index 0000000..d9a081f
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************\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 org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\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
+\r
+/**\r
+ * TextFactory for chart title\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class TitleFactory extends ReadFactoryImpl<Resource, String>   {\r
+    @Override\r
+    public String perform(ReadGraph graph, Resource chart) throws DatabaseException {\r
+        Layer0 l0 = Layer0.getInstance(graph);\r
+        JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+        Resource title = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.TextTitle));\r
+        if(title == null)\r
+            return "";\r
+        else {\r
+            String label = graph.getPossibleRelatedValue(title, l0.HasLabel, Bindings.STRING);\r
+            return label == null ? "" : label;\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/TitleModifier.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/TitleModifier.java
new file mode 100644 (file)
index 0000000..d47fbcd
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************\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 org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl;\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.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+\r
+/**\r
+ * TitleModifier for chart title\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class TitleModifier extends TextModifyListenerImpl<Resource> {\r
+\r
+    @Override\r
+    public void applyText(WriteGraph graph, Resource chart, String text) throws DatabaseException {\r
+        Layer0 l0 = Layer0.getInstance(graph);\r
+        JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+        Resource title = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.TextTitle));\r
+        if(title == null) {\r
+            title = GraphUtils.create2(graph, jfree.TextTitle,\r
+                    jfree.Title_position, jfree.Top);\r
+        }\r
+        graph.claimLiteral(title, l0.HasLabel, text);\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarGeneralPropertiesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarGeneralPropertiesTab.java
new file mode 100644 (file)
index 0000000..8d4d6e3
--- /dev/null
@@ -0,0 +1,129 @@
+/*******************************************************************************\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.bar;\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.widgets.Combo;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.swt.widgets.Label;\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.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.properties.LabelPropertyTabContributor;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.BooleanPropertyFactory;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.BooleanSelectionListener;\r
+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
+\r
+/**\r
+ * General properties of a bar chart\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class BarGeneralPropertiesTab extends LabelPropertyTabContributor {\r
+\r
+    private ScrolledComposite sc;\r
+    private Composite composite;\r
+    private Button hgrid, htitle, hlegend;\r
+    private TrackedText name, title;\r
+    private Combo type;\r
+\r
+    @Override\r
+    public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {    \r
+        // Scrolled composite containing all of the properties in this tab\r
+        sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);\r
+        GridLayoutFactory.fillDefaults().applyTo(sc);\r
+        sc.setExpandHorizontal(true);\r
+        sc.setExpandVertical(true);\r
+\r
+        composite = new Composite(sc, SWT.NONE);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite);\r
+\r
+        // General properties\r
+        Group general = new Group(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(general);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(general);\r
+        general.setText("General");\r
+\r
+        // Name\r
+        Label label = new Label(general, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        label.setText("Name:");\r
+\r
+        Composite c = new Composite(general, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(c);\r
+        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(c);\r
+\r
+        name = new org.simantics.browsing.ui.swt.widgets.TrackedText(c, support, SWT.BORDER);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget());\r
+        name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
+        name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
+        name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
+\r
+        // Type\r
+        label = new Label(c, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        label.setText("Type:");\r
+\r
+        type = new Combo(c, SWT.BORDER | SWT.READ_ONLY);\r
+        type.setItems(new String[] {"Normal", "Stacked"});\r
+        type.select(0);\r
+\r
+        // Title (Which is different than name)\r
+        label = new Label(general, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        label.setText("Title:");\r
+\r
+        title = new org.simantics.browsing.ui.swt.widgets.TrackedText(general, support, SWT.BORDER);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget());\r
+        title.setTextFactory(new TitleFactory());\r
+        title.addModifyListener(new TitleModifier());\r
+        title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
+\r
+        // Group for hide options\r
+        Group hideGroup = new Group(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(hideGroup);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup);\r
+        hideGroup.setText("Hide");\r
+\r
+        hgrid = new Button(hideGroup, support, SWT.CHECK);\r
+        hgrid.setText("Grid");\r
+        hgrid.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid, true));\r
+        hgrid.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleGrid));\r
+        htitle = new Button(hideGroup, support, SWT.CHECK);\r
+        htitle.setText("Title");\r
+        htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true));\r
+        htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible));\r
+        hlegend = new Button(hideGroup, support, SWT.CHECK);\r
+        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
+        sc.setContent(composite);\r
+        Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
+        sc.setMinSize(size);\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarSeriesPropertyComposite.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarSeriesPropertyComposite.java
new file mode 100644 (file)
index 0000000..3b463a7
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************\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.bar;\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.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\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.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+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
+\r
+/**\r
+ * Composite for modifying properties of a series in a bar chart\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class BarSeriesPropertyComposite extends Composite {\r
+    \r
+    private TrackedText variable, label;\r
+    \r
+    public BarSeriesPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) {\r
+        super(parent, style);\r
+        \r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this);\r
+\r
+        // Variable for the series\r
+        Label label = new Label(this, SWT.NONE);\r
+        label.setText("Variable:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+\r
+        variable = new TrackedText(this, support, SWT.BORDER);\r
+        variable.setTextFactory(new RVIFactory());\r
+        variable.addModifyListener(new RVIModifier(variable.getWidget(), support));\r
+        variable.setColorProvider(new JFreeChartPropertyColorProvider(this.variable.getResourceManager()));\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(this.variable.getWidget());\r
+\r
+        // Label to be displayed in chart for this series\r
+        label = new Label(this, SWT.NONE);\r
+        label.setText("Label:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+\r
+        this.label = new TrackedText(this, support, SWT.BORDER);\r
+        this.label.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, ""));\r
+        this.label.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
+        this.label.setColorProvider(new JFreeChartPropertyColorProvider(this.label.getResourceManager()));\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(this.label.getWidget());\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarSeriesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarSeriesTab.java
new file mode 100644 (file)
index 0000000..4dd81ff
--- /dev/null
@@ -0,0 +1,214 @@
+/*******************************************************************************\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.bar;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.ScrolledComposite;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Tree;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
+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
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.LabelPropertyTabContributor;\r
+import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.xyline.AxisAndVariablesExplorerComposite;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+/**\r
+ * Tab containing the series of a bar chart\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class BarSeriesTab 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
+\r
+    public BarSeriesTab() {\r
+        additionalSupport = new WidgetSupportImpl();\r
+    }\r
+\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
+\r
+        // (Ontology-based) GraphExplorer displaying variables in a bar chart\r
+        explorer = new AxisAndVariablesExplorerComposite(ArrayMap.keys(\r
+                "displaySelectors", "displayFilter").values(false, false), site, composite, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE);\r
+        explorer.setBrowseContexts(SysdynResource.URIs.BarSeriesBrowseContext);\r
+        explorer.setInputSource(new SingleSelectionInputSource(\r
+                Resource.class));\r
+        explorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning\r
+        explorer.finish();\r
+\r
+        ((Tree)explorer.getExplorerControl()).addSelectionListener(new SelectionAdapter() {\r
+            public void widgetSelected(SelectionEvent e) {\r
+                updateSelection(context);\r
+            }\r
+        });\r
+        GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer);\r
+\r
+        // Scrolled composite for displaying properties of a selection in explorer\r
+        propertyContainer = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);\r
+        GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(propertyContainer);\r
+        GridLayoutFactory.fillDefaults().applyTo(propertyContainer);\r
+        propertyContainer.setExpandHorizontal(true);\r
+        propertyContainer.setExpandVertical(true);\r
+\r
+        // Buttons for adding and removing variables from a pie plot\r
+        Composite buttonComposite = new Composite(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(buttonComposite);\r
+        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite);\r
+\r
+        add = new Button(buttonComposite, additionalSupport, SWT.NONE);\r
+        add.setText("Add");\r
+        add.addSelectionListener(new NewVariableListener(context));\r
+\r
+        remove = new Button(buttonComposite, additionalSupport, SWT.NONE);\r
+        remove.setText("Remove");\r
+        remove.addSelectionListener(new RemoveListener(context));\r
+    }\r
+\r
+    /**\r
+     * Updates the content of propertyContainer  \r
+     * @param context\r
+     */\r
+    private void updateSelection(ISessionContext context) {\r
+        ISelectionProvider selectionProvider = (ISelectionProvider)explorer.getAdapter(ISelectionProvider.class);\r
+        IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection();\r
+        final Resource resource = AdaptionUtils.adaptToSingle(selection, Resource.class);\r
+        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
+        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
+     *\r
+     */\r
+    private class NewVariableListener extends SelectionListenerImpl<Resource> {\r
+\r
+        public NewVariableListener(ISessionContext context) {\r
+            super(context);\r
+        }\r
+\r
+        @Override\r
+        public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+            Resource dataset = null;\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+            Layer0 l0 = Layer0.getInstance(graph);\r
+\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
+\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
+\r
+    /**\r
+     * SelectionListener for remove button\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class RemoveListener extends SelectionListenerImpl<Resource> {\r
+\r
+        public RemoveListener(ISessionContext context) {\r
+            super(context);\r
+        }\r
+\r
+        /**\r
+         * Removes selected resource from explorer\r
+         */\r
+        @Override\r
+        public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+            if(input == null)\r
+                return; \r
+\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+            Layer0 l0 = Layer0.getInstance(graph);\r
+            Resource list = null;\r
+            if(graph.isInstanceOf(input, jfree.Series)) {\r
+                // Remove series from dataset and seriesList\r
+                Resource dataset = graph.getPossibleObject(input, l0.PartOf);\r
+                if(dataset != null)\r
+                    list = graph.getPossibleObject(dataset, jfree.Dataset_seriesList);\r
+\r
+                if(list != null)\r
+                    ListUtils.removeElement(graph, list, input);\r
+                RemoverUtil.remove(graph, input);\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
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieGeneralPropertiesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieGeneralPropertiesTab.java
new file mode 100644 (file)
index 0000000..2bfe94b
--- /dev/null
@@ -0,0 +1,124 @@
+/*******************************************************************************\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.pie;\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.widgets.Combo;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.swt.widgets.Label;\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.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.properties.LabelPropertyTabContributor;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.BooleanPropertyFactory;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.BooleanSelectionListener;\r
+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
+\r
+/**\r
+ * General properties of a pie chart\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class PieGeneralPropertiesTab extends LabelPropertyTabContributor {\r
+\r
+    private ScrolledComposite sc;\r
+    private Composite composite;\r
+    private Button htitle, hlegend;\r
+    private TrackedText name, title;\r
+    private Combo type;\r
+\r
+    @Override\r
+    public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {    \r
+        // Scrolled composite containing all of the properties in this tab\r
+        sc = new ScrolledComposite(body, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);\r
+        GridLayoutFactory.fillDefaults().applyTo(sc);\r
+        sc.setExpandHorizontal(true);\r
+        sc.setExpandVertical(true);\r
+\r
+        composite = new Composite(sc, SWT.NONE);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite);\r
+\r
+        // General properties\r
+        Group general = new Group(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(general);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(general);\r
+        general.setText("General");\r
+\r
+        // Name\r
+        Label label = new Label(general, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        label.setText("Name:");\r
+\r
+        Composite c = new Composite(general, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(c);\r
+        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(c);\r
+\r
+        name = new org.simantics.browsing.ui.swt.widgets.TrackedText(c, support, SWT.BORDER);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget());\r
+        name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
+        name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
+        name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
+\r
+        // Type\r
+        label = new Label(c, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        label.setText("Type:");\r
+\r
+        type = new Combo(c, SWT.BORDER | SWT.READ_ONLY);\r
+        type.setItems(new String[] {"Normal", "Stacked"});\r
+        type.select(0);\r
+\r
+        // Title (Which is different than name)\r
+        label = new Label(general, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        label.setText("Title:");\r
+\r
+        title = new org.simantics.browsing.ui.swt.widgets.TrackedText(general, support, SWT.BORDER);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget());\r
+        title.setTextFactory(new TitleFactory());\r
+        title.addModifyListener(new TitleModifier());\r
+        title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
+\r
+        // Group for hide options\r
+        Group hideGroup = new Group(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(hideGroup);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(hideGroup);\r
+        hideGroup.setText("Hide");\r
+\r
+        htitle = new Button(hideGroup, support, SWT.CHECK);\r
+        htitle.setText("Title");\r
+        htitle.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible, true));\r
+        htitle.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.TextTitle, JFreeChartResource.URIs.visible));\r
+        hlegend = new Button(hideGroup, support, SWT.CHECK);\r
+        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
+        sc.setContent(composite);\r
+        Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
+        sc.setMinSize(size);\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieSeriesPropertyComposite.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieSeriesPropertyComposite.java
new file mode 100644 (file)
index 0000000..642f070
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************\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.pie;\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.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\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.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.BooleanPropertyFactory;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.BooleanSelectionListener;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.ColorPicker;\r
+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
+\r
+/**\r
+ * Composite containing the properties of a series\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class PieSeriesPropertyComposite extends Composite {\r
+    \r
+    private TrackedText variable, label;\r
+    \r
+    public PieSeriesPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) {\r
+        super(parent, style);\r
+        \r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this);\r
+\r
+        // Variable for the series\r
+        Label label = new Label(this, SWT.NONE);\r
+        label.setText("Variable:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+\r
+        variable = new TrackedText(this, support, SWT.BORDER);\r
+        variable.setTextFactory(new RVIFactory());\r
+        variable.addModifyListener(new RVIModifier(variable.getWidget(), support));\r
+        variable.setColorProvider(new JFreeChartPropertyColorProvider(this.variable.getResourceManager()));\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(this.variable.getWidget());\r
+\r
+        // Label to be displayed in chart for this series\r
+        label = new Label(this, SWT.NONE);\r
+        label.setText("Label:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+\r
+        this.label = new TrackedText(this, support, SWT.BORDER);\r
+        this.label.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, ""));\r
+        this.label.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
+        this.label.setColorProvider(new JFreeChartPropertyColorProvider(this.label.getResourceManager()));\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(this.label.getWidget());\r
+\r
+        // Color\r
+        label = new Label(this, SWT.NONE);\r
+        label.setText("Color:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+\r
+        Composite colorPicker = new ColorPicker(this, context, support, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker);\r
+\r
+        // Exploded\r
+        label = new Label(this, SWT.NONE);\r
+        label.setText("");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+        \r
+        Button exploded = new Button(this, support, SWT.CHECK);\r
+        exploded.setText("Exploded");\r
+        exploded.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Series_exploded));\r
+        exploded.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Series_exploded));\r
+        GridDataFactory.fillDefaults().applyTo(exploded.getWidget());\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieSeriesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/pie/PieSeriesTab.java
new file mode 100644 (file)
index 0000000..96a5fd4
--- /dev/null
@@ -0,0 +1,197 @@
+/*******************************************************************************\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.pie;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.ScrolledComposite;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Tree;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
+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.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.utils.ListUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.RemoverUtil;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.LabelPropertyTabContributor;\r
+import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.xyline.AxisAndVariablesExplorerComposite;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+/**\r
+ * Tab for modifying series in a pie chart configuration\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class PieSeriesTab extends LabelPropertyTabContributor {\r
+\r
+    private GraphExplorerComposite explorer;\r
+    private ScrolledComposite propertyContainer;\r
+    private WidgetSupportImpl additionalSupport;\r
+    private Button add, remove;\r
+\r
+    public PieSeriesTab() {\r
+        additionalSupport = new WidgetSupportImpl();\r
+    }\r
+\r
+    @Override\r
+    public void createControls(Composite body, IWorkbenchSite site, final ISessionContext context, WidgetSupport support) {\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
+\r
+        // (Ontology-based) GraphExplorer displaying variables of a pie chart\r
+        explorer = new AxisAndVariablesExplorerComposite(ArrayMap.keys(\r
+                "displaySelectors", "displayFilter").values(false, false), site, composite, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE);\r
+        explorer.setBrowseContexts(SysdynResource.URIs.PieSeriesBrowseContext);\r
+        explorer.setInputSource(new SingleSelectionInputSource(\r
+                Resource.class));\r
+        explorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning\r
+        explorer.finish();\r
+\r
+        ((Tree)explorer.getExplorerControl()).addSelectionListener(new SelectionAdapter() {\r
+            public void widgetSelected(SelectionEvent e) {\r
+                updateSelection(context);\r
+            }\r
+        });\r
+        GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer);\r
+\r
+        // Scrolled composite for displaying properties of a selection in explorer\r
+        propertyContainer = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);\r
+        GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(propertyContainer);\r
+        GridLayoutFactory.fillDefaults().applyTo(propertyContainer);\r
+        propertyContainer.setExpandHorizontal(true);\r
+        propertyContainer.setExpandVertical(true);\r
+\r
+\r
+        // Buttons for adding and removing variables from a pie plot\r
+        Composite buttonComposite = new Composite(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(buttonComposite);\r
+        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite);\r
+\r
+        add = new Button(buttonComposite, additionalSupport, SWT.NONE);\r
+        add.setText("Add");\r
+        add.addSelectionListener(new NewVariableListener(context));\r
+\r
+        remove = new Button(buttonComposite, additionalSupport, SWT.NONE);\r
+        remove.setText("Remove");\r
+        remove.addSelectionListener(new RemoveListener(context));\r
+    }\r
+\r
+    /**\r
+     * Updates the content of propertyContainer  \r
+     * @param context\r
+     */\r
+    private void updateSelection(ISessionContext context) {\r
+        ISelectionProvider selectionProvider = (ISelectionProvider)explorer.getAdapter(ISelectionProvider.class);\r
+        IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection();\r
+        final Resource resource = AdaptionUtils.adaptToSingle(selection, Resource.class);\r
+        if(resource == null)\r
+            return;\r
+\r
+        for(Control child : propertyContainer.getChildren()) {\r
+            child.dispose();\r
+        }\r
+\r
+        PieSeriesPropertyComposite spc = new PieSeriesPropertyComposite(propertyContainer, context, additionalSupport, SWT.NONE);\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
+     *\r
+     */\r
+    private class NewVariableListener extends SelectionListenerImpl<Resource> {\r
+\r
+        public NewVariableListener(ISessionContext context) {\r
+            super(context);\r
+        }\r
+\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
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * SelectionListener for remove button\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class RemoveListener extends SelectionListenerImpl<Resource> {\r
+\r
+        public RemoveListener(ISessionContext context) {\r
+            super(context);\r
+        }\r
+\r
+        /**\r
+         * Removes selected resource from explorer\r
+         */\r
+        @Override\r
+        public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+            if(input == null)\r
+                return; \r
+\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+            Layer0 l0 = Layer0.getInstance(graph);\r
+            Resource list = null;\r
+            if(graph.isInstanceOf(input, jfree.Series)) {\r
+                // Remove series from dataset and seriesList\r
+                Resource dataset = graph.getPossibleObject(input, l0.PartOf);\r
+                if(dataset != null)\r
+                    list = graph.getPossibleObject(dataset, jfree.Dataset_seriesList);\r
+\r
+                if(list != null)\r
+                    ListUtils.removeElement(graph, list, input);\r
+                RemoverUtil.remove(graph, input);\r
+            }\r
+        }\r
+    }\r
+\r
+\r
+}\r
@@ -9,7 +9,7 @@
  * Contributors:\r
  *     VTT Technical Research Centre of Finland - initial API and implementation\r
  *******************************************************************************/\r
-package org.simantics.sysdyn.ui.trend.chart.properties;\r
+package org.simantics.sysdyn.ui.trend.chart.properties.xyline;\r
 \r
 import java.util.ArrayList;\r
 import java.util.Map;\r
similarity index 91%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/AxisPropertyComposite.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/AxisPropertyComposite.java
index 882dd10b13175d7ad7120aae080c62c110f08389..d029ddf4e8ae1045ef675f57e96a8d092c813fb9 100644 (file)
@@ -9,7 +9,7 @@
  * Contributors:\r
  *     VTT Technical Research Centre of Finland - initial API and implementation\r
  *******************************************************************************/\r
-package org.simantics.sysdyn.ui.trend.chart.properties;\r
+package org.simantics.sysdyn.ui.trend.chart.properties.xyline;\r
 \r
 import org.eclipse.jface.dialogs.IInputValidator;\r
 import org.eclipse.jface.layout.GridDataFactory;\r
@@ -27,9 +27,12 @@ import org.simantics.layer0.Layer0;
 import org.simantics.modeling.ui.chart.property.DoublePropertyFactory;\r
 import org.simantics.modeling.ui.chart.property.DoublePropertyModifier;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.AxisHidePropertyComposite;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.ColorPicker;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
 \r
 /**\r
- * Composite for displaying axis properties in {@link ChartAxisAndVariablesTab}\r
+ * Composite for displaying axis properties in {@link XYLineAxisAndVariablesTab}\r
  * \r
  * @author Teemu Lempinen\r
  *\r
similarity index 90%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/SeriesPropertyComposite.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/SeriesPropertyComposite.java
index b1f94d347aec13f40422c7af427c43e29f154c52..4b09224c5f9503b48a295ffb66fa99d51accb34c 100644 (file)
@@ -9,7 +9,7 @@
  * Contributors:\r
  *     VTT Technical Research Centre of Finland - initial API and implementation\r
  *******************************************************************************/\r
-package org.simantics.sysdyn.ui.trend.chart.properties;\r
+package org.simantics.sysdyn.ui.trend.chart.properties.xyline;\r
 \r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
@@ -34,10 +34,15 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.ColorPicker;\r
+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.TrackedSpinner;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
 /**\r
- * Composite for displaying series properties in {@link ChartAxisAndVariablesTab}\r
+ * Composite for displaying series properties in {@link XYLineAxisAndVariablesTab}\r
  * \r
  * @author Teemu Lempinen\r
  *\r
@@ -63,7 +68,7 @@ public class SeriesPropertyComposite extends Composite {
         variable.setColorProvider(new JFreeChartPropertyColorProvider(this.variable.getResourceManager()));\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(this.variable.getWidget());\r
 \r
-        // Label to be displayed in chart for this series (usually same as the variable \r
+        // Label to be displayed in chart for this series \r
         label = new Label(this, SWT.NONE);\r
         label.setText("Label:");\r
         GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
similarity index 96%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/ChartAxisAndVariablesTab.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineAxisAndVariablesTab.java
index 7c33faaa79cfadee2ba34f3e5ad6058de81b7b7d..530d611a0ba2ce80926b7dc1b9e3f1b0624b81f3 100644 (file)
@@ -9,7 +9,7 @@
  * Contributors:\r
  *     VTT Technical Research Centre of Finland - initial API and implementation\r
  *******************************************************************************/\r
-package org.simantics.sysdyn.ui.trend.chart.properties;\r
+package org.simantics.sysdyn.ui.trend.chart.properties.xyline;\r
 \r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
@@ -54,14 +54,14 @@ import org.simantics.utils.datastructures.ArrayMap;
  * @author Teemu Lempinen\r
  *\r
  */\r
-public class ChartAxisAndVariablesTab extends LabelPropertyTabContributor {\r
+public class XYLineAxisAndVariablesTab extends LabelPropertyTabContributor {\r
 \r
     private GraphExplorerComposite explorer;\r
     private ScrolledComposite propertyContainer;\r
     private Button addAxis, addVariable, remove;\r
     private WidgetSupportImpl additionalSupport;\r
 \r
-    public ChartAxisAndVariablesTab() {\r
+    public XYLineAxisAndVariablesTab() {\r
         additionalSupport = new WidgetSupportImpl();\r
     }\r
 \r
similarity index 82%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/GeneralChartPropertiesTab.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineGeneralPropertiesTab.java
index 25d486c3be94b03912a2430a1323cf86979052b4..ea64a17dc1601c3d81c8f0a5d2a77ff10bb0a761 100644 (file)
@@ -9,7 +9,7 @@
  * Contributors:\r
  *     VTT Technical Research Centre of Finland - initial API and implementation\r
  *******************************************************************************/\r
-package org.simantics.sysdyn.ui.trend.chart.properties;\r
+package org.simantics.sysdyn.ui.trend.chart.properties.xyline;\r
 \r
 import org.eclipse.jface.dialogs.IInputValidator;\r
 import org.eclipse.jface.layout.GridDataFactory;\r
@@ -27,25 +27,28 @@ import org.simantics.browsing.ui.swt.widgets.Button;
 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.TextModifyListenerImpl;\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.request.PossibleObjectWithType;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.layer0.Layer0;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.modeling.ui.chart.property.DoublePropertyFactory;\r
 import org.simantics.modeling.ui.chart.property.DoublePropertyModifier;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.ui.properties.LabelPropertyTabContributor;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.AxisHidePropertyComposite;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.BooleanPropertyFactory;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.BooleanSelectionListener;\r
+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.TitleFactory;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.TitleModifier;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
 /**\r
@@ -54,12 +57,11 @@ import org.simantics.ui.utils.AdaptionUtils;
  * @author Teemu Lempinen\r
  *\r
  */\r
-public class GeneralChartPropertiesTab extends LabelPropertyTabContributor implements Widget {\r
+public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor implements Widget {\r
 \r
     private ScrolledComposite sc;\r
     private Composite composite;\r
-    private org.simantics.browsing.ui.swt.widgets.TrackedText name, title;\r
-    private TrackedText xlabel, xvariable, xmin, xmax;\r
+    private TrackedText name, title, xlabel, xvariable, xmin, xmax;\r
     private Combo type;\r
     private Button hgrid, htitle, hlegend;\r
     private WidgetSupportImpl domainAxisSupport = new WidgetSupportImpl();\r
@@ -219,46 +221,6 @@ public class GeneralChartPropertiesTab extends LabelPropertyTabContributor imple
         });\r
     }\r
 \r
-    /**\r
-     * TextFactory for chart title\r
-     * @author Teemu Lempinen\r
-     *\r
-     */\r
-    private class TitleFactory extends ReadFactoryImpl<Resource, String>   {\r
-        @Override\r
-        public String perform(ReadGraph graph, Resource chart) throws DatabaseException {\r
-            Layer0 l0 = Layer0.getInstance(graph);\r
-            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
-            Resource title = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.TextTitle));\r
-            if(title == null)\r
-                return "";\r
-            else {\r
-                String label = graph.getPossibleRelatedValue(title, l0.HasLabel, Bindings.STRING);\r
-                return label == null ? "" : label;\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * TitleModifier for chart title\r
-     * @author Teemu Lempinen\r
-     *\r
-     */\r
-    private class TitleModifier extends TextModifyListenerImpl<Resource> {\r
-\r
-        @Override\r
-        public void applyText(WriteGraph graph, Resource chart, String text) throws DatabaseException {\r
-            Layer0 l0 = Layer0.getInstance(graph);\r
-            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
-            Resource title = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.TextTitle));\r
-            if(title == null) {\r
-                title = GraphUtils.create2(graph, jfree.TextTitle,\r
-                        jfree.Title_position, jfree.Top);\r
-            }\r
-            graph.claimLiteral(title, l0.HasLabel, text);\r
-        }\r
-\r
-    }\r
     \r
     /**\r
      * Validator for validating that an input is double\r
index e2d8cdebcdce806e95b1ae42b0c52647ab4cee65..39f85dcbf4dd07996e9e8007e04848da475cdcf5 100644 (file)
@@ -78,7 +78,7 @@ public abstract class SysdynDatasetSelectionListener implements ISelectionListen
         // Empty selection or pinned trend -> Do nothing\r
         if(selection.isEmpty() || Boolean.TRUE.equals(PinTrend.getState()))\r
             return;\r
-        \r
+\r
         if(selection instanceof IStructuredSelection) {\r
             // Remove all previously added result listeners from model\r
             if(!resultListeners.isEmpty()) {\r
@@ -185,7 +185,7 @@ public abstract class SysdynDatasetSelectionListener implements ISelectionListen
      * @throws DatabaseException\r
      */\r
     private void updateDatasets(ReadGraph graph, Collection<Variable> variables) throws DatabaseException {\r
-        \r
+\r
         ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
         for(Variable variable : variables) {\r
             // Get all active datasets for the variable and add them to the result\r
@@ -193,7 +193,7 @@ public abstract class SysdynDatasetSelectionListener implements ISelectionListen
             if(activeDataSets != null && !activeDataSets.isEmpty())\r
                 datasets.addAll(activeDataSets);\r
         }\r
-        \r
+\r
         selectionChanged(datasets);\r
     }\r
 \r
@@ -215,7 +215,7 @@ public abstract class SysdynDatasetSelectionListener implements ISelectionListen
         } catch (DatabaseException e) {\r
             return dataSets;\r
         }\r
-        \r
+\r
         // Remove the first '.'\r
         if(rvi.length() > 1)\r
             rvi = rvi.substring(1);\r
@@ -233,14 +233,16 @@ public abstract class SysdynDatasetSelectionListener implements ISelectionListen
         Collection<SysdynResult> activeResults = model.getAndUpdateActiveResults(g);\r
         for(SysdynResult sysdynResult : activeResults) {\r
             for(String currvi : rvis.keySet()) {\r
-                SysdynDataSet sds = sysdynResult.getDataSet(currvi.substring(1).replace("/", "."));\r
-                if(sds != null) {\r
-                    try {\r
-                    sds.name = rvis.get(currvi).substring(1).replace("/", ".");\r
-                    } catch (NullPointerException e) {\r
-                        e.printStackTrace();\r
+                if(currvi != null && currvi.length() > 0) {\r
+                    SysdynDataSet sds = sysdynResult.getDataSet(currvi.substring(1).replace("/", "."));\r
+                    if(sds != null) {\r
+                        try {\r
+                            sds.name = rvis.get(currvi).substring(1).replace("/", ".");\r
+                        } catch (NullPointerException e) {\r
+                            e.printStackTrace();\r
+                        }\r
+                        dataSets.add(sds);\r
                     }\r
-                    dataSets.add(sds);\r
                 }\r
             }\r
         }\r
index e77511bc98cd7eee87dd27efff18ee3877d8a326..131bb2000a75d12f534fa95af003d1c90f29ac4d 100644 (file)
@@ -230,7 +230,7 @@ public class HistoryVariable extends ChildVariable implements PropertyProvider {
      * @return\r
      */\r
     protected VariableValueSubscription registerSubscription(ExternalRead<?> request, Listener<Variable> procedure, String property) {\r
-        if(SysdynVariableProperties.TIME.equals(property) && experiment instanceof SysdynPlaybackExperiment) {\r
+        if(SysdynVariableProperties.TIME.equals(property)) {\r
             // Current time is requested from experiment\r
             VariableValueSubscription subscription = new VariableValueSubscription(request, this, property, procedure);\r
             experiment.addVariableValueSubscription(subscription);\r
@@ -275,7 +275,7 @@ public class HistoryVariable extends ChildVariable implements PropertyProvider {
                 return new ConstantPropertyVariable(this, name, exp.getTime(), Datatypes.DOUBLE);\r
             } else {\r
                 // Experiment is not compatible, return time = 0\r
-                return new ConstantPropertyVariable(this, name, 0, Datatypes.DOUBLE);\r
+                return null;\r
             }\r
         } else if(SysdynVariableProperties.VALUES.equals(name)) {\r
             // Get the values of this variable from the currently active experiment\r