]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #3082
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 11 Jan 2012 13:15:18 +0000 (13:15 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 11 Jan 2012 13:15:18 +0000 (13:15 +0000)
Bug fixes

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

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYDataset.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyFunction.java

index 35cf2eec22c7d26f9386789505e6942123a29edb..fa2fa2c49f3318da864ab3f4b98dff16a3a5b4d1 100644 (file)
@@ -89,7 +89,7 @@ public class XYDataset extends AbstractDataset {
                     Resource rendererResource = graph.getPossibleObject(resource, jfree.Dataset_renderer);\r
                     if(rendererResource != null)\r
                         renderer = graph.adapt(rendererResource, IRenderer.class);\r
-                    \r
+\r
                     ArrayList<TempSeries> series = new ArrayList<TempSeries>();\r
 \r
                     String realizationURI = getRealizationURI(graph);\r
@@ -128,10 +128,13 @@ public class XYDataset extends AbstractDataset {
 \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
-\r
+                                if(v == null)\r
+                                    return new Pair<ArrayList<TempSeries>, IRenderer>(series, renderer);\r
 \r
                                 // Get values\r
                                 Object object =  v.getPossiblePropertyValue(graph, SysdynVariableProperties.ACTIVE_DATASETS , Bindings.VARIANT);\r
@@ -185,6 +188,8 @@ public class XYDataset extends AbstractDataset {
                                     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
@@ -223,6 +228,8 @@ public class XYDataset extends AbstractDataset {
                                 try {\r
                                     // Get a variable for the series\r
                                     Variable v = Variables.getVariable(graph, realizationURI + rvi);\r
+                                    if(v == null)\r
+                                        return null;\r
                                     Double time = v.getPossiblePropertyValue(graph, SysdynVariableProperties.TIME , Bindings.DOUBLE);\r
                                     return time;\r
                                 } catch (MissingVariableException e) {\r
@@ -419,9 +426,29 @@ public class XYDataset extends AbstractDataset {
     @Override\r
     public AbstractRenderer getRenderer() {\r
         if(renderer == null) {\r
-            XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);\r
-            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());\r
-            return renderer;\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
@@ -436,7 +463,7 @@ public class XYDataset extends AbstractDataset {
     private String getRealizationURI(ReadGraph graph) throws DatabaseException {\r
         if(resource == null)\r
             return null;\r
-        \r
+\r
         Layer0 l0 = Layer0.getInstance(graph);\r
         ModelingResources mr = ModelingResources.getInstance(graph);\r
 \r
@@ -448,7 +475,7 @@ public class XYDataset extends AbstractDataset {
 \r
         if(model == null)\r
             return null;\r
-        \r
+\r
         // Find the variable realization of the current experiment\r
         String realizationURI = null;\r
         Resource realization = graph.syncRequest(new PossibleActiveExperiment(model));\r
index 40cbadefc777ba073b94b5d5a677a3bdfb2a038d..d919c5406b527cb3a039ff9380b791874559c915 100644 (file)
@@ -95,6 +95,8 @@ public class RangeComposite extends Composite implements Widget {
                 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
                     Resource variable = v.getRepresents(graph);\r
                     \r
                     // Return the enumerations assigned to that variable\r
index 422f9e9ae42c85bde6857a8f0c2725fdaf787dad..29efea0396afee5c8dc1964d9baf130f70a61394 100644 (file)
@@ -49,6 +49,9 @@ public class VariableNameUtils {
                 * How this works when range used in equations has the same string as\r
                 * the renamed variable? Should it be possible? \r
                 */ \r
+           if(originalName.equals(newName))\r
+               return; // Do nothing\r
+           \r
                Layer0 l0 = Layer0.getInstance(graph);\r
                SysdynResource sr = SysdynResource.getInstance(graph);\r
                Resource configuration = graph.getSingleObject(variable, l0.PartOf);\r
index dbad2a45667f3a4b49569bca01f96f45d474f5af..88dbac818b6849a58270c5ff3fe5a9dfc231ebde 100644 (file)
@@ -57,13 +57,9 @@ public class DependencyFunction {
 \r
         if (!graph.hasStatement(component) || !graph.hasStatement(component, l0.PartOf))\r
             return Collections.emptyList();\r
-\r
-        // Find all variables that are linked to component with arrows\r
-        Set<String> dependencies = ValidationUtils.getDependencies(graph, component);\r
-        Set<String> references = null;\r
-\r
+        \r
         ArrayList<Issue> result = new ArrayList<Issue>();\r
-\r
+        Set<String> references = null;\r
         \r
         // Find all references in equations of component\r
         try {\r
@@ -72,6 +68,9 @@ public class DependencyFunction {
             return result;\r
         } \r
 \r
+        // Find all variables that are linked to component with arrows\r
+        Set<String> dependencies = ValidationUtils.getDependencies(graph, component);\r
+\r
         // Check that all arrow dependencies are used in equations\r
         if (dependencies != null) {\r
             for (String dependency : dependencies) {\r