I will be the first to admit I am slow to upgrade JARs in my project. I have been using jfreechart-1.0.0-rc1.jar and jcommon-1.0.0-rc1.jar for about a year successfully generating scatterplots with background images and then exporting as JPEGs.
The code is simple and uses a background image that is in PNG format:
Code: Select all
XYSeriesCollection dataset = fetchFwdData(); // my function
JFreeChart chart = null;
try {
chart = ChartFactory.createScatterPlot(
null, // chart title
null, // domain axis label
null, // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
false, // tooltips
false); // urls
if( mFwdImage != null ) { // mFwdImage is a java.awt.Image loaded from a PNG file.
chart.getXYPlot().setBackgroundImage(mFwdImage);
}
} catch (java.lang.Exception e ) {
e.printStackTrace();
}
try {
org.jfree.chart.ChartUtilities.writeChartAsJPEG(baos, 1.0f, chart, mWidth, mHeight);
} catch (java.io.IOException e) {
System.out.println(e.toString());
}
java.awt.Image fwdJpeg = new NSData(embedComment( baos.toByteArray(), baos.size(), null ));
// embedcomment is my code to insert a comment about
// the data in the chart
With jfreechart-1.0.4.jar and jcommon-1.0.8.jar, the background image looses details as if a mask is placed on the background image.
With jfreechart-1.0.9.jar and jcommon-1.0.12.jar, the images are solid black, ie, no features visible, no series visible.
I have attempted changing the alpha value for the background, but that is not helping. Any suggestions as to why simply changing the JARs would cause the image to degrade as described?
For the time being I can stay with the older jars, but it bothers me to not be able to go forward with the improvements. Jfreechart has been a great tool thus far, and I am sure I am missing something, but I do not know what it is. Any and all help appreciated.
Thanks,
David