Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic IndexOutOfBounds exception on LayeredLayout (Read 7994 times)
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
IndexOutOfBounds exception on LayeredLayout
May 24th, 2007 at 12:36pm
Print Post  
hi,

I was given the task to test how JDiagram handles large amount of nodes.

I've created a chart with 2000 boxes, and connected them with randomal algorithm with 1000 arrows.
Each time when I run it, I get a IndexOutOfBoundsException exception:


Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.mindfusion.jdiagram.jlayout.LayeredLayout.d(Unknown Source)
at com.mindfusion.jdiagram.jlayout.LayeredLayout.arrange(Unknown Source)
at com.mindfusion.jdiagram.LayeredLayout.arrange(Unknown Source)
at GUIManager.performance(GUIManager.java:173)
at ButtonAction.actionPerformed(ButtonAction.java:40)
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.plaf.basic.BasicButtonListener.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)


What may be the reason?
Thanks!
  
Back to top
 
IP Logged
 
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Re: IndexOutOfBounds exception on LayeredLayout
Reply #1 - May 24th, 2007 at 12:37pm
Print Post  
Need to add:

I'm using a LayeredLayout with these parameters:

layout.setNodeDistance(ADFlowChart.BOX_WIDTH);
layout.setArrowsCompactFactor(2f);
layout.setTimeLimit(100);
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: IndexOutOfBounds exception on LayeredLayout
Reply #2 - May 25th, 2007 at 4:42am
Print Post  
Hi,

We'll test this now.

Thank you,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: IndexOutOfBounds exception on LayeredLayout
Reply #3 - May 25th, 2007 at 7:23am
Print Post  
Hi,

We could not reproduce this; perhaps the random links generation algorithm we used produces slightly different results than yours. Could you email me a saved diagram with which you get the exception?

Thank you,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: IndexOutOfBounds exception on LayeredLayout
Reply #4 - May 25th, 2007 at 9:51am
Print Post  
We have ported some fixes we have done in the Flowchart.NET's layered layout since the JDiagram first release - this version might work better:

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

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



Posts: 163
Joined: May 2nd, 2007
Re: IndexOutOfBounds exception on LayeredLayout
Reply #5 - May 27th, 2007 at 9:01am
Print Post  
Thanks.
I've tried this new jar - and the outofbounds exception doesn't appear anymore.
On the other hand, when I try a large amount of boxes and connections (5000 boxes and 5000 connections) - I get StackOverflow exception when running code line:
layout.arrange(m_chart);

The exception looks like that:

Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError

at java.util.ArrayList.add(Unknown Source)

at com.mindfusion.jdiagram.BaseList.add(Unknown Source)

at java.util.AbstractList.add(Unknown Source)

at com.mindfusion.jdiagram.FCNode.b(Unknown Source)

at com.mindfusion.jdiagram.FCNode.create(Unknown Source)

at com.mindfusion.jdiagram.StraightFactory.createNode(Unknown Source)

at com.mindfusion.jdiagram.FCLink.create(Unknown Source)

at com.mindfusion.jdiagram.StraightFactory.createLink(Unknown Source)

at com.mindfusion.jdiagram.FCNode.a(Unknown Source)
....


The entire layout code is:

LayeredLayout layout = new LayeredLayout();
layout.setNodeDistance(ADFlowChart.BOX_WIDTH);
layout.setArrowsCompactFactor(2);
layout.arrange(m_chart);

This happens every time I create this diagram and tries to arrange it in layout.
  
Back to top
 
IP Logged
 
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Re: IndexOutOfBounds exception on LayeredLayout
Reply #6 - May 27th, 2007 at 9:09am
Print Post  
Another thing:
I've tried to save the diagram to send to you for tests.
I got a StackOverflowError when trying to save...
It looked like that:

Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
at java.util.concurrent.ConcurrentHashMap.get(Unknown Source)
at java.io.ObjectStreamClass.lookup(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at com.mindfusion.jdiagram.Serialization.a(Unknown Source)
at com.mindfusion.jdiagram.Item.writeExternal(Unknown Source)
at com.mindfusion.jdiagram.Node.writeExternal(Unknown Source)
at com.mindfusion.jdiagram.Box.writeExternal(Unknown Source)
at java.io.ObjectOutputStream.writeExternalData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at com.mindfusion.jdiagram.BoxLink.writeExternal(Unknown Source)
at java.io.ObjectOutputStream.writeExternalData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at com.mindfusion.jdiagram.Arrow.writeExternal(Unknown Source)
at java.io.ObjectOutputStream.writeExternalData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at com.mindfusion.jdiagram.BaseList.writeExternal(Unknown Source)
at java.io.ObjectOutputStream.writeExternalData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at com.mindfusion.jdiagram.Node.writeExternal(Unknown Source)
at com.mindfusion.jdiagram.Box.writeExternal(Unknown Source)
at java.io.ObjectOutputStream.writeExternalData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
......
  
Back to top
 
IP Logged
 
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Re: IndexOutOfBounds exception on LayeredLayout
Reply #7 - May 27th, 2007 at 9:57am
Print Post  
To help understand the problem, this is my code for random boxes:


int NUM_OF_INSTANCES = 5000;
int NUM_OF_CONNECTIONS = NUM_OF_INSTANCES;
for (int i=1; i< NUM_OF_INSTANCES; i++) {
com.mindfusion.jdiagram.Box box = m_chart.createBox(0, 0, ADFlowChart.BOX_WIDTH, ADFlowChart.BOX_HEIGHT);
box.setBrush(new SolidBrush(Color.getHSBColor((float)Math.random(), (float)Math.random(), (float)Math.random())));
box.setTag(String.valueOf(i));
}
for (int i=1; i<NUM_OF_CONNECTIONS ; i++) {
int x = (int)(Math.random() * NUM_OF_INSTANCES);
int y = (int)(Math.random() * NUM_OF_INSTANCES);
m_chart.createArrow(m_chart.findBox(String.valueOf(x)), m_chart.findBox(String.valueOf(y)));
}


LayeredLayout layout = new LayeredLayout();
layout.setNodeDistance(ADFlowChart.BOX_WIDTH);
layout.setArrowsCompactFactor(0.2f);
//layout.setTimeLimit(100);
layout.arrange(m_chart);
m_chart.resizeToFitItems(10);
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: IndexOutOfBounds exception on LayeredLayout
Reply #8 - May 27th, 2007 at 4:54pm
Print Post  
In both cases it's a StackOverflowError, so try running your application with a larger stack size using the -Xss option of java.exe.

It seems the saving problem happens in the Java serialization code while it tries to build the object graph for externalizable objects, so increasing the stack size might be the only solution for that. We'll check our layout code to see if we can optimize its memory usage somehow.

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



Posts: 163
Joined: May 2nd, 2007
Re: IndexOutOfBounds exception on LayeredLayout
Reply #9 - May 28th, 2007 at 5:41am
Print Post  
I'll check it out - thanks.
Yoav
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint