From 788c3031395b45c36fdc4a140e94f18f394b1650 Mon Sep 17 00:00:00 2001 From: luukkainen Date: Wed, 17 Sep 2014 07:58:19 +0000 Subject: [PATCH] fixes #5317 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30287 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../simantics/jfreechart/chart/AbstractPlot.java | 16 +++++++++++++--- .../org/simantics/jfreechart/chart/IPlot.java | 8 +++++++- .../simantics/jfreechart/chart/JFreeChart.java | 4 +++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/AbstractPlot.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/AbstractPlot.java index ebfba892..112b0f33 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/AbstractPlot.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/AbstractPlot.java @@ -16,6 +16,7 @@ import java.util.HashMap; import javax.swing.SwingUtilities; +import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.Axis; import org.jfree.chart.plot.Plot; import org.simantics.db.ReadGraph; @@ -41,7 +42,7 @@ public abstract class AbstractPlot implements IPlot { protected Plot plot; protected PlotProperties currentProperties; private PlotPropertyListener listener; - + private org.jfree.chart.JFreeChart jfreechart; public AbstractPlot(ReadGraph graph, Resource resource) { this.resource = resource; @@ -67,6 +68,15 @@ public abstract class AbstractPlot implements IPlot { public Resource getResource() { return resource; } + + @Override + public void setJFreeChart(JFreeChart jfreechart) { + this.jfreechart = jfreechart; + } + + public org.jfree.chart.JFreeChart getJfreechart() { + return jfreechart; + } protected abstract Plot newPlot(); protected abstract void setPlotProperties(PlotProperties properties); @@ -143,7 +153,7 @@ public abstract class AbstractPlot implements IPlot { } @Override - public void configurePlot() { + public void configurePlot(PlotProperties properties) { // TODO Auto-generated method stub } @@ -200,7 +210,7 @@ public abstract class AbstractPlot implements IPlot { @Override public void run() { setPlotProperties(result); - configurePlot(); + configurePlot(result); } }); } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/IPlot.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/IPlot.java index c040a5f5..473ee385 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/IPlot.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/IPlot.java @@ -11,9 +11,11 @@ *******************************************************************************/ package org.simantics.jfreechart.chart; +import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.Plot; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; +import org.simantics.jfreechart.chart.AbstractPlot.PlotProperties; /** * Interface for JFreeChart.Plot type resource @@ -38,6 +40,10 @@ public interface IPlot extends IJFreeChartComponent { */ public Resource getResource(); - public void configurePlot(); + public void configurePlot(PlotProperties properties); + + public void setJFreeChart(JFreeChart jfreechart); + + public JFreeChart getJfreechart(); } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/JFreeChart.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/JFreeChart.java index ea8df3d6..a6a66b72 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/JFreeChart.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/JFreeChart.java @@ -84,7 +84,9 @@ public class JFreeChart implements IJFreeChart { if(jfreechart == null) jfreechart = new org.jfree.chart.JFreeChart(plot.getPlot()); - + + plot.setJFreeChart(jfreechart); + if(listener == null) { listener = new JFreeChartListener(); SimanticsUI.getSession().asyncRequest(new Read>() { -- 2.47.1