Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) NullPointerException in Overview when rebuilding (Read 7762 times)
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
NullPointerException in Overview when rebuilding
Jun 6th, 2007 at 7:12am
Print Post  
It seems that if I rebuild a Flowchart while the chart and the Overview are visible, I get NullPointerException in the Overview:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.mindfusion.jdiagram.TextLayout.a(Unknown Source)
at com.mindfusion.jdiagram.TextLayout.a(Unknown Source)
at com.mindfusion.jdiagram.Box.a(Unknown Source)
at com.mindfusion.jdiagram.Box.a(Unknown Source)
at com.mindfusion.jdiagram.Overview.a(Unknown Source)
at com.mindfusion.jdiagram.Overview.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(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)

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: NullPointerException in Overview when rebuildi
Reply #1 - Jun 6th, 2007 at 10:38am
Print Post  
Try setting the Overview.Document to a temporary empty chart while rebuilding the original chart, than set it back to the original. What exactly happens while rebuilding the flowchart so we can investigate this here?

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Re: NullPointerException in Overview when rebuildi
Reply #2 - Jun 6th, 2007 at 10:59am
Print Post  
When trying your advice - i got a different exception:

Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(Unknown Source)
at com.mindfusion.jdiagram.FlowChart.c(Unknown Source)
at com.mindfusion.jdiagram.FlowChart.a(Unknown Source)
at com.mindfusion.jdiagram.FlowChart.a(Unknown Source)
at com.mindfusion.jdiagram.FlowChart.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(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)



When I rebuild the Flowchart, I do the following:

chart.clearAll();
chart.createBox(...)    { x 20 }
chart.createArrow(....)  { x 10 }
AnnealLayout layout = new AnnealLayout();
layout.set different parameters
layout.arrange(chart)
chart.repaint();
chart.resizeToFitMinimum();
m_seelctedBox = this.getBoxes().get(0);


That's it. I also have a method for CustomDraw (Additional) if it makes a difference.

Thanks,
yoav
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: NullPointerException in Overview when rebuildi
Reply #3 - Jun 7th, 2007 at 6:16am
Print Post  
Could you check if this version fixes the exception

http://www.mindfusion.org/_temp/JDiagram.jar

without assigning a temporary flowchart to the Overview.

Thanks,
Stoyan
  
Back to top
 
IP Logged
 
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Re: NullPointerException in Overview when rebuildi
Reply #4 - Jun 7th, 2007 at 10:52am
Print Post  
Now I get these exceptions:

Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(Unknown Source)
at com.mindfusion.jdiagram.FlowChart.c(Unknown Source)
at com.mindfusion.jdiagram.FlowChart.a(Unknown Source)
at com.mindfusion.jdiagram.FlowChart.a(Unknown Source)
at com.mindfusion.jdiagram.FlowChart.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(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)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 6, Size: 0
at java.util.ArrayList.RangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.mindfusion.jdiagram.BaseList.get(Unknown Source)
at com.mindfusion.jdiagram.FlowChart.getBoxAt(Unknown Source)
at com.mindfusion.jdiagram.FlowChart.b(Unknown Source)
at com.mindfusion.jdiagram.FlowChart.c(Unknown Source)
at com.mindfusion.jdiagram.FlowChart$MouseMonitor.mouseMoved(Unknown Source)
at java.awt.AWTEventMulticaster.mouseMoved(Unknown Source)
at java.awt.AWTEventMulticaster.mouseMoved(Unknown Source)
at java.awt.Component.processMouseMotionEvent(Unknown Source)
at javax.swing.JComponent.processMouseMotionEvent(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)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: NullPointerException in Overview when rebuildi
Reply #5 - Jun 7th, 2007 at 11:06am
Print Post  
Do you rebuild the chart from a mouseMoved event handler?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: NullPointerException in Overview when rebuildi
Reply #6 - Jun 8th, 2007 at 10:07am
Print Post  
Do you by any chance rebuild the chart from a different thread?
  
Back to top
 
IP Logged
 
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Re: NullPointerException in Overview when rebuildi
Reply #7 - Jun 13th, 2007 at 1:15pm
Print Post  
I may have build the diagram from a different thread.
After adding synchronized property to the update method, it seems that the errors vanished.
It seems fine now.
Thanks!
  
Back to top
 
IP Logged
 
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Re: NullPointerException in Overview when rebuildi
Reply #8 - Jun 13th, 2007 at 1:50pm
Print Post  
No, it's not solved - it happens again.
Sad

I got a new exception, though...


Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(Unknown Source)
at com.mindfusion.jdiagram.Overview.drawContents(Unknown Source)
at com.mindfusion.jdiagram.Overview.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(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)



  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: NullPointerException in Overview when rebuildi
Reply #9 - Jun 13th, 2007 at 5:02pm
Print Post  
Try enclosing the rebuild code between FlowChart.suspendRepaint() and FlowChart.resumeRepaint() calls. The diagram should be always in a valid state if the rebuilding and drawing code run in the same thread, but that might help anyway.
  
Back to top
 
IP Logged
 
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Re: NullPointerException in Overview when rebuildi
Reply #10 - Jun 14th, 2007 at 4:19am
Print Post  
I've tried using these methods - and the problem doesn't appear again.
I've tested a few times and it seems fine.
Hope it stays that way!
Smiley
Thanks,
Yoav
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint