|
|
Re: RAP & JFreeChart [message #547666 is a reply to message #547647] |
Mon, 19 July 2010 10:05 |
|
Hi Benjamin,
Thank you for your response.
I've managed to use JFreeChart in Label widget without using image file
at all.
Here's my simplified code in case if anyone needs it :
....
Label label = new Label(parent,SWT.NONE);
Image image = null;
JFreeChart chart = ChartFactory.createBarChart("Bar Chart", null, null,
new DefaultCategoryDataset(), PlotOrientation.VERTICAL, true, true, false);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ByteArrayInputStream bis = null;
try
{
ChartUtilities.writeChartAsPNG(bos, chart, 300, 300);
image = new Image(Display.getCurrent(), bis = new
ByteArrayInputStream(bos.toByteArray()));
label.setImage(image);
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try {bos.close();}
catch (IOException e){}
if (bis != null)
{
try {bis.close();}
catch (IOException e){}
}
}
....
The above code lacks routine to dispose image which I've put it on
somewhere else.
Thanks & Regards,
Setya
> Hi Setya,
>
> as far as I know, JFreeChart can render the charts to an image file.
> This can be used as Image for a Label for something similar. See the
> BIRT integration tutorial which has an example of how to use it.
> And it would be awesome to write a FAQ entry about integrating
> JFreeChart into RAP.
>
> Regards,
> Ben
>
> Setya wrote:
>> Has anybody successfully integrated the two ?
>>
>>
>> Thanks & Regards,
>>
>> Setya
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03235 seconds