]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
chart component moved to jfreechart plug-in.
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 16 Jan 2013 10:53:01 +0000 (10:53 +0000)
committerluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 16 Jan 2013 10:53:01 +0000 (10:53 +0000)
refs #3988

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26620 ac1ea38d-2e2b-0410-8846-a27921b304fc

18 files changed:
org.simantics.sysdyn.feature/feature.xml
org.simantics.sysdyn.ui/META-INF/MANIFEST.MF
org.simantics.sysdyn.ui/adapters.xml
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/ChartDropAction.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/BarChartNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/LineChartNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/PieChartNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/DiagramViewer.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ChartPanelOrientationHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/AllVariablesOfModel.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/CategoryDataset.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/PieDataset.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SysdynRangeHandlerFactory.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/XYDataset.java [new file with mode: 0644]
org.simantics.sysdyn.ui/sysdyn.product

index 8399d120976a7a8bfa592b6e7d2b0196aa0c829a..855e54a1f035dca31201a01ca72645e425bf096e 100644 (file)
          download-size="0"\r
          install-size="0"\r
          version="0.0.0"/>\r
-<!--\r
-   <plugin\r
-         id="org.simantics.document.ontology2"\r
-         download-size="0"\r
-         install-size="0"\r
-         version="0.0.0"\r
-         unpack="false"/>\r
-\r
-   <plugin\r
-         id="org.simantics.document.server"\r
-         download-size="0"\r
-         install-size="0"\r
-         version="0.0.0"\r
-         unpack="false"/>\r
-\r
-   <plugin\r
-         id="org.simantics.document.vaadin"\r
-         download-size="0"\r
-         install-size="0"\r
-         version="0.0.0"\r
-         unpack="false"/>\r
 \r
    <plugin\r
-         id="org.simantics.document.workbench"\r
+         id="org.simantics.jfreechart"\r
          download-size="0"\r
          install-size="0"\r
          version="0.0.0"\r
          unpack="false"/>\r
 \r
-   <plugin\r
-         id="org.simantics.document.workbench.ontology"\r
-         download-size="0"\r
-         install-size="0"\r
-         version="0.0.0"\r
-         unpack="false"/>\r
-\r
-   <plugin\r
-         id="org.simantics.views2.swt"\r
-         download-size="0"\r
-         install-size="0"\r
-         version="0.0.0"\r
-         unpack="false"/>\r
-\r
-   <plugin\r
-         id="org.simantics.swt.ontology"\r
-         download-size="0"\r
-         install-size="0"\r
-         version="0.0.0"\r
-         unpack="false"/>\r
--->\r
 </feature>\r
index 12553dbce0cada828c734fb6867826fdc3ea6645..37abd3d84b9ff4fb0428e03c0ca888e926414244 100644 (file)
@@ -54,7 +54,8 @@ Require-Bundle: org.simantics.layer0.utils;bundle-version="0.6.2",
  org.eclipse.ui.forms;bundle-version="3.5.2",
  org.simantics.scenegraph.swing;bundle-version="1.0.0",
  org.eclipse.nebula.widgets.tablecombo;bundle-version="1.0.0",
- org.simantics.fmu;bundle-version="1.0.0"
+ org.simantics.fmu;bundle-version="1.0.0",
+ org.simantics.jfreechart;bundle-version="1.0.0"
 Bundle-Activator: org.simantics.sysdyn.ui.Activator
 Bundle-ActivationPolicy: lazy
 Export-Package: org.simantics.sysdyn.ui.browser.nodes
