getting exception randomly...

A free public discussion forum for the JFreeChart class library.

getting exception randomly...

Postby lixiang » Mon Mar 15, 2010 6:45 am

I am getting the following exception randomly :? .

Code: Select all
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Range(double, double): require lower (1.263437112E12) <= upper (1.263434411E12).
   at org.jfree.data.Range.<init>(Range.java:90)
   at org.jfree.data.time.TimeSeriesCollection.getDomainBounds(TimeSeriesCollection.java:614)
   at org.jfree.data.general.DatasetUtilities.findDomainBounds(DatasetUtilities.java:666)
   at org.jfree.data.general.DatasetUtilities.findDomainBounds(DatasetUtilities.java:642)
   at org.jfree.chart.plot.XYPlot.getDataRange(XYPlot.java:4459)
   at org.jfree.chart.axis.DateAxis.autoAdjustRange(DateAxis.java:1284)
   at org.jfree.chart.axis.DateAxis.configure(DateAxis.java:716)
   at org.jfree.chart.plot.XYPlot.configureDomainAxes(XYPlot.java:959)
   at org.jfree.chart.plot.XYPlot.datasetChanged(XYPlot.java:4513)
   at org.jfree.chart.plot.XYPlot.mapDatasetToRangeAxes(XYPlot.java:1509)
   at org.jfree.chart.plot.XYPlot.mapDatasetToRangeAxis(XYPlot.java:1488)
   at org.jfree.chart.plot.XYPlot.<init>(XYPlot.java:653)
   at org.jfree.chart.ChartFactory.createTimeSeriesChart(ChartFactory.java:1899)
   at li.xiang.nmonanalyser.ui.InternalChartFrame.createCPUAllTagCharts(InternalChartFrame.java:284)
   at li.xiang.nmonanalyser.ui.InternalChartFrame.<init>(InternalChartFrame.java:89)
   at li.xiang.nmonanalyser.ui.MainFrame$1AppActionListener.actionPerformed(MainFrame.java:62)
   at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
   at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
   at javax.swing.AbstractButton.doClick(Unknown Source)
   at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
   at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
   at java.awt.Component.processMouseEvent(Unknown Source)
   at javax.swing.JComponent.processMouseEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Container.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.run(Unknown Source)


any suggestions as to what might be the problem here?
Thanks much.
lixiang
 
Posts: 3
Joined: Mon Mar 15, 2010 5:58 am

Re: getting exception randomly...

Postby lixiang » Mon Mar 15, 2010 6:53 am

it seem happen when i read the data from a file and update the timeseries in a thread.
lixiang
 
Posts: 3
Joined: Mon Mar 15, 2010 5:58 am

Re: getting exception randomly...

Postby lixiang » Tue Mar 16, 2010 2:14 am

i search in google: it's synchronized problem, because jfreechart is not thread-safe? it's true ?

update(add) the TimeSeriesCollection in a thread(class XXXLoader), and update the Charts display in Swing thread. the jfreechart will get some value from the TimeSeriesCollection to range the chart's display and some get range's method is not thread-safe, so some time the range will get incorrect value and throws the Exception ?

Code: Select all
public class XXXLoader implements Runnable{

   public void fireOnLoadLine(String line) {
      LoadEventData eventData = new LoadEventData(this,line);
      synchronized(listeners){
         for(int i=0;i<listeners.size();i++){
            listeners.get(i).onLoadLine(eventData);
         }
      }
   }

   public void run() {
      try {
         String line = null;
         while((line=buffReader.readLine())!=null&&(!Thread.interrupted())){
            //...
            fireOnLoadLine(line);    // === > notify the observers.
         }
}

Code: Select all
public class XXXDataSet  ....{  // XXXLoader 's observer.

   private final TimeSeriesCollection xxxDS;
   private final TimeSeries xxxSeries;

   public  XXXDataSet(){
      xxxDS= new TimeSeriesCollection();
      xxxSeries = new TimeSeries("xxx");
      xxxDS.addSeries(xxxSeries);
      
   }
   public TimeSeriesCollection getXXXDataSet(){
      synchronized(xxxDS){
         return xxxDS;
      }
   }
   public void onLoadLine(LoadEventData e) {
      //do something
      xxxSeries.add(dateItem,xxxValue);          //  ===> add the TimeSeries.
   }
}

Code: Select all
public class MainFrame{

   public static void main(String[] args){
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
                }
            });          
   }
   private static void createAndShowGUI() {
      final JFrame appFrame = new JFrame();
      final JDesktopPane mainFrameDesktop = new JDesktopPane();
                // do  something
                InternalChartFrame in = new InternalChartFrame();   // <===== i create charts here ...
      mainFrameDesktop.add(in);
                // ....
       }
}


Code: Select all
public class InternalChartFrame extends JInternalFrame{

   private XXXLoader xxxLoader ;
   private Thread loaderThread;

   public InternalChartFrame(){
                XXXDataSet xxxDS = new XXXDataSet();
                xxxLoader.addObserver(xxxDS);
                loaderThread = new Thread(xxxLoader);
                xxxLoader.start();
                //....
                JFreeChart chartXXX = ChartFactory.createXYAreaChart(
                                        ...
                                        xxxDS.getXXXDataSet();
                                        ...);
                //... create ChartPlane and add to  JInternalFrame.
        }
}
lixiang
 
Posts: 3
Joined: Mon Mar 15, 2010 5:58 am

Re: getting exception randomly...

Postby ysbn » Sun Mar 27, 2011 5:45 pm

I'm getting this too, any fix/workaround?
ysbn
 
Posts: 5
Joined: Thu Jul 22, 2010 1:06 pm


Return to JFreeChart - General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 21 guests