From: lempinen Date: Wed, 11 Jan 2012 13:15:18 +0000 (+0000) Subject: refs #3082 X-Git-Tag: simantics-1.6~61 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=52d34d809962171bf9e4376a23dec522493a10f9;p=simantics%2Fsysdyn.git refs #3082 Bug fixes git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@23916 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYDataset.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYDataset.java index 35cf2eec..fa2fa2c4 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYDataset.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYDataset.java @@ -89,7 +89,7 @@ public class XYDataset extends AbstractDataset { Resource rendererResource = graph.getPossibleObject(resource, jfree.Dataset_renderer); if(rendererResource != null) renderer = graph.adapt(rendererResource, IRenderer.class); - + ArrayList series = new ArrayList(); String realizationURI = getRealizationURI(graph); @@ -128,10 +128,13 @@ public class XYDataset extends AbstractDataset { Resource c = graph.getPossibleObject(r, jfree.color); Color color = c == null ? null : G2DUtils.getColor(graph, c); + + String label = graph.getPossibleRelatedValue(r, Layer0.getInstance(graph).HasLabel); // Get a variable for the series Variable v = Variables.getVariable(graph, realizationURI + rvi); - + if(v == null) + return new Pair, IRenderer>(series, renderer); // Get values Object object = v.getPossiblePropertyValue(graph, SysdynVariableProperties.ACTIVE_DATASETS , Bindings.VARIANT); @@ -185,6 +188,8 @@ public class XYDataset extends AbstractDataset { if(ta!=null && va!=null && (va.length == ta.length)) { // Add series if everything OK String name = dataset.name; + if(label != null) + name = label; if(dataset.result != null && !dataset.result.isEmpty()) name = name + " : " + dataset.result; series.add(new TempSeries(name, new double[][] {ta, va}, width, color)); @@ -223,6 +228,8 @@ public class XYDataset extends AbstractDataset { try { // Get a variable for the series Variable v = Variables.getVariable(graph, realizationURI + rvi); + if(v == null) + return null; Double time = v.getPossiblePropertyValue(graph, SysdynVariableProperties.TIME , Bindings.DOUBLE); return time; } catch (MissingVariableException e) { @@ -419,9 +426,29 @@ public class XYDataset extends AbstractDataset { @Override public AbstractRenderer getRenderer() { if(renderer == null) { - XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); - renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); - return renderer; + + try { + renderer = SimanticsUI.getSession().syncRequest(new Read() { + + @Override + public IRenderer perform(ReadGraph graph) throws DatabaseException { + JFreeChartResource jfree = JFreeChartResource.getInstance(graph); + IRenderer renderer = null; + Resource rendererResource = graph.getPossibleObject(resource, jfree.Dataset_renderer); + if(rendererResource != null) + renderer = graph.adapt(rendererResource, IRenderer.class); + return renderer; + } + }); + } catch (DatabaseException e) { + } + if(renderer == null) { + XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); + renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); + return renderer; + } else { + return renderer.getRenderer(); + } } else { return renderer.getRenderer(); } @@ -436,7 +463,7 @@ public class XYDataset extends AbstractDataset { private String getRealizationURI(ReadGraph graph) throws DatabaseException { if(resource == null) return null; - + Layer0 l0 = Layer0.getInstance(graph); ModelingResources mr = ModelingResources.getInstance(graph); @@ -448,7 +475,7 @@ public class XYDataset extends AbstractDataset { if(model == null) return null; - + // Find the variable realization of the current experiment String realizationURI = null; Resource realization = graph.syncRequest(new PossibleActiveExperiment(model)); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java index 40cbadef..d919c540 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java @@ -95,6 +95,8 @@ public class RangeComposite extends Composite implements Widget { try { // Find the variable for the current variableRVI Variable v = Variables.getVariable(graph, realizationURI + rvi.trim()); + if(v == null) + return null; Resource variable = v.getRepresents(graph); // Return the enumerations assigned to that variable diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameUtils.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameUtils.java index 422f9e9a..29efea03 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameUtils.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameUtils.java @@ -49,6 +49,9 @@ public class VariableNameUtils { * How this works when range used in equations has the same string as * the renamed variable? Should it be possible? */ + if(originalName.equals(newName)) + return; // Do nothing + Layer0 l0 = Layer0.getInstance(graph); SysdynResource sr = SysdynResource.getInstance(graph); Resource configuration = graph.getSingleObject(variable, l0.PartOf); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyFunction.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyFunction.java index dbad2a45..88dbac81 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyFunction.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyFunction.java @@ -57,13 +57,9 @@ public class DependencyFunction { if (!graph.hasStatement(component) || !graph.hasStatement(component, l0.PartOf)) return Collections.emptyList(); - - // Find all variables that are linked to component with arrows - Set dependencies = ValidationUtils.getDependencies(graph, component); - Set references = null; - + ArrayList result = new ArrayList(); - + Set references = null; // Find all references in equations of component try { @@ -72,6 +68,9 @@ public class DependencyFunction { return result; } + // Find all variables that are linked to component with arrows + Set dependencies = ValidationUtils.getDependencies(graph, component); + // Check that all arrow dependencies are used in equations if (dependencies != null) { for (String dependency : dependencies) {