JFreeChart 1.0.13

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
tmtjond
Posts: 23
Joined: Thu Jul 24, 2008 3:21 am

Re: JFreeChart 1.0.13

Post by tmtjond » Wed Sep 16, 2009 2:43 am

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?

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: JFreeChart 1.0.13

Post by david.gilbert » Wed Sep 16, 2009 7:02 am

David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

arriba
Posts: 6
Joined: Thu Apr 19, 2007 8:55 am

Re: JFreeChart 1.0.13

Post by arriba » Wed Sep 30, 2009 10:31 am

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

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: JFreeChart 1.0.13

Post by david.gilbert » Mon Oct 05, 2009 9:18 pm

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

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

ninitha
Posts: 51
Joined: Mon Aug 24, 2009 7:05 am
antibot: No, of course not.

Re: JFreeChart 1.0.13

Post by ninitha » Fri Oct 09, 2009 7:34 am


Was shocked to see the blog david... a good programmer like you shouldnt be dumped so...hope u get compensation for that soon...

arriba
Posts: 6
Joined: Thu Apr 19, 2007 8:55 am

Re: JFreeChart 1.0.13

Post by arriba » Mon Oct 12, 2009 8:16 pm

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();

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: JFreeChart 1.0.13

Post by paradoxoff » Mon Oct 12, 2009 10:44 pm

Why don´t you simply draw the JFreeChart directly to the Graphics2D returned by pdftemplate.createGraphics)...)?

Code: Select all

chart.draw(g, new Retcangle2D.Float(0.0f, 0.0f, rect.getWidth(), rect.getHeight()));
In that way you can avoid all Swing pitfalls.

arriba
Posts: 6
Joined: Thu Apr 19, 2007 8:55 am

Re: JFreeChart 1.0.13

Post by arriba » Wed Oct 14, 2009 4:38 pm

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.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: JFreeChart 1.0.13

Post by david.gilbert » Wed Oct 14, 2009 7:01 pm

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)
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?
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: JFreeChart 1.0.13

Post by paradoxoff » Wed Oct 14, 2009 10:58 pm

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?

arriba
Posts: 6
Joined: Thu Apr 19, 2007 8:55 am

Re: JFreeChart 1.0.13

Post by arriba » Thu Oct 15, 2009 1:44 pm

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.

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: JFreeChart 1.0.13

Post by paradoxoff » Fri Oct 16, 2009 9:26 am

arriba wrote: BTW I tried the draw method directly on the chart and it did the same, i.e. draw an image.
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.

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();
}
Either there is an option in itext to activate the "image mode", or you have accidentally placed an Image in the rendering process, e. g. by first drawing the JFreeChart onto an Image by using one of the ChartUtilities methods followed by drawing the image on the Graphics2D.
But since your problem seems to be solved, it is probably not necessary to further discuss that.

jerusalem1
Posts: 1
Joined: Thu Dec 03, 2009 6:29 pm
antibot: No, of course not.

Re: JFreeChart 1.0.13

Post by jerusalem1 » Thu Dec 03, 2009 11:04 pm

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. :twisted:

malyvelky
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

Post by malyvelky » Mon Feb 15, 2010 12:01 pm

david.gilbert wrote:
hockey_dave wrote:I see that there still isn't a 1.0.13 in the maven repository and it's now August. :)
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...
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.

Junaid
Posts: 13
Joined: Tue Jul 20, 2010 2:25 pm
antibot: No, of course not.
Contact:

Re: JFreeChart 1.0.13

Post by Junaid » Tue Aug 03, 2010 7:05 am

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

Locked