index d2ce6b7a9ab21a4c23d590ab23d255ae14bfd576..179907b0d1286ea7fe9f2f8c117d84ee31cddeae 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-0.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.elements.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.elements.StockFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements.ModuleFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements.ValveFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements.AuxiliaryFactory" />\r           <resource uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements.CloudFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements.InputFactory" />\r\r              <type uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements.StockFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements.ModuleFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements.ValveFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements.AuxiliaryFactory" />\r           <type uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements.CloudFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements.InputFactory" />                        \r       </target>\r      \r       <!-- Additional symbols -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r          <resource uri="http://www.simantics.org/Sysdyn-0.0/AdditionalSymbols/MultilineText"\r            class="org.simantics.sysdyn.ui.elements.MultilineTextElementFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/AdditionalSymbols/MultilineText"\r            class="org.simantics.sysdyn.ui.elements.MultilineTextElementFactory" />         \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.elements.connections.RouteFlowEdgeFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements.connections.RouteFlowEdgeFactory" />            \r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements.connections.RouteFlowConnectionFactory">\r            <graph/>\r        </type>                          \r                       \r               <resource uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements.connections.DependencyEdgeFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements.connections.DependencyEdgeFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements.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/ModelingBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>              \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.VariableChildRule"/>                  \r              \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        <resource uri="http://www.simantics.org/Sysdyn-0.0/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.historyDataset.VariableChildRule"/>     \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterChildRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterChildRule"/>               \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableNameLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.VariableNameLabelRule"/>\r\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.VariableImageRule"/>   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ChartImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.ChartImageRule"/>      \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ResultImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.ResultImageRule"/>                        \r            \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        <resource uri="http://www.simantics.org/Sysdyn-0.0/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableLabelRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.historyDataset.VariableLabelRule"/>                \r                \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        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterLabelRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterLabelRule"/>    \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterLabelDecorationRule"/>               \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterModifierRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterModifierRule"/>    \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterSorterRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterSorterRule"/>                                      \r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSharedFunctionLibraryAction" />   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewExperiment"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewExperimentAction" />   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSimulationPlaybackExperiment"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSimulationPlaybackExperimentAction" />    \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewLineChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewLineChartAction" /> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewBarChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewBarChartAction" /> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewPieChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewPieChartAction" />        \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSheet"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSheetAction" />       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewHistoryData"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewHistoryDataAction" />                                                                                              \r    </target>         \r    \r   <target interface="org.simantics.db.layer0.adapter.DropActionFactory">\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/FunctionDropAction"\r            class="org.simantics.sysdyn.ui.browser.actions.drop.FunctionDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/ChartDropAction"\r            class="org.simantics.sysdyn.ui.browser.actions.drop.ChartDropAction" />            \r   \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            \r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />                        \r    </target>     \r  \r    <target interface="org.simantics.db.layer0.adapter.Remover">\r        <type uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleSymbol"\r            class="org.simantics.sysdyn.ui.browser.actions.remove.ModuleTypeRemover">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/Sysdyn-0.0/Variable"\r            class="org.simantics.sysdyn.ui.actions.SysdynVariableRemover">\r            <this />\r        </type>\r    </target>\r    \r    \r    <target interface="org.simantics.browsing.ui.model.nodetypes.NodeType">\r        <baseType uri="http://www.simantics.org/Layer0-0.0/Entity" />\r        <type\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleSymbolNodeType"\r            class="org.simantics.sysdyn.ui.browser.nodeTypes.ModuleSymbolNodeType"\r            constructor="create">\r            <this/>\r        </type>        \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.elements.profiles.SimulationPlaybackStyle">\r        </resource>\r                <resource uri="http://www.simantics.org/Sysdyn-0.0/IssueStyle"\r            class="org.simantics.sysdyn.ui.elements.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-0.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementFactory" />\r            \r        <type uri="http://www.simantics.org/JFreeChart-0.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-0.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-0.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-0.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-0.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-0.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-0.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-0.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-0.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-0.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-0.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-0.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-0.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-0.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-0.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-0.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-0.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.elements.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.elements.StockFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements.ModuleFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements.ValveFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements.AuxiliaryFactory" />\r           <resource uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements.CloudFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements.InputFactory" />\r\r              <type uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements.StockFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements.ModuleFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements.ValveFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements.AuxiliaryFactory" />\r           <type uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements.CloudFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements.InputFactory" />                        \r       </target>\r      \r       <!-- Additional symbols -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r          <resource uri="http://www.simantics.org/Sysdyn-0.0/AdditionalSymbols/MultilineText"\r            class="org.simantics.sysdyn.ui.elements.MultilineTextElementFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/AdditionalSymbols/MultilineText"\r            class="org.simantics.sysdyn.ui.elements.MultilineTextElementFactory" />         \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.elements.connections.RouteFlowEdgeFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements.connections.RouteFlowEdgeFactory" />            \r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements.connections.RouteFlowConnectionFactory">\r            <graph/>\r        </type>                          \r                       \r               <resource uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements.connections.DependencyEdgeFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements.connections.DependencyEdgeFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements.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/ModelingBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>              \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.VariableChildRule"/>                  \r                  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.historyDataset.VariableChildRule"/>     \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterChildRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterChildRule"/>               \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableNameLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.VariableNameLabelRule"/>\r\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/VariableImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.VariableImageRule"/>   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ChartImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.ChartImageRule"/>      \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ResultImageRule"\r            class="org.simantics.sysdyn.ui.browser.imagerules.ResultImageRule"/>                        \r            \r  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableLabelRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.historyDataset.VariableLabelRule"/>                \r\r            \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterLabelRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterLabelRule"/>    \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterLabelDecorationRule"/>               \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterModifierRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterModifierRule"/>    \r        <resource uri=" http://www.simantics.org/Sysdyn-0.0/Module/ParameterOverrideBrowseContext/ParameterSorterRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.modules.ParameterSorterRule"/>                                      \r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSharedFunctionLibraryAction" />   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewExperiment"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewExperimentAction" />   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSimulationPlaybackExperiment"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSimulationPlaybackExperimentAction" />    \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewLineChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewLineChartAction" /> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewBarChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewBarChartAction" /> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewPieChart"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewPieChartAction" />        \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewSheet"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewSheetAction" />       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/NewHistoryData"\r            class="org.simantics.sysdyn.ui.browser.actions.newActions.NewHistoryDataAction" />                                                                                              \r    </target>         \r    \r   <target interface="org.simantics.db.layer0.adapter.DropActionFactory">\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/FunctionDropAction"\r            class="org.simantics.sysdyn.ui.browser.actions.drop.FunctionDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingActionContext/Actions/ChartDropAction"\r            class="org.simantics.sysdyn.ui.browser.actions.drop.ChartDropAction" />            \r   \r                    \r    </target>     \r  \r    <target interface="org.simantics.db.layer0.adapter.Remover">\r        <type uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleSymbol"\r            class="org.simantics.sysdyn.ui.browser.actions.remove.ModuleTypeRemover">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/Sysdyn-0.0/Variable"\r            class="org.simantics.sysdyn.ui.actions.SysdynVariableRemover">\r            <this />\r        </type>\r    </target>\r    \r    \r    <target interface="org.simantics.browsing.ui.model.nodetypes.NodeType">\r        <baseType uri="http://www.simantics.org/Layer0-0.0/Entity" />\r        <type\r            uri="http://www.simantics.org/Sysdyn-0.0/ModelingBrowseContext/ModuleSymbolNodeType"\r            class="org.simantics.sysdyn.ui.browser.nodeTypes.ModuleSymbolNodeType"\r            constructor="create">\r            <this/>\r        </type>        \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.elements.profiles.SimulationPlaybackStyle">\r        </resource>\r                <resource uri="http://www.simantics.org/Sysdyn-0.0/IssueStyle"\r            class="org.simantics.sysdyn.ui.elements.profiles.IssueDecorationStyle">\r        </resource>\r    </target>\r    \r \r    <!--  TODO: currently maps jfree concepts directly to Sysdyn implementations. Sysdyn needs tool specific types for the datasets. -->\r    <!--  TODO: AllVariablesOfModel query is run on random Resources; listing all possible types explicitly is cumbersome, we need a better implementation. -->\r    <target interface="org.simantics.jfreechart.chart.properties.IAllVariablesOfModel">  \r        <type uri="http://www.simantics.org/Sysdyn-1.1/SysdynModel"\r            class="org.simantics.sysdyn.ui.trend.AllVariablesOfModel">\r            <this />\r        </type>  \r        <type uri="http://www.simantics.org/JFreeChart-1.0/NumberAxis"\r            class="org.simantics.sysdyn.ui.trend.AllVariablesOfModel">\r            <this />\r        </type>   \r        <type uri="http://www.simantics.org/JFreeChart-1.0/Series"\r            class="org.simantics.sysdyn.ui.trend.AllVariablesOfModel">\r            <this />\r        </type>      \r    </target> \r       \r    <target interface="org.simantics.jfreechart.chart.properties.RangeHandlerFactory">  \r        <type uri="http://www.simantics.org/Sysdyn-1.1/SysdynModel"\r            class="org.simantics.sysdyn.ui.trend.SysdynRangeHandlerFactory">\r        </type>        \r    </target> \r    \r    <!--  TODO: currently maps jfree concepts directly to Sysdyn implementations. Sysdyn needs tool specific types for the datasets. -->\r     <target interface="org.simantics.jfreechart.chart.IDataset">\r        <type uri="http://www.simantics.org/JFreeChart-0.0/XYDataset"\r            class="org.simantics.sysdyn.ui.trend.XYDataset">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-0.0/CategoryDataset"\r            class="org.simantics.sysdyn.ui.trend.CategoryDataset">\r            <graph />\r            <this />\r        </type>        \r        <type uri="http://www.simantics.org/JFreeChart-0.0/PieDataset"\r            class="org.simantics.sysdyn.ui.trend.PieDataset">\r            <graph />\r            <this />\r        </type>          \r    </target>\r
 </adapters>
