Bundle-Version: 0.1.0.qualifier
Require-Bundle: org.simantics.layer0,
org.simantics.layer0x.ontology;bundle-version="1.0.0",
- org.simantics.g2d.ontology;bundle-version="1.0.0"
+ org.simantics.g2d.ontology;bundle-version="1.0.0",
+ org.simantics.diagram.ontology;bundle-version="2.1.0",
+ org.simantics.structural.ontology;bundle-version="1.1.0",
+ org.simantics.modeling.ontology;bundle-version="1.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.simantics.sysdyn
L0 = <http://www.simantics.org/Layer0-1.0>
L0X = <http://www.simantics.org/Layer0X-1.0>
G2D = <http://www.simantics.org/G2D-1.0>
+DIA = <http://www.simantics.org/Diagram-2.1>
+MOD = <http://www.simantics.org/Modeling-1.1>
+STR = <http://www.simantics.org/Structural-1.0>
//#####################################################################
// Ontology for defining JFreeChart charts
>-- JFREE.Chart.visibleBorder --> L0.Boolean <R L0.HasProperty : L0.FunctionalRelation
>-- JFREE.Chart.borderWidth --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
>-- JFREE.Chart.visibleLegend --> L0.Boolean <R L0.HasProperty : L0.FunctionalRelation
+ >-- JFREE.Chart.time --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
//#####################################################################
// Titles
JFREE.Top <T JFREE.Position
JFREE.Left <T JFREE.Position
JFREE.Right <T JFREE.Position
+
+
+//#####################################################################
+// Symbol
+//#####################################################################
+JFREE.ChartElement <T DIA.Element
+ L0.HasDescription "Element for displaying charts in diagrams"
+ >-- JFREE.ChartElement.component --> JFREE.Chart <R L0.IsWeaklyRelatedTo
\ No newline at end of file
public final Resource CategoryDataset;\r
public final Resource CategoryPlot;\r
public final Resource Chart;\r
+ public final Resource ChartElement;\r
+ public final Resource ChartElement_component;\r
public final Resource Chart_borderColor;\r
public final Resource Chart_borderColor_Inverse;\r
public final Resource Chart_borderWidth;\r
public final Resource Chart_borderWidth_Inverse;\r
+ public final Resource Chart_time;\r
+ public final Resource Chart_time_Inverse;\r
public final Resource Chart_visibleBorder;\r
public final Resource Chart_visibleBorder_Inverse;\r
public final Resource Chart_visibleLegend;\r
public static final String CategoryDataset = "http://www.simantics.org/JFreeChart-1.0/CategoryDataset";\r
public static final String CategoryPlot = "http://www.simantics.org/JFreeChart-1.0/CategoryPlot";\r
public static final String Chart = "http://www.simantics.org/JFreeChart-1.0/Chart";\r
+ public static final String ChartElement = "http://www.simantics.org/JFreeChart-1.0/ChartElement";\r
+ public static final String ChartElement_component = "http://www.simantics.org/JFreeChart-1.0/ChartElement/component";\r
public static final String Chart_borderColor = "http://www.simantics.org/JFreeChart-1.0/Chart/borderColor";\r
public static final String Chart_borderColor_Inverse = "http://www.simantics.org/JFreeChart-1.0/Chart/borderColor/Inverse";\r
public static final String Chart_borderWidth = "http://www.simantics.org/JFreeChart-1.0/Chart/borderWidth";\r
public static final String Chart_borderWidth_Inverse = "http://www.simantics.org/JFreeChart-1.0/Chart/borderWidth/Inverse";\r
+ public static final String Chart_time = "http://www.simantics.org/JFreeChart-1.0/Chart/time";\r
+ public static final String Chart_time_Inverse = "http://www.simantics.org/JFreeChart-1.0/Chart/time/Inverse";\r
public static final String Chart_visibleBorder = "http://www.simantics.org/JFreeChart-1.0/Chart/visibleBorder";\r
public static final String Chart_visibleBorder_Inverse = "http://www.simantics.org/JFreeChart-1.0/Chart/visibleBorder/Inverse";\r
public static final String Chart_visibleLegend = "http://www.simantics.org/JFreeChart-1.0/Chart/visibleLegend";\r
CategoryDataset = getResourceOrNull(graph, URIs.CategoryDataset);\r
CategoryPlot = getResourceOrNull(graph, URIs.CategoryPlot);\r
Chart = getResourceOrNull(graph, URIs.Chart);\r
+ ChartElement = getResourceOrNull(graph, URIs.ChartElement);\r
+ ChartElement_component = getResourceOrNull(graph, URIs.ChartElement_component);\r
Chart_borderColor = getResourceOrNull(graph, URIs.Chart_borderColor);\r
Chart_borderColor_Inverse = getResourceOrNull(graph, URIs.Chart_borderColor_Inverse);\r
Chart_borderWidth = getResourceOrNull(graph, URIs.Chart_borderWidth);\r
Chart_borderWidth_Inverse = getResourceOrNull(graph, URIs.Chart_borderWidth_Inverse);\r
+ Chart_time = getResourceOrNull(graph, URIs.Chart_time);\r
+ Chart_time_Inverse = getResourceOrNull(graph, URIs.Chart_time_Inverse);\r
Chart_visibleBorder = getResourceOrNull(graph, URIs.Chart_visibleBorder);\r
Chart_visibleBorder_Inverse = getResourceOrNull(graph, URIs.Chart_visibleBorder_Inverse);\r
Chart_visibleLegend = getResourceOrNull(graph, URIs.Chart_visibleLegend);\r
org.simantics.history;bundle-version="1.0.0",
org.simantics.utils.thread.swt;bundle-version="1.1.0",
org.simantics.jfreechart.ontology;bundle-version="0.1.0",
- org.eclipse.ui.forms;bundle-version="3.5.2"
+ org.eclipse.ui.forms;bundle-version="3.5.2",
+ org.simantics.scenegraph.swing;bundle-version="1.0.0"
Bundle-Activator: org.simantics.sysdyn.ui.Activator
Bundle-ActivationPolicy: lazy
Export-Package: org.simantics.sysdyn.ui.browser.nodes
import java.util.ArrayList;\r
import java.util.HashMap;\r
\r
+import javax.swing.SwingUtilities;\r
+\r
import org.jfree.chart.axis.Axis;\r
+import org.jfree.chart.plot.Plot;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.common.request.ObjectsWithType;\r
protected ArrayList<IDataset> datasets;\r
protected HashMap<IDataset, IAxis> rangeMappings;\r
protected HashMap<IDataset, IAxis> domainMappings;\r
+ protected Plot plot;\r
\r
public AbstractPlot(ReadGraph graph, Resource resource) {\r
this.resource = resource;\r
public Resource getResource() {\r
return resource;\r
}\r
+ \r
+ protected abstract Plot newPlot();\r
+ protected abstract void setPlotProperties();\r
+ \r
+ @Override\r
+ public Plot getPlot() {\r
+ if(plot == null)\r
+ plot = newPlot();\r
+ \r
+ SwingUtilities.invokeLater(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ setPlotProperties();\r
+ }\r
+ });\r
+ \r
+ return plot;\r
+ }\r
}\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
- // Time\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
-\r
+ if(time == null)\r
+ time = chartTime;\r
if(time == null)\r
time = v.getPossiblePropertyValue(graph, SysdynVariableProperties.TIME, Bindings.DOUBLE);\r
\r
\r
@Override\r
public void run() {\r
-\r
// Remove all unused series\r
dataset.clear();\r
BarRenderer renderer = ((BarRenderer)getRenderer());\r
*/\r
public class CategoryPlot extends AbstractPlot {\r
\r
- private org.jfree.chart.plot.CategoryPlot plot;\r
private Boolean visibleGrid;\r
\r
\r
}\r
\r
@Override\r
- public Plot getPlot() {\r
- if(plot == null) {\r
- plot = new org.jfree.chart.plot.CategoryPlot(null, null, null, null);\r
- } \r
+ protected Plot newPlot() {\r
+ return new org.jfree.chart.plot.CategoryPlot(null, null, null, null);\r
+ }\r
+\r
+ @Override\r
+ protected void setPlotProperties() {\r
+ if(!(plot instanceof org.jfree.chart.plot.CategoryPlot))\r
+ return;\r
+ \r
+ org.jfree.chart.plot.CategoryPlot cplot = (org.jfree.chart.plot.CategoryPlot) plot;\r
/* Support using multiple axis, but prefer using only one domain and \r
* one range axis\r
*/\r
for(int i = 0; i < ranges.size(); i++) {\r
- plot.setRangeAxis(i, (ValueAxis)ranges.get(i).getAxis());\r
+ cplot.setRangeAxis(i, (ValueAxis)ranges.get(i).getAxis());\r
}\r
\r
for(int i = 0; i < domains.size(); i++) {\r
- plot.setDomainAxis(i, (CategoryAxis)domains.get(i).getAxis());\r
+ cplot.setDomainAxis(i, (CategoryAxis)domains.get(i).getAxis());\r
}\r
\r
IAxis axis;\r
for(int i = 0; i < datasets.size(); i++) {\r
IDataset dataset = datasets.get(i);\r
org.jfree.data.category.CategoryDataset ds = (org.jfree.data.category.CategoryDataset)dataset.getDataset();\r
- plot.setDataset(i, ds);\r
+ cplot.setDataset(i, ds);\r
// System.out.println("setting dataset " + i + ": " + ds);\r
- plot.setRenderer(i, (CategoryItemRenderer)dataset.getRenderer());\r
+ cplot.setRenderer(i, (CategoryItemRenderer)dataset.getRenderer());\r
axis = rangeMappings.get(dataset);\r
if(axis != null && ranges.contains(axis))\r
- plot.mapDatasetToRangeAxis(i, ranges.indexOf(axis));\r
+ cplot.mapDatasetToRangeAxis(i, ranges.indexOf(axis));\r
axis = domainMappings.get(dataset);\r
if(axis != null && ranges.contains(axis))\r
- plot.mapDatasetToDomainAxis(i, domains.indexOf(axis));\r
+ cplot.mapDatasetToDomainAxis(i, domains.indexOf(axis));\r
}\r
\r
if(visibleGrid != null) {\r
- plot.setRangeGridlinesVisible(visibleGrid);\r
- plot.setDomainGridlinesVisible(false);\r
+ cplot.setRangeGridlinesVisible(visibleGrid);\r
+ cplot.setDomainGridlinesVisible(false);\r
}\r
\r
// Cleaner look: no outline borders\r
- plot.setInsets(new RectangleInsets(2,2,2,2), false);\r
- plot.setOutlineVisible(false);\r
- \r
- return plot;\r
+ cplot.setInsets(new RectangleInsets(2,2,2,2), false);\r
+ cplot.setOutlineVisible(false);\r
}\r
\r
}\r
import org.eclipse.jface.layout.GridLayoutFactory;\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.awt.SWT_AWT;\r
-import org.eclipse.swt.events.DisposeEvent;\r
-import org.eclipse.swt.events.DisposeListener;\r
import org.eclipse.swt.widgets.Composite;\r
import org.jfree.chart.ChartPanel;\r
import org.jfree.chart.JFreeChart;\r
*/\r
private void CreateContent(final Resource chartResource) {\r
composite = this;\r
- \r
- composite.addDisposeListener(new DisposeListener() {\r
- \r
- @Override\r
- public void widgetDisposed(DisposeEvent e) {\r
- if(chart != null)\r
- chart.dispose(); \r
- }\r
- });\r
- \r
+\r
GridLayoutFactory.fillDefaults().applyTo(composite);\r
GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
frame = SWT_AWT.new_Frame(composite);\r
\r
import java.awt.Color;\r
import java.awt.Font;\r
-import java.lang.reflect.InvocationTargetException;\r
import java.util.Collection;\r
\r
import javax.swing.SwingUtilities;\r
if(plot == null)\r
return null;\r
\r
- try {\r
- SwingUtilities.invokeAndWait(new RunnableWithObject(plot) {\r
- @Override\r
- public void run() {\r
- jfreechart = new org.jfree.chart.JFreeChart(plot.getPlot());\r
- \r
- jfreechart.setBackgroundPaint(Color.WHITE);\r
+ jfreechart = new org.jfree.chart.JFreeChart(plot.getPlot());\r
+\r
+ SwingUtilities.invokeLater(new RunnableWithObject(plot) {\r
+ @Override\r
+ public void run() {\r
+ if(jfreechart == null)\r
+ return;\r
+\r
+ jfreechart.setBackgroundPaint(Color.WHITE);\r
+ if(jfreechart.getLegend() != null) {\r
jfreechart.getLegend().setBorder(0, 0, 0, 0);\r
int size = jfreechart.getLegend().getItemFont().getSize();\r
jfreechart.getLegend().setItemFont(new Font("helvetica", Font.PLAIN, size));\r
- \r
- org.jfree.chart.title.TextTitle t = (org.jfree.chart.title.TextTitle)title.getTitle();\r
- if(t.isVisible()) {\r
- t.setFont(new Font("georgia", Font.BOLD, 13));\r
- t.setPadding(new RectangleInsets(4, 0, 0, 0));\r
- jfreechart.setTitle(t);\r
- }\r
-\r
- if(legendVisible != null && !legendVisible) {\r
- jfreechart.removeLegend();\r
- }\r
}\r
- });\r
- } catch (InterruptedException e) {\r
- e.printStackTrace();\r
- } catch (InvocationTargetException e) {\r
- e.printStackTrace();\r
- }\r
+\r
+ org.jfree.chart.title.TextTitle t = (org.jfree.chart.title.TextTitle)title.getTitle();\r
+ if(t.isVisible()) {\r
+ t.setFont(new Font("georgia", Font.BOLD, 13));\r
+ t.setPadding(new RectangleInsets(4, 0, 0, 0));\r
+ jfreechart.setTitle(t);\r
+ }\r
+\r
+ if(legendVisible != null && !legendVisible) {\r
+ jfreechart.removeLegend();\r
+ }\r
+ }\r
+ });\r
+\r
return jfreechart;\r
}\r
\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
- // Time\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
-\r
+ if(time == null)\r
+ time = chartTime;\r
if(time == null)\r
time = v.getPossiblePropertyValue(graph, SysdynVariableProperties.TIME, Bindings.DOUBLE);\r
\r
*/\r
public class PiePlot extends AbstractPlot {\r
\r
- private org.jfree.chart.plot.PiePlot plot;\r
private org.jfree.data.general.PieDataset pieDataset;\r
private DatasetChangeListener listener;\r
\r
}\r
}\r
\r
- @Override\r
- public Plot getPlot() {\r
- if(plot == null) {\r
- plot = new MyPiePlot();\r
- plot.setToolTipGenerator(new StandardPieToolTipGenerator());\r
+ /**\r
+ * Pie plot class with a stricter equals condition\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+ private class MyPiePlot extends org.jfree.chart.plot.PiePlot {\r
+\r
+ private static final long serialVersionUID = -5917620061541212934L;\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ boolean result = super.equals(obj);\r
+ if(result == true) {\r
+ org.jfree.chart.plot.PiePlot that = (org.jfree.chart.plot.PiePlot) obj;\r
+ if (this.getDataset() != that.getDataset()) {\r
+ return false; // Normally plot does not check this. We need this to properly update the charts\r
+ }\r
+ }\r
+\r
+ return result;\r
}\r
\r
+ }\r
+\r
+ @Override\r
+ protected Plot newPlot() {\r
+ MyPiePlot plot = new MyPiePlot();\r
+ plot.setToolTipGenerator(new StandardPieToolTipGenerator());\r
+ return plot;\r
+ }\r
+\r
+ @Override\r
+ protected void setPlotProperties() {\r
+ if(!(plot instanceof MyPiePlot))\r
+ return;\r
+ \r
+ final MyPiePlot piePlot = (MyPiePlot)plot;\r
+ \r
if(!datasets.isEmpty()) {\r
// We assume that a pie plot has only one dataset\r
final IDataset ds = datasets.get(0);\r
Dataset dataset = ((PieDataset)ds).getDataset();\r
+ \r
+ if(dataset == null)\r
+ return;\r
\r
if(pieDataset != null && listener != null) {\r
pieDataset.removeChangeListener(listener);\r
}\r
\r
pieDataset = (org.jfree.data.general.PieDataset)dataset;\r
- plot.setDataset(pieDataset);\r
+ piePlot.setDataset(pieDataset);\r
if(Boolean.FALSE.equals(labelsVisible))\r
- plot.setLabelGenerator(null);\r
- else if(plot.getLabelGenerator() == null)\r
- plot.setLabelGenerator(new StandardPieSectionLabelGenerator());\r
+ piePlot.setLabelGenerator(null);\r
+ else if(piePlot.getLabelGenerator() == null)\r
+ piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator());\r
\r
listener = new DatasetChangeListener() {\r
\r
HashMap<String, Color> colorMap = ((PieDataset)ds).getColorMap();\r
HashMap<String, Boolean> explodedMap = ((PieDataset)ds).getExplodedMap();\r
\r
- for(Object o : plot.getDataset().getKeys()) {\r
+ for(Object o : piePlot.getDataset().getKeys()) {\r
if(o instanceof Comparable) {\r
Comparable<?> key = (Comparable<?>)o;\r
if(explodedMap.containsKey(key) && explodedMap.get(key)) {\r
- plot.setExplodePercent(key, 0.3);\r
+ piePlot.setExplodePercent(key, 0.3);\r
\r
} else {\r
- plot.setExplodePercent(key, 0);\r
+ piePlot.setExplodePercent(key, 0);\r
}\r
}\r
}\r
for(String name : explodedMap.keySet()) {\r
Boolean exploded = explodedMap.get(name);\r
if(Boolean.TRUE.equals(exploded))\r
- plot.setExplodePercent(name, 0.3);\r
+ piePlot.setExplodePercent(name, 0.3);\r
} \r
- plot.clearSectionPaints(false);\r
- plot.setDrawingSupplier(new DefaultDrawingSupplier());\r
+ piePlot.clearSectionPaints(false);\r
+ piePlot.setDrawingSupplier(new DefaultDrawingSupplier());\r
for(String name : colorMap.keySet())\r
- plot.setSectionPaint(name, colorMap.get(name));\r
+ piePlot.setSectionPaint(name, colorMap.get(name));\r
}\r
};\r
\r
}\r
\r
// Cleaner look: no outline borders\r
- plot.setInsets(new RectangleInsets(0,0,0,0), false);\r
- plot.setOutlineVisible(false);\r
- plot.setLabelBackgroundPaint(Color.WHITE);\r
- plot.setLabelFont(new Font("helvetica", Font.PLAIN, 11));\r
- \r
- return plot;\r
- }\r
-\r
- /**\r
- * Pie plot class with a stricter equals condition\r
- * @author Teemu Lempinen\r
- *\r
- */\r
- private class MyPiePlot extends org.jfree.chart.plot.PiePlot {\r
-\r
- private static final long serialVersionUID = -5917620061541212934L;\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- boolean result = super.equals(obj);\r
- if(result == true) {\r
- org.jfree.chart.plot.PiePlot that = (org.jfree.chart.plot.PiePlot) obj;\r
- if (this.getDataset() != that.getDataset()) {\r
- return false; // Normally plot does not check this. We need this to properly update the charts\r
- }\r
- }\r
-\r
- return result;\r
- }\r
-\r
+ piePlot.setInsets(new RectangleInsets(0,0,0,0), false);\r
+ piePlot.setOutlineVisible(false);\r
+ piePlot.setLabelBackgroundPaint(Color.WHITE);\r
+ piePlot.setLabelFont(new Font("helvetica", Font.PLAIN, 11));\r
}\r
\r
}\r
*/\r
public class XYPlot extends AbstractPlot {\r
\r
- private org.jfree.chart.plot.XYPlot plot;\r
private Boolean visibleGrid;\r
\r
-\r
public XYPlot(ReadGraph graph, Resource plotResource) {\r
super(graph, plotResource);\r
\r
}\r
\r
@Override\r
- public Plot getPlot() {\r
- if(plot == null)\r
- plot = new org.jfree.chart.plot.XYPlot(null, null, null, null);\r
+ protected Plot newPlot() {\r
+ return new org.jfree.chart.plot.XYPlot(null, null, null, null);\r
+ }\r
+\r
+ @Override\r
+ protected void setPlotProperties() {\r
+ if(!(plot instanceof org.jfree.chart.plot.XYPlot))\r
+ return;\r
\r
- plot.clearDomainAxes();\r
- plot.clearRangeAxes();\r
+ org.jfree.chart.plot.XYPlot xyplot = (org.jfree.chart.plot.XYPlot)plot;\r
+ xyplot.clearDomainAxes();\r
+ xyplot.clearRangeAxes();\r
\r
for(int i = 0; i < ranges.size(); i++) {\r
- plot.setRangeAxis(i, (ValueAxis)ranges.get(i).getAxis());\r
+ xyplot.setRangeAxis(i, (ValueAxis)ranges.get(i).getAxis());\r
}\r
\r
for(int i = 0; i < domains.size(); i++) {\r
- plot.setDomainAxis(i, (ValueAxis)domains.get(i).getAxis());\r
+ xyplot.setDomainAxis(i, (ValueAxis)domains.get(i).getAxis());\r
}\r
\r
IAxis axis;\r
for(int i = 0; i < datasets.size(); i++) {\r
IDataset dataset = datasets.get(i);\r
- plot.setDataset(i, (XYDataset)dataset.getDataset());\r
- plot.setRenderer(i, (XYItemRenderer)dataset.getRenderer());\r
+ xyplot.setDataset(i, (XYDataset)dataset.getDataset());\r
+ xyplot.setRenderer(i, (XYItemRenderer)dataset.getRenderer());\r
axis = rangeMappings.get(dataset);\r
if(axis != null && ranges.contains(axis))\r
- plot.mapDatasetToRangeAxis(i, ranges.indexOf(axis));\r
+ xyplot.mapDatasetToRangeAxis(i, ranges.indexOf(axis));\r
axis = domainMappings.get(dataset);\r
if(axis != null && ranges.contains(axis))\r
- plot.mapDatasetToDomainAxis(i, domains.indexOf(axis));\r
+ xyplot.mapDatasetToDomainAxis(i, domains.indexOf(axis));\r
}\r
\r
if(visibleGrid == null)\r
visibleGrid = true;\r
\r
- plot.setRangeGridlinesVisible(visibleGrid);\r
- plot.setDomainGridlinesVisible(visibleGrid);\r
+ xyplot.setRangeGridlinesVisible(visibleGrid);\r
+ xyplot.setDomainGridlinesVisible(visibleGrid);\r
\r
// Cleaner look: no outline borders\r
- plot.setInsets(new RectangleInsets(2,2,2,2), false);\r
- plot.setOutlineVisible(false);\r
- \r
- return plot;\r
+ xyplot.setInsets(new RectangleInsets(2,2,2,2), false);\r
+ xyplot.setOutlineVisible(false);\r
}\r
\r
}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.trend.chart.properties;\r
+\r
+import org.eclipse.jface.dialogs.IInputValidator;\r
+\r
+/**\r
+ * Validator for validating that an input is double.\r
+ * \r
+ * Can allow empty strings.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class DoubleValidator implements IInputValidator {\r
+ \r
+ boolean allowEmpty;\r
+ \r
+ /**\r
+ * New double validator. Does not allow empty strings\r
+ */\r
+ public DoubleValidator() {\r
+ this(false);\r
+ }\r
+ \r
+ /**\r
+ * New double validator.\r
+ * @param allowEmpty Are empty strings allowed\r
+ */\r
+ public DoubleValidator(boolean allowEmpty) {\r
+ this.allowEmpty = allowEmpty;\r
+ }\r
+ \r
+ @Override\r
+ public String isValid(String newText) {\r
+ if (allowEmpty && newText.trim().isEmpty())\r
+ return null;\r
+ try {\r
+ Double.parseDouble(newText);\r
+ return null;\r
+ } catch (NumberFormatException e) {\r
+ return e.getMessage();\r
+ }\r
+ }\r
+}\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.trend.chart.properties.bar;\r
\r
-import org.eclipse.jface.dialogs.IInputValidator;\r
import org.eclipse.jface.layout.GridDataFactory;\r
import org.eclipse.jface.layout.GridLayoutFactory;\r
import org.eclipse.jface.viewers.StructuredSelection;\r
import org.simantics.sysdyn.ui.properties.LabelPropertyTabContributor;\r
import org.simantics.sysdyn.ui.trend.chart.properties.AxisHidePropertyComposite;\r
import org.simantics.sysdyn.ui.trend.chart.properties.ColorPicker;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.DoubleValidator;\r
import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
import org.simantics.sysdyn.ui.trend.chart.properties.TrackedSpinner;\r
import org.simantics.ui.utils.AdaptionUtils;\r
rangemin.setColorProvider(new JFreeChartPropertyColorProvider(rangemin.getResourceManager()));\r
rangemin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min));\r
rangemin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min));\r
- rangemin.setInputValidator(new DoubleValidator());\r
+ rangemin.setInputValidator(new DoubleValidator(true));\r
\r
label = new Label(minmax, SWT.NONE);\r
label.setText("Max:");\r
rangemax.setColorProvider(new JFreeChartPropertyColorProvider(rangemax.getResourceManager()));\r
rangemax.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max));\r
rangemax.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max));\r
- rangemax.setInputValidator(new DoubleValidator());\r
+ rangemax.setInputValidator(new DoubleValidator(true));\r
\r
// Range Color\r
label = new Label(rangeGroup, SWT.NONE);\r
}\r
});\r
}\r
-\r
-\r
- /**\r
- * Validator for validating that an input is double\r
- * @author Teemu Lempinen\r
- *\r
- */\r
- private class DoubleValidator implements IInputValidator {\r
- @Override\r
- public String isValid(String newText) {\r
- if (newText.trim().isEmpty())\r
- return null;\r
- try {\r
- Double.parseDouble(newText);\r
- return null;\r
- } catch (NumberFormatException e) {\r
- return e.getMessage();\r
- }\r
- }\r
- }\r
}\r
\r
import org.eclipse.jface.layout.GridDataFactory;\r
import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.layout.LayoutConstants;\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.custom.ScrolledComposite;\r
import org.eclipse.swt.graphics.Point;\r
import org.simantics.layer0.utils.direct.GraphUtils;\r
import org.simantics.sysdyn.JFreeChartResource;\r
import org.simantics.sysdyn.ui.properties.LabelPropertyTabContributor;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
import org.simantics.sysdyn.ui.trend.chart.properties.BooleanPropertyFactory;\r
import org.simantics.sysdyn.ui.trend.chart.properties.BooleanSelectionListener;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.DoubleValidator;\r
import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
import org.simantics.sysdyn.ui.trend.chart.properties.TitleFactory;\r
import org.simantics.sysdyn.ui.trend.chart.properties.TitleModifier;\r
private ScrolledComposite sc;\r
private Composite composite;\r
private Button hgrid, htitle, hlegend;\r
- private TrackedText name, title;\r
+ private TrackedText name, title, time;\r
private TrackedCombo type;\r
\r
\r
// General properties\r
Group general = new Group(composite, SWT.NONE);\r
GridDataFactory.fillDefaults().grab(true, false).applyTo(general);\r
- GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(general);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(general);\r
general.setText("General");\r
\r
+ // first column: labels\r
+ Composite labelColumn1 = new Composite(general, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1);\r
+ GridLayoutFactory.fillDefaults().applyTo(labelColumn1);\r
+ \r
+ // first column: name and title\r
+ Composite propertyColumn1 = new Composite(general, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1);\r
+ GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1);\r
+ \r
+ // first column: labels\r
+ Composite labelColumn2 = new Composite(general, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2);\r
+ GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2);\r
+ \r
+ // first column: type and time\r
+ Composite propertyColumn2 = new Composite(general, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2);\r
+ GridLayoutFactory.fillDefaults().applyTo(propertyColumn2);\r
+ \r
// Name\r
- Label label = new Label(general, SWT.NONE);\r
- GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+ Label label = new Label(labelColumn1, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
label.setText("Name:");\r
\r
- Composite c = new Composite(general, SWT.NONE);\r
- GridDataFactory.fillDefaults().applyTo(c);\r
- GridLayoutFactory.fillDefaults().numColumns(3).applyTo(c);\r
-\r
- name = new org.simantics.browsing.ui.swt.widgets.TrackedText(c, support, SWT.BORDER);\r
+ name = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER);\r
GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget());\r
name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
\r
// Type\r
- label = new Label(c, SWT.NONE);\r
- GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+ label = new Label(labelColumn2, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
label.setText("Type:");\r
\r
- type = new TrackedCombo(c, support, SWT.BORDER | SWT.READ_ONLY);\r
+ type = new TrackedCombo(propertyColumn2, support, SWT.BORDER | SWT.READ_ONLY);\r
type.addModifyListener(new TypeModifyListener());\r
type.setItemFactory(new TypeItemFactory());\r
type.setSelectionFactory(new TypeSelectionFactory());\r
GridDataFactory.fillDefaults().applyTo(type.getWidget());\r
\r
// Title (Which is different than name)\r
- label = new Label(general, SWT.NONE);\r
- GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+ label = new Label(labelColumn1, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
label.setText("Title:");\r
\r
- title = new org.simantics.browsing.ui.swt.widgets.TrackedText(general, support, SWT.BORDER);\r
+ title = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER);\r
GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget());\r
title.setTextFactory(new TitleFactory());\r
title.addModifyListener(new TitleModifier());\r
title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
\r
+ // Time\r
+ label = new Label(labelColumn2, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+ label.setText("Time:");\r
+ \r
+ time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER);\r
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget());\r
+ time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time));\r
+ time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time));\r
+ time.setInputValidator(new DoubleValidator(true));\r
+ time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager()));\r
+ \r
// Group for hide options\r
Group hideGroup = new Group(composite, SWT.NONE);\r
GridDataFactory.fillDefaults().applyTo(hideGroup);\r
hlegend.setSelectionFactory(new BooleanPropertyFactory(null, JFreeChartResource.URIs.Chart_visibleLegend, true));\r
hlegend.addSelectionListener(new BooleanSelectionListener(context, null, JFreeChartResource.URIs.Chart_visibleLegend));\r
\r
+ \r
+ \r
// Resize scrolled composite\r
sc.setContent(composite);\r
Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.DoubleValidator;\r
import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
import org.simantics.sysdyn.ui.trend.chart.properties.RVIFactory;\r
import org.simantics.sysdyn.ui.trend.chart.properties.RVIModifier;\r
*/\r
public class BarSeriesPropertyComposite extends Composite {\r
\r
- private TrackedText variable, label;\r
+ private TrackedText variable, label, time;\r
\r
public BarSeriesPropertyComposite(Composite parent, final ISessionContext context, WidgetSupport support, int style) {\r
super(parent, style);\r
this.label.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
this.label.setColorProvider(new JFreeChartPropertyColorProvider(this.label.getResourceManager()));\r
GridDataFactory.fillDefaults().grab(true, false).applyTo(this.label.getWidget());\r
+ \r
+ // Time\r
+ label = new Label(this, SWT.NONE);\r
+ GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+ label.setText("Time:");\r
+ \r
+ Composite composite = new Composite(this, SWT.NONE);\r
+ GridDataFactory.fillDefaults().applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().applyTo(composite);\r
+ \r
+ time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER);\r
+ time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time));\r
+ time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time));\r
+ time.setInputValidator(new DoubleValidator(true));\r
+ time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager()));\r
+ GridDataFactory.fillDefaults().applyTo(time.getWidget());\r
}\r
}\r
\r
import org.eclipse.jface.layout.GridDataFactory;\r
import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.layout.LayoutConstants;\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.custom.ScrolledComposite;\r
import org.eclipse.swt.graphics.Point;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.JFreeChartResource;\r
import org.simantics.sysdyn.ui.properties.LabelPropertyTabContributor;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
import org.simantics.sysdyn.ui.trend.chart.properties.BooleanPropertyFactory;\r
import org.simantics.sysdyn.ui.trend.chart.properties.BooleanSelectionListener;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.DoubleValidator;\r
import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
import org.simantics.sysdyn.ui.trend.chart.properties.TitleFactory;\r
import org.simantics.sysdyn.ui.trend.chart.properties.TitleModifier;\r
private ScrolledComposite sc;\r
private Composite composite;\r
private Button htitle, hlegend, hlabels;\r
- private TrackedText name, title;\r
+ private TrackedText name, title, time;\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { \r
// General properties\r
Group general = new Group(composite, SWT.NONE);\r
GridDataFactory.fillDefaults().grab(true, false).applyTo(general);\r
- GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(general);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(general);\r
general.setText("General");\r
\r
+ // first column: labels\r
+ Composite labelColumn1 = new Composite(general, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1);\r
+ GridLayoutFactory.fillDefaults().applyTo(labelColumn1);\r
+ \r
+ // first column: name and title\r
+ Composite propertyColumn1 = new Composite(general, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1);\r
+ GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1);\r
+ \r
+ // first column: labels\r
+ Composite labelColumn2 = new Composite(general, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2);\r
+ GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2);\r
+ \r
+ // first column: type and time\r
+ Composite propertyColumn2 = new Composite(general, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2);\r
+ GridLayoutFactory.fillDefaults().applyTo(propertyColumn2);\r
+ \r
// Name\r
- Label label = new Label(general, SWT.NONE);\r
- GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+ Label label = new Label(labelColumn1, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
label.setText("Name:");\r
\r
- name = new org.simantics.browsing.ui.swt.widgets.TrackedText(general, support, SWT.BORDER);\r
+ name = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER);\r
GridDataFactory.fillDefaults().grab(true, false).applyTo(name.getWidget());\r
name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
name.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
\r
+ // Dummy data for now. Waiting for different pie chart types\r
+ label = new Label(labelColumn2, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(label);\r
+ label.setText("");\r
+ \r
+ label = new Label(propertyColumn2, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(label);\r
+ label.setText("");\r
+ \r
// Title (Which is different than name)\r
- label = new Label(general, SWT.NONE);\r
- GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+ label = new Label(labelColumn1, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
label.setText("Title:");\r
\r
- title = new org.simantics.browsing.ui.swt.widgets.TrackedText(general, support, SWT.BORDER);\r
+ title = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn1, support, SWT.BORDER);\r
GridDataFactory.fillDefaults().grab(true, false).applyTo(title.getWidget());\r
title.setTextFactory(new TitleFactory());\r
title.addModifyListener(new TitleModifier());\r
title.setColorProvider(new JFreeChartPropertyColorProvider(name.getResourceManager()));\r
\r
+ // Time\r
+ label = new Label(labelColumn2, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+ label.setText("Time:");\r
+ \r
+ time = new org.simantics.browsing.ui.swt.widgets.TrackedText(propertyColumn2, support, SWT.BORDER);\r
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(time.getWidget());\r
+ time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Chart_time));\r
+ time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Chart_time));\r
+ time.setInputValidator(new DoubleValidator(true));\r
+ time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager()));\r
+\r
// Group for hide options\r
Group hideGroup = new Group(composite, SWT.NONE);\r
GridDataFactory.fillDefaults().applyTo(hideGroup);\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.JFreeChartResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
import org.simantics.sysdyn.ui.trend.chart.properties.BooleanPropertyFactory;\r
import org.simantics.sysdyn.ui.trend.chart.properties.BooleanSelectionListener;\r
import org.simantics.sysdyn.ui.trend.chart.properties.ColorPicker;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.DoubleValidator;\r
import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
import org.simantics.sysdyn.ui.trend.chart.properties.RVIFactory;\r
import org.simantics.sysdyn.ui.trend.chart.properties.RVIModifier;\r
*/\r
public class PieSeriesPropertyComposite extends Composite {\r
\r
- private TrackedText variable, label;\r
+ private TrackedText variable, label, time;\r
\r
public PieSeriesPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) {\r
super(parent, style);\r
Composite colorPicker = new ColorPicker(this, context, support, SWT.NONE);\r
GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker);\r
\r
+ // Time\r
+ label = new Label(this, SWT.NONE);\r
+ GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+ label.setText("Time:");\r
+ \r
+ Composite composite = new Composite(this, SWT.NONE);\r
+ GridDataFactory.fillDefaults().applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().applyTo(composite);\r
+ \r
+ time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER);\r
+ time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time));\r
+ time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time));\r
+ time.setInputValidator(new DoubleValidator(true));\r
+ time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager()));\r
+ GridDataFactory.fillDefaults().applyTo(time.getWidget());\r
+ \r
// Exploded\r
label = new Label(this, SWT.NONE);\r
label.setText("");\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.trend.chart.properties.xyline;\r
\r
-import org.eclipse.jface.dialogs.IInputValidator;\r
import org.eclipse.jface.layout.GridDataFactory;\r
import org.eclipse.jface.layout.GridLayoutFactory;\r
import org.eclipse.swt.SWT;\r
import org.simantics.sysdyn.JFreeChartResource;\r
import org.simantics.sysdyn.ui.trend.chart.properties.AxisHidePropertyComposite;\r
import org.simantics.sysdyn.ui.trend.chart.properties.ColorPicker;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.DoubleValidator;\r
import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
\r
/**\r
min.setColorProvider(new JFreeChartPropertyColorProvider(min.getResourceManager()));\r
min.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min));\r
min.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min));\r
- min.setInputValidator(new DoubleValidator());\r
+ min.setInputValidator(new DoubleValidator(true));\r
\r
label = new Label(minmax, SWT.NONE);\r
label.setText("Max:");\r
max.setColorProvider(new JFreeChartPropertyColorProvider(max.getResourceManager()));\r
max.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max));\r
max.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max));\r
- max.setInputValidator(new DoubleValidator());\r
+ max.setInputValidator(new DoubleValidator(true));\r
\r
\r
// Color\r
GridDataFactory.fillDefaults().applyTo(axisHide);\r
}\r
\r
- /**\r
- * Validator for validating that an input is double\r
- * @author Teemu Lempinen\r
- *\r
- */\r
- private class DoubleValidator implements IInputValidator {\r
- @Override\r
- public String isValid(String newText) {\r
- if (newText.trim().isEmpty())\r
- return null;\r
- try {\r
- Double.parseDouble(newText);\r
- return null;\r
- } catch (NumberFormatException e) {\r
- return e.getMessage();\r
- }\r
- }\r
- }\r
- \r
-\r
}\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.trend.chart.properties.xyline;\r
\r
-import org.eclipse.jface.dialogs.IInputValidator;\r
import org.eclipse.jface.layout.GridDataFactory;\r
import org.eclipse.jface.layout.GridLayoutFactory;\r
import org.eclipse.jface.viewers.StructuredSelection;\r
import org.simantics.sysdyn.ui.trend.chart.properties.AxisHidePropertyComposite;\r
import org.simantics.sysdyn.ui.trend.chart.properties.BooleanPropertyFactory;\r
import org.simantics.sysdyn.ui.trend.chart.properties.BooleanSelectionListener;\r
+import org.simantics.sysdyn.ui.trend.chart.properties.DoubleValidator;\r
import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
import org.simantics.sysdyn.ui.trend.chart.properties.RVIFactory;\r
import org.simantics.sysdyn.ui.trend.chart.properties.RVIModifier;\r
xmin.setColorProvider(new JFreeChartPropertyColorProvider(xmin.getResourceManager()));\r
xmin.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_min));\r
xmin.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_min));\r
- xmin.setInputValidator(new DoubleValidator());\r
+ xmin.setInputValidator(new DoubleValidator(true));\r
\r
label = new Label(minmax, SWT.NONE);\r
label.setText("Max:");\r
xmax.setColorProvider(new JFreeChartPropertyColorProvider(xmax.getResourceManager()));\r
xmax.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Axis_max));\r
xmax.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Axis_max));\r
- xmax.setInputValidator(new DoubleValidator());\r
+ xmax.setInputValidator(new DoubleValidator(true));\r
\r
// Set the same width to both label rows\r
composite.layout();\r
});\r
}\r
\r
- \r
- /**\r
- * Validator for validating that an input is double\r
- * @author Teemu Lempinen\r
- *\r
- */\r
- private class DoubleValidator implements IInputValidator {\r
- @Override\r
- public String isValid(String newText) {\r
- if (newText.trim().isEmpty())\r
- return null;\r
- try {\r
- Double.parseDouble(newText);\r
- return null;\r
- } catch (NumberFormatException e) {\r
- return e.getMessage();\r
- }\r
- }\r
- }\r
- \r
-\r
-}\r
+}
\ No newline at end of file
if(variable != null)\r
vars.add(variable);\r
}\r
+ \r
+ // If there is no vars and only one selection, it can be a chart\r
+ if(vars.isEmpty() && ress.size() == 1) {\r
+ Resource r = ress.iterator().next();\r
+ JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+ if(graph.isInstanceOf(r, jfree.ChartElement)) {\r
+ if(graph.hasStatement(r, jfree.ChartElement_component)) {\r
+ r = graph.getSingleObject(r, jfree.ChartElement_component);\r
+ selectionChanged(graph, r);\r
+ return;\r
+ }\r
+ }\r
+ }\r
+ \r
} else {\r
// Selection is a jfreechart\r
if(ress.size() == 1) {\r
Resource r = ress.iterator().next();\r
- if(graph.isInstanceOf(r, JFreeChartResource.getInstance(graph).Chart)) {\r
+ JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
+ if(graph.isInstanceOf(r, jfree.Chart)) {\r
selectionChanged(graph, r);\r
return;\r
}\r