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

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Miguel Zabaraín

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

Post by Miguel Zabaraín » Fri Sep 01, 2000 3:45 pm

Hi everybody...

Please could somebody tell me why the following Exception is raised when I use the setDataSource method on a chart?????.

the Exception is:

sun.dc.pr.PRException: endPath: bad path
at sun.dc.pr.Rasterizer.endPath(Rasterizer.java, Compiled Code)
at sun.java2d.pipe.DuctusRenderer.createShapeRasterizer(DuctusRenderer.java, Compiled Code)
at sun.java2d.pipe.DuctusShapeRenderer.renderPath(DuctusShapeRenderer.java, Compiled Code)
at sun.java2d.pipe.DuctusShapeRenderer.draw(DuctusShapeRenderer.java, Compiled Code)
at sun.java2d.SunGraphics2D.draw(SunGraphics2D.java, Compiled Code)
at com.jrefinery.chart.XYPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(Unknown Source)
at com.jrefinery.chart.JFreeChartPanel.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JComponent.paintChildren(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JComponent.paintChildren(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JComponent.paintWithBuffer(JComponent.java:3750)
at javax.swing.JComponent._paintImmediately(JComponent.java:3695)
at javax.swing.JComponent.paintImmediately(JComponent.java:3544)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:365)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:198)
at javax.swing.SystemEventQueueUtilities.processRunnableEvent(SystemEventQueueUtilities.java:398)
at javax.swing.SystemEventQueueUtilities.access$0(SystemEventQueueUtilities.java:394)
at javax.swing.SystemEventQueueUtilities$RunnableTarget.processEvent(SystemEventQueueUtilities.java:435)
at java.awt.Component.dispatchEventImpl(Component.java, Compiled Code)
at java.awt.Component.dispatchEvent(Component.java, Compiled Code)
at java.awt.EventQueue.dispatchEvent(EventQueue.java, Compiled Code)
at java.awt.EventDispatchThread.pumpOneEventForComponent(EventDispatchThread.java, Compiled Code)
at java.awt.EventDispatchThread.pumpEventsForComponent(EventDispatchThread.java:95)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:90)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

*******************************************
The data I've passed is constructed as follows:

data[0][k][0] = new GregorianCalendar(Integer.parseInt(year),
Integer.parseInt(month)-1,
Integer.parseInt(day),
Integer.parseInt(hour),
Integer.parseInt
(minute)).getTime();

data[0][k][1] = new Double(value);

This is the data for a TimeSeriesChart, and I'm using It this way:


XYDataSource xyData = new DefaultXYDataSource(new String[]{"qwe"},
dC.getTimeSeriesData());
System.out.println("hasta aquí OK");

chart.setDataSource(xyData);


I'm sure the Exception is raised on the 'chart.setDataSource(xyData)'
statement, hence the 'hasta aquí OK' message is shown.

Please write back as soon as You can.....

Thanks in advance.

Miguel Zabaraín

PRException fixed...to David Gilbert an Luis Gasca

Post by Miguel Zabaraín » Mon Sep 04, 2000 6:23 pm

Don't worry about the problem, I've got the solution..............

Do You remenber that I told You that the problem was on the

' chart.setDataSource(xyData); '

statement?, OK... that's NOT TRUE at all, just because of that I did add following the previous statement this one:

' chart.getPlot().setChart(chart); ' and the program WORKS OK.......

so I think the really problem is that if You don't add that line then when JFreeChart tries to calculate the corresponding pixel for a high data value, the corresponding pixel value is out of the screen bounds
because NO RECALCULATION is done to get the correspondance between the data maxValue and the plot maxValue.

Have in mind that before I've attempted to change the data to the chart I did already constuct It with this values:

1
5
30
45
26
68
22
14
126
33

If You try to set this values to the chart the PRException is not rised:

56
54
21
2
25
32
58
12
85
54,

but when using the following values without the ' chart.getPlot().setChart(chart); ' statement, the PRException is rised:

56
54
214
2
25
32
58
12
854
54,

and this is because of the 854 value and probabbly the 214 value.

Look at the chart's data maxValue when I`s constructed (126), let's say that the corresponding screen's pixel for this is (580,x) or (x,580).

Now imagine the corresponding screen's pixel for the data value 854 whitout reescaling the plot this pixel value is far beyond 2000!!!!!!!!!!!!!!!!!!!!, and then try to locate the (2000,x) pixel or the (x,2000) one...........

David Gilbert

RE: PRException fixed...to David Gilbert an Luis G

Post by David Gilbert » Wed Oct 18, 2000 9:01 pm

Miguel,

Thanks for the info you supplied on this bug...it has helped me to work out what is going on. There are two things:

First, when the data source is changed using chart.setDataSource(newData) the axes are not being given a chance to adjust their range (assuming autoRangeAdjust is ON, which is the default). I will post a fix for this shortly - it involves some tidying up of the event notification system. In the meantime, the work-around you suggest achieves the same end result.

Second, the exception is thrown because Graphics2D has a bug which doesn't allow shapes with large coordinates to be rendered. Refer to the Java Developers Connection Bug Parade, bug ids 4376103, 4265778, 4297004 and 4204453.

In the case of JFreeChart, the large (screen) coordinate values result from values of the new data source being far outside the axis range (determined from the previous data source).

Regards,

DG.

Locked