Problem with TimeSeriesChart
Problem with TimeSeriesChart
D.G:
I use TimeSeriesChart(jfreechart0.8.1) to show a monitoring chart, at the same time put data to tables. I test my module in this way: using jbuilder7(jdk.1.3.1), I make the module to run (start at 2002-09-07 21:16:05 Beijing Time). A thread adds value to series once every 5 seconds. This morning, I get a terrible chart. And , the Chart do not repaint, but data are still put into tables. I mail the pic to your mailbox. In jbuilder's debug window, JB prints two exceptions about every 30 seconds. These two exceptions are:
sun.dc.pr.PRException, first appear at 2002-09-07 21:27:14 Beijing Time.
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.SunGraphics2D.draw(SunGraphics2D.java:1599)
at com.jrefinery.chart.StandardXYItemRenderer.drawItem(Unknown Source)
at com.jrefinery.chart.XYPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(JFreeChart.java:653)
at com.jrefinery.chart.JFreeChartPanel.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(JComponent.java:687)
at javax.swing.JComponent.paintChildren(JComponent.java:498)
at javax.swing.JComponent.paint(JComponent.java:696)
at javax.swing.JComponent.paintChildren(JComponent.java:498)
at javax.swing.JComponent.paint(JComponent.java:696)
at javax.swing.JViewport.paint(JViewport.java:668)
at javax.swing.JComponent.paintWithBuffer(JComponent.java:3878)
at javax.swing.JComponent._paintImmediately(JComponent.java:3821)
at javax.swing.JComponent.paintImmediately(JComponent.java:3672)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:370)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:337)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
java.lang.IllegalArgumentException, first appear at 2002-09-07 23:07:25 Beijing Time.
java.lang.IllegalArgumentException
at java.util.SimpleTimeZone.getOffset(SimpleTimeZone.java:427)
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:1510)
at java.util.Calendar.updateTime(Calendar.java:1508)
at java.util.Calendar.getTimeInMillis(Calendar.java:890)
at java.util.Calendar.getTime(Calendar.java:871)
at com.jrefinery.data.Minute.getStart(Unknown Source)
at com.jrefinery.data.Second.getStart(Unknown Source)
at com.jrefinery.data.Millisecond.getEnd(Unknown Source)
at com.jrefinery.data.TimeSeriesCollection.getEndXValue(Unknown Source)
at com.jrefinery.data.DatasetUtilities.getMaximumDomainValue(Unknown Source)
at com.jrefinery.chart.XYPlot.getMaximumHorizontalDataValue(Unknown Source)
at com.jrefinery.chart.HorizontalDateAxis.autoAdjustRange(Unknown Source)
at com.jrefinery.chart.HorizontalDateAxis.configure(Unknown Source)
at com.jrefinery.chart.Plot.chartChanged(Unknown Source)
at com.jrefinery.chart.JFreeChart.notifyListeners(JFreeChart.java:724)
at com.jrefinery.chart.JFreeChart.datasetChanged(JFreeChart.java:738)
at com.jrefinery.data.AbstractDataset.notifyListeners(Unknown Source)
at com.jrefinery.data.AbstractDataset.fireDatasetChanged(Unknown Source)
at com.jrefinery.data.AbstractSeriesDataset.seriesChanged(Unknown Source)
at com.jrefinery.data.Series.notifyListeners(Unknown Source)
at com.jrefinery.data.Series.fireSeriesChanged(Unknown Source)
at com.jrefinery.data.BasicTimeSeries.add(Unknown Source)
at com.jrefinery.data.BasicTimeSeries.add(Unknown Source)
at com.runway.pm.PMChartPanel.addNewValueToSeries02(PMChartPanel.java:947)
at com.runway.pm.PMRequestThread.callToHandleMessage02(PMRequestThread.java:302)
at com.runway.pm.PMRequestThread.run(PMRequestThread.java:199)
Although the time label on time aix show the range from 00:59:00 to 00:59:55 , I am not sure what time the Chart stoped. But I check the log of this module and get this information "2002-09-07 23:07:25,384 [Thread-6] ERROR com.runway.pm.PMChartPanel - The process of adding new data to chart failed"; that time is the IllegalArgumentException first throwed(mentioned above). This log info appears in the log accomplied by IllegalArgumentException throwed every time.
But just now, I re-test my module, then find that the Chart still repaint well when PRException was throwed, but IllegalArgumentException was not throwed now.
Another phenomena is that the more data put into data collection, the more slowly the chart repaint . This phenomena can be detected directly.
IllegalArgumentException occured in series.add() method.
for (int j = 0; j < numOfLines; j ++) {
dataValue[j] = Double.parseDouble( (String) (resultHash.get(englishName[j])));
series[j].add(new Millisecond(valueDate), dataValue[j]);
}
I am not sure whether data that out of chart range should be removed from the Collection of data. How can I do to solve these problem? I need your help. Or should I re-create Chart every some time?
Regards
Auroean
I use TimeSeriesChart(jfreechart0.8.1) to show a monitoring chart, at the same time put data to tables. I test my module in this way: using jbuilder7(jdk.1.3.1), I make the module to run (start at 2002-09-07 21:16:05 Beijing Time). A thread adds value to series once every 5 seconds. This morning, I get a terrible chart. And , the Chart do not repaint, but data are still put into tables. I mail the pic to your mailbox. In jbuilder's debug window, JB prints two exceptions about every 30 seconds. These two exceptions are:
sun.dc.pr.PRException, first appear at 2002-09-07 21:27:14 Beijing Time.
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.SunGraphics2D.draw(SunGraphics2D.java:1599)
at com.jrefinery.chart.StandardXYItemRenderer.drawItem(Unknown Source)
at com.jrefinery.chart.XYPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(JFreeChart.java:653)
at com.jrefinery.chart.JFreeChartPanel.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(JComponent.java:687)
at javax.swing.JComponent.paintChildren(JComponent.java:498)
at javax.swing.JComponent.paint(JComponent.java:696)
at javax.swing.JComponent.paintChildren(JComponent.java:498)
at javax.swing.JComponent.paint(JComponent.java:696)
at javax.swing.JViewport.paint(JViewport.java:668)
at javax.swing.JComponent.paintWithBuffer(JComponent.java:3878)
at javax.swing.JComponent._paintImmediately(JComponent.java:3821)
at javax.swing.JComponent.paintImmediately(JComponent.java:3672)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:370)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:337)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
java.lang.IllegalArgumentException, first appear at 2002-09-07 23:07:25 Beijing Time.
java.lang.IllegalArgumentException
at java.util.SimpleTimeZone.getOffset(SimpleTimeZone.java:427)
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:1510)
at java.util.Calendar.updateTime(Calendar.java:1508)
at java.util.Calendar.getTimeInMillis(Calendar.java:890)
at java.util.Calendar.getTime(Calendar.java:871)
at com.jrefinery.data.Minute.getStart(Unknown Source)
at com.jrefinery.data.Second.getStart(Unknown Source)
at com.jrefinery.data.Millisecond.getEnd(Unknown Source)
at com.jrefinery.data.TimeSeriesCollection.getEndXValue(Unknown Source)
at com.jrefinery.data.DatasetUtilities.getMaximumDomainValue(Unknown Source)
at com.jrefinery.chart.XYPlot.getMaximumHorizontalDataValue(Unknown Source)
at com.jrefinery.chart.HorizontalDateAxis.autoAdjustRange(Unknown Source)
at com.jrefinery.chart.HorizontalDateAxis.configure(Unknown Source)
at com.jrefinery.chart.Plot.chartChanged(Unknown Source)
at com.jrefinery.chart.JFreeChart.notifyListeners(JFreeChart.java:724)
at com.jrefinery.chart.JFreeChart.datasetChanged(JFreeChart.java:738)
at com.jrefinery.data.AbstractDataset.notifyListeners(Unknown Source)
at com.jrefinery.data.AbstractDataset.fireDatasetChanged(Unknown Source)
at com.jrefinery.data.AbstractSeriesDataset.seriesChanged(Unknown Source)
at com.jrefinery.data.Series.notifyListeners(Unknown Source)
at com.jrefinery.data.Series.fireSeriesChanged(Unknown Source)
at com.jrefinery.data.BasicTimeSeries.add(Unknown Source)
at com.jrefinery.data.BasicTimeSeries.add(Unknown Source)
at com.runway.pm.PMChartPanel.addNewValueToSeries02(PMChartPanel.java:947)
at com.runway.pm.PMRequestThread.callToHandleMessage02(PMRequestThread.java:302)
at com.runway.pm.PMRequestThread.run(PMRequestThread.java:199)
Although the time label on time aix show the range from 00:59:00 to 00:59:55 , I am not sure what time the Chart stoped. But I check the log of this module and get this information "2002-09-07 23:07:25,384 [Thread-6] ERROR com.runway.pm.PMChartPanel - The process of adding new data to chart failed"; that time is the IllegalArgumentException first throwed(mentioned above). This log info appears in the log accomplied by IllegalArgumentException throwed every time.
But just now, I re-test my module, then find that the Chart still repaint well when PRException was throwed, but IllegalArgumentException was not throwed now.
Another phenomena is that the more data put into data collection, the more slowly the chart repaint . This phenomena can be detected directly.
IllegalArgumentException occured in series.add() method.
for (int j = 0; j < numOfLines; j ++) {
dataValue[j] = Double.parseDouble( (String) (resultHash.get(englishName[j])));
series[j].add(new Millisecond(valueDate), dataValue[j]);
}
I am not sure whether data that out of chart range should be removed from the Collection of data. How can I do to solve these problem? I need your help. Or should I re-create Chart every some time?
Regards
Auroean
Re: Problem with TimeSeriesChart
Hi Auroean,
I think the answer will be to modify the BasicTimeSeries class so that it (optionally) deletes "old" data. I'll probably add a new attribute get/setWindowLength(...) where you can specify the time period, and automatically remove the old data whenever a new value is added.
Regards,
DG.
I think the answer will be to modify the BasicTimeSeries class so that it (optionally) deletes "old" data. I'll probably add a new attribute get/setWindowLength(...) where you can specify the time period, and automatically remove the old data whenever a new value is added.
Regards,
DG.
Re: Problem with TimeSeriesChart
Hi DG.
Thanks you.
I try to delete "old" data by using these codes:
private void deleteData(BasicTimeSeries timeSeries) {
int index = timeSeries.getItemCount();
if ( index > 20 ) {
timeSeries.delete(0, 3);
}
}
but, an Exception is throwed:
java.lang.IndexOutOfBoundsException: Index: 13, Size: 13
at java.util.ArrayList.RangeCheck(ArrayList.java:491)
at java.util.ArrayList.get(ArrayList.java:307)
at com.jrefinery.data.BasicTimeSeries.getDataPair(Unknown Source)
at com.jrefinery.data.TimeSeriesCollection.getXValue(Unknown Source)
at com.jrefinery.chart.StandardXYItemRenderer.drawItem(Unknown Source)
at com.jrefinery.chart.XYPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(JFreeChart.java:653)
at com.jrefinery.chart.JFreeChartPanel.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(JComponent.java:687)
at javax.swing.JComponent.paintChildren(JComponent.java:498)
at javax.swing.JComponent.paint(JComponent.java:696)
at javax.swing.JComponent.paintChildren(JComponent.java:498)
at javax.swing.JComponent.paint(JComponent.java:696)
at javax.swing.JViewport.paint(JViewport.java:668)
at javax.swing.JComponent.paintWithBuffer(JComponent.java:3878)
at javax.swing.JComponent._paintImmediately(JComponent.java:3821)
at javax.swing.JComponent.paintImmediately(JComponent.java:3672)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:370)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:337)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
But the chart worked well. I think the IndexOutOfBoundsException was catched by JFreeChart. I don't know whether the IndexOutOfBoundsException was caused by the above method - deleteData.
REGARDS
Aurorean.
Thanks you.
I try to delete "old" data by using these codes:
private void deleteData(BasicTimeSeries timeSeries) {
int index = timeSeries.getItemCount();
if ( index > 20 ) {
timeSeries.delete(0, 3);
}
}
but, an Exception is throwed:
java.lang.IndexOutOfBoundsException: Index: 13, Size: 13
at java.util.ArrayList.RangeCheck(ArrayList.java:491)
at java.util.ArrayList.get(ArrayList.java:307)
at com.jrefinery.data.BasicTimeSeries.getDataPair(Unknown Source)
at com.jrefinery.data.TimeSeriesCollection.getXValue(Unknown Source)
at com.jrefinery.chart.StandardXYItemRenderer.drawItem(Unknown Source)
at com.jrefinery.chart.XYPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(JFreeChart.java:653)
at com.jrefinery.chart.JFreeChartPanel.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(JComponent.java:687)
at javax.swing.JComponent.paintChildren(JComponent.java:498)
at javax.swing.JComponent.paint(JComponent.java:696)
at javax.swing.JComponent.paintChildren(JComponent.java:498)
at javax.swing.JComponent.paint(JComponent.java:696)
at javax.swing.JViewport.paint(JViewport.java:668)
at javax.swing.JComponent.paintWithBuffer(JComponent.java:3878)
at javax.swing.JComponent._paintImmediately(JComponent.java:3821)
at javax.swing.JComponent.paintImmediately(JComponent.java:3672)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:370)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:337)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
But the chart worked well. I think the IndexOutOfBoundsException was catched by JFreeChart. I don't know whether the IndexOutOfBoundsException was caused by the above method - deleteData.
REGARDS
Aurorean.
Re: Problem with TimeSeriesChart
At the moment if you modify the dataset in one thread while the chart is reading the dataset (during the drawing process) in another thread, then you will get occasional errors. I think this might be what is happening here. I will be looking into a solution for this problem...
Regards,
DG
Regards,
DG
Re: Problem with TimeSeriesChart
Thanks for you response.
I think this problem may be caused by swing. The repaint process of swing is a multi-thread process. In BasicTimeSeries, the method delete(i, j) fisrt delete these data from list, and then call fireSeriesChanged().
I think this problem may be caused by swing. The repaint process of swing is a multi-thread process. In BasicTimeSeries, the method delete(i, j) fisrt delete these data from list, and then call fireSeriesChanged().
Re: Problem with TimeSeriesChart
I have de same problem with the IndexOutOfBoundsException. Did you found a solution?
Thank's
Thank's
Re: Problem with TimeSeriesChart
mondo:
Sorry. I saw your reply just now.
I have no solution to solve these problem. But I set sleep time of the monitor thread to 20 seconds, then this problem disappeared.
I do not know the reason.
Regards,
aurorean.
Sorry. I saw your reply just now.
I have no solution to solve these problem. But I set sleep time of the monitor thread to 20 seconds, then this problem disappeared.
I do not know the reason.
Regards,
aurorean.
Re: Problem with TimeSeriesChart
How can you modify the sleep time of the monitor thread?
Thank's
Thank's
Re: Problem with TimeSeriesChart
A possible solution:
if (series.getItemCount() > 20)
{
Runnable delete = new Runnable() {
public void run() {
series.delete(0,5);
}};
SwingUtilities.invokeLater(delete);
}
if (series.getItemCount() > 20)
{
Runnable delete = new Runnable() {
public void run() {
series.delete(0,5);
}};
SwingUtilities.invokeLater(delete);
}