]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
added XY Area renderer
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 21 Dec 2011 09:41:33 +0000 (09:41 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 21 Dec 2011 09:41:33 +0000 (09:41 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@23658 ac1ea38d-2e2b-0410-8846-a27921b304fc

13 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/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/adapters.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewXYLineChartHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ChartUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYAreaRenderer.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYDataset.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYLineRenderer.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYPlot.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarGeneralPropertiesTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineGeneralPropertiesTab.java

index 32d291bd66ab100b8531c63ed4ed5c748555e2ba..b48384c3c9643f06abc96f041414f02f93920b2f 100644 (file)
Binary files a/org.simantics.jfreechart.ontology/graph.tg and b/org.simantics.jfreechart.ontology/graph.tg differ
index 5aa93b6ba1814e56190b8a9b786f15ef7a134926..01933123e7fa42751d5c4cda86e9732fc1e5ebb2 100644 (file)
@@ -105,6 +105,9 @@ JFREE.Series <T L0.Entity
 
 JFREE.Renderer <T L0.Entity
 
+JFREE.XYLineRenderer <T JFREE.Renderer
+JFREE.XYAreaRenderer <T JFREE.Renderer
+
 JFREE.BarRenderer <T JFREE.Renderer
 JFREE.StackedBarRenderer <T JFREE.Renderer
     
index 5de6725d1d1bf211e12a3bb33c8caabaa1e5ee95..78a96672b30816327e5eab9dcdf9e0df7e3bef7f 100644 (file)
@@ -5,7 +5,6 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.request.Read;\r
 import org.simantics.db.Session;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.service.QueryControl;\r
 \r
 public class JFreeChartResource {\r
     \r
@@ -88,7 +87,9 @@ public class JFreeChartResource {
     public final Resource Title_position;\r
     public final Resource Top;\r
     public final Resource ValueAxis;\r
+    public final Resource XYAreaRenderer;\r
     public final Resource XYDataset;\r
+    public final Resource XYLineRenderer;\r
     public final Resource XYPlot;\r
     public final Resource backgroundColor;\r
     public final Resource backgroundColor_Inverse;\r
@@ -185,7 +186,9 @@ public class JFreeChartResource {
         public static final String Title_position = "http://www.simantics.org/JFreeChart-1.0/Title/position";\r
         public static final String Top = "http://www.simantics.org/JFreeChart-1.0/Top";\r
         public static final String ValueAxis = "http://www.simantics.org/JFreeChart-1.0/ValueAxis";\r
+        public static final String XYAreaRenderer = "http://www.simantics.org/JFreeChart-1.0/XYAreaRenderer";\r
         public static final String XYDataset = "http://www.simantics.org/JFreeChart-1.0/XYDataset";\r
+        public static final String XYLineRenderer = "http://www.simantics.org/JFreeChart-1.0/XYLineRenderer";\r
         public static final String XYPlot = "http://www.simantics.org/JFreeChart-1.0/XYPlot";\r
         public static final String backgroundColor = "http://www.simantics.org/JFreeChart-1.0/backgroundColor";\r
         public static final String backgroundColor_Inverse = "http://www.simantics.org/JFreeChart-1.0/backgroundColor/Inverse";\r
@@ -292,7 +295,9 @@ public class JFreeChartResource {
         Title_position = getResourceOrNull(graph, URIs.Title_position);\r
         Top = getResourceOrNull(graph, URIs.Top);\r
         ValueAxis = getResourceOrNull(graph, URIs.ValueAxis);\r
+        XYAreaRenderer = getResourceOrNull(graph, URIs.XYAreaRenderer);\r
         XYDataset = getResourceOrNull(graph, URIs.XYDataset);\r
+        XYLineRenderer = getResourceOrNull(graph, URIs.XYLineRenderer);\r
         XYPlot = getResourceOrNull(graph, URIs.XYPlot);\r
         backgroundColor = getResourceOrNull(graph, URIs.backgroundColor);\r
         backgroundColor_Inverse = getResourceOrNull(graph, URIs.backgroundColor_Inverse);\r
@@ -314,8 +319,7 @@ public class JFreeChartResource {
         Session session = graph.getSession();\r
         JFreeChartResource ret = session.peekService(JFreeChartResource.class);\r
         if(ret == null) {\r
-            QueryControl qc = graph.getService(QueryControl.class);\r
-            ret = new JFreeChartResource(qc.getIndependentGraph(graph));\r
+            ret = new JFreeChartResource(graph);\r
             session.registerService(JFreeChartResource.class, ret);\r
         }\r
         return ret;\r
@@ -326,8 +330,7 @@ public class JFreeChartResource {
         if(ret == null) {\r
             ret = session.syncRequest(new Read<JFreeChartResource>() {\r
                 public JFreeChartResource perform(ReadGraph graph) throws DatabaseException {\r
-                    QueryControl qc = graph.getService(QueryControl.class);\r
-                    return new JFreeChartResource(qc.getIndependentGraph(graph));\r
+                    return new JFreeChartResource(graph);\r
                 }\r
             });\r
             session.registerService(JFreeChartResource.class, ret);\r
index dda9fead0c740270971641933aa5b45e6a1c4f00..6ea72e254b8a29fd3dbb853bf377059461330f24 100644 (file)
@@ -5,7 +5,6 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.request.Read;\r
 import org.simantics.db.Session;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.service.QueryControl;\r
 \r
 public class SysdynResource {\r
     \r
@@ -875,8 +874,7 @@ public class SysdynResource {
         Session session = graph.getSession();\r
         SysdynResource ret = session.peekService(SysdynResource.class);\r
         if(ret == null) {\r
-            QueryControl qc = graph.getService(QueryControl.class);\r
-            ret = new SysdynResource(qc.getIndependentGraph(graph));\r
+            ret = new SysdynResource(graph);\r
             session.registerService(SysdynResource.class, ret);\r
         }\r
         return ret;\r
@@ -887,8 +885,7 @@ public class SysdynResource {
         if(ret == null) {\r
             ret = session.syncRequest(new Read<SysdynResource>() {\r
                 public SysdynResource perform(ReadGraph graph) throws DatabaseException {\r
-                    QueryControl qc = graph.getService(QueryControl.class);\r
-                    return new SysdynResource(qc.getIndependentGraph(graph));\r
+                    return new SysdynResource(graph);\r
                 }\r
             });\r
             session.registerService(SysdynResource.class, ret);\r
index 390ea2d9b15384af7af797ac2baf68ac3fb141df..ecd9bdd09872c2e9b0b43f8c3d58ed30e872bde6 100644 (file)
@@ -10,5 +10,5 @@
         VTT Technical Research Centre of Finland - initial API and implementation\r
  -->\r
 
-<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r     <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-0.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r\r               <resource\r                      uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-1.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-0.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <resource uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.InputFactory" />                       \r       </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />            \r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowConnectionFactory">\r            <graph/>\r        </type>                       \r                       \r               <resource uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r   </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-0.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-0.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-0.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r       <!-- ModelBrowser2 -->\r \r       <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.VariableChildRule"/>  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>           \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>                          \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisLabelRule"/> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>       \r                     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>       \r                                               \r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/OpenWorkbook"\r            class="org.simantics.sysdyn.ui.browser.actions.OpenWorkbookAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewSharedFunctionLibraryAction" />            \r    </target>         \r    \r   <target interface="org.simantics.db.layer0.adapter.DropActionFactory">\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/AxisDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisDropAction" />            \r    </target>     \r  \r  <!-- PROFILES -->\r    <target interface="org.simantics.scenegraph.profile.Style">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/SimulationPlaybackStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.SimulationPlaybackStyle">\r        </resource>\r                <resource uri="http://www.simantics.org/Sysdyn-0.0/IssueStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.IssueDecorationStyle">\r        </resource>\r    </target>\r    \r  <!-- Charts -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r        <resource uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementFactory" />\r            \r        <type uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementFactory" />\r    </target>\r                \r    <target interface="org.simantics.diagram.synchronization.graph.ElementWriter">\r        <resource uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementWriter" />\r    </target>\r                    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IJFreeChart">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/Chart"\r            class="org.simantics.sysdyn.ui.trend.chart.JFreeChart">\r            <graph />\r            <this />\r        </type>\r    </target>  \r    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IDataset">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.XYDataset">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryDataset">\r            <graph />\r            <this />\r        </type>        \r        <type uri="http://www.simantics.org/JFreeChart-1.0/PieDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.PieDataset">\r            <graph />\r            <this />\r        </type>          \r    </target>\r    \r     <target interface="org.simantics.sysdyn.ui.trend.chart.ITitle">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/TextTitle"\r            class="org.simantics.sysdyn.ui.trend.chart.TextTitle">\r            <graph />\r            <this />\r        </type>\r    </target>\r    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IAxis">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/NumberAxis"\r            class="org.simantics.sysdyn.ui.trend.chart.NumberAxis">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryAxis"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryAxis">\r            <graph />\r            <this />\r        </type>        \r    </target>\r       \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IPlot">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYPlot"\r            class="org.simantics.sysdyn.ui.trend.chart.XYPlot">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryPlot"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryPlot">\r            <graph />\r            <this />\r        </type>      \r        <type uri="http://www.simantics.org/JFreeChart-1.0/PiePlot"\r            class="org.simantics.sysdyn.ui.trend.chart.PiePlot">\r            <graph />\r            <this />\r        </type>               \r    </target>\r    \r     <target interface="org.simantics.sysdyn.ui.trend.chart.IRenderer">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/BarRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.BarRenderer">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/StackedBarRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.StackedBarRenderer">\r            <graph />\r            <this />\r        </type>        \r    </target>    \r       \r
+<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r     <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-0.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r\r               <resource\r                      uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-1.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-0.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <resource uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.InputFactory" />                       \r       </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />            \r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowConnectionFactory">\r            <graph/>\r        </type>                       \r                       \r               <resource uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r   </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-0.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-0.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-0.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r       <!-- ModelBrowser2 -->\r \r       <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.VariableChildRule"/>  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>           \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>                          \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisLabelRule"/> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>       \r                     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>       \r                                               \r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/OpenWorkbook"\r            class="org.simantics.sysdyn.ui.browser.actions.OpenWorkbookAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewSharedFunctionLibraryAction" />            \r    </target>         \r    \r   <target interface="org.simantics.db.layer0.adapter.DropActionFactory">\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/AxisDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisDropAction" />            \r    </target>     \r  \r  <!-- PROFILES -->\r    <target interface="org.simantics.scenegraph.profile.Style">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/SimulationPlaybackStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.SimulationPlaybackStyle">\r        </resource>\r                <resource uri="http://www.simantics.org/Sysdyn-0.0/IssueStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.IssueDecorationStyle">\r        </resource>\r    </target>\r    \r  <!-- Charts -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r        <resource uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementFactory" />\r            \r        <type uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementFactory" />\r    </target>\r                \r    <target interface="org.simantics.diagram.synchronization.graph.ElementWriter">\r        <resource uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementWriter" />\r    </target>\r                    \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     \r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYLineRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.XYLineRenderer">\r            <graph />\r            <this />\r        </type>  \r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYAreaRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.XYAreaRenderer">\r            <graph />\r            <this />\r        </type>        \r                \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 46b44408d67c47727798d8090ec9e90100333962..98c94da8c2dd2f9d5d3bf676723831f0af101963 100644 (file)
@@ -79,12 +79,15 @@ public class NewXYLineChartHandler extends AbstractHandler {
                         l0.HasName, "NumberAxis" + UUID.randomUUID().toString());\r
                 Resource rangeAxis = GraphUtils.create2(g, jfree.NumberAxis,\r
                         l0.HasName, "NumberAxis" + UUID.randomUUID().toString());\r
+                \r
+                Resource renderer = GraphUtils.create2(g, jfree.XYLineRenderer);\r
 \r
                 Resource dataset = GraphUtils.create2(g, jfree.XYDataset,\r
                         l0.HasName, "XYDataset" + UUID.randomUUID().toString(),\r
                         jfree.Dataset_mapToDomainAxis, domainAxis,\r
                         jfree.Dataset_mapToRangeAxis, rangeAxis,\r
-                        jfree.Dataset_seriesList, ListUtils.create(g, new ArrayList<Resource>()));\r
+                        jfree.Dataset_seriesList, ListUtils.create(g, new ArrayList<Resource>()),\r
+                        jfree.Dataset_renderer, renderer);\r
 \r
                 GraphUtils.create2(g, jfree.XYPlot,\r
                         l0.HasName, "XYPlot" + UUID.randomUUID().toString(),\r
index 32081bbeb0c96c4ac9fe04a6a8dfed892cd124dd..92e8ba4d15738cf4e40056bd7b9d99a092f3462c 100644 (file)
@@ -77,11 +77,13 @@ public class ChartUtils {
         JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
         Layer0 l0 = Layer0.getInstance(graph);\r
         \r
+        \r
         // Create a dataset for the axis\r
         Resource dataset = GraphUtils.create2(graph, jfree.XYDataset,\r
                 l0.HasName, "XYDataset" + UUID.randomUUID().toString(),\r
                 jfree.Dataset_mapToDomainAxis, domainAxis,\r
                 jfree.Dataset_mapToRangeAxis, rangeAxis,\r
+                jfree.Dataset_renderer, GraphUtils.create2(graph, jfree.XYLineRenderer),\r
                 l0.PartOf, plot);\r
         \r
         return dataset;\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYAreaRenderer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYAreaRenderer.java
new file mode 100644 (file)
index 0000000..6533778
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************\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.labels.StandardXYToolTipGenerator;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+\r
+/**\r
+ * Renderer representing jfree chart renderer for xy areas\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class XYAreaRenderer extends AbstractRenderer {\r
+\r
+    private org.jfree.chart.renderer.xy.XYAreaRenderer renderer;\r
+    \r
+    public XYAreaRenderer(ReadGraph graph, Resource resource) {\r
+        super(graph, resource);\r
+    }\r
+\r
+    @Override\r
+    public org.jfree.chart.renderer.AbstractRenderer getRenderer() {\r
+        if(renderer == null) {\r
+            renderer = new org.jfree.chart.renderer.xy.XYAreaRenderer();\r
+            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());\r
+        }\r
+        return renderer;\r
+    }\r
+\r
+}
\ No newline at end of file
index 30f65e95c5ff5c79a89109d09dd07c30fc8e88d8..35cf2eec22c7d26f9386789505e6942123a29edb 100644 (file)
@@ -50,6 +50,7 @@ import org.simantics.sysdyn.adapter.SysdynVariableProperties;
 import org.simantics.sysdyn.adapter.VariableRVIUtils;\r
 import org.simantics.sysdyn.manager.SysdynDataSet;\r
 import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.datastructures.Pair;\r
 \r
 /**\r
  * Class representing a JFreeChart.XYDataset\r
@@ -59,7 +60,7 @@ import org.simantics.ui.SimanticsUI;
  */\r
 public class XYDataset extends AbstractDataset {\r
 \r
-    private XYLineAndShapeRenderer renderer;\r
+    private IRenderer renderer;\r
 \r
     public XYDataset(ReadGraph graph, final Resource datasetResource) {\r
         super(graph, datasetResource);\r
@@ -77,18 +78,24 @@ public class XYDataset extends AbstractDataset {
 \r
         if(datasetListener == null || datasetListener.isDisposed()) {\r
             datasetListener = new DataSetListener();\r
-            SimanticsUI.getSession().asyncRequest(new Read<ArrayList<TempSeries>>() {\r
+            SimanticsUI.getSession().asyncRequest(new Read<Pair<ArrayList<TempSeries>, IRenderer>>() {\r
 \r
                 @Override\r
-                public ArrayList<TempSeries> perform(ReadGraph graph) throws DatabaseException {\r
+                public Pair<ArrayList<TempSeries>, IRenderer> perform(ReadGraph graph) throws DatabaseException {\r
                     JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
 \r
+                    // Renderer\r
+                    IRenderer renderer = null;\r
+                    Resource rendererResource = graph.getPossibleObject(resource, jfree.Dataset_renderer);\r
+                    if(rendererResource != null)\r
+                        renderer = graph.adapt(rendererResource, IRenderer.class);\r
+                    \r
                     ArrayList<TempSeries> series = new ArrayList<TempSeries>();\r
 \r
                     String realizationURI = getRealizationURI(graph);\r
 \r
                     if(realizationURI == null)\r
-                        return series; // No experiment -> No results\r
+                        return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer); // No experiment -> No results\r
 \r
                     // Get a variable for the x-axis (if not time)\r
                     double[] domainValues = null;\r
@@ -129,7 +136,7 @@ public class XYDataset extends AbstractDataset {
                                 // Get values\r
                                 Object object =  v.getPossiblePropertyValue(graph, SysdynVariableProperties.ACTIVE_DATASETS , Bindings.VARIANT);\r
                                 if(object == null || !(object instanceof ArrayList<?>))\r
-                                    return series;\r
+                                    return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
 \r
                                 ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
 \r
@@ -191,7 +198,7 @@ public class XYDataset extends AbstractDataset {
                             }\r
                         }\r
                     }\r
-                    return series;\r
+                    return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
                 }\r
 \r
             }, datasetListener); \r
@@ -245,7 +252,7 @@ public class XYDataset extends AbstractDataset {
         }\r
     }\r
 \r
-    private class DataSetListener implements Listener<ArrayList<TempSeries>> {\r
+    private class DataSetListener implements Listener<Pair<ArrayList<TempSeries>, IRenderer>> {\r
 \r
         private boolean disposed = false;\r
 \r
@@ -259,27 +266,33 @@ public class XYDataset extends AbstractDataset {
         }\r
 \r
         @Override\r
-        public void execute(final ArrayList<TempSeries> series) {\r
+        public void execute(Pair<ArrayList<TempSeries>, IRenderer> result) {\r
+            final ArrayList<TempSeries> series = result.first;\r
+            renderer = result.second;\r
+            \r
             // Modify series in AWT thread to avoid synchronization problems\r
             SwingUtilities.invokeLater(new Runnable() {\r
 \r
                 @Override\r
                 public void run() {\r
 \r
-                    /*\r
-                     *  Drawing supplier with a modified first yellow. The default first\r
-                     *  yellow is too light to be visible against a white background\r
-                     */\r
-                    Paint[] paintSequence = ChartColor.createDefaultPaintArray();\r
-                    paintSequence[3] = new Color(0xFF, 0xDD, 0x00);\r
-                    DefaultDrawingSupplier drawingsupplier = new DefaultDrawingSupplier(\r
-                            paintSequence,\r
-                            DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE,\r
-                            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,\r
-                            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,\r
-                            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,\r
-                            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);\r
-                    ((AbstractXYItemRenderer)getRenderer()).getPlot().setDrawingSupplier(drawingsupplier);\r
+                    org.jfree.chart.plot.XYPlot plot = ((AbstractXYItemRenderer)getRenderer()).getPlot();\r
+                    if(plot != null) {\r
+                        /*\r
+                         *  Drawing supplier with a modified first yellow. The default first\r
+                         *  yellow is too light to be visible against a white background\r
+                         */\r
+                        Paint[] paintSequence = ChartColor.createDefaultPaintArray();\r
+                        paintSequence[3] = new Color(0xFF, 0xDD, 0x00);\r
+                        DefaultDrawingSupplier drawingsupplier = new DefaultDrawingSupplier(\r
+                                paintSequence,\r
+                                DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE,\r
+                                DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,\r
+                                DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,\r
+                                DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,\r
+                                DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);\r
+                        plot.setDrawingSupplier(drawingsupplier);\r
+                    }\r
                     // Remove all series\r
                     for(int i = dataset.getSeriesCount() - 1; i >= 0; i-- ) {\r
                         dataset.removeSeries(dataset.getSeriesKey(i));\r
@@ -406,10 +419,12 @@ public class XYDataset extends AbstractDataset {
     @Override\r
     public AbstractRenderer getRenderer() {\r
         if(renderer == null) {\r
-            renderer = new XYLineAndShapeRenderer(true, false);\r
+            XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);\r
             renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());\r
+            return renderer;\r
+        } else {\r
+            return renderer.getRenderer();\r
         }\r
-        return renderer;\r
     }\r
 \r
     /**\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYLineRenderer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYLineRenderer.java
new file mode 100644 (file)
index 0000000..cb2a6d1
--- /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;\r
+\r
+import org.jfree.chart.labels.StandardXYToolTipGenerator;\r
+import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+\r
+/**\r
+ * Renderer representing jfree chart renderer for xy lines\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class XYLineRenderer extends AbstractRenderer {\r
+\r
+    XYLineAndShapeRenderer renderer;\r
+    \r
+    public XYLineRenderer(ReadGraph graph, Resource resource) {\r
+        super(graph, resource);\r
+    }\r
+\r
+    @Override\r
+    public org.jfree.chart.renderer.AbstractRenderer getRenderer() {\r
+        if(renderer == null) {\r
+            renderer = new XYLineAndShapeRenderer(true, false);\r
+            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());\r
+        }\r
+        return renderer;\r
+    }\r
+\r
+}\r
index a4767c3cbd46fc5513f5ef04f53bc91f59a69f62..bea1ce22f978e1c31b32ed741401be9f56eb0aec 100644 (file)
@@ -37,19 +37,26 @@ public class XYPlot extends AbstractPlot {
     protected Plot newPlot() {\r
         return new org.jfree.chart.plot.XYPlot(null, null, null, null);\r
     }\r
-    \r
+\r
     @Override\r
     protected void getOtherProperties(ReadGraph graph, PlotProperties properties) throws DatabaseException {\r
         JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
         Boolean visibleGrid = graph.getPossibleRelatedValue(resource, jfree.Plot_visibleGrid);\r
         properties.otherProperties.put("visibleGrid", visibleGrid);\r
+        if(!properties.datasets.isEmpty()) {\r
+            IDataset idataset = properties.datasets.get(0);\r
+            Resource renderer = graph.getPossibleObject(idataset.getResource(), jfree.Dataset_renderer);\r
+            if(renderer != null) {\r
+                properties.otherProperties.put("renderer", graph.adapt(renderer, IRenderer.class));\r
+            }\r
+        }\r
     }\r
 \r
     @Override\r
     protected void setPlotProperties(PlotProperties properties) {\r
         if(!(plot instanceof org.jfree.chart.plot.XYPlot))\r
             return;\r
-        \r
+\r
         org.jfree.chart.plot.XYPlot xyplot = (org.jfree.chart.plot.XYPlot)plot;\r
         xyplot.clearDomainAxes();\r
         xyplot.clearRangeAxes();\r
@@ -81,7 +88,7 @@ public class XYPlot extends AbstractPlot {
 \r
         xyplot.setRangeGridlinesVisible(visibleGrid);\r
         xyplot.setDomainGridlinesVisible(visibleGrid);\r
-        \r
+\r
         // Cleaner look: no outline borders\r
         xyplot.setInsets(new RectangleInsets(2,5,2,10), false);\r
         xyplot.setOutlineVisible(false);\r
index 5982d6dc30f10a06f9fac3ea88674cc4a2ae4eec..be09d06ac9fbdbfa63bf2579b44269a7904ec8b4 100644 (file)
@@ -89,17 +89,17 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor {
         GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1);\r
         GridLayoutFactory.fillDefaults().applyTo(labelColumn1);\r
         \r
-        // first column: name and title\r
+        // second column: name and title\r
         Composite propertyColumn1 = new Composite(general, SWT.NONE);\r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1);\r
         GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1);\r
         \r
-        // first column: labels\r
+        // third column: labels\r
         Composite labelColumn2 = new Composite(general, SWT.NONE);\r
         GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2);\r
         GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2);\r
         \r
-        // first column: type and time\r
+        // fourth column: type and time\r
         Composite propertyColumn2 = new Composite(general, SWT.NONE);\r
         GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2);\r
         GridLayoutFactory.fillDefaults().applyTo(propertyColumn2);\r
index 857a7cafc5aabadaa06d50a4e7b8a9d6d5f8add2..c4e730da501d271ae1e0f3ad110257cdd497654d 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.trend.chart.properties.xyline;\r
 \r
+import java.util.Collection;\r
+import java.util.LinkedHashMap;\r
+import java.util.Map;\r
+\r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.jface.viewers.StructuredSelection;\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
@@ -25,17 +28,23 @@ import org.eclipse.ui.IWorkbenchSite;
 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.TrackedCombo;\r
 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ComboModifyListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ObjectsWithType;\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
@@ -62,7 +71,7 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl
     private ScrolledComposite sc;\r
     private Composite composite;\r
     private TrackedText name, title, xlabel, xvariable, xmin, xmax;\r
-    private Combo type;\r
+    private TrackedCombo type;\r
     private Button hgrid, htitle, hlegend;\r
     private WidgetSupportImpl domainAxisSupport = new WidgetSupportImpl();\r
 \r
@@ -107,9 +116,11 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl
         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[] {"Line", "Fancy", "Area", "3D"});\r
-        type.select(0);\r
+        type = new TrackedCombo(c, support, SWT.BORDER | SWT.READ_ONLY);\r
+        type.addModifyListener(new TypeModifyListener());\r
+        type.setItemFactory(new TypeItemFactory());\r
+        type.setSelectionFactory(new TypeSelectionFactory());\r
+        GridDataFactory.fillDefaults().applyTo(type.getWidget());\r
 \r
         // Title (Which is different than name)\r
         label = new Label(general, SWT.NONE);\r
@@ -224,5 +235,82 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl
             }\r
         });\r
     }\r
+    \r
+    /**\r
+     * \r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class TypeSelectionFactory extends ReadFactoryImpl<Resource, String> {\r
+        @Override\r
+        public String perform(ReadGraph graph, Resource chart) throws DatabaseException {\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+            Layer0 l0 = Layer0.getInstance(graph);\r
+\r
+            Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.XYPlot));\r
+            if(plot != null) {\r
+                Collection<Resource> datasets = graph.syncRequest(new ObjectsWithType(plot, l0.ConsistsOf, jfree.XYDataset));\r
+                if(!datasets.isEmpty()) {\r
+                    Resource dataset = datasets.iterator().next();\r
+                    if(dataset != null) {\r
+                        Resource renderer = graph.syncRequest(new PossibleObjectWithType(dataset, jfree.Dataset_renderer, jfree.Renderer));\r
+                        if(renderer != null && graph.isInstanceOf(renderer, jfree.XYAreaRenderer))\r
+                            return "Area";\r
+                    }\r
+                }\r
+            }\r
+            return "Line";\r
+        }\r
+    }\r
+\r
+    /**\r
+     * RangeItemFactory finds all inexes of a given enumeration \r
+     * and adds "Sum" and "All" to the returned indexes\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class TypeItemFactory extends ReadFactoryImpl<Resource, Map<String, Object>> {\r
+        @Override\r
+        public Map<String, Object> perform(ReadGraph graph, Resource series) throws DatabaseException {\r
+            LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>();\r
+            result.put("Line", "Line");\r
+            result.put("Area", "Area");\r
+//            result.put("Stacked Area", "Stacked Area");\r
+            return result;\r
+        }\r
+    }\r
+\r
+    /**\r
+     * TypeModifyListener for modifying the type of a bar chart \r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class TypeModifyListener  extends ComboModifyListenerImpl<Resource> {\r
+        @Override\r
+        public void applyText(WriteGraph graph, Resource chart, String text) throws DatabaseException {\r
+            JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+            Layer0 l0 = Layer0.getInstance(graph);\r
+\r
+            Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.XYPlot));\r
+            if(plot == null)\r
+                return;\r
+\r
+            Collection<Resource> datasets = graph.syncRequest(new ObjectsWithType(plot, l0.ConsistsOf, jfree.XYDataset));\r
+            if(datasets == null || datasets.isEmpty())\r
+                return;\r
+\r
+            for(Resource dataset : datasets) {\r
+                graph.deny(dataset, jfree.Dataset_renderer);\r
+\r
+                Resource renderer;\r
+                if(text.equals("Area"))\r
+                    renderer = GraphUtils.create2(graph, jfree.XYAreaRenderer);\r
+                else\r
+                    renderer = GraphUtils.create2(graph, jfree.XYLineRenderer);\r
+\r
+                graph.claim(dataset, jfree.Dataset_renderer, renderer);\r
+            }\r
+        }\r
+    }\r
 \r
 }
\ No newline at end of file