RCP with Dynamic Chart evaluation
RCP with Dynamic Chart evaluation
I am evaluating if we should use JFreeChart in our project. We need dynamic chart with Eclipse RCP. I am not sure how good for now JFreeChart support it. Based on information from this forum, it seems there are two ways to do it, one is SWT-AWT bridge and the other is SWT JFreeChart Support but it is in experimental phase. Could you please tell me
- Why SWT-AWT way is not good?
- What kind of situation now for the JFreeChart to support SWT with dynamic chart? Is it working properly already even in experiment? I see a thread regarding SWTMemoryUsage but it reported some bugs there and that thread moved to develoepr mailing list. So I have no idea what current stage regrarding this issue.
- Is there any developer guide on JFreeChart SWT support?
- Is there any demo source code for SWT with dynamich chart there?
Thanks,
Han
- Why SWT-AWT way is not good?
- What kind of situation now for the JFreeChart to support SWT with dynamic chart? Is it working properly already even in experiment? I see a thread regarding SWTMemoryUsage but it reported some bugs there and that thread moved to develoepr mailing list. So I have no idea what current stage regrarding this issue.
- Is there any developer guide on JFreeChart SWT support?
- Is there any demo source code for SWT with dynamich chart there?
Thanks,
Han
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: RCP with Dynamic Chart evaluation
Until SWT includes "out-of-the-box" support for the Graphics2D API (if it ever does), I think JFreeChart will always be a second class citizen on SWT. We're trying out different ways to make JFreeChart useable in SWT, but it isn't the highest priority for me personally (I don't use SWT). Others are working on it though.
I haven't tried it out. Some people have reported that it works well, others have said it has problems. I don't know enough about it to say any more.rspan wrote:- Why SWT-AWT way is not good?
I've been busy on some other things, so I don't know exactly the current state. I don't recall running the SWTMemoryUsage demo - do you have a link to the thread?rspan wrote:- What kind of situation now for the JFreeChart to support SWT with dynamic chart? Is it working properly already even in experiment? I see a thread regarding SWTMemoryUsage but it reported some bugs there and that thread moved to develoepr mailing list. So I have no idea what current stage regrarding this issue.
No to both. The code is still experimental, so I haven't committed any time to documenting it.rspan wrote:- Is there any developer guide on JFreeChart SWT support?
- Is there any demo source code for SWT with dynamich chart there?
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 59
- Joined: Fri Oct 13, 2006 11:35 am
- Contact:
regarding dynamic plot in rcp
Hi Rspan,
I am using the current experimental of swt-jfreechart version to diplay in RCP view .
It was working just similar to swing version .
In the current project i need to display that chart in an RCP view , It is working great .
With the SWT_AWT bridge the mouse events on the chart are not handled properly thats the reason we have eliminated to use SWT_AWT compatability and went for direct display in composite it self .
To the extent I have gone for my project Jfreechart-swt supports most of the features including dynamic plot also been able to diplay inside an RCP View.
by
raghavan
I am using the current experimental of swt-jfreechart version to diplay in RCP view .
It was working just similar to swing version .
In the current project i need to display that chart in an RCP view , It is working great .
With the SWT_AWT bridge the mouse events on the chart are not handled properly thats the reason we have eliminated to use SWT_AWT compatability and went for direct display in composite it self .
To the extent I have gone for my project Jfreechart-swt supports most of the features including dynamic plot also been able to diplay inside an RCP View.
by
raghavan
-
- Posts: 59
- Joined: Fri Oct 13, 2006 11:35 am
- Contact:
example
the code example
use the chart composite class of jfreechart-swt version to get the display .
Code: Select all
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.time.Millisecond;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.experimental.chart.swt.ChartComposite;
import org.jfree.ui.RectangleInsets;
public class SWTMemoryUsageDemo {
private static Display display;
private static ChartComposite chartComposite;
private TimeSeries total;
private TimeSeries free;
class DataGenerator extends Timer implements ActionListener {
DataGenerator(int i) {
super(i, null);
addActionListener(this);
}
public void actionPerformed(ActionEvent actionevent) {
// for SWT UI thread issue, use Display.asyncExec()
display.asyncExec(new Runnable() {
public void run() {
long l = Runtime.getRuntime().freeMemory();
long l1 = Runtime.getRuntime().totalMemory();
addTotalObservation(l1);
addFreeObservation(l);
// for chart redraw, use ChartComposite.forceRedraw();
// if not use this, then chart will not redraw.
// I don't know why.
chartComposite.forceRedraw();
}
});
}
}
public SWTMemoryUsageDemo(int i) {
total = new TimeSeries("Total Memory", org.jfree.data.time.Millisecond.class);
total.setMaximumItemAge(i);
free = new TimeSeries("Free Memory", org.jfree.data.time.Millisecond.class);
free.setMaximumItemAge(i);
}
public JFreeChart createChart() {
TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
timeseriescollection.addSeries(total);
timeseriescollection.addSeries(free);
DateAxis dateaxis = new DateAxis("Time");
NumberAxis numberaxis = new NumberAxis("Memory");
dateaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
numberaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
dateaxis.setLabelFont(new Font("SansSerif", 0, 14));
numberaxis.setLabelFont(new Font("SansSerif", 0, 14));
XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
xylineandshaperenderer.setSeriesPaint(0, Color.red);
xylineandshaperenderer.setSeriesPaint(1, Color.green);
xylineandshaperenderer.setStroke(new BasicStroke(3F, 0, 2));
XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
xyplot.setBackgroundPaint(Color.lightGray);
xyplot.setDomainGridlinePaint(Color.white);
xyplot.setRangeGridlinePaint(Color.white);
xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
dateaxis.setAutoRange(true);
dateaxis.setLowerMargin(0.0D);
dateaxis.setUpperMargin(0.0D);
dateaxis.setTickLabelsVisible(true);
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
JFreeChart jfreechart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", 1, 24), xyplot, true);
jfreechart.setBackgroundPaint(Color.white);
return jfreechart;
}
private void addTotalObservation(final double d) {
total.addOrUpdate(new Millisecond(), d);
}
private void addFreeObservation(final double d) {
free.addOrUpdate(new Millisecond(), d);
}
public static void main(String args[]) {
display = new Display();
Shell shell = new Shell(display);
shell.setSize(600, 300);
shell.setLayout(new FillLayout());
shell.setText("Memory Usage Demo");
SWTMemoryUsageDemo memoryusagedemo = new SWTMemoryUsageDemo(30000);
JFreeChart chart = memoryusagedemo.createChart();
chartComposite = new ChartComposite(shell, SWT.NONE, chart, true);
chartComposite.setDisplayToolTips(true);
chartComposite.setHorizontalAxisTrace(false);
chartComposite.setVerticalAxisTrace(false);
shell.open();
(memoryusagedemo.new DataGenerator(100)).start();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
Thanks. raghavan_26 for the sample. Especially your notes on how to get display. That is very improtant bucase I need to get the display from the view.
Did you go the same problem which Silent mention, basically running for amount of time, out of handler exception happens or if resize the windows, then happend Exception in thread "AWT-EventQueue-0" org.eclipse.swt.SWTException: Widget is disposed. How do you fix that?
Thanks.
Did you go the same problem which Silent mention, basically running for amount of time, out of handler exception happens or if resize the windows, then happend Exception in thread "AWT-EventQueue-0" org.eclipse.swt.SWTException: Widget is disposed. How do you fix that?
Thanks.
-
- Posts: 59
- Joined: Fri Oct 13, 2006 11:35 am
- Contact:
hi ,
I ran that class for a number of time , Ist time I was running i was able to get SWTException , then again I ran it a noer of times and even maximized and minimized the chart composite I dint get any exception what u were talking of "AWT-EventQueue-0" exception .
But the only problem I get using that class is even though I close the composite the process is still running in memory. so I had to terminate it exclusively .
I ran that class for a number of time , Ist time I was running i was able to get SWTException , then again I ran it a noer of times and even maximized and minimized the chart composite I dint get any exception what u were talking of "AWT-EventQueue-0" exception .
But the only problem I get using that class is even though I close the composite the process is still running in memory. so I had to terminate it exclusively .