]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Improved the sensitivity analysis property view so that the buttons and are shown...
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 2 Jul 2013 05:18:22 +0000 (05:18 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 2 Jul 2013 05:18:22 +0000 (05:18 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27671 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.jfreechart/src/org/simantics/jfreechart/chart/ChartUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSensitivityAnalysisExperimentNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/sensitivity/NormalDistributionProperties.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/SensitivityExperimentParameter.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynSensitivityAnalysisExperiment.java

index ae9a23c41a1b2c3669c54d89c9f74515166d6542..78b36e6289d0874e833c4c515fd70ce94cadcbf6 100644 (file)
@@ -32,10 +32,13 @@ import org.w3c.dom.Document;
  * Utilities for handling charts\r
  * \r
  * @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
  *\r
  */\r
 public class ChartUtils {\r
     \r
+       public static final String emptyVariableName = "<Write variable name>";\r
+\r
     /**\r
      * Creates a new range axis of type jfree.NumberAxis to a plot\r
      * \r
@@ -116,7 +119,7 @@ public class ChartUtils {
         // Create series\r
         Resource series = GraphUtils.create2(graph, jfree.Series,\r
                 l0.HasName, "Series" + UUID.randomUUID().toString(),\r
-                jfree.variableRVI, rvi == null ? " <Write variable name>" : rvi,\r
+                jfree.variableRVI, rvi == null ? " " + emptyVariableName : rvi,\r
                 l0.PartOf, dataset);\r
 \r
         // Add series to the dataset's series list\r
index ac823f5b73180eac831121520402c56c9e5d7c1b..05f5300293e9bb19141a8ed4e2f985f4feced5d1 100644 (file)
@@ -18,6 +18,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.jfreechart.chart.ChartUtils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -41,7 +42,7 @@ public class NewSensitivityAnalysisExperimentNodeHandler extends NewExperimentNo
         \r
         Resource parameter = GraphUtils.create2(graph, sr.SensitivityAnalysisExperiment_Parameter,\r
                 sr.SensitivityAnalysisExperiment_Parameter_propabilityDistribution, distribution,\r
-                sr.SensitivityAnalysisExperiment_Parameter_variable, "<Write variable name>",\r
+                sr.SensitivityAnalysisExperiment_Parameter_variable, ChartUtils.emptyVariableName,\r
                 L0.PartOf, experiment);\r
         \r
         ArrayList<Resource> parameterList = new ArrayList<Resource>();\r
index ae039710818a31b2b00aaae5d94b6b8b6846b545..12d743f84a322561977ab7d722c8759a2d0cffd6 100644 (file)
@@ -68,6 +68,7 @@ import org.simantics.db.common.utils.ListUtils;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.db.request.Read;\r
+import org.simantics.jfreechart.chart.ChartUtils;\r
 import org.simantics.jfreechart.chart.properties.RangeComposite;\r
 import org.simantics.jfreechart.chart.properties.xyline.AxisAndVariablesExplorerComposite;\r
 import org.simantics.layer0.Layer0;\r
@@ -224,6 +225,60 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo
         \r
         GridDataFactory.fillDefaults().hint(250, SWT.DEFAULT).grab(false, true).applyTo(explorer);\r
 \r
+        Composite buttonComposite = new Composite(explorer, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(buttonComposite);\r
+        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite);\r
+        \r
+        Button addVariable = new Button(buttonComposite, support, SWT.NONE);\r
+        addVariable.setText("Add parameter");\r
+        addVariable.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+            @Override\r
+            public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+                SysdynResource sr = SysdynResource.getInstance(graph);\r
+                Layer0 L0 = Layer0.getInstance(graph);\r
+                \r
+                Resource distribution = GraphUtils.create2(graph, sr.UniformDistribution,\r
+                        sr.UniformDistribution_minValue, 0.0,\r
+                        sr.UniformDistribution_maxValue, 10.0);\r
+                \r
+                Resource parameter = GraphUtils.create2(graph, sr.SensitivityAnalysisExperiment_Parameter,\r
+                        sr.SensitivityAnalysisExperiment_Parameter_propabilityDistribution, distribution,\r
+                        sr.SensitivityAnalysisExperiment_Parameter_variable, ChartUtils.emptyVariableName,\r
+                        L0.PartOf, input);\r
+                \r
+                Resource parameterList = graph.getPossibleObject(input, sr.SensitivityAnalysisExperiment_parameterList);\r
+                ListUtils.insertBack(graph, parameterList, Collections.singleton(parameter));\r
+            }\r
+        });\r
+\r
+        remove = new Button(buttonComposite, parameterSupport, SWT.NONE);\r
+        remove.setText("Remove");\r
+        remove.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+            @Override\r
+            public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+                if(input == null)\r
+                    return;\r
+                \r
+                SysdynResource sr = SysdynResource.getInstance(graph);\r
+                Layer0 L0 = Layer0.getInstance(graph);\r
+                \r
+                Resource experiment = graph.getPossibleObject(input, L0.PartOf);\r
+                Resource parameterList = graph.getPossibleObject(experiment, sr.SensitivityAnalysisExperiment_parameterList);\r
+                \r
+                if(ListUtils.toList(graph, parameterList).size() > 1)\r
+                    ListUtils.removeElement(graph, parameterList, input);\r
\r
+            }\r
+            \r
+        });\r
+\r
+        propertyContainer.setContent(content);\r
+        Point tsize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
+        propertyContainer.setMinSize(tsize);\r
+        \r
+        \r
         Group parameterPropertyGroup = new Group(content, SWT.NONE);\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(parameterPropertyGroup);\r
         GridLayoutFactory.fillDefaults().applyTo(parameterPropertyGroup);\r
@@ -349,62 +404,6 @@ public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributo
         DistributionPropertyWidget dpw = new DistributionPropertyWidget(parameterProperties, context, parameterSupport, SWT.NONE);\r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(dpw);\r
 \r
-        \r
-        Composite buttonComposite = new Composite(content, SWT.NONE);\r
-        GridDataFactory.fillDefaults().applyTo(buttonComposite);\r
-        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite);\r
-        \r
-        \r
-        Button addVariable = new Button(buttonComposite, support, SWT.NONE);\r
-        addVariable.setText("Add parameter");\r
-        addVariable.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
-\r
-            @Override\r
-            public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
-                SysdynResource sr = SysdynResource.getInstance(graph);\r
-                Layer0 L0 = Layer0.getInstance(graph);\r
-                \r
-                Resource distribution = GraphUtils.create2(graph, sr.UniformDistribution,\r
-                        sr.UniformDistribution_minValue, 0.0,\r
-                        sr.UniformDistribution_maxValue, 10.0);\r
-                \r
-                Resource parameter = GraphUtils.create2(graph, sr.SensitivityAnalysisExperiment_Parameter,\r
-                        sr.SensitivityAnalysisExperiment_Parameter_propabilityDistribution, distribution,\r
-                        sr.SensitivityAnalysisExperiment_Parameter_variable, "<Write variable name>",\r
-                        L0.PartOf, input);\r
-                \r
-                Resource parameterList = graph.getPossibleObject(input, sr.SensitivityAnalysisExperiment_parameterList);\r
-                ListUtils.insertBack(graph, parameterList, Collections.singleton(parameter));\r
-            }\r
-        });\r
-\r
-        remove = new Button(buttonComposite, parameterSupport, SWT.NONE);\r
-        remove.setText("Remove");\r
-        remove.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
-\r
-            @Override\r
-            public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
-                if(input == null)\r
-                    return;\r
-                \r
-                SysdynResource sr = SysdynResource.getInstance(graph);\r
-                Layer0 L0 = Layer0.getInstance(graph);\r
-                \r
-                Resource experiment = graph.getPossibleObject(input, L0.PartOf);\r
-                Resource parameterList = graph.getPossibleObject(experiment, sr.SensitivityAnalysisExperiment_parameterList);\r
-                \r
-                if(ListUtils.toList(graph, parameterList).size() > 1)\r
-                    ListUtils.removeElement(graph, parameterList, input);\r
\r
-            }\r
-            \r
-        });\r
-        \r
-\r
-        propertyContainer.setContent(content);\r
-        Point size = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
-        propertyContainer.setMinSize(size);\r
-\r
     }\r
 \r
 \r
index 20c3f76f48e82dec48802defed8facef8a8e4b76..ccb5fb2a5e064679288d3d4e4396d4b8073713f3 100644 (file)
@@ -48,12 +48,24 @@ public class NormalDistributionProperties implements IDistributionProperties {
     @Override\r
     public Composite createContent(Composite parent, ISessionContext context, WidgetSupport support) {\r
         Composite composite = new Composite(parent, SWT.NONE);\r
-        GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);\r
+        GridLayoutFactory.fillDefaults().numColumns(4).applyTo(composite);\r
         \r
-        // minValue\r
+        // mean\r
         Label label = new Label(composite, SWT.NONE);\r
+        label.setText("Mean (\u03BC)");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        \r
+        mean = new TrackedText(composite, support, SWT.BORDER);\r
+        mean.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.NormalDistribution_mean));\r
+        mean.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.NormalDistribution_mean));\r
+        mean.setInputValidator(new DoubleValidator(true));\r
+        mean.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), mean.getWidget())));\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(mean.getWidget());\r
+        \r
+        // minValue\r
+        label = new Label(composite, SWT.NONE);\r
         label.setText("Min value");\r
-        GridDataFactory.fillDefaults().applyTo(label);\r
+        GridDataFactory.fillDefaults().indent(15, 0).align(SWT.END, SWT.CENTER).applyTo(label);\r
         \r
         minValue = new TrackedText(composite, support, SWT.BORDER);\r
         minValue.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.NormalDistribution_minValue));\r
@@ -62,10 +74,22 @@ public class NormalDistributionProperties implements IDistributionProperties {
         minValue.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), minValue.getWidget())));\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(minValue.getWidget());\r
 \r
+        // stdDeviation\r
+        label = new Label(composite, SWT.NONE);\r
+        label.setText("Standard deviation (\u03C3)");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+        \r
+        stdDeviation = new TrackedText(composite, support, SWT.BORDER);\r
+        stdDeviation.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.NormalDistribution_stdDeviation));\r
+        stdDeviation.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.NormalDistribution_stdDeviation));\r
+        stdDeviation.setInputValidator(new DoubleValidator(true));\r
+        stdDeviation.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), stdDeviation.getWidget())));\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(stdDeviation.getWidget());\r
+        \r
         // maxValue\r
         label = new Label(composite, SWT.NONE);\r
         label.setText("Max value");\r
-        GridDataFactory.fillDefaults().applyTo(label);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
         \r
         maxValue = new TrackedText(composite, support, SWT.BORDER);\r
         maxValue.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.NormalDistribution_maxValue));\r
@@ -74,30 +98,6 @@ public class NormalDistributionProperties implements IDistributionProperties {
         maxValue.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), maxValue.getWidget())));\r
         GridDataFactory.fillDefaults().grab(true, false).applyTo(maxValue.getWidget());\r
         \r
-        // mean\r
-        label = new Label(composite, SWT.NONE);\r
-        label.setText("Mean");\r
-        GridDataFactory.fillDefaults().applyTo(label);\r
-        \r
-        mean = new TrackedText(composite, support, SWT.BORDER);\r
-        mean.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.NormalDistribution_mean));\r
-        mean.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.NormalDistribution_mean));\r
-        mean.setInputValidator(new DoubleValidator(true));\r
-        mean.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), mean.getWidget())));\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(mean.getWidget());\r
-        \r
-        // stdDeviation\r
-        label = new Label(composite, SWT.NONE);\r
-        label.setText("Standard deviation");\r
-        GridDataFactory.fillDefaults().applyTo(label);\r
-        \r
-        stdDeviation = new TrackedText(composite, support, SWT.BORDER);\r
-        stdDeviation.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.NormalDistribution_stdDeviation));\r
-        stdDeviation.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.NormalDistribution_stdDeviation));\r
-        stdDeviation.setInputValidator(new DoubleValidator(true));\r
-        stdDeviation.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), stdDeviation.getWidget())));\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(stdDeviation.getWidget());\r
-        \r
         return composite;\r
     }\r
 \r
index 098521890af33e48acf7c9319a09e7220d282070..8dc6bdd1e78bf8225791ff09b00e239c5083df16 100644 (file)
@@ -47,31 +47,33 @@ public class SensitivityExperimentParameter {
             SysdynModel sm = smm.getModel(graph, graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration));\r
             \r
             Variable variable = RepresentationUtils.getVariable(sm.getConfiguration(), variableName);\r
-            \r
-            if(indexes == null && (variable.getArrayIndexes() != null & variable.getArrayIndexes().size() > 0)) {\r
-                indexes = new String[variable.getArrayIndexes().size()];\r
-                \r
-                for(int i = 0; i < variable.getArrayIndexes().size(); i++) {\r
-                    Enumeration e = variable.getArrayIndexes().get(i);\r
-                    indexes[i] = e.getEnumerationIndexes().get(0).getName();\r
-                }\r
-            }\r
-            \r
-            if(indexes != null) {\r
-                StringBuilder sb = new StringBuilder();\r
-                sb.append("[");\r
-                for(int i = 0; i < indexes.length; i++) {\r
-                    if(i > 0)\r
-                        sb.append(",");\r
-\r
-                    String index = indexes[i];\r
-                    sb.append(index);\r
-                }\r
-                sb.append("]");\r
-                String result = IndexUtils.rangeToIndexes(variable, sb.toString());\r
-                fullName = variableName + result;\r
-            } else {\r
-                fullName = variableName;\r
+                   \r
+            if (variable != null) {\r
+                   if(indexes == null && (variable.getArrayIndexes() != null & variable.getArrayIndexes().size() > 0)) {\r
+                       indexes = new String[variable.getArrayIndexes().size()];\r
+                       \r
+                       for(int i = 0; i < variable.getArrayIndexes().size(); i++) {\r
+                           Enumeration e = variable.getArrayIndexes().get(i);\r
+                           indexes[i] = e.getEnumerationIndexes().get(0).getName();\r
+                       }\r
+                   }\r
+                   \r
+                   if(indexes != null) {\r
+                       StringBuilder sb = new StringBuilder();\r
+                       sb.append("[");\r
+                       for(int i = 0; i < indexes.length; i++) {\r
+                           if(i > 0)\r
+                               sb.append(",");\r
+       \r
+                           String index = indexes[i];\r
+                           sb.append(index);\r
+                       }\r
+                       sb.append("]");\r
+                       String result = IndexUtils.rangeToIndexes(variable, sb.toString());\r
+                       fullName = variableName + result;\r
+                   } else {\r
+                       fullName = variableName;\r
+                   }\r
             }\r
         } catch (DatabaseException e) {\r
 \r
index e139e379547447525fea652e9211d6a49e428fa4..ea5f79906a9fafe791b48a294b389089f21064dc 100644 (file)
@@ -184,8 +184,9 @@ public class SysdynSensitivityAnalysisExperiment extends SysdynExperiment {
                     if(parameters != null) {\r
                         parameters.clear();\r
                         for(Resource p : parameterResources) {\r
-                            SensitivityExperimentParameter parameter = graph.adapt(p, SensitivityExperimentParameter.class);\r
-                            parameters.add(parameter);\r
+                                       SensitivityExperimentParameter parameter = graph.adapt(p, SensitivityExperimentParameter.class);\r
+                               if (parameter.getFullName() != null)\r
+                                       parameters.add(parameter);\r
                         }\r
                     }\r
                 }\r