Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsBendpointEditPolicy setReferencePoints IndexOutOfBoundsException
https://www.eclipse.org/forums/index.php/mv/msg/77436/241092/#msg_241092
When I drag around a Bendpoint I very occiasionally get an
IndexOutOfBoundsException:
java.lang.IndexOutOfBoundsException: Index: -1, Size: 3
at org.eclipse.draw2d.geometry.PointList.getPoint(PointList.jav a:189)
at
org.eclipse.gef.editpolicies.BendpointEditPolicy.setReferenc ePoints(BendpointEditPolicy.java:288)
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:983)
at org.eclipse.gef.tools.SelectionTool.mouseDrag(SelectionTool. java:511)
at org.eclipse.gef.EditDomain.mouseDrag(EditDomain.java:226)
Occaisionally the index is the same as size.
I only get it very rarely when I drag a bendpoint from the middle very
rapidly towards one of the endpoints.
In this case it seems that setReferencePoints would tend to return either
the first or last of the getConnection().getPoints();
and this in turn would cause the code
points.getPoint(ref1, bpIndex - 1);
or
points.getPoint(ref1, bpIndex + 1);
to throw the IndexOutOfBoundsException.
Am I doing something wrong? ( I am not using the Manhattan router )?
Its simple enough to fix if it is a bug but I wondered since this code has
been stable for a while whether I was doing something wrong...]]>J F2008-01-29T12:07:19-00:00Re: BendpointEditPolicy setReferencePoints IndexOutOfBoundsException
https://www.eclipse.org/forums/index.php/mv/msg/77436/241097/#msg_241097
problem, simply creating an Or gate and an XOR gate and joining them with
a Connection. I then grabbed a central bendpoint and Waggled it around (
Mouse pressed )...
java.lang.IndexOutOfBoundsException: Index: 4, Size: 4
at org.eclipse.draw2d.geometry.PointList.getPoint(PointList.jav a:189)
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:983)
at org.eclipse.gef.tools.SelectionTool.mouseDrag(SelectionTool. java:511)
at org.eclipse.gef.EditDomain.mouseDrag(EditDomain.java:226)
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:198)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 19)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:289)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:169)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:363)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
I'll post the fix once I test it...]]>J F2008-01-29T13:03:25-00:00Re: BendpointEditPolicy setReferencePoints IndexOutOfBoundsException
https://www.eclipse.org/forums/index.php/mv/msg/77436/241102/#msg_241102
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;
}
}