Slightly different way that I have used
is:
ByteArrayOutputStream baos = new
ByteArrayOutputStream(bufSize);
ImageIO.write(bufImg, DEFAULT_IMAGE_TYPE,
baos);
imageData = new NSData(baos.toByteArray());
where DEFAULT_IMAGE_TYPE is "png" or image
type defined, bufImg is BufferedImage. That should replace the last two
line of your code.
Cheers
Cheong Hee
----- Original Message -----
Sent: Thursday, January 07, 2010 9:18
AM
Subject: Re: from JFreeChart
(BufferedImage_) to NSData_
JFreeChart
lineChart = createChart( dataSet );
ByteArrayOutputStream stream = new
ByteArrayOutputStream();
ChartUtilities.writeChartAsPNG(stream,
lineChart, 500, 300);
return new
NSData(stream.toByteArray());
Alternatively you can use writeChartAsJPEG.
Or let ERPlot deal with it by using the chart binding:
MyChart :
ERPCategoryChart {
chart =
lineChart;
width =
500;
height =
300;
}
Sharpy..
On 07/01/2010, at 9:54 AM, Baiss Eric Magnusson wrote:
In the below method how do I get
the return stuff from JFreeChart to be put into a NSData which is bound to
the <data> binding of a WOImage, which is the way I've see to use for
the Line Chart I'm creating. It seems that JFreeChart uses .png by
default, which is good n'est-ce pas?
public NSData lineChartJFree() {
XYSeriesCollection
dataSet = createDataset();
JFreeChart lineChart =
createChart( dataSet );
BufferedImage
bufFromJFree = lineChart.createBufferedImage( 800, 500 );
Raster rast =
bufFromJFree.getData();
return new
NSData( rast.??? );
}
Baiss -
I looked at this package and, frankly, it does not make that much
sense to me either. But then I find that when Anjo puts things in, be can
often be ... concise, shall we say ... in how he documents things. I could
probably buy and read through the doc for JFreeChart, but I have not done
that yet.
I put a new Example project in Wonder. It is
Examples/Misc/ERComponentTour. There is, after all, nothing analogous to
the D2WComponentTour example and there are lots of non-D2W components in
Wonder. The first (and presently only) page in that app is for
"ERPCategoryChart & ERPPieChart." And there is no ERPPieChart yet. And
the examples there are probably not the smartest. It certainly seems that
for the AreaChart and WaterfallChart, this dataset does not make sense.
But this is the first version, so it is obviously better than what was
there before. And anyone who wants to show better examples of these
components is certainly welcome to do so.
This example does show a minimal usage of the ERPCategoryChart. Let
me know if this helps at all. Or, if it does not, what would be needed to
make it make more sense? Let me know what you end up figuring out and I
can probably use that to improve the example.
cheers -
ray
_______________________________________________ Do
not post admin requests to the list. They will be ignored. Webobjects-dev
mailing list (email@hidden) Help/Unsubscribe/Update
your Subscription:
_______________________________________________ Do not post admin
requests to the list. They will be ignored. Webobjects-dev mailing
list
(email@hidden) Help/Unsubscribe/Update your
email sent to email@hidden
|