*******************************************************************************/\r
package org.simantics.jfreechart.chart;\r
\r
-import java.util.ArrayList;\r
import java.util.HashMap;\r
\r
import javax.swing.SwingUtilities;\r
public org.jfree.chart.JFreeChart getJfreechart() {\r
return jfreechart;\r
}\r
+ \r
+ public PlotProperties getPlotProperties() {\r
+ return currentProperties;\r
+ }\r
\r
protected abstract Plot newPlot();\r
- protected abstract void setPlotProperties(PlotProperties properties);\r
+ protected void setPlotProperties(PlotProperties properties) {\r
+ this.currentProperties = properties;\r
+ }\r
protected abstract void getOtherProperties(ReadGraph graph, PlotProperties properties) throws DatabaseException;\r
\r
@Override\r
\r
@Override\r
public void configurePlot(PlotProperties properties) {\r
- // TODO Auto-generated method stub\r
\r
}\r
\r
- protected class PlotProperties {\r
- public ArrayList<IAxis> ranges;\r
- public ArrayList<IAxis> domains;\r
- public ArrayList<IDataset> datasets;\r
- public HashMap<IDataset, IAxis> rangeMappings;\r
- public HashMap<IDataset, IAxis> domainMappings;\r
- public HashMap<String, Object> otherProperties;\r
- \r
- public PlotProperties() {\r
- datasets = new ArrayList<IDataset>();\r
- rangeMappings = new HashMap<IDataset, IAxis>();\r
- domainMappings = new HashMap<IDataset, IAxis>();\r
- ranges = new ArrayList<IAxis>();\r
- domains = new ArrayList<IAxis>();\r
- otherProperties = new HashMap<String, Object>();\r
- }\r
-\r
- @Override\r
- public boolean equals(Object other) {\r
- if(!this.getClass().equals(other.getClass()))\r
- return false;\r
- PlotProperties p = (PlotProperties)other;\r
- if(!ranges.equals(p.ranges))\r
- return false;\r
- if(!domains.equals(p.domains))\r
- return false;\r
- if(!datasets.equals(p.datasets))\r
- return false;\r
- if(!rangeMappings.equals(p.rangeMappings))\r
- return false;\r
- if(!domainMappings.equals(p.domainMappings))\r
- return false;\r
- if(!otherProperties.equals(p.otherProperties))\r
- return false;\r
- return true;\r
- }\r
- }\r
-\r
private class PlotPropertyListener implements Listener<PlotProperties> {\r
\r
private boolean disposed = false;\r
// Cleaner look: no outline borders\r
cplot.setInsets(new RectangleInsets(2,5,2,2), false);\r
cplot.setOutlineVisible(false);\r
+ super.setPlotProperties(properties);\r
}\r
\r
@Override\r
return jPanel;\r
}\r
\r
- private void setPanel(final ChartPanel panel) {\r
+ protected void setPanel(final ChartPanel panel) {\r
ThreadUtils.asyncExec(AWTThread.getThreadAccess(), new Runnable() {\r
\r
@Override\r
}\r
});\r
}\r
+ \r
+ public ChartPanel getChartPanel() {\r
+ return chartPanel;\r
+ }\r
+ \r
+ public IJFreeChart getChart() {\r
+ return chart;\r
+ }\r
\r
/**\r
* Creates and displays the chart defined in chartResource\r
\r
import org.jfree.data.category.DefaultCategoryDataset;\r
import org.jfree.data.general.AbstractDataset;\r
+import org.jfree.data.general.DatasetChangeEvent;\r
+import org.jfree.data.general.DatasetChangeListener;\r
\r
@SuppressWarnings("rawtypes")\r
-public class FilteringCategoryDataset extends AbstractDataset implements org.jfree.data.category.CategoryDataset, FilteredDataset{\r
+public class FilteringCategoryDataset extends AbstractDataset implements org.jfree.data.category.CategoryDataset, FilteredDataset, DatasetChangeListener{\r
\r
private static final long serialVersionUID = -4955124650051030544L;\r
\r
this.filtered = new DefaultCategoryDataset();\r
this.other = other;\r
this.used = filtered;\r
+ this.original.addChangeListener(this);\r
updateFiltered();\r
}\r
\r
return other;\r
}\r
\r
- \r
+ @Override\r
+ public void datasetChanged(DatasetChangeEvent event) {\r
+ // bypass change events from the original dataset.\r
+ fireDatasetChanged();\r
+ }\r
\r
\r
}\r
*/\r
public JFreeChart getChart();\r
\r
+ public IPlot getPlot();\r
+ \r
}\r
import org.jfree.chart.plot.Plot;\r
import org.simantics.db.Resource;\r
import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.jfreechart.chart.AbstractPlot.PlotProperties;\r
\r
/**\r
* Interface for JFreeChart.Plot type resource\r
\r
public void configurePlot(PlotProperties properties);\r
\r
+ public PlotProperties getPlotProperties();\r
\r
public void setJFreeChart(JFreeChart jfreechart);\r
\r
\r
return jfreechart;\r
}\r
+ \r
+ @Override\r
+ public IPlot getPlot() {\r
+ return plot;\r
+ }\r
\r
@Override\r
public void dispose() {\r
piePlot.setOutlineVisible(false);\r
piePlot.setLabelBackgroundPaint(Color.WHITE);\r
piePlot.setLabelFont(new Font("helvetica", Font.PLAIN, 11));\r
+ super.setPlotProperties(properties);\r
}\r
\r
}\r
--- /dev/null
+package org.simantics.jfreechart.chart;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+\r
+public class PlotProperties {\r
+ \r
+ public ArrayList<IAxis> ranges;\r
+ public ArrayList<IAxis> domains;\r
+ public ArrayList<IDataset> datasets;\r
+ public HashMap<IDataset, IAxis> rangeMappings;\r
+ public HashMap<IDataset, IAxis> domainMappings;\r
+ public HashMap<String, Object> otherProperties;\r
+ \r
+ public PlotProperties() {\r
+ datasets = new ArrayList<IDataset>();\r
+ rangeMappings = new HashMap<IDataset, IAxis>();\r
+ domainMappings = new HashMap<IDataset, IAxis>();\r
+ ranges = new ArrayList<IAxis>();\r
+ domains = new ArrayList<IAxis>();\r
+ otherProperties = new HashMap<String, Object>();\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object other) {\r
+ if(!this.getClass().equals(other.getClass()))\r
+ return false;\r
+ PlotProperties p = (PlotProperties)other;\r
+ if(!ranges.equals(p.ranges))\r
+ return false;\r
+ if(!domains.equals(p.domains))\r
+ return false;\r
+ if(!datasets.equals(p.datasets))\r
+ return false;\r
+ if(!rangeMappings.equals(p.rangeMappings))\r
+ return false;\r
+ if(!domainMappings.equals(p.domainMappings))\r
+ return false;\r
+ if(!otherProperties.equals(p.otherProperties))\r
+ return false;\r
+ return true;\r
+ }\r
+ \r
+}\r