\ No newline at end of file
index 5c5f8544a3c86f1190d9ab80960e7409fc43e8f4..e34af3c44ea39fe4bd55564a5c181db12ae07918 100644 (file)
             Structural model browser view for Sysdyn.\r
          </description>\r
       </view>\r
-      <view\r
-            category="org.simantics.sysdyn.ui.category"\r
-            class="org.simantics.sysdyn.ui.trend.ChartPanel"\r
-            icon="platform:/plugin/com.famfamfam.silk/icons/chart_line.png"\r
-            id="org.simantics.sysdyn.ui.chartPanel"\r
-            name="Chart Panel"\r
-            restorable="true">\r
-      </view>\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.perspectives">\r
                relative="org.simantics.browsing.ui.graph.propertyView">\r
          </view>\r
          <view\r
-               id="org.simantics.sysdyn.ui.chartPanel"\r
+               id="org.simantics.jfreechart.chartPanel"\r
                minimized="true"\r
                ratio="0.5"\r
                relationship="right"\r
index 19ec9743fcf51873eb79a3c26825f69f878c2ed9..686a3703d269402d705221c9dc041b5d81ace7e4 100644 (file)
@@ -25,10 +25,10 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.DropActionFactory;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.jfreechart.chart.ChartUtils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.AdaptionUtils;\r
 \r
