hallo,
i'm using the ecplice-ide and develop with swt/jface. it is possible to using JFreeChart with swt/jface ?
thank's
using JFreeChart with SWT and/or JFace
I'm, into this problem to.
The bridge is to use SWT_AWT.
See below:
regards
mst
The bridge is to use SWT_AWT.
See below:
Code: Select all
protected void createContents() {
shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application");
final Composite drawarea = new Composite(shell, SWT.NONE);
drawarea.setBounds(65, 65, 317, 192);
Frame canvasFrame = SWT_AWT.new_Frame(drawarea);
final java.awt.Canvas canvas = new java.awt.Canvas();
canvasFrame.add(canvas);
final java.awt.Graphics2D g2d = (java.awt.Graphics2D) canvas.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// and so on...
}
regards
mst
exist a way WITHOUT awt ??
regards
ingo
Code: Select all
protected Control createContents(Composite parent){
TableColumn column;
final Composite composite = new Composite(parent,SWT.EMBEDDED);
composite.setLayout(new FillLayout());
SashForm sash = new SashForm(composite,SWT.VERTICAL);
Composite compChart = new Composite(sash,SWT.BORDER);
// create chart-object for upper sash
CategoryDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);
ChartPanel chartPanel = new ChartPanel(chart, false);
??? add chart to compChart WITHOUT any awt-objects ???
// create and fill tableviewer for lower sash
viewer = new TableViewer(sash,SWT.BORDER|SWT.HORIZONTAL|SWT.VERTICAL);
sash.setWeights(new int[]{60,40});
Table table = viewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
...
return composite;
}
ingo
Hi,
JFreeChart is a standards compliant library and aims to be 100% Java. Support of non-standard (and non-superior) component systems does not offer anything valuable. The SWT is not faster than the AWT/Swing and is not platform independent.
JFreeChart relies on Java2D and will not work without that API. You have to use the bridge code offered by SWT if you want to use JFreeChart. There is no other way.
Have mo' fun,
said Thomas
JFreeChart is a standards compliant library and aims to be 100% Java. Support of non-standard (and non-superior) component systems does not offer anything valuable. The SWT is not faster than the AWT/Swing and is not platform independent.
JFreeChart relies on Java2D and will not work without that API. You have to use the bridge code offered by SWT if you want to use JFreeChart. There is no other way.
Have mo' fun,
said Thomas
Render to an image
Actually, there is another way, which I just successfully prototyped a few minutes ago. Draw the chart to memory (as JPEG, PNG, etc) and then render an SWT image from the exported image in memory.
The code looks something like this:
The code looks something like this:
Code: Select all
Rectangle _size = ((Canvas) event.widget).getBounds();
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
ChartUtilities.writeChartAsPNG(outstream, _chart, _size.width, _size.height);
byte[] image_buffer = outstream.toByteArray();
ByteArrayInputStream instream = new ByteArrayInputStream(image_buffer);
ImageData image_data = new ImageData(instream);
_image = new Image(event.display, image_data);
event.gc.drawImage(_image, 0, 0);