BasicTimeSeries Exception, BUG??

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Moussa A. Ba

BasicTimeSeries Exception, BUG??

Post by Moussa A. Ba » Mon Dec 02, 2002 9:43 pm

Good Afternoon, I am using the BasicTimeSeries to create a dynamic XY graph. I received an IndexOutofBoundsException every few seconds. To update the series, I simply do a

Millisecond newxacc = new Millisecond();
xaccseries.add(newxacc,new Double(xacc));
yaccseries.add(newxacc,new Double(yacc));

I have included below the code I use to create the graph, the Exceptions are at the end of the message.


xaccseries = new BasicTimeSeries("X acceleration",Millisecond.class);
xaccseries.setHistoryCount(6000);
yaccseries = new BasicTimeSeries("Y acceleration",Millisecond.class);
yaccseries.setHistoryCount(6000);
TimeSeriesCollection xdataset = new TimeSeriesCollection();
xdataset.addSeries(xaccseries);
xdataset.addSeries(yaccseries);
HorizontalDateAxis domain = new HorizontalDateAxis("Time");
HorizontalDateAxis tdomain = new HorizontalDateAxis("Time");
VerticalNumberAxis xrange = new VerticalNumberAxis("X & Y acceleration");
VerticalNumberAxis temprange = new VerticalNumberAxis("Temperature F");

XYPlot xyplot = new XYPlot(xdataset, domain, xrange);
xyplot.setBackgroundPaint(Color.white);
xyplot.setSeriesPaint(new Paint[] {Color.red, Color.blue});
xyplot.setSeriesStroke(0, seriesStroke);

domain.setAutoRange(true);
domain.setLowerMargin(0.0);
domain.setUpperMargin(0.0);
domain.setGridPaint(Color.black);
domain.setGridStroke(gridStroke);
domain.setTickLabelsVisible(true);
domain.setGridLinesVisible(false);
domain.setCrosshairVisible(false);

xrange.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
xrange.setGridPaint(Color.black);
xrange.setGridStroke(gridStroke);
xrange.setGridLinesVisible(true);
xrange.setCrosshairVisible(false);
xrange.setAutoRange(true);
xrange.setMaximumAxisValue(2.0);
xrange.setMinimumAxisValue(-2.0);




java.lang.IndexOutOfBoundsException: Index: 38, Size: 38

at java.util.ArrayList.RangeCheck(ArrayList.java:508)

at java.util.ArrayList.get(ArrayList.java:320)

at com.jrefinery.data.BasicTimeSeries.getDataPair(BasicTimeSeries.java:268)

at com.jrefinery.data.TimeSeriesCollection.getXValue(TimeSeriesCollection.java:319)

at com.jrefinery.chart.StandardXYItemRenderer.drawItem(StandardXYItemRenderer.java:369)

at com.jrefinery.chart.XYPlot.render(XYPlot.java:787)

at com.jrefinery.chart.XYPlot.draw(XYPlot.java:739)

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:804)

at javax.swing.JComponent.paintChildren(JComponent.java:643)

at javax.swing.JComponent.paint(JComponent.java:813)

at javax.swing.JComponent.paintChildren(JComponent.java:643)

at javax.swing.JComponent.paint(JComponent.java:813)

at javax.swing.JLayeredPane.paint(JLayeredPane.java:552)

at javax.swing.JComponent.paintChildren(JComponent.java:643)

at javax.swing.JComponent.paint(JComponent.java:813)

at javax.swing.JComponent.paintChildren(JComponent.java:643)

at javax.swing.JComponent.paint(JComponent.java:813)

at javax.swing.JComponent.paintChildren(JComponent.java:643)

at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4742)

at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4688)

at javax.swing.JComponent._paintImmediately(JComponent.java:4632)

at javax.swing.JComponent.paintImmediately(JComponent.java:4464)

at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)

at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:443)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

java.lang.IndexOutOfBoundsException: Index: 50, Size: 50

at java.util.ArrayList.RangeCheck(ArrayList.java:508)

at java.util.ArrayList.get(ArrayList.java:320)

at com.jrefinery.data.BasicTimeSeries.getDataPair(BasicTimeSeries.java:268)

at com.jrefinery.data.TimeSeriesCollection.getXValue(TimeSeriesCollection.java:319)

at com.jrefinery.chart.StandardXYItemRenderer.drawItem(StandardXYItemRenderer.java:369)

at com.jrefinery.chart.XYPlot.render(XYPlot.java:787)

at com.jrefinery.chart.XYPlot.draw(XYPlot.java:739)

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:804)

at javax.swing.JComponent.paintChildren(JComponent.java:643)

at javax.swing.JComponent.paint(JComponent.java:813)

at javax.swing.JComponent.paintChildren(JComponent.java:643)

at javax.swing.JComponent.paint(JComponent.java:813)

at javax.swing.JLayeredPane.paint(JLayeredPane.java:552)

at javax.swing.JComponent.paintChildren(JComponent.java:643)

at javax.swing.JComponent.paint(JComponent.java:813)

at javax.swing.JComponent.paintChildren(JComponent.java:643)

at javax.swing.JComponent.paint(JComponent.java:813)

at javax.swing.JComponent.paintChildren(JComponent.java:643)

at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4742)

at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4688)

at javax.swing.JComponent._paintImmediately(JComponent.java:4632)

at javax.swing.JComponent.paintImmediately(JComponent.java:4464)

at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)

at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:443)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

David Gilbert

Re: BasicTimeSeries Exception, BUG??

Post by David Gilbert » Tue Dec 03, 2002 12:10 am

Hi Moussa,

My guess is that this is a multithreading problem. In the current version of JFreeChart there is no thread synchronisation. It's being worked on for the next release...

Regards,

DG

Locked