#901 Freeze with XYAreaRenderer, outline, and 2 pix width stroke

General (896)

Context :
JFreeChart 1.0.11
JCommon 1.0.14
Ubuntu 8.10 on ATI Radeon 9800
JDK 1.6u12 or 1.7b42 (19/12/2008)

Using a TimeSeries Chart with
* a XYAreaRenderer
* with outline (setOutline(true))
* a custom Stroke
* some special values in the chart (see below)

The chart does not get displayed, and the program is stuck in a rendering loop

The attached sample code reproduces the issue.
If I remove the outline or the stroke, everything goes well.


  • Mkiki

    Mkiki - 2008-12-27

    java code to reproduce the issue

  • David Gilbert

    David Gilbert - 2008-12-31

    Thanks for the report. I can reproduce this bug on JRE 1.6.0_10 on Windows XP. I think it might be related to this Java2D bug:


    If you change the stroke to a solid one (rather than dashed) it works fine. A workaround (if you want to retain the dashed outline) is to clip the polygon representing the area in the chart before drawing the outline. The following patch to the renderer does this (although the constructive area geometry performed by the Area class is likely to cost a bit of CPU time):

    Index: XYAreaRenderer.java

    --- XYAreaRenderer.java (revision 1758)
    +++ XYAreaRenderer.java (working copy)
    @@ -84,6 +84,7 @@
    import java.awt.Polygon;
    import java.awt.Shape;
    import java.awt.Stroke;
    +import java.awt.geom.Area;
    import java.awt.geom.GeneralPath;
    import java.awt.geom.Line2D;
    import java.awt.geom.Rectangle2D;
    @@ -552,9 +553,16 @@

    // draw an outline around the Area.
    if (isOutline()) {
    + Area poly = new Area(areaState.area);
    + Area clip = new Area(new Rectangle2D.Double(
    + dataArea.getX() - 5.0, dataArea.getY() - 5.0,
    + dataArea.getWidth() + 10.0,
    + dataArea.getHeight() + 10.0));
    + poly.intersect(clip);
    g2.setStroke(getItemOutlineStroke(series, item));
    g2.setPaint(getItemOutlinePaint(series, item));
    - g2.draw(areaState.area);
    + g2.draw(poly);

    Perhaps an improvement on this patch would be to detect if the stroke is dashed before performing the clipping.


    Dave Gilbert
    JFreeChart Project Leader

  • David Gilbert

    David Gilbert - 2008-12-31
    • assigned_to: nobody --> mungady
  • David Gilbert

    David Gilbert - 2009-01-01
    • status: open --> closed
  • David Gilbert

    David Gilbert - 2009-01-01

    I included a fix/workaround in the 1.0.12 release.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks