Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » IOOBE while dragging bendpoint
IOOBE while dragging bendpoint [message #560089] Tue, 21 September 2010 07:45 Go to next message
Andreas Scharf is currently offline Andreas ScharfFriend
Messages: 20
Registered: September 2010
Junior Member
Hi,

sometimes I get an IndexOutOfBoundsException while dragging a bendpoint. Here's the stack trace:

java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
at org.eclipse.draw2d.geometry.PointList.getPoint(PointList.jav a:190)
at org.eclipse.gef.editpolicies.BendpointEditPolicy.setReferenc ePoints(BendpointEditPolicy.java:290)
at org.eclipse.gef.editpolicies.BendpointEditPolicy.showMoveBen dpointFeedback(BendpointEditPolicy.java:342)
at org.eclipse.gef.editpolicies.BendpointEditPolicy.showSourceF eedback(BendpointEditPolicy.java:375)
at org.eclipse.gef.editparts.AbstractEditPart.showSourceFeedbac k(AbstractEditPart.java:974)
at org.eclipse.gef.tools.SimpleDragTracker.showSourceFeedback(S impleDragTracker.java:229)
at org.eclipse.gef.tools.SimpleDragTracker.handleDragInProgress (SimpleDragTracker.java:137)
at org.eclipse.gef.tools.AbstractTool.mouseDrag(AbstractTool.ja va:994)
at org.eclipse.gef.tools.SelectionTool.mouseDrag(SelectionTool. java:511)
at org.eclipse.gef.EditDomain.mouseDrag(EditDomain.java:230)
at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouse Moved(DomainEventDispatcher.java:357)
at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseMove( LightweightSystem.java:533)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:199)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3880)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3473)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2405)
...

Any idea?

King regards,
Andreas
Re: IOOBE while dragging bendpoint [message #628756 is a reply to message #560089] Fri, 24 September 2010 00:14 Go to previous messageGo to next message
rex is currently offline rexFriend
Messages: 9
Registered: September 2010
Junior Member
No sure which version you are referring to. I polled out version 3.6 and those line numbers you listed above do not match the source. Here is the method from 3.6.

	private void setReferencePoints(BendpointRequest request) {
		PointList points = getConnection().getPoints();
		int bpIndex = -1;
		List bendPoints = (List) getConnection().getRoutingConstraint();
		Point bp = ((Bendpoint) bendPoints.get(request.getIndex()))
				.getLocation();

		int smallestDistance = -1;

		for (int i = 0; i < points.size(); i++) {
			if (smallestDistance == -1
					|| points.getPoint(i).getDistance2(bp) < smallestDistance) {
				bpIndex = i;
				smallestDistance = points.getPoint(i).getDistance2(bp);
				if (smallestDistance == 0)
					break;
			}
		}

		points.getPoint(ref1, bpIndex - 1);
		getConnection().translateToAbsolute(ref1);
		points.getPoint(ref2, bpIndex + 1);
		getConnection().translateToAbsolute(ref2);
	}


Look at the code I think the bpIndex - 1 and the bpIndex + 1 have chance to go wrong. With this in mind, could you please try it a couple times and give us a detailed steps for reproducing?

Thank you.
Re: IOOBE while dragging bendpoint [message #628793 is a reply to message #628756] Fri, 24 September 2010 07:52 Go to previous messageGo to next message
Andreas Scharf is currently offline Andreas ScharfFriend
Messages: 20
Registered: September 2010
Junior Member
That's exactly the code I've also seen and I agree that bpIndex - 1 and bpIndex + 1 will fail sometimes. However I couldn't reproduce it with the Logic example and our application is a commercial one for which I cant show code here.

Basically I think that bpIndex should be checked before accessing the list of point.

What do you think?

Kind regards,
Andreas
Re: IOOBE while dragging bendpoint [message #628834 is a reply to message #628793] Fri, 24 September 2010 11:22 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
The problem is in
public int getDistance2(Point pt) {
	long i = pt.x - x;
	long j = pt.y - y;
	long result = i * i + j * j;
	if (result > Integer.MAX_VALUE)
		return Integer.MAX_VALUE;
	return (int)result;
}


here if result becomes more then Integer.MAX_VALUE then the distance returned is Integer.MAX_VALUE

once it becomes MAX
points.getPoint(i).getDistance2(bp) < smallestDistance will be always false and bpIndex will reach to end of index of point list(in u r case there are only two point in the point list)

This should be a case of very long connection whose distance between first and last point would be more then int MAX..

hope this helps in reproducing the problem..


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: IOOBE while dragging bendpoint [message #628906 is a reply to message #628834] Fri, 24 September 2010 16:45 Go to previous messageGo to next message
rex is currently offline rexFriend
Messages: 9
Registered: September 2010
Junior Member
Thanks guys. I think the information is sufficient for opening a bug. Andreas, you are the OP, do you want to do that?
Re: IOOBE while dragging bendpoint [message #629100 is a reply to message #628906] Mon, 27 September 2010 08:31 Go to previous messageGo to next message
Andreas Scharf is currently offline Andreas ScharfFriend
Messages: 20
Registered: September 2010
Junior Member
Sorry for the delay in response. Of course I can file a bug. Because this is the first time I file a bug I just saw that the bug should be reproducable. In my case the bug is reproducable but I cannot give an (open source) example where this bug appears.

Question: Should I try to find a way to reproduce it with let's say Logic or should I just file a bug with our collected information?

Greetings,
Andreas
Re: IOOBE while dragging bendpoint [message #629109 is a reply to message #629100] Mon, 27 September 2010 09:05 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
First of all does u r scanario include a long connection(long means very long)...
if yes then i think can be reproduced in logic example which has bendpoint connections...


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: IOOBE while dragging bendpoint [message #629112 is a reply to message #629109] Mon, 27 September 2010 09:17 Go to previous message
Andreas Scharf is currently offline Andreas ScharfFriend
Messages: 20
Registered: September 2010
Junior Member
No, that's the point. I can reproduce it even with short connections. I will do some debugging and see where exactly the problem is.
Previous Topic:CompoundDirectedGraph layout problem
Next Topic:Could anybody tell me how to implement normal Table control with GEF?
Goto Forum:
  


Current Time: Fri Apr 19 01:16:42 GMT 2024

Powered by FUDForum. Page generated in 0.02682 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top