JFreeChart 1.0.13
Re: JFreeChart 1.0.13
I know you were working on the date tick unit mechanism and fixing some related bugs.
Do you have any schedule for the release of JFreeChart 1.0.14/ or the fix for the date axis/tick unit?
Do you have any schedule for the release of JFreeChart 1.0.14/ or the fix for the date axis/tick unit?
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: JFreeChart 1.0.13
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Re: JFreeChart 1.0.13
Hello Dave,
Utill this version (1.0.12 and below) i used to print a chart in a PDF file (using iText) and i used (and still) set recursively "on" the double buffer (JComponent.setDoubleBuffered(boolean)) which means that any text in the chart was selectable. If i do not do that the printing would result in a poor grpahic image.
Since this version i get the poor graphic image. What's wrong ? I still set the double buffer and switching from 1.0.13 to 1.0.12 fixes the problems.
thanx in advance
Fadi
Utill this version (1.0.12 and below) i used to print a chart in a PDF file (using iText) and i used (and still) set recursively "on" the double buffer (JComponent.setDoubleBuffered(boolean)) which means that any text in the chart was selectable. If i do not do that the printing would result in a poor grpahic image.
Since this version i get the poor graphic image. What's wrong ? I still set the double buffer and switching from 1.0.13 to 1.0.12 fixes the problems.
thanx in advance
Fadi
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: JFreeChart 1.0.13
I don't understand what effect setDoubleBuffered(true) would have. Post a bug report, including a complete program to reproduce the problem, and be sure to state the iText version also.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Re: JFreeChart 1.0.13
david.gilbert wrote:http://www.jfree.org/phpBB2/viewtopic.php?f=3&t=29226
Was shocked to see the blog david... a good programmer like you shouldnt be dumped so...hope u get compensation for that soon...
Re: JFreeChart 1.0.13
David,
The double buffer should be set to False, i'm sorry if i said on. If it is "on" (true) then Swing would use the paint(Graphics) method and create a buffered image before displaying it, to accelerate the display i suppose and minimize the flickering on the screen or something like that.
I use paint(Graphics) method of a jfreechart to write into an iText PDF document, and i recursivly call setDoubleBuffered(false) on the jfeechart component and all its subcomponents, that way, when writing the pdf document, no buffered image is written, but everything (including text in the jfreechart) is written directly in the PDF and in the resulting PDF document you can actually "select" any text in the jfreechart (labels, axis values, etc.) If this was not done, the double buffering would result in a poor graphics image. Any version of iText would do. This is a sample code (supposing you have a ChartPanel instance already created)
FileOutputStream out = new FileOutputStream(pdfFileName, false);
Document document = new Document();
document.setPageCount(1);
document.setPageSize(700, 400); //or any size, A4 for example
PdfWriter pdfwriter = PdfWriter.getInstance(document, out);
document.open();
DefaultFontMapper mapper = new DefaultFontMapper();
FontFactory.registerDirectories();
mapper.insertDirectory(fontsDirectory); //++ Any font directory, Windows font directory would be fine
com.lowagie.text.Rectangle rect = document.getPageSize();
PdfTemplate pdftemplate = pdfcontentbyte.createTemplate(rect.getWidth(), rect.getHeight());
Graphics2D g = pdftemplate.createGraphics(rect.getWidth(), rect.getHeight(), mapper);
myChartPanel.setDoubleBuffered(false);
Here, recurse on all the components of myChartPanel and then all their components and .setDoubleBuffered(false)
myChartPanel.paint(g);
g.dispose();
pdfcontentbyte.addTemplate(pdftemplate, 0.0F, 0.0F);
document.close();
out.close();
The double buffer should be set to False, i'm sorry if i said on. If it is "on" (true) then Swing would use the paint(Graphics) method and create a buffered image before displaying it, to accelerate the display i suppose and minimize the flickering on the screen or something like that.
I use paint(Graphics) method of a jfreechart to write into an iText PDF document, and i recursivly call setDoubleBuffered(false) on the jfeechart component and all its subcomponents, that way, when writing the pdf document, no buffered image is written, but everything (including text in the jfreechart) is written directly in the PDF and in the resulting PDF document you can actually "select" any text in the jfreechart (labels, axis values, etc.) If this was not done, the double buffering would result in a poor graphics image. Any version of iText would do. This is a sample code (supposing you have a ChartPanel instance already created)
FileOutputStream out = new FileOutputStream(pdfFileName, false);
Document document = new Document();
document.setPageCount(1);
document.setPageSize(700, 400); //or any size, A4 for example
PdfWriter pdfwriter = PdfWriter.getInstance(document, out);
document.open();
DefaultFontMapper mapper = new DefaultFontMapper();
FontFactory.registerDirectories();
mapper.insertDirectory(fontsDirectory); //++ Any font directory, Windows font directory would be fine
com.lowagie.text.Rectangle rect = document.getPageSize();
PdfTemplate pdftemplate = pdfcontentbyte.createTemplate(rect.getWidth(), rect.getHeight());
Graphics2D g = pdftemplate.createGraphics(rect.getWidth(), rect.getHeight(), mapper);
myChartPanel.setDoubleBuffered(false);
Here, recurse on all the components of myChartPanel and then all their components and .setDoubleBuffered(false)
myChartPanel.paint(g);
g.dispose();
pdfcontentbyte.addTemplate(pdftemplate, 0.0F, 0.0F);
document.close();
out.close();
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: JFreeChart 1.0.13
Why don´t you simply draw the JFreeChart directly to the Graphics2D returned by pdftemplate.createGraphics)...)?
In that way you can avoid all Swing pitfalls.
Code: Select all
chart.draw(g, new Retcangle2D.Float(0.0f, 0.0f, rect.getWidth(), rect.getHeight()));
Re: JFreeChart 1.0.13
Because this would give the same result in 1.0.13, a poor graphic image (and adds more size to the generated PDF, of course)
ChartPanel IS a Swing component, so the double buffering is used on it too.
My guess is that, even if i set recursivly the double buffer to false on the chart panel, someone added a setDoubleBuffered(true) in the 1.0.13 just before painting the chart... annihilating my super recursive setDoubleBuffered(false) that i call one line before my .paint() call
Again, 1.0.12 does not have this problem.
ChartPanel IS a Swing component, so the double buffering is used on it too.
My guess is that, even if i set recursivly the double buffer to false on the chart panel, someone added a setDoubleBuffered(true) in the 1.0.13 just before painting the chart... annihilating my super recursive setDoubleBuffered(false) that i call one line before my .paint() call
Again, 1.0.12 does not have this problem.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: JFreeChart 1.0.13
I think you are wrong there. The drawing on the ChartPanel is all done by the chart.draw() method that paradoxoff pointed you to. So you'll get the same Java2D calls by calling it directly, plus you get to totally by-pass any buffering that Swing and the ChartPanel class might be doing for you. Did you try it?arriba wrote:Because this would give the same result in 1.0.13, a poor graphic image (and adds more size to the generated PDF, of course)
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: JFreeChart 1.0.13
The ChartPanel does not call setDoubleBuffered(true). A ChartPanel doesn´t have to do that because it has its own "buffer".
The ChartPanel has an option to use a chartBuffer, i. e. an Image. If the chartBuffer is used, the ChartPanel will not draw the chart directly on the Graphics2D used in the paintComponent(Graphics g) method, but first draw the chart on the Graphics2D of the buffer image and then draw the image on the "original" Graphics2D. In 1.0.12, the default for the chartBuffer is false, in 1.0.13 the default is true.
I you have not changed the defaults, you will thus render directly on the PdfGraphics2D with 1.0.12 (--> high quality with selectable text), but you will render an Image on the PdfGraphics2D with 1.0.13 (--> low quality, especially when you print and/or enlarge the zoom, and text will not be selectable).
Solution: when you construct the ChartPanel, use a constructor that allows you top set the chartBuffer option, and set it to false.
But I would strongly recommend that you try to render your charts directly on the PdfGraphics2D, and forget about the ChartPanel to produce PDF´s. You are right that this will not lead to an improvement in 1.0.13 (unless you follow the hint above), but why didn´t you do it for 1.0.12? Or do you not only want to render a single JfreeChart, but an entire swing container containing further JComponents in addition to a ChartPanel with a chart?
The ChartPanel has an option to use a chartBuffer, i. e. an Image. If the chartBuffer is used, the ChartPanel will not draw the chart directly on the Graphics2D used in the paintComponent(Graphics g) method, but first draw the chart on the Graphics2D of the buffer image and then draw the image on the "original" Graphics2D. In 1.0.12, the default for the chartBuffer is false, in 1.0.13 the default is true.
I you have not changed the defaults, you will thus render directly on the PdfGraphics2D with 1.0.12 (--> high quality with selectable text), but you will render an Image on the PdfGraphics2D with 1.0.13 (--> low quality, especially when you print and/or enlarge the zoom, and text will not be selectable).
Solution: when you construct the ChartPanel, use a constructor that allows you top set the chartBuffer option, and set it to false.
But I would strongly recommend that you try to render your charts directly on the PdfGraphics2D, and forget about the ChartPanel to produce PDF´s. You are right that this will not lead to an improvement in 1.0.13 (unless you follow the hint above), but why didn´t you do it for 1.0.12? Or do you not only want to render a single JfreeChart, but an entire swing container containing further JComponents in addition to a ChartPanel with a chart?
Re: JFreeChart 1.0.13
Paradoxoff, that explains it. I only said that chartpanel uses setDoubleBuffered as a wild guess.
I will try with the inner chartpanel buffer off, i think this is the trick.
BTW I tried the draw method directly on the chart and it did the same, i.e. draw an image. I don't use it usually because i'm painting other Swing/non-Swing components on the same PDF.
I will try with the inner chartpanel buffer off, i think this is the trick.
BTW I tried the draw method directly on the chart and it did the same, i.e. draw an image. I don't use it usually because i'm painting other Swing/non-Swing components on the same PDF.
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: JFreeChart 1.0.13
That is odd. I regularly draw JFreeCharts directly on theGraphics2D returned by pdftemplate.createGraphics(...), and I always got a real, zoomable, nice-looking PDF output.arriba wrote: BTW I tried the draw method directly on the chart and it did the same, i.e. draw an image.
Code: Select all
public void exportChart(JFreeChart chart, int width,int height) throws IOException{
com.lowagie.text.Rectangle rect = new com.lowagie.text.Rectangle((float)width,(float)height);
com.lowagie.text.Document document = new com.lowagie.text.Document(rect);
PdfWriter writer = null;
try{
writer = PdfWriter.getInstance(document, getOutputStream());
}
catch(DocumentException e){
throw new IOException("Root cause "+e.getClass().getName()+", "+e.getMessage());
}
document.open();
DefaultFontMapper mapper = new DefaultFontMapper();
FontFactory.registerDirectories();
mapper.insertDirectory("C:\\WINNT\\Fonts");
PdfContentByte cb = writer.getDirectContent();
PdfTemplate tp = cb.createTemplate(width, height);
Graphics2D g2d = tp.createGraphics(width, height, mapper);
tp.setWidth(width);
tp.setHeight(height);
chart.draw(g2d,new Rectangle(width,height));
g2d.dispose();
cb.addTemplate(tp, 0, 0);
document.close();
}
But since your problem seems to be solved, it is probably not necessary to further discuss that.
-
- Posts: 1
- Joined: Thu Dec 03, 2009 6:29 pm
- antibot: No, of course not.
Re: JFreeChart 1.0.13
I could try to find some time to build a pom.xml file which is usable with JFreeChart. As always, I'm quite busy ATM, so don't expect it to happen within a day or two. 

