Thanks for help!
No need to look into it more you're right! I put a panel on the Frame
and add my JFreeChart panel in the first panel and... this works!!!! I
can use mouse to zoom/unzoom charts!
Otherwise do you know where I can get some information on SWT_AWT and
the way SWT integrates AWT/Swing?
I find very good that you're really reactive on problems we can face. Many thanks!
Mathieu
Steve Northover wrote:
We are looking into it. For now,
here is some info from eclipse.platform.swt:
Is this a bug? - I dont know.
In order to receive swing mouse events you must place a Panel on the
Frame
got from new_Frame and add the swing widgets to the Panel. If you put
the
widgets in the Frame directly they dont get mouse events. AWT widgets
work
fine but not Swing ones.
Hi all,
I'm trying to use the SWT_AWT library and I integrated some JFreeChart
(a nice open source chart drawing component) chart in my application.
This
works I can see my charts in SWT embedded composite, but I have a
little
problem with mouse events. JFreeChart allows to zoom/unzoom charts by
drawing
a rectangle with mouse, but I can't do it in the embedded composite.
Does somebody have an idea on how I could get jfreechart mouse events
working?
Maybe I have to connect SWT events to AWT event? A problem of focus?
Thanks for help.
Mathieu.
PS : Here is a snippet of the way I integrated JFreeChart on SWT :
public ScatterPlotView(Composite parent, int style) {
super(parent, style);
GridLayout layout = new GridLayout(1, true);
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
setLayout(layout);
Composite jFreeComp = new Composite(this, SWT.EMBEDDED);
jFreeComp.setLayoutData(new GridData(GridData.FILL_VERTICAL
| GridData.FILL_HORIZONTAL));
java.awt.Frame jfreeFrame = SWT_AWT.new_Frame(jFreeComp);
XYDataset data = "" SampleXYDataset2();
JFreeChart chart = ChartFactory.createScatterPlot(
"Scatter Plot",
"X", "Y",
data,
PlotOrientation.VERTICAL,
true,
true,
false
);
Legend legend = chart.getLegend();
if (legend instanceof StandardLegend) {
StandardLegend sl = (StandardLegend)
legend;
sl.setDisplaySeriesShapes(true);
}
NumberAxis domainAxis = (NumberAxis)
chart.getXYPlot().getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500,
270));
chartPanel.setVerticalAxisTrace(true);
chartPanel.setHorizontalAxisTrace(true);
chartPanel.setVerticalZoom(true);
chartPanel.setHorizontalZoom(true);
chartPanel.setAutoscrolls(true);
chartPanel.setMouseZoomable(true);
jfreeFrame.add(chartPanel);
}
_______________________________________________
platform-swt-dev
mailing list platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev
|