index 91fe6d6c20b331d7be22944d19ad0616d17d1196..9dff79b6ac85b287c6c6268d64436d1459a98484 100644 (file)
@@ -19,9 +19,9 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.jfreechart.chart.ChartUtils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
-import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
 /**\r
index 1aa188f6e741519ba4796edad8d68e935022e7c2..ef2ec4924b66771afbf8ec11bf35917a83463075 100644 (file)
@@ -19,9 +19,9 @@ import org.simantics.db.common.utils.ListUtils;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.jfreechart.chart.ChartUtils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
-import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
 /**\r
index 82f2750c23bd90cf5946e1991282a2a7524868c1..776cbdb02959112578777840e1e2734bde605af9 100644 (file)
@@ -19,9 +19,9 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.jfreechart.chart.ChartUtils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.JFreeChartResource;\r
-import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
 /**\r
index 11285898fd048317044715efc63e9341a74966ff..01292dcf23844b9e2d5ce78d0097db1bb531d741 100644 (file)
@@ -36,6 +36,7 @@ import org.simantics.g2d.element.IElementClassProvider;
 import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
 import org.simantics.g2d.participant.GridPainter;\r
 import org.simantics.g2d.participant.RulerPainter;\r
+import org.simantics.jfreechart.chart.element.PopulateChartDropParticipant;\r
 import org.simantics.modeling.mapping.ElementCopyAdvisor;\r
 import org.simantics.modeling.mapping.MappedElementCopyAdvisor;\r
 import org.simantics.modeling.ui.diagramEditor.handlers.LinkBrowsingHandler;\r
@@ -53,7 +54,6 @@ import org.simantics.sysdyn.ui.elements.connections.RouteFlowEdgeClass;
 import org.simantics.sysdyn.ui.elements.connections.SysdynConnectionClass;\r
 import org.simantics.sysdyn.ui.handlers.ExtendedCopyPasteHandler;\r
 import org.simantics.sysdyn.ui.properties.SysdynPropertyPage;\r
-import org.simantics.sysdyn.ui.trend.chart.element.PopulateChartDropParticipant;\r
 import org.simantics.ui.workbench.IPropertyPage;\r
 import org.simantics.utils.datastructures.hints.IHintContext;\r
 import org.simantics.utils.threads.AWTThread;\r
index 87ee362a7b398ab4ca9cb2b868ddb82a106c20cb..2d32ce846db95f3ec33f1b0eeb16d6769fc3918c 100644 (file)
@@ -24,8 +24,8 @@ import org.eclipse.ui.commands.ICommandService;
 import org.eclipse.ui.commands.IElementUpdater;\r
 import org.eclipse.ui.handlers.HandlerUtil;\r
 import org.eclipse.ui.menus.UIElement;\r
+import org.simantics.jfreechart.ChartPanel;\r
 import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.trend.ChartPanel;\r
 \r
 /**\r
  * This handler changes the orientation of a {@link ChartPanel}\r
index fa40108a6d40419233f43314ad8dcbbbc65849d0..a4de67b02389c3e9b1613f5ed8f0b7fa835a066f 100644 (file)
@@ -30,6 +30,14 @@ import org.simantics.db.exception.ServiceException;
 import org.simantics.db.layer0.request.PossibleActiveVariableFromVariable;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.jfreechart.chart.properties.ChartTab;\r
+import org.simantics.jfreechart.chart.properties.bar.BarAxisTab;\r
+import org.simantics.jfreechart.chart.properties.bar.BarGeneralPropertiesTab;\r
+import org.simantics.jfreechart.chart.properties.bar.BarSeriesTab;\r
+import org.simantics.jfreechart.chart.properties.pie.PieGeneralPropertiesTab;\r
+import org.simantics.jfreechart.chart.properties.pie.PieSeriesTab;\r
+import org.simantics.jfreechart.chart.properties.xyline.XYLineAxisAndVariablesTab;\r
+import org.simantics.jfreechart.chart.properties.xyline.XYLineGeneralPropertiesTab;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ModelingResources;\r
 import org.simantics.modeling.ui.property.svg.SVGElementComposite;\r
@@ -39,14 +47,6 @@ 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.ChartTab;\r
-import org.simantics.sysdyn.ui.trend.chart.properties.bar.BarAxisTab;\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.selection.AnyVariable;\r
 import org.simantics.ui.selection.WorkbenchSelectionElement;\r
 import org.simantics.utils.ui.AdaptionUtils;\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/AllVariablesOfModel.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/AllVariablesOfModel.java
new file mode 100644 (file)
index 0000000..18da4cb
--- /dev/null
@@ -0,0 +1,100 @@
+package org.simantics.sysdyn.ui.trend;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\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.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.jfreechart.chart.properties.IAllVariablesOfModel;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.strings.AlphanumComparator;\r
+\r
+/**\r
+ * Request for getting all variables of a model in a String array. Includes also \r
+ * variables inside modules.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class AllVariablesOfModel implements IAllVariablesOfModel{\r
+    \r
+    private Resource model;\r
+    \r
+    public AllVariablesOfModel(Resource model) {\r
+        this.model = model;\r
+    }\r
+\r
+    @Override\r
+    public String[] perform(ReadGraph graph) throws DatabaseException {\r
+        Layer0 l0 = Layer0.getInstance(graph);\r
+        SimulationResource simu = SimulationResource.getInstance(graph);\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        \r
+        // Find the model of this resource\r
+        Resource model = this.model;\r
+        while(model != null && !graph.isInstanceOf(model, sr.SysdynModel))\r
+            model = graph.getPossibleObject(model, l0.PartOf);\r
+        \r
+        if(model == null)\r
+            return new String[0];\r
+        \r
+        // Find the models configuration\r
+        Resource conf = graph.getSingleObject(model, simu.HasConfiguration);\r
+        List<String> items = new ArrayList<String>();\r
+        \r
+        // Recursively read all configurations and add items\r
+        ReadConfiguration(graph, conf, "", items);\r
+        \r
+        // Add time to the variable list\r
+        items.add("time");\r
+        \r
+        // Finally sort the results\r
+        Collections.sort(items, AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);\r
+        return items.toArray(new String[items.size()]);\r
+    }\r
+    \r
+    /**\r
+     * Read components in a configuration and recursively all module configurations\r
+     * \r
+     * @param graph ReadGraph\r
+     * @param configuration Resource to be read\r
+     * @param path Current path from base realization\r
+     * @param items Found variables\r
+     * @throws DatabaseException\r
+     */\r
+    private void ReadConfiguration(ReadGraph graph, Resource configuration, String path, Collection<String> items) throws DatabaseException {\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        Layer0 l0 = Layer0.getInstance(graph);\r
+        StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+\r
+        String name;\r
+        for(Resource resource : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.IndependentVariable))) {\r
+            name = path + NameUtils.getSafeName(graph, resource);\r
+            items.add(name);\r
+        }\r
+        \r
+        for(Resource resource : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Input))) {\r
+            name = path + NameUtils.getSafeName(graph, resource);\r
+            items.add(name);\r
+        }\r
+\r
+        for(Resource module : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Module))) {\r
+            Resource instanceOf = graph.getPossibleObject(module, l0.InstanceOf);\r
+            Resource conf = graph.getPossibleObject(instanceOf, sr2.IsDefinedBy);\r
+            if(conf != null) {\r
+                String p = path + NameUtils.getSafeName(graph, module)  + ".";\r
+                ReadConfiguration(graph, conf, p, items);\r
+            }\r
+        }\r
+    }\r
+\r
+}\r
+\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/CategoryDataset.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/CategoryDataset.java
new file mode 100644 (file)
index 0000000..d4c021c
--- /dev/null
@@ -0,0 +1,314 @@
+/*******************************************************************************\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;\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.jfreechart.chart.AbstractDataset;\r
+import org.simantics.jfreechart.chart.IRenderer;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.operation.Layer0X;\r
+import org.simantics.sysdyn.Functions;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.adapter.VariableRVIUtils;\r
+import org.simantics.sysdyn.manager.SysdynDataSet;\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 implements org.simantics.jfreechart.chart.CategoryDataset{\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() || SimanticsUI.getSession() == null)\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
+                                // Get values\r
+                                Variable dsVariable = v.browsePossible(graph, "#" + Functions.ACTIVE_DATASETS + "#");\r
+                                if(dsVariable == null)\r
+                                       return series;\r
+                                \r
+                                Object object = dsVariable.getValue(graph);\r
+                                \r
+                                if(object == null || !(object instanceof ArrayList<?>))\r
+                                    return series;\r
+\r
+                                ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
+\r
+                                for(Object o : (ArrayList<?>)object) {\r
+                                    if(o instanceof SysdynDataSet)\r
+                                        datasets.add((SysdynDataSet)o);\r
+                                }\r
+\r
+                                String[] filter = graph.getPossibleRelatedValue(r, jfree.variableFilter);\r
+                                if(filter != null) {\r
+                                    ArrayList<SysdynDataSet> result2 = VariableRVIUtils.getDataset(datasets, filter);\r
+                                    if(result2 != null) {\r
+                                        datasets = result2;\r
+                                    }\r
+                                }\r
+\r
+                                // Find if a specific time is set for this chart\r
+                                Double chartTime = null;\r
+                                if(!datasets.isEmpty()) {\r
+                                    Layer0 l0 = Layer0.getInstance(graph);\r
+                                    Resource datasetResource = graph.getPossibleObject(r, l0.PartOf);\r
+                                    if(datasetResource != null) {\r
+                                        Resource plot = graph.getPossibleObject(datasetResource, l0.PartOf);\r
+                                        if(plot != null) {\r
+                                            Resource chart = graph.getPossibleObject(plot, l0.PartOf);\r
+                                            if(chart != null)\r
+                                                chartTime = graph.getPossibleRelatedValue(chart, jfree.Chart_time);\r
+                                        }\r
+                                    }\r
+                                }\r
+\r
+                                for(SysdynDataSet dataset : datasets) {\r
+                                    double[] va = dataset.values;\r
+\r
+\r
+                                    if(va == null || va.length == 0)\r
+                                        continue;\r
+\r
+                                    /*\r
+                                     *  Time\r
+                                     *  \r
+                                     *  1. find time for the individual series.\r
+                                     *  2. find time for the whole chart\r
+                                     *  3. find simulation time\r
+                                     */\r
+                                    Double time = graph.getPossibleRelatedValue(r, jfree.Series_time, Bindings.DOUBLE);\r
+                                    if(time == null)\r
+                                        time = chartTime;\r
+                                    if(time == null) {\r
+                                        // Get a variable for the experiment run\r
+                                        Variable run = Variables.getVariable(graph, realizationURI);\r
+                                        if(run == null)\r
+                                            return null;\r
+                                        Variable timeVar = run.browsePossible(graph, "#" + Functions.TIME + "#");\r
+                                        if(timeVar != null)\r
+                                            time = timeVar.getValue(graph, Bindings.DOUBLE);\r
+            \r
+                                    }\r
+\r
+                                    // Value\r
+                                    Double value = null;\r
+                                    if(time == null) {\r
+                                        value = va[va.length - 1];\r
+                                    } else {\r
+                                        double[] ta = dataset.times;\r
+                                        for(int i = 0; i < ta.length; i++) {\r
+                                            double t = ta[i];\r
+                                            if(time <= t) {\r
+                                                value = va[i]; \r
+                                                break;\r
+                                            }\r
+                                        }\r
+\r
+                                        if(value == null)\r
+                                            value = va[va.length - 1];\r
+                                    }\r
+                                    String label = graph.getPossibleRelatedValue(r, Layer0.getInstance(graph).HasLabel); // Called to refresh paints when label changes\r
+                                    String name = dataset.name;\r
+                                    series.add(new TempSeries(label == null || label.isEmpty() ? name : label, dataset.result, value));\r
+                                }\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
+    @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
+                    // Remove all unused series\r
+                    dataset.clear();\r
+                    BarRenderer renderer = ((BarRenderer)getRenderer());\r
+                    renderer.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
+                        if(renderer instanceof org.jfree.chart.renderer.category.StackedBarRenderer && s.name.contains("[")) {\r
+                            String category = s.name.substring(0, s.name.indexOf('['));\r
+                            if(s.result != null)\r
+                                category = category + " : " + s.result;\r
+                            String series = s.name.substring(s.name.indexOf('['));\r
+                            dataset.addValue(s.value, series, category);\r
+                        } else {\r
+                            dataset.addValue(s.value, s.result == null ? "Current" : s.result, s.name);\r
+                        }\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 result;\r
+        public Double value;\r
+\r
+        public TempSeries(String name, String result, Double value) {\r
+            this.name = name;\r
+            this.value = value;\r
+            this.result = result;\r
+        }\r
+\r
+        @Override\r
+        public String toString() {\r
+            return "TempSeries: " + name + ", " + value + ", " + result;\r
+        }\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/PieDataset.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/PieDataset.java
new file mode 100644 (file)
index 0000000..eb3d1cb
--- /dev/null
@@ -0,0 +1,332 @@
+/*******************************************************************************\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;\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.jfreechart.chart.AbstractDataset;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.operation.Layer0X;\r
+import org.simantics.sysdyn.Functions;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.adapter.VariableRVIUtils;\r
+import org.simantics.sysdyn.manager.SysdynDataSet;\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 implements org.simantics.jfreechart.chart.PieDataset{\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
+        } 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() ||  SimanticsUI.getSession() == null)\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
+\r
+                        colorMap = new HashMap<String, Color>();\r
+                        explodedMap = new HashMap<String, Boolean>();\r
+\r
+                        for(Resource r : seriesList) {\r
+                            String label = graph.getPossibleRelatedValue(r, Layer0.getInstance(graph).HasLabel);\r
+                            String rvi = graph.getPossibleRelatedValue(r, jfree.variableRVI);\r
+                            if(rvi == null)\r
+                                continue;\r
+\r
+                            try {\r
+                                // Get visual properties\r
+                                Resource c = graph.getPossibleObject(r, jfree.color);\r
+                                Color color = c == null ? null : G2DUtils.getColor(graph, c);\r
+                                Boolean exploded = graph.getPossibleRelatedValue(r, jfree.Series_exploded, Bindings.BOOLEAN);\r
+\r
+                                // Get a variable for the series\r
+                                Variable v = Variables.getVariable(graph, realizationURI + rvi);\r
+\r
+                                // Get values\r
+                                Variable dsVariable = v.browsePossible(graph, "#" + Functions.ACTIVE_DATASETS + "#");\r
+                                if(dsVariable == null)\r
+                                       return series;\r
+                                \r
+                                Object object = dsVariable.getValue(graph);\r
+                                if(object == null || !(object instanceof ArrayList<?>))\r
+                                    return series;\r
+\r
+                                ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
+\r
+                                for(Object o : (ArrayList<?>)object) {\r
+                                    if(o instanceof SysdynDataSet)\r
+                                        datasets.add((SysdynDataSet)o);\r
+                                }\r
+\r
+                                String[] filter = graph.getPossibleRelatedValue(r, jfree.variableFilter);\r
+                                if(filter != null) {\r
+                                    ArrayList<SysdynDataSet> result2 = VariableRVIUtils.getDataset(datasets, filter);\r
+                                    if(result2 != null) {\r
+                                        datasets = result2;\r
+                                    }\r
+                                }\r
+\r
+                                // Find if a specific time is set for this chart\r
+                                Double chartTime = null;\r
+                                if(!datasets.isEmpty()) {\r
+                                    Layer0 l0 = Layer0.getInstance(graph);\r
+                                    Resource datasetResource = graph.getPossibleObject(r, l0.PartOf);\r
+                                    if(datasetResource != null) {\r
+                                        Resource plot = graph.getPossibleObject(datasetResource, l0.PartOf);\r
+                                        if(plot != null) {\r
+                                            Resource chart = graph.getPossibleObject(plot, l0.PartOf);\r
+                                            if(chart != null)\r
+                                                chartTime = graph.getPossibleRelatedValue(chart, jfree.Chart_time);\r
+                                        }\r
+                                    }\r
+                                }\r
+                                \r
+                                for(SysdynDataSet dataset : datasets) {\r
+                                    double[] va = dataset.values;\r
+\r
+                                    if(va == null || va.length == 0)\r
+                                        continue;\r
+\r
+                                    /*\r
+                                     *  Time\r
+                                     *  \r
+                                     *  1. find time for the individual series.\r
+                                     *  2. find time for the whole chart\r
+                                     *  3. find simulation time\r
+                                     */\r
+                                    Double time = graph.getPossibleRelatedValue(r, jfree.Series_time, Bindings.DOUBLE);\r
+                                    if(time == null)\r
+                                        time = chartTime;\r
+                                    if(time == null) {\r
+                                        // Get a variable for the experiment run\r
+                                        Variable run = Variables.getVariable(graph, realizationURI);\r
+                                        if(run == null)\r
+                                            return null;\r
+                                        Variable timeVar = run.browsePossible(graph, "#" + Functions.TIME + "#");\r
+                                        if(timeVar != null)\r
+                                            time =  timeVar.getValue(graph, Bindings.DOUBLE);\r
+                                    }\r
+                                    \r
+                                    // Value\r
+                                    Double value = null;\r
+                                    if(time == null) {\r
+                                        value = va[va.length - 1];\r
+                                    } else {\r
+                                        double[] ta = dataset.times;\r
+                                        for(int i = 0; i < ta.length; i++) {\r
+                                            double t = ta[i];\r
+                                            if(time <= t) {\r
+                                                value = va[i]; \r
+                                                break;\r
+                                            }\r
+                                        }\r
+\r
+                                        if(value == null)\r
+                                            value = va[va.length - 1];\r
+                                    }\r
+\r
+                                    String name = label == null || label.isEmpty() ? dataset.name : label;\r
+                                    if(dataset.result != null)\r
+                                        name = name + " : " + dataset.result; \r
+                                    colorMap.put(name, color);\r
+                                    explodedMap.put(name, exploded);\r
+                                    series.add(new TempSeries(name, value));\r
+                                }\r
+                            } catch (MissingVariableException e) {\r
+                                // Do nothing, if variable was not found. Move on to the next series\r
+                            }\r
+                        }\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/SysdynRangeHandlerFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SysdynRangeHandlerFactory.java
new file mode 100644 (file)
index 0000000..74bbee0
--- /dev/null
@@ -0,0 +1,141 @@
+package org.simantics.sysdyn.ui.trend;\r
+\r
+import java.util.HashMap;\r
+import java.util.LinkedHashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\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.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.jfreechart.chart.ChartUtils;\r
+import org.simantics.jfreechart.chart.properties.RangeHandlerFactory;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.datastructures.Quad;\r
+\r
+public class SysdynRangeHandlerFactory implements RangeHandlerFactory {\r
+       \r
+       @Override\r
+       public Read<LinkedHashMap<String, Resource>> getRequest(final Resource series) {\r
+               // TODO Auto-generated method stub\r
+               return new Read<LinkedHashMap<String, Resource>>() {\r
+\r
+            @Override\r
+            public LinkedHashMap<String, Resource> perform(ReadGraph graph) throws DatabaseException {\r
+                JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+                SysdynResource sr = SysdynResource.getInstance(graph);\r
+\r
+                String realizationURI = ChartUtils.getCurrentRealizationURI(graph, series);\r
+                String rvi = graph.getPossibleRelatedValue(series, jfree.variableRVI);\r
+                if(rvi == null)\r
+                    return null;\r
+                \r
+                try {\r
+                    // Find the variable for the current variableRVI\r
+                    Variable v = Variables.getVariable(graph, realizationURI + rvi.trim());\r
+                    if(v == null)\r
+                        return null;\r
+                    \r
+                    // Find all enumeration replacements in the variable's path\r
+                    HashMap<Resource, Resource> redeclarations = new HashMap<Resource, Resource>();\r
+                    Variable parent = v;\r
+                    while((parent = parent.getParent(graph)) != null) {\r
+                       Resource represents = parent.getRepresents(graph);\r
+                       Resource type = graph.getSingleObject(represents, Layer0.getInstance(graph).InstanceOf);\r
+                       if(!graph.isInheritedFrom(type, sr.Module))\r
+                               break;\r
+                       \r
+                       for(Resource redeclaration : graph.getObjects(represents, sr.Module_redeclaration)) {\r
+                               redeclarations.put(\r
+                                               graph.getPossibleObject(redeclaration, sr.Redeclaration_replacedEnumeration), \r
+                                               graph.getPossibleObject(redeclaration, sr.Redeclaration_replacingEnumeration)\r
+                                               );\r
+                       }\r
+                    }\r
+                    \r
+                    \r
+                    \r
+                    \r
+                    Resource variable = v.getRepresents(graph);\r
+                    \r
+                    // Return the enumerations assigned to that variable\r
+                    Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList);\r
+                    if(arrayIndexes != null) {\r
+                        LinkedHashMap<String, Resource> result = new LinkedHashMap<String, Resource>();\r
+                        for(Resource enumeration : ListUtils.toList(graph, arrayIndexes)) {\r
+                               \r
+                               // Find possible redeclarations for enumeration\r
+                               Resource redeclaration = enumeration;\r
+                               while(redeclarations.get(redeclaration) != null)\r
+                                       redeclaration = redeclarations.get(redeclaration);\r
+                               \r
+                            String enumerationName = NameUtils.getSafeName(graph, redeclaration);\r
+                            result.put(enumerationName, redeclaration);\r
+                        }\r
+                        return result;\r
+                    }\r
+                } catch (DatabaseException e) {\r
+                    // No variable was found, return null\r
+                }\r
+                return null;\r
+            }\r
+\r
+        };\r
+       }\r
+       \r
+       @Override\r
+       public ReadFactoryImpl<Resource, Map<String, Object>> getRangeItemFactory(int index, Resource res) {\r
+               return new RangeItemFactory(index, res);\r
+       }\r
+       \r
+       \r
+    /**\r
+     * RangeItemFactory finds all inexes of a given enumeration \r
+     * and adds "Sum" and "All" to the returned indexes\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class RangeItemFactory extends ReadFactoryImpl<Resource, Map<String, Object>> {\r
+\r
+        private int index;\r
+        private Resource enumeration;\r
+\r
+        /**\r
+         * \r
+         * @param index Index of the enumeration in the variable\r
+         * @param enumeration The enumeration\r
+         */\r
+        public RangeItemFactory(int index, Resource enumeration) {\r
+            this.index = index;\r
+            this.enumeration = enumeration;\r
+        }\r
+\r
+        public Object getIdentity(Object inputContents) {\r
+            return new Quad<Object, Integer, Resource, Class<?>>(inputContents, index, enumeration, getClass());\r
+        }\r
+        @Override\r
+        public Map<String, Object> perform(ReadGraph graph, Resource series) throws DatabaseException {\r
+            SysdynResource sr = SysdynResource.getInstance(graph);\r
+            LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>();\r
+            Resource enumerationIndexes = graph.getPossibleObject(enumeration, sr.Enumeration_enumerationIndexList);\r
+            List<Resource> indexes = ListUtils.toList(graph, enumerationIndexes);\r
+            // First add "All" and "Sum", then all of the enumeration indexes in order\r
+            result.put("All", "All");\r
+            result.put("Sum", "Sum");\r
+            for(Resource index : indexes) {\r
+                String name = NameUtils.getSafeName(graph, index);\r
+                result.put(name, name);\r
+            }\r
+            return result;\r
+        }\r
+    }\r
+\r
+}\r
index e730e1fb429b0a4f3555dcdd589d9da4e64b3c55..83bcc56da4fb99cecbadea02f09044027c7b9a7e 100644 (file)
@@ -31,8 +31,8 @@ import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
+import org.simantics.jfreechart.chart.IJFreeChart;\r
 import org.simantics.sysdyn.manager.SysdynDataSet;\r