-
- Posts: 5
- Joined: Thu Aug 06, 2009 12:55 pm
- antibot: No, of course not.
- Location: Czech Republic, Prague
- Contact:
Re: JFreeChart 1.0.13
There are now instructions for setting up an automated process of releasing JFreeChart to Maven Central. Hopefully we will manage to bring it alive and publish there v1.0.13 and all future versions as well.david.gilbert wrote:I guess no-one so far has had an urgent need to get JFreeChart 1.0.13 into the Maven central repository, otherwise they'd have made it happen...hockey_dave wrote:I see that there still isn't a 1.0.13 in the maven repository and it's now August.
Re: JFreeChart 1.0.13
Hi David,
We have been using JFreeChart in our product and it has been a nice experience using it. We have recently made an upgrade to ver 1.0.13.
I am facing some issues while removing the gaps from timeline. I am using segmentedTimeLine for gap removal. I have posted the query on the general forum, specifically in "intraday chart SegmentedTimeLine problem", explaining the issue.
Our company had paid for priority support, but I am not able to find a link where I can post my query in priority support. Please point me to the correct link.
Regards,
Junaid
We have been using JFreeChart in our product and it has been a nice experience using it. We have recently made an upgrade to ver 1.0.13.
I am facing some issues while removing the gaps from timeline. I am using segmentedTimeLine for gap removal. I have posted the query on the general forum, specifically in "intraday chart SegmentedTimeLine problem", explaining the issue.
Our company had paid for priority support, but I am not able to find a link where I can post my query in priority support. Please point me to the correct link.
Regards,
Junaid