Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#17 sun.dc.pr.PRException: endPath: bad path

open
David Gilbert
General (896)
5
2001-12-03
2001-11-15
Anonymous
No

I built a time serie with only two points, both of
them has exactly the same X value.
The resulting time-series chart reports the following
exception while painting:

sun.dc.pr.PRException: endPath: bad path

at sun.dc.pr.Rasterizer.endPath(Rasterizer.java:540)
at
sun.java2d.pipe.DuctusRenderer.createShapeRasterizer
(DuctusRenderer.java:296)
at sun.java2d.pipe.DuctusShapeRenderer.renderPath
(DuctusShapeRenderer.java:59)
at sun.java2d.pipe.DuctusShapeRenderer.draw
(DuctusShapeRenderer.java:48)
at sun.java2d.pipe.ValidatePipe.draw
(ValidatePipe.java:110)
at sun.java2d.SunGraphics2D.draw
(SunGraphics2D.java:1599)
at com.jrefinery.chart.XYPlot.draw(XYPlot.java:288)
at com.jrefinery.chart.JFreeChart.draw(Unknown Source)
at com.jrefinery.chart.JFreeChartPanel.paintComponent
(Unknown Source)
at javax.swing.JComponent.paint(JComponent.java:739)
at javax.swing.JComponent.paintChildren
(JComponent.java:523)
at javax.swing.JComponent.paint(JComponent.java:748)
at javax.swing.JComponent.paintChildren
(JComponent.java:523)
at javax.swing.JComponent.paint(JComponent.java:748)
at javax.swing.JLayeredPane.paint
(JLayeredPane.java:546)
at javax.swing.JComponent.paintChildren
(JComponent.java:523)
at javax.swing.JComponent.paint(JComponent.java:719)
at java.awt.GraphicsCallback$PaintCallback.run
(GraphicsCallback.java:23)
at sun.awt.SunGraphicsCallback.runOneComponent
(SunGraphicsCallback.java:54)
at sun.awt.SunGraphicsCallback.runComponents
(SunGraphicsCallback.java:91)
at java.awt.Container.paint(Container.java:960)
at sun.awt.RepaintArea.paint(RepaintArea.java:298)
at sun.awt.windows.WComponentPeer.handleEvent
(WComponentPeer.java:193)
at java.awt.Component.dispatchEventImpl
(Component.java:2665)
at java.awt.Container.dispatchEventImpl
(Container.java:1213)
at java.awt.Window.dispatchEventImpl(Window.java:912)
at java.awt.Component.dispatchEvent
(Component.java:2499)
at java.awt.EventQueue.dispatchEvent
(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent
(EventDispatchThread.java:103)
at java.awt.EventDispatchThread.pumpEvents
(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run
(EventDispatchThread.java:84)

Here is one simple class reproducing the problem:

import javax.swing.*;

import com.jrefinery.chart.*;
import java.awt.*;

public class Test extends JFrame
{

Long[][][] data = {
{ {new Long(10000044), new Long(0)}, {new Long
(10000044), new Long(1)} }
};

public Test()
{
DefaultXYDataSource source = new
DefaultXYDataSource(data);
JFreeChart chart = JFreeChart.createTimeSeriesChart
(source);
JFreeChartPanel panel = new JFreeChartPanel(chart);
this.getContentPane().add(panel,
BorderLayout.CENTER);
}
public static void main(String[] args)
{
Test frame = new Test();
frame.setVisible(true);
}
}

Discussion

  • Logged In: NO

    I have the same problem but the error seems to be random !

     
  • David Gilbert
    David Gilbert
    2001-12-03

    Logged In: YES
    user_id=112975

    I took your demo code and altered it so that it works with
    version 0.6.0:

    package com.jrefinery.chart.demo;

    import javax.swing.*;

    import com.jrefinery.chart.*;
    import com.jrefinery.data.*;
    import java.awt.*;

    public class Test extends JFrame {

    Long[][][] data = { { {new Long(10000044), new Long(0)},
    {new Long(10000044), new Long(1)} } };

    public Test() {
    DefaultXYDataset source = new
    DefaultXYDataset(data);
    JFreeChart chart =
    ChartFactory.createTimeSeriesChart("Title", "Domain",
    "Range", source, true);
    JFreeChartPanel panel = new JFreeChartPanel(chart);
    this.getContentPane().add(panel, BorderLayout.CENTER);
    }

    public static void main(String[] args) {
    Test frame = new Test();
    frame.setVisible(true);
    }
    }

    Running this in JBuilder5 on SuSE Linux 7.3, I don't get any
    exceptions...just a chart with no data (which may be a
    problem in itself).

    What JDK and OS are you using?

    DG.

     
  • David Gilbert
    David Gilbert
    2001-12-03

    • labels: --> General
    • assigned_to: nobody --> mungady
     
  • Logged In: YES
    user_id=392820

    To mungady:

    I'm using jfreechart rel. 0.5.6, with JDK 1.3.1 on Windows
    NT OS.

     
  • Logged In: NO

    I see this same problem also. I'm using JFreeChart 0.7.2
    with JDK 1.4.0 on Windows 2000 and it appears when I
    generate a time series chart using the ChartFactory class
    with a TimeSeriesCollection of empty BasicTimeSeries (no
    TimeSeriesDataPair objects added) and try to write it to a
    PNG.

    The PNG appears to be written correctly, as an empty chart
    with correct titles and legend, which means that the error
    must happen very late in the rendering process, but an
    exception is still thrown.

    Here is the stack trace:

    sun.dc.pr.PRException: endPath: bad path
    at sun.dc.pr.Rasterizer.endPath(Rasterizer.java:537)
    at
    sun.java2d.pipe.DuctusRenderer.createShapeRasterizer
    (DuctusRenderer.java:374)
    at sun.java2d.pipe.DuctusShapeRenderer.renderPath
    (DuctusShapeRenderer.java:57)
    at sun.java2d.pipe.DuctusShapeRenderer.draw
    (DuctusShapeRenderer.java:45)

    at sun.java2d.SunGraphics2D.draw
    (SunGraphics2D.java:2162)
    at com.jrefinery.chart.XYPlot.drawVerticalLine
    (Unknown Source)
    at com.jrefinery.chart.XYPlot.draw(Unknown Source)
    at com.jrefinery.chart.JFreeChart.draw(Unknown
    Source)
    at
    com.jrefinery.chart.JFreeChart.createBufferedImage(Unknown
    Source)
    at
    com.jrefinery.chart.ChartUtilities.writeChartAsPNG(Unknown
    Source)

     
  • Logged In: NO

    This problem appears to happen when crosshairs are turned
    on. There probably is a numerical error in computing
    crosshair coordinates. When I disable crosshairs, I don't
    get an exception.

    Here is a workaround that disables crosshairs:

    ((XYPlot)chart.getPlot()).getDomainAxis
    ().setCrosshairVisible(false);
    ((XYPlot)chart.getPlot()).getRangeAxis().setCrosshairVisible
    (false);

     
  • Mark Gillett
    Mark Gillett
    2002-03-14

    Logged In: YES
    user_id=485740

    We are working on creating PNG TimeSeriesChart from our own
    XML data structure, and are experiencing the same problems,
    specifically we are seeing the following stack trace
    (Windows 2000/Java 1.3/Catalina Servlet Container 4.0.1).

    sun.dc.pr.PRException: endPath: bad path
    at sun.dc.pr.Rasterizer.endPath(Rasterizer.java:540)
    at
    sun.java2d.pipe.DuctusRenderer.createShapeRasterizer
    (DuctusRenderer.java:296)
    at sun.java2d.pipe.DuctusShapeRenderer.renderPath
    (DuctusShapeRenderer.java:59)
    at sun.java2d.pipe.DuctusShapeRenderer.draw
    (DuctusShapeRenderer.java:48)
    at sun.java2d.pipe.ValidatePipe.draw
    (ValidatePipe.java:110)
    at sun.java2d.SunGraphics2D.draw
    (SunGraphics2D.java:1599)
    at com.jrefinery.chart.XYPlot.drawVerticalLine
    (Unknown Source)
    at com.jrefinery.chart.XYPlot.draw(Unknown Source)
    at com.jrefinery.chart.JFreeChart.draw(Unknown
    Source)
    at
    com.jrefinery.chart.JFreeChart.createBufferedImage(Unknown
    Source)
    at
    com.jrefinery.chart.ChartUtilities.writeChartAsPNG(Unknown
    Source)
    at com.ixif.tools.web.ui.graph.graphServlet.doPost
    (Unknown Source)

    The code in our com.ixif.tools.web.ui.graph.graphServlet
    class is as follows:

    <snip>

    package com.ixif.tools.web.ui.graph;

    import java.io.*;
    import java.util.*;
    import javax.swing.*;

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;

    import com.sun.image.codec.jpeg.*;

    import com.jrefinery.chart.*;
    import com.jrefinery.chart.data.*;
    import com.jrefinery.data.*;

    import org.xml.sax.*;

    //....... code continues relevant sections included ....

    private JFreeChart createChart(TimeSeriesCollection data,
    String title)
    {
    JFreeChart chart;

        try
        \{
            System.out.println\("GraphCenter ::
    

    createChart() - start");

    // you can add xlabel and ylabel here
    DateAxis dateAxis = new HorizontalDateAxis();
    ValueAxis valueAxis = new VerticalNumberAxis();

            valueAxis.setAxisRange\(0, 5\);
            valueAxis.setTickMarksVisible
    

    (false);
    valueAxis.setTickLabelsVisible
    (false);

            XYPlot plot = new XYPlot\(dateAxis,
    

    valueAxis);
    plot.setXYItemRenderer(new
    VerticalXYBarRenderer());

            chart = new JFreeChart\(data, plot,
    

    title, JFreeChart.DEFAULT_TITLE_FONT, true);
    chart.setBackgroundPaint(new
    GradientPaint(0, 0, Color.white, 1000, 0, Color.white));

            // set color for ok, warning and
    

    critical, unknown and pending
    java.awt.Paint[] paint = new
    java.awt.Paint[] { Color.green, Color.orange, Color.red,
    Color.magenta, Color.gray};
    plot.setSeriesPaint(paint);

            System.out.println\("GraphCenter ::
    

    createChart() - chart created");
    return chart;
    }
    catch (Exception e)
    {
    System.out.println(e.getMessage());
    return null;
    }

    \}
    
    </snip>
    

    <snip>
    // ...... problem is created with code below .......

    public JFreeChart getDayChart\(\)
    \{
        System.out.println\("GraphCenter ::
    

    getDayChart()");

        TimeSeriesCollection data = new
    

    TimeSeriesCollection();

        // creating time series
        BasicTimeSeries time\_ok = new
    

    BasicTimeSeries("OK", "Day", "Value", Hour.class);
    BasicTimeSeries time_warning = new
    BasicTimeSeries("WARNING", "Day", "Value", Hour.class);
    BasicTimeSeries time_critical = new
    BasicTimeSeries("CRITICAL", "Day", "Value", Hour.class);
    BasicTimeSeries time_unknown = new
    BasicTimeSeries("UNKNOWN", "Day", "Value", Hour.class);

        BasicTimeSeries time\_pending = new
    

    BasicTimeSeries("PENDING", "Day", "Value", Hour.class);

        Integer state\_ok = new Integer\(5\);
        Integer state\_warning = new Integer\(4\);
        Integer state\_critical = new Integer\(3\);
        Integer state\_unknown = new Integer\(2\);
        Integer state\_pending = new Integer\(1\);
    
        int state;
        com.jrefinery.data.Hour time;
    
        GregorianCalendar today = new
    

    GregorianCalendar();
    GregorianCalendar when = new
    GregorianCalendar(today.get(Calendar.YEAR), today.get
    (Calendar.MONTH), today.get(Calendar.DAY_OF_MONTH));
    when.add(Calendar.DATE, -1);
    System.out.println("from - " + when.getTime
    ());

        try
        \{
            while \(today.after\(when\)\)
            \{
                //System.out.println
    

    (when.getTime());
    state = history.getState
    (when, Calendar.HOUR,1);

                time = new
    

    com.jrefinery.data.Hour(when.getTime());
    when.add(Calendar.HOUR,1);
    System.out.println
    (when.getTime());

            switch \(state\)
            \{
                case 5:
                \{
                    time\_ok.add\(time,
    

    state_ok);
    break;
    }
    case 4:
    {
    time_warning.add
    (time, state_warning);
    break;
    }
    case 3:
    {
    time_critical.add
    (time, state_critical);
    break;
    }
    case 2:
    {
    time_unknown.add
    (time, state_unknown);
    break;
    }
    case 1:
    {
    time_pending.add
    (time, state_pending);
    break;
    }
    default:
    {
    time_unknown.add
    (time, state_unknown);
    }
    }

            \}
    
        \}
        catch \(Exception e\)
        \{
            System.out.println\(e.getMessage\(\)\);
        \}
        // end
    
        data.addSeries\(time\_ok\);
    data.addSeries\(time\_warning\);
    data.addSeries\(time\_critical\);
    data.addSeries\(time\_unknown\);
    data.addSeries\(time\_pending\);
    
        return createChart\(data, "Day"\);
    \}
    

    </snip>

    <snip>
    // graphServlet, which includes :.....

            JFreeChart chart;
            chart = getDayChart\(\);
    
            ChartUtilities.writeChartAsPNG
    

    ((OutputStream) out, chart, 550, 200);
    </snip>

    Any ideas, it seems that jFreeChart is directly accessing
    the sun.java2d.SunGraphics2D.draw which I havent seen used
    recently (since jdk 1.2).

    Best Regards,

    Mark Gillett
    "Contrary to popular belief, Unix is a friendly operating
    system - it's just very picky about who it makes friends
    with !!!!"

     
  • Logged In: NO

    Hi, I just wanted to add a comment that I get the same error.

    For me it's happened when I initialized an array of doubles,
    then I passed in those values into the chart. Apparently
    there was a Double.NaN value in the array, and when it tried
    to render that, it gave me the same error that I see here. I
    had to make sure that I didn't pass in a Double.NaN value to
    prevent this from happening.

    Keep up the great work!
    - John

    email: "locke" + "06" + "23" + "(at)" + "yahoo" + "(dot)" +
    "com"

    Here's the stack trace for it:

    sun.dc.pr.PRException: endPath: bad path
    at sun.dc.pr.Rasterizer.endPath(Rasterizer.java:540)
    at
    sun.java2d.pipe.DuctusRenderer.createShapeRasterizer(DuctusRenderer.java:377)
    at
    sun.java2d.pipe.DuctusShapeRenderer.renderPath(DuctusShapeRenderer.java:60)
    at
    sun.java2d.pipe.DuctusShapeRenderer.fill(DuctusShapeRenderer.java:52)
    at sun.java2d.pipe.ValidatePipe.fill(ValidatePipe.java:122)
    at sun.java2d.SunGraphics2D.fill(SunGraphics2D.java:2193)
    at
    com.jrefinery.chart.VerticalBarRenderer.drawCategoryItem(VerticalBarRenderer.java:283)
    at
    com.jrefinery.chart.VerticalCategoryPlot.render(VerticalCategoryPlot.java:431)
    at
    com.jrefinery.chart.OverlaidVerticalCategoryPlot.render(OverlaidVerticalCategoryPlot.java:187)
    at
    com.jrefinery.chart.VerticalCategoryPlot.draw(VerticalCategoryPlot.java:394)
    at com.jrefinery.chart.JFreeChart.draw(JFreeChart.java:618)
    at
    com.jrefinery.chart.ChartPanel.paintComponent(ChartPanel.java:800)
    at javax.swing.JComponent.paint(JComponent.java:807)
    at
    javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4737)
    at
    javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4690)
    at
    javax.swing.JComponent._paintImmediately(JComponent.java:4634)
    at
    javax.swing.JComponent.paintImmediately(JComponent.java:4466)
    at
    javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:407)
    at
    javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:120)
    at
    java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:181)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:446)
    at
    java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:193)
    at
    java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:147)
    at
    java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:141)
    at
    java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:133)
    at
    java.awt.EventDispatchThread.run(EventDispatchThread.java:101)

     
  • Logged In: YES
    user_id=605548

    I have the same problem when a data serie contains one or
    more "NaN".

    [java] sun.dc.pr.PRException: endPath: bad path
    [java] at sun.dc.pr.Rasterizer.endPath(Rasterizer.java:537)
    [java] at
    sun.java2d.pipe.DuctusRenderer.createShapeRasterizer(DuctusRenderer.java:374)
    [java] at
    sun.java2d.pipe.DuctusShapeRenderer.renderPath(DuctusShapeRenderer.java:57)
    [java] at
    sun.java2d.pipe.DuctusShapeRenderer.draw(DuctusShapeRenderer.java:45)
    [java] at
    sun.java2d.SunGraphics2D.draw(SunGraphics2D.java:2162)
    [java] at
    com.jrefinery.chart.renderer.StandardXYItemRenderer.drawItem(Unknown
    Source)
    [java] at
    com.jrefinery.chart.plot.XYPlot.render(Unknown Source)
    [java] at com.jrefinery.chart.plot.XYPlot.draw(Unknown
    Source)
    [java] at com.jrefinery.chart.JFreeChart.draw(Unknown
    Source)
    [java] at
    com.jrefinery.chart.ChartPanel.paintComponent(Unknown Source)

     
  • Juu
    Juu
    2003-04-20

    Logged In: YES
    user_id=198381

    I get this problem as well. And there are 2 related bugs on
    Sun's site about this, 4755500 and 4485298.

    Anyway, not adding NaNs seemed to work for me.

     
  • Juu
    Juu
    2003-04-20

    Logged In: YES
    user_id=198381

    I get this problem as well. And there are 2 related bugs on
    Sun's site about this, 4755500 and 4485298.

    Anyway, not adding NaNs seemed to work for me.

     
  • Logged In: NO

    Hello,

    We are also getting this type of exception. Hovewer in our
    case, I believe it is due to the zooming factor.

    Using a timeseries plot, say we draw a polyline with 100
    points, depending on where you zoom you might get following
    cases:
    1- showing more than two points (no-zoom to middle zoom),
    thus having some lines that connect these points --> ok
    2- showing two points (high zoom), thus having one line
    connecting the two points and maybe two other lines
    connecting to the points that are "outside" the current view --
    > ok
    3- showing one point (very high zoom), thus having two lines
    that connect on the "outside" of the view --> often resulting
    in the sun.dc.pr.PRException
    4- not shoing any point (huge zoom factor), thus having one
    line --> exception

    My conclusion is that if the data precision of the points being
    shown is too high, that is a value of 0.001 or less between
    ticks, we get such an exception.

    Proposal:
    - set an optional parameter for the axis that specifies the
    limit of the displayed range in case of zooming.
    - if this parameter is set, then you block zooming below this
    range.

    Marc
    (acidmarco at yahoo dot fr)

    PS: here is part of the stack trace...

    sun.dc.pr.PRException: endPath: bad path
    at sun.dc.pr.Rasterizer.endPath(Rasterizer.java:537)
    at
    sun.java2d.pipe.DuctusRenderer.createShapeRasterizer
    (DuctusRenderer.java:374)
    at sun.java2d.pipe.DuctusShapeRenderer.renderPath
    (DuctusShapeRenderer.java:57)
    at sun.java2d.pipe.DuctusShapeRenderer.draw
    (DuctusShapeRenderer.java:45)
    at
    sun.java2d.pipe.PixelToShapeConverter.drawPolyline
    (PixelToShapeConverter.java:101)
    at sun.java2d.SunGraphics2D.drawPolyline
    (SunGraphics2D.java:2061)

     
  • Logged In: NO

    Call chart.setAntiAlias(false);
    At least this worked for me

     
  • Logged In: NO

    Call chart.setAntiAlias(false);
    At least this worked for me

     
  • Logged In: NO

    Call chart.setAntialias(false);
    At least this worked for me.

     
  • Logged In: NO

    IMHO:

    The translateValueToJava2D routines should never return
    NaN, which (I think) would fix this problem for everyone.

    Even if I am sure that I'm not asking JFreeChart to plot
    anything beyond the range of a double, this exception can be
    generated.