From: lempinen Date: Wed, 21 Dec 2011 09:41:33 +0000 (+0000) Subject: added XY Area renderer X-Git-Tag: simantics-1.6~65 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=90b6edc3f1a286b1833e7f27c7963cfd1a52ea9c;p=simantics%2Fsysdyn.git added XY Area renderer git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@23658 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.jfreechart.ontology/graph.tg b/org.simantics.jfreechart.ontology/graph.tg index 32d291bd..b48384c3 100644 Binary files a/org.simantics.jfreechart.ontology/graph.tg and b/org.simantics.jfreechart.ontology/graph.tg differ diff --git a/org.simantics.jfreechart.ontology/graph/JFreeChart.pgraph b/org.simantics.jfreechart.ontology/graph/JFreeChart.pgraph index 5aa93b6b..01933123 100644 --- a/org.simantics.jfreechart.ontology/graph/JFreeChart.pgraph +++ b/org.simantics.jfreechart.ontology/graph/JFreeChart.pgraph @@ -105,6 +105,9 @@ JFREE.Series () { public JFreeChartResource perform(ReadGraph graph) throws DatabaseException { - QueryControl qc = graph.getService(QueryControl.class); - return new JFreeChartResource(qc.getIndependentGraph(graph)); + return new JFreeChartResource(graph); } }); session.registerService(JFreeChartResource.class, ret); diff --git a/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java b/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java index dda9fead..6ea72e25 100644 --- a/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java +++ b/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java @@ -5,7 +5,6 @@ import org.simantics.db.ReadGraph; import org.simantics.db.request.Read; import org.simantics.db.Session; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.service.QueryControl; public class SysdynResource { @@ -875,8 +874,7 @@ public class SysdynResource { Session session = graph.getSession(); SysdynResource ret = session.peekService(SysdynResource.class); if(ret == null) { - QueryControl qc = graph.getService(QueryControl.class); - ret = new SysdynResource(qc.getIndependentGraph(graph)); + ret = new SysdynResource(graph); session.registerService(SysdynResource.class, ret); } return ret; @@ -887,8 +885,7 @@ public class SysdynResource { if(ret == null) { ret = session.syncRequest(new Read() { public SysdynResource perform(ReadGraph graph) throws DatabaseException { - QueryControl qc = graph.getService(QueryControl.class); - return new SysdynResource(qc.getIndependentGraph(graph)); + return new SysdynResource(graph); } }); session.registerService(SysdynResource.class, ret); diff --git a/org.simantics.sysdyn.ui/adapters.xml b/org.simantics.sysdyn.ui/adapters.xml index 390ea2d9..ecd9bdd0 100644 --- a/org.simantics.sysdyn.ui/adapters.xml +++ b/org.simantics.sysdyn.ui/adapters.xml @@ -10,5 +10,5 @@ VTT Technical Research Centre of Finland - initial API and implementation --> - none 0 fill 1 + none 0 fill 1 \ No newline at end of file diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewXYLineChartHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewXYLineChartHandler.java index 46b44408..98c94da8 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewXYLineChartHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewXYLineChartHandler.java @@ -79,12 +79,15 @@ public class NewXYLineChartHandler extends AbstractHandler { l0.HasName, "NumberAxis" + UUID.randomUUID().toString()); Resource rangeAxis = GraphUtils.create2(g, jfree.NumberAxis, l0.HasName, "NumberAxis" + UUID.randomUUID().toString()); + + Resource renderer = GraphUtils.create2(g, jfree.XYLineRenderer); Resource dataset = GraphUtils.create2(g, jfree.XYDataset, l0.HasName, "XYDataset" + UUID.randomUUID().toString(), jfree.Dataset_mapToDomainAxis, domainAxis, jfree.Dataset_mapToRangeAxis, rangeAxis, - jfree.Dataset_seriesList, ListUtils.create(g, new ArrayList())); + jfree.Dataset_seriesList, ListUtils.create(g, new ArrayList()), + jfree.Dataset_renderer, renderer); GraphUtils.create2(g, jfree.XYPlot, l0.HasName, "XYPlot" + UUID.randomUUID().toString(), diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ChartUtils.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ChartUtils.java index 32081bbe..92e8ba4d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ChartUtils.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/ChartUtils.java @@ -77,11 +77,13 @@ public class ChartUtils { JFreeChartResource jfree = JFreeChartResource.getInstance(graph); Layer0 l0 = Layer0.getInstance(graph); + // Create a dataset for the axis Resource dataset = GraphUtils.create2(graph, jfree.XYDataset, l0.HasName, "XYDataset" + UUID.randomUUID().toString(), jfree.Dataset_mapToDomainAxis, domainAxis, jfree.Dataset_mapToRangeAxis, rangeAxis, + jfree.Dataset_renderer, GraphUtils.create2(graph, jfree.XYLineRenderer), l0.PartOf, plot); return dataset; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYAreaRenderer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYAreaRenderer.java new file mode 100644 index 00000000..65337783 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYAreaRenderer.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.sysdyn.ui.trend.chart; + +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; + +/** + * Renderer representing jfree chart renderer for xy areas + * @author Teemu Lempinen + * + */ +public class XYAreaRenderer extends AbstractRenderer { + + private org.jfree.chart.renderer.xy.XYAreaRenderer renderer; + + public XYAreaRenderer(ReadGraph graph, Resource resource) { + super(graph, resource); + } + + @Override + public org.jfree.chart.renderer.AbstractRenderer getRenderer() { + if(renderer == null) { + renderer = new org.jfree.chart.renderer.xy.XYAreaRenderer(); + renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); + } + return renderer; + } + +} \ No newline at end of file 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 30f65e95..35cf2eec 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 @@ -50,6 +50,7 @@ import org.simantics.sysdyn.adapter.SysdynVariableProperties; import org.simantics.sysdyn.adapter.VariableRVIUtils; import org.simantics.sysdyn.manager.SysdynDataSet; import org.simantics.ui.SimanticsUI; +import org.simantics.utils.datastructures.Pair; /** * Class representing a JFreeChart.XYDataset @@ -59,7 +60,7 @@ import org.simantics.ui.SimanticsUI; */ public class XYDataset extends AbstractDataset { - private XYLineAndShapeRenderer renderer; + private IRenderer renderer; public XYDataset(ReadGraph graph, final Resource datasetResource) { super(graph, datasetResource); @@ -77,18 +78,24 @@ public class XYDataset extends AbstractDataset { if(datasetListener == null || datasetListener.isDisposed()) { datasetListener = new DataSetListener(); - SimanticsUI.getSession().asyncRequest(new Read>() { + SimanticsUI.getSession().asyncRequest(new Read, IRenderer>>() { @Override - public ArrayList perform(ReadGraph graph) throws DatabaseException { + public Pair, IRenderer> perform(ReadGraph graph) throws DatabaseException { JFreeChartResource jfree = JFreeChartResource.getInstance(graph); + // Renderer + IRenderer renderer = null; + 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); if(realizationURI == null) - return series; // No experiment -> No results + return new Pair, IRenderer>(series, renderer); // No experiment -> No results // Get a variable for the x-axis (if not time) double[] domainValues = null; @@ -129,7 +136,7 @@ public class XYDataset extends AbstractDataset { // Get values Object object = v.getPossiblePropertyValue(graph, SysdynVariableProperties.ACTIVE_DATASETS , Bindings.VARIANT); if(object == null || !(object instanceof ArrayList)) - return series; + return new Pair, IRenderer>(series, renderer); ArrayList datasets = new ArrayList(); @@ -191,7 +198,7 @@ public class XYDataset extends AbstractDataset { } } } - return series; + return new Pair, IRenderer>(series, renderer); } }, datasetListener); @@ -245,7 +252,7 @@ public class XYDataset extends AbstractDataset { } } - private class DataSetListener implements Listener> { + private class DataSetListener implements Listener, IRenderer>> { private boolean disposed = false; @@ -259,27 +266,33 @@ public class XYDataset extends AbstractDataset { } @Override - public void execute(final ArrayList series) { + public void execute(Pair, IRenderer> result) { + final ArrayList series = result.first; + renderer = result.second; + // Modify series in AWT thread to avoid synchronization problems SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - /* - * Drawing supplier with a modified first yellow. The default first - * yellow is too light to be visible against a white background - */ - Paint[] paintSequence = ChartColor.createDefaultPaintArray(); - paintSequence[3] = new Color(0xFF, 0xDD, 0x00); - DefaultDrawingSupplier drawingsupplier = new DefaultDrawingSupplier( - paintSequence, - DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, - DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, - DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, - DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, - DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); - ((AbstractXYItemRenderer)getRenderer()).getPlot().setDrawingSupplier(drawingsupplier); + org.jfree.chart.plot.XYPlot plot = ((AbstractXYItemRenderer)getRenderer()).getPlot(); + if(plot != null) { + /* + * Drawing supplier with a modified first yellow. The default first + * yellow is too light to be visible against a white background + */ + Paint[] paintSequence = ChartColor.createDefaultPaintArray(); + paintSequence[3] = new Color(0xFF, 0xDD, 0x00); + DefaultDrawingSupplier drawingsupplier = new DefaultDrawingSupplier( + paintSequence, + DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, + DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, + DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, + DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, + DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); + plot.setDrawingSupplier(drawingsupplier); + } // Remove all series for(int i = dataset.getSeriesCount() - 1; i >= 0; i-- ) { dataset.removeSeries(dataset.getSeriesKey(i)); @@ -406,10 +419,12 @@ public class XYDataset extends AbstractDataset { @Override public AbstractRenderer getRenderer() { if(renderer == null) { - renderer = new XYLineAndShapeRenderer(true, false); + XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); + return renderer; + } else { + return renderer.getRenderer(); } - return renderer; } /** diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYLineRenderer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYLineRenderer.java new file mode 100644 index 00000000..cb2a6d14 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYLineRenderer.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.sysdyn.ui.trend.chart; + +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; + +/** + * Renderer representing jfree chart renderer for xy lines + * @author Teemu Lempinen + * + */ +public class XYLineRenderer extends AbstractRenderer { + + XYLineAndShapeRenderer renderer; + + public XYLineRenderer(ReadGraph graph, Resource resource) { + super(graph, resource); + } + + @Override + public org.jfree.chart.renderer.AbstractRenderer getRenderer() { + if(renderer == null) { + renderer = new XYLineAndShapeRenderer(true, false); + renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); + } + return renderer; + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYPlot.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYPlot.java index a4767c3c..bea1ce22 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYPlot.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/XYPlot.java @@ -37,19 +37,26 @@ public class XYPlot extends AbstractPlot { protected Plot newPlot() { return new org.jfree.chart.plot.XYPlot(null, null, null, null); } - + @Override protected void getOtherProperties(ReadGraph graph, PlotProperties properties) throws DatabaseException { JFreeChartResource jfree = JFreeChartResource.getInstance(graph); Boolean visibleGrid = graph.getPossibleRelatedValue(resource, jfree.Plot_visibleGrid); properties.otherProperties.put("visibleGrid", visibleGrid); + if(!properties.datasets.isEmpty()) { + IDataset idataset = properties.datasets.get(0); + Resource renderer = graph.getPossibleObject(idataset.getResource(), jfree.Dataset_renderer); + if(renderer != null) { + properties.otherProperties.put("renderer", graph.adapt(renderer, IRenderer.class)); + } + } } @Override protected void setPlotProperties(PlotProperties properties) { if(!(plot instanceof org.jfree.chart.plot.XYPlot)) return; - + org.jfree.chart.plot.XYPlot xyplot = (org.jfree.chart.plot.XYPlot)plot; xyplot.clearDomainAxes(); xyplot.clearRangeAxes(); @@ -81,7 +88,7 @@ public class XYPlot extends AbstractPlot { xyplot.setRangeGridlinesVisible(visibleGrid); xyplot.setDomainGridlinesVisible(visibleGrid); - + // Cleaner look: no outline borders xyplot.setInsets(new RectangleInsets(2,5,2,10), false); xyplot.setOutlineVisible(false); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarGeneralPropertiesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarGeneralPropertiesTab.java index 5982d6dc..be09d06a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarGeneralPropertiesTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/bar/BarGeneralPropertiesTab.java @@ -89,17 +89,17 @@ public class BarGeneralPropertiesTab extends LabelPropertyTabContributor { GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn1); GridLayoutFactory.fillDefaults().applyTo(labelColumn1); - // first column: name and title + // second column: name and title Composite propertyColumn1 = new Composite(general, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(propertyColumn1); GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(propertyColumn1); - // first column: labels + // third column: labels Composite labelColumn2 = new Composite(general, SWT.NONE); GridDataFactory.fillDefaults().grab(false, true).applyTo(labelColumn2); GridLayoutFactory.fillDefaults().spacing(0, LayoutConstants.getSpacing().y).applyTo(labelColumn2); - // first column: type and time + // fourth column: type and time Composite propertyColumn2 = new Composite(general, SWT.NONE); GridDataFactory.fillDefaults().grab(false, true).applyTo(propertyColumn2); GridLayoutFactory.fillDefaults().applyTo(propertyColumn2); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineGeneralPropertiesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineGeneralPropertiesTab.java index 857a7caf..c4e730da 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineGeneralPropertiesTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/xyline/XYLineGeneralPropertiesTab.java @@ -11,13 +11,16 @@ *******************************************************************************/ package org.simantics.sysdyn.ui.trend.chart.properties.xyline; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; + import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; @@ -25,17 +28,23 @@ import org.eclipse.ui.IWorkbenchSite; import org.simantics.browsing.ui.swt.widgets.Button; import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory; import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier; +import org.simantics.browsing.ui.swt.widgets.TrackedCombo; import org.simantics.browsing.ui.swt.widgets.TrackedText; +import org.simantics.browsing.ui.swt.widgets.impl.ComboModifyListenerImpl; +import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; import org.simantics.browsing.ui.swt.widgets.impl.Widget; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.common.request.PossibleObjectWithType; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; import org.simantics.layer0.Layer0; +import org.simantics.layer0.utils.direct.GraphUtils; import org.simantics.modeling.ui.chart.property.DoublePropertyFactory; import org.simantics.modeling.ui.chart.property.DoublePropertyModifier; import org.simantics.sysdyn.JFreeChartResource; @@ -62,7 +71,7 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl private ScrolledComposite sc; private Composite composite; private TrackedText name, title, xlabel, xvariable, xmin, xmax; - private Combo type; + private TrackedCombo type; private Button hgrid, htitle, hlegend; private WidgetSupportImpl domainAxisSupport = new WidgetSupportImpl(); @@ -107,9 +116,11 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); label.setText("Type:"); - type = new Combo(c, SWT.BORDER | SWT.READ_ONLY); - type.setItems(new String[] {"Line", "Fancy", "Area", "3D"}); - type.select(0); + type = new TrackedCombo(c, support, SWT.BORDER | SWT.READ_ONLY); + type.addModifyListener(new TypeModifyListener()); + type.setItemFactory(new TypeItemFactory()); + type.setSelectionFactory(new TypeSelectionFactory()); + GridDataFactory.fillDefaults().applyTo(type.getWidget()); // Title (Which is different than name) label = new Label(general, SWT.NONE); @@ -224,5 +235,82 @@ public class XYLineGeneralPropertiesTab extends LabelPropertyTabContributor impl } }); } + + /** + * + * @author Teemu Lempinen + * + */ + private class TypeSelectionFactory extends ReadFactoryImpl { + @Override + public String perform(ReadGraph graph, Resource chart) throws DatabaseException { + JFreeChartResource jfree = JFreeChartResource.getInstance(graph); + Layer0 l0 = Layer0.getInstance(graph); + + Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.XYPlot)); + if(plot != null) { + Collection datasets = graph.syncRequest(new ObjectsWithType(plot, l0.ConsistsOf, jfree.XYDataset)); + if(!datasets.isEmpty()) { + Resource dataset = datasets.iterator().next(); + if(dataset != null) { + Resource renderer = graph.syncRequest(new PossibleObjectWithType(dataset, jfree.Dataset_renderer, jfree.Renderer)); + if(renderer != null && graph.isInstanceOf(renderer, jfree.XYAreaRenderer)) + return "Area"; + } + } + } + return "Line"; + } + } + + /** + * RangeItemFactory finds all inexes of a given enumeration + * and adds "Sum" and "All" to the returned indexes + * @author Teemu Lempinen + * + */ + private class TypeItemFactory extends ReadFactoryImpl> { + @Override + public Map perform(ReadGraph graph, Resource series) throws DatabaseException { + LinkedHashMap result = new LinkedHashMap(); + result.put("Line", "Line"); + result.put("Area", "Area"); +// result.put("Stacked Area", "Stacked Area"); + return result; + } + } + + /** + * TypeModifyListener for modifying the type of a bar chart + * @author Teemu Lempinen + * + */ + private class TypeModifyListener extends ComboModifyListenerImpl { + @Override + public void applyText(WriteGraph graph, Resource chart, String text) throws DatabaseException { + JFreeChartResource jfree = JFreeChartResource.getInstance(graph); + Layer0 l0 = Layer0.getInstance(graph); + + Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.XYPlot)); + if(plot == null) + return; + + Collection datasets = graph.syncRequest(new ObjectsWithType(plot, l0.ConsistsOf, jfree.XYDataset)); + if(datasets == null || datasets.isEmpty()) + return; + + for(Resource dataset : datasets) { + graph.deny(dataset, jfree.Dataset_renderer); + + Resource renderer; + if(text.equals("Area")) + renderer = GraphUtils.create2(graph, jfree.XYAreaRenderer); + else + renderer = GraphUtils.create2(graph, jfree.XYLineRenderer); + + graph.claim(dataset, jfree.Dataset_renderer, renderer); + } + } + } } \ No newline at end of file