-import org.simantics.sysdyn.ui.trend.chart.IJFreeChart;\r
 import org.simantics.sysdyn.ui.viewUtils.SysdynDatasetSelectionListener;\r
 \r
 /**\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/XYDataset.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/XYDataset.java
new file mode 100644 (file)
index 0000000..363669c
--- /dev/null
@@ -0,0 +1,503 @@
+/*******************************************************************************\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;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Paint;\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.ChartColor;\r
+import org.jfree.chart.labels.StandardXYToolTipGenerator;\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
+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.jfreechart.chart.AbstractDataset;\r
+import org.simantics.jfreechart.chart.IRenderer;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.operation.Layer0X;\r
+import org.simantics.sysdyn.Functions;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+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
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class XYDataset extends AbstractDataset implements org.simantics.jfreechart.chart.XYDataset{\r
+\r
+    private IRenderer renderer;\r
+\r
+    public XYDataset(ReadGraph graph, final Resource datasetResource) {\r
+        super(graph, datasetResource);\r
+    }\r
+\r
+    private DefaultXYDataset dataset;\r
+    private DataSetListener datasetListener;\r
+    private TimeListener timeListener;\r
+\r
+    @Override\r
+    public Dataset getDataset() {\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<Pair<ArrayList<TempSeries>, IRenderer>>() {\r
+\r
+                @Override\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 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
+                    Resource domainAxis = graph.getPossibleObject(resource, jfree.Dataset_mapToDomainAxis);\r
+                    if(domainAxis != null) {\r
+                        String rvi = graph.getPossibleRelatedValue(domainAxis, jfree.variableRVI);\r
+                        if(rvi != null && !rvi.isEmpty()) {\r
+                            try {\r
+                                Variable domainVariable = Variables.getVariable(graph, realizationURI + rvi);\r
+                                Variable valuesVariable = domainVariable.browsePossible(graph, "#" + Functions.VALUES +"#");\r
+                                if(valuesVariable != null) {\r
+                                       double[][] valuesArray = valuesVariable.getValue(graph);\r
+                                       if(valuesArray.length > 0)\r
+                                               domainValues = valuesArray[0];\r
+                                }\r
+                            } catch(MissingVariableException e) {\r
+                                //Do nothing, use time as domain axis\r
+                            }\r
+                        }\r
+                    }\r
+\r
+                    Resource seriesList = graph.getPossibleObject(resource, jfree.Dataset_seriesList);\r
+\r
+                    // Get properties for all series\r
+                    if(seriesList != null) {\r
+                        for(Resource r : ListUtils.toList(graph, seriesList)) {\r
+                            String rvi = graph.getPossibleRelatedValue(r, jfree.variableRVI);\r
+                            if(rvi == null)\r
+                                continue;\r
+\r
+                            try {\r
+                                // Get visual properties\r
+                                Integer width = graph.getPossibleRelatedValue(r, jfree.Series_lineWidth, Bindings.INTEGER);\r
+                                if(width == null) width = 1;\r
+\r
+                                Resource c = graph.getPossibleObject(r, jfree.color);\r
+                                Color color = c == null ? null : G2DUtils.getColor(graph, c);\r
+                                \r
+                                String label = graph.getPossibleRelatedValue(r, Layer0.getInstance(graph).HasLabel);\r
+\r
+                                // Get a variable for the series\r
+                                Variable v = Variables.getVariable(graph, realizationURI + rvi);\r
+                                if(v == null)\r
+                                    return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
+\r
+                                // Get values\r
+                                Variable dsVariable = v.browsePossible(graph, "#" + Functions.ACTIVE_DATASETS + "#");\r
+                                Object object = null;\r
+                                if(dsVariable != null)\r
+                                        object = dsVariable.getValue(graph);\r
+\r
+                                if(object == null || !(object instanceof ArrayList<?>))\r
+                                    return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
+\r
+                                ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
+\r
+                                for(Object o : (ArrayList<?>)object) {\r
+                                    if(o instanceof SysdynDataSet)\r
+                                        datasets.add((SysdynDataSet)o);\r
+                                }\r
+\r
+\r
+                                String[] filter = graph.getPossibleRelatedValue(r, jfree.variableFilter);\r
+                                if(filter != null) {\r
+                                    ArrayList<SysdynDataSet> result2 = VariableRVIUtils.getDataset(datasets, filter);\r
+                                    if(result2 != null) {\r
+                                        datasets = result2;\r
+                                    }\r
+                                }\r
+\r
+                                for(SysdynDataSet dataset : datasets) {\r
+                                    double[] va = dataset.values;\r
+\r
+                                    // Get domain axis values (time OR other variable) \r
+                                    double[] ta;\r
+                                    if(domainValues != null) {\r
+                                        ta = domainValues;\r
+\r
+                                        // If domainAxis is other than time, parameter values size is different. \r
+                                        if(domainValues.length > va.length) {\r
+                                            double value = va[0];\r
+                                            va = new double[domainValues.length];\r
+                                            for(int i = 0; i < domainValues.length; i++)\r
+                                                va[i] = value;\r
+                                        }\r
+\r
+                                        // If domainAxis is a parameter, the domainValues array is too short\r
+                                        if(domainValues.length < va.length && domainValues.length == 2 && domainValues[0] == domainValues[1]) {\r
+                                            double value = domainValues[0];\r
+                                            ta = new double[va.length];\r
+                                            for(int i = 0; i < va.length; i++)\r
+                                                ta[i] = value;\r
+                                        }\r
+\r
+                                    } else {\r
+                                        ta = dataset.times;\r
+                                    }\r
+\r
+                                    if(ta!=null && va!=null && (va.length == ta.length)) {\r
+                                        // Add series if everything OK\r
+                                        String name = dataset.name;\r
+                                        if(label != null)\r
+                                            name = label;\r
+                                        if(dataset.result != null && !dataset.result.isEmpty())\r
+                                            name = name + " : " + dataset.result;\r
+                                        series.add(new TempSeries(name, new double[][] {ta, va}, width, color));\r
+                                        if(ta.length == 0 || va.length == 0)\r
+                                            System.out.println(dataset.name + " : " + dataset.result + ". Sizes: " + va.length + " and " + ta.length);\r
+                                    }\r
+                                }\r
+\r
+                            } catch (MissingVariableException e) {\r
+                                // Do nothing, if variable was not found. Move on to the next series\r
+                            }\r
+                        }\r
+                    }\r
+                    return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
+                }\r
+\r
+            }, datasetListener); \r
+        }\r
+\r
+        if(timeListener == null || timeListener.isDisposed()) {\r
+            timeListener = new TimeListener();\r
+            SimanticsUI.getSession().asyncRequest(new Read<Double>() {\r
+                @Override\r
+                public Double perform(ReadGraph graph) throws DatabaseException {\r
+                    JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+                    // Get properties for all series\r
+                    Resource series = graph.getPossibleObject(resource, jfree.Dataset_seriesList);\r
+                    if(series != null) {\r
+                        List<Resource> seriesList = ListUtils.toList(graph, series);\r
+                        if(seriesList != null) {\r
+                            String realizationURI = getRealizationURI(graph);\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 experiment run\r
+                                       Variable v = Variables.getVariable(graph, realizationURI);\r
+                                       if(v == null)\r
+                                               return null;\r
+                                       Variable timeVar = v.browsePossible(graph, "#" + Functions.TIME + "#");\r
+                                       if(timeVar != null)\r
+                                           return timeVar.getValue(graph, Bindings.DOUBLE);\r
+                                } catch (MissingVariableException e) {\r
+                                       // Do nothing, if variable was not found.\r
+                                }\r
+                            }\r
+                        }\r
+                    }\r
+                    return null;\r
+                }\r
+\r
+            }, timeListener);\r
+        }\r
+        return dataset;\r
+    }\r
+\r
+    /**\r
+     * Class for identifying a time marker in a plot\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class TimeMarker extends ValueMarker {\r
+        private static final long serialVersionUID = 2018755066561629172L;\r
+\r
+        public TimeMarker(double value, Paint paint, Stroke stroke) {\r
+            super(value, paint, stroke);\r
+        }\r
+    }\r
+\r
+    private class DataSetListener implements Listener<Pair<ArrayList<TempSeries>, IRenderer>> {\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(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
+                    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
+                    }\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
+    /**\r
+     * Listener for updating the time indicator for XY plots\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class TimeListener implements Listener<Double> {\r
+\r
+        private ValueMarker marker;\r
+        private boolean disposed = false;\r
+        private 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
+\r
+        public TimeListener() {\r
+            this.marker = new TimeMarker(0.0, Color.red, dashStroke);\r
+        }\r
+\r
+        public void dispose() {\r
+            this.disposed = true;\r
+            if(marker != null) {\r
+                org.jfree.chart.plot.XYPlot plot = ((AbstractXYItemRenderer)getRenderer()).getPlot();\r
+                if(plot != null)\r
+                    plot.removeDomainMarker(marker);\r
+            }\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
+                    if(plot == null)\r
+                        return;\r
+\r
+                    plot.removeDomainMarker(marker);\r
+                    if(time != null) {\r
+                        marker.setValue(time);\r
+                        if(plot.getDomainMarkers(Layer.FOREGROUND) == null || !plot.getDomainMarkers(Layer.FOREGROUND).contains(marker)) {\r
+                            int i = 0;\r
+                            for(i = 0; i < plot.getDatasetCount(); i++) {\r
+                                if(plot.getDataset(i) != null && plot.getDataset(i).equals(dataset))\r
+                                    break;\r
+                            }\r
+                            plot.addDomainMarker(i, marker, Layer.FOREGROUND);\r
+                        }\r
+                    }\r
+\r
+                }\r
+            });\r
+        }\r
+\r
+        @Override\r
+        public void exception(Throwable t) {\r
+            t.printStackTrace();\r
+        }\r
+\r
+    }\r
+\r
+    @Override\r
+    public void dispose() {\r
+        if(timeListener != null) {\r
+            timeListener.dispose();\r
+            timeListener = null;\r
+        }\r
+\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
+     *\r
+     */\r
+    private class TempSeries {\r
+        public double[][] values;\r
+        public String name;\r
+        public int width;\r
+        public Color color;\r
+\r
+        public TempSeries(String name, double[][] values, int width, Color color) {\r
+            this.name = name;\r
+            this.values = values;\r
+            this.width = width;\r
+            this.color = color;\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public AbstractRenderer getRenderer() {\r
+        if(renderer == null) {\r
+\r
+            try {\r
+                renderer = SimanticsUI.getSession().syncRequest(new Read<IRenderer>() {\r
+\r
+                    @Override\r
+                    public IRenderer perform(ReadGraph graph) throws DatabaseException {\r
+                        JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\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
+                        return renderer;\r
+                    }\r
+                });\r
+            } catch (DatabaseException e) {\r
+            }\r
+            if(renderer == null) {\r
+                XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);\r
+                renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());\r
+                return renderer;\r
+            } else {\r
+                return renderer.getRenderer();\r
+            }\r
+        } else {\r
+            return renderer.getRenderer();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Get the realization uri of the current dataset resource\r
+     * @param graph ReadGraph\r
+     * @return realization uri for current dataset resource\r
+     * @throws DatabaseException\r
+     */\r
+    private String getRealizationURI(ReadGraph graph) throws DatabaseException {\r
+        if(resource == null)\r
+            return null;\r
+\r
+        Layer0 l0 = Layer0.getInstance(graph);\r
+        ModelingResources mr = ModelingResources.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
+        if(model == null)\r
+            return null;\r
+\r
+        // Find the variable realization of the current experiment\r
+        String realizationURI = null;\r
+        Resource realization = graph.syncRequest(new PossibleActiveExperiment(model));\r
+        if (realization == null) {\r
+            Layer0X L0X = Layer0X.getInstance(graph);\r
+            realization = graph.getPossibleObject(model, L0X.HasBaseRealization);\r
+        }\r
+        if (realization != null)\r
+            realizationURI = graph.getURI(realization);\r
+\r
+        return realizationURI;\r
+    }\r
+}\r
index 7c70aedba19c97495fc4933c885977416b3d746c..6d9d5612cec84f77f2a0c71c793117e32e0478a4 100644 (file)
@@ -3,15 +3,12 @@
 \r
 <product name="Simantics System Dynamic Tool" uid="org.simantics.sysdyn.product.Sysdyn" id="org.simantics.sysdyn.ui.product" application="org.simantics.workbench.application" version="1.8" useFeatures="true" includeLaunchers="false">\r
 \r
-\r
    <configIni use="default">\r
    </configIni>\r
 \r
    <launcherArgs>\r
-      <programArgs>-fixerrors
---launcher.XXMaxPermSize
-192m
--data @noDefault</programArgs>\r
+      <programArgs>-fixerrors\r
+--launcher.XXMaxPermSize 192m</programArgs>\r
       <vmArgs>-ea  -Xmx768M -XX:MaxPermSize=192m -Xshare:off</vmArgs>\r
       <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>\r
    </launcherArgs>\r
@@ -27,7 +24,6 @@
       </win>\r
    </launcher>\r
 \r
-\r
    <vm>\r
       <windows include="true">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6</windows>\r
    </vm>\r