double y I experience a strange problem:
Dragging a Shape (a derivative of Circle, in my case) "sometimes" results in bogus ordinate values.
I tried to reproduce in a very simple program, but there the error does NOT seem to happen.
In my real program, in a deeply nested Pane, I add, among other things a:
class SCircle extends Circle {
...
public SCircle(SPoint p) {
super();
...
// mouse events
addEventHandler(MouseEvent.DRAG_DETECTED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
dragging = true;
tooltip.show(SCircle.this, getCenterX(), getCenterY()+2*RADIUS);
}
});
addEventHandler(MouseEvent.MOUSE_DRAGGED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
if (dragging && center != null) { <----- BREAKPOINT HERE
moveTo(event.getX(), event.getY());
}
}
});
addEventHandler(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
if (dragging) {
if (center != null) {
moveTo(event.getX(), event.getY());
}
tooltip.hide();
dragging = false;
}
}
});
...
}
protected void moveTo(double x, double y) {
StringBuilder sb = new StringBuilder();
sb.append("moveTo(");
sb.append(String.valueOf(x));
sb.append(", ");
sb.append(String.valueOf(y));
sb.append("): ");
switch (center.getConstraint()) {
case FIX:
sb.append("FIX!");
break;
case FIXX:
sb.append("FIXX");
center.setY(y);
break;
case FIXY:
sb.append("FIXY");
center.setX(x);
break;
case NONE:
sb.append("done");
center.setX(x);
center.setY(y);
break;
}
LOGGER.trace(sb.toString());
setTooltipString();
}
...
}
Here I experience several malfunctions, main one is that "sometimes" (roughly one in five) I get completely bogus values with event.getY(), i.e.: values way out off the screen.
Typical printout (print is in moveTo(), but breakpointing shows bogus value is already in event.y) follows:
2013-10-19 14:43:01 TRACE SPoint:99 - setX(153.0): done.
2013-10-19 14:43:01 TRACE SPoint:133 - setY(179.0): done.
2013-10-19 14:43:01 TRACE SCircle:199 - moveTo(153.0, 179.0): done
2013-10-19 14:43:01 TRACE SPoint:99 - setX(145.0): done.
2013-10-19 14:43:01 TRACE SPoint:133 - setY(163.0): done.
2013-10-19 14:43:01 TRACE SCircle:199 - moveTo(145.0, 163.0): done
2013-10-19 14:43:01 TRACE SPoint:99 - setX(145.0): done.
2013-10-19 14:43:01 TRACE SPoint:133 - setY(160.0): done.
2013-10-19 14:43:01 TRACE SCircle:199 - moveTo(145.0, 160.0): done
2013-10-19 15:03:12 TRACE SPoint:99 - setX(144.0): done.
2013-10-19 15:03:12 TRACE SPoint:133 - setY(-2066.0): [clipping Y UP to 50.0] done.
2013-10-19 15:03:12 TRACE SCircle:199 - moveTo(144.0, -2066.0): done
2013-10-19 15:03:12 TRACE SPoint:99 - setX(132.0): done.
2013-10-19 15:03:12 TRACE SPoint:133 - setY(127.0): done.
2013-10-19 15:03:12 TRACE SCircle:199 - moveTo(132.0, 127.0): done
2013-10-19 15:03:12 TRACE SPoint:99 - setX(132.0): done.
2013-10-19 15:03:12 TRACE SPoint:133 - setY(-2098.0): [clipping Y UP to 50.0] done.
2013-10-19 15:03:12 TRACE SCircle:199 - moveTo(132.0, -2098.0): done
2013-10-19 15:03:35 TRACE SPoint:99 - setX(248.0): done.
2013-10-19 15:03:35 TRACE SPoint:133 - setY(127.0): done.
2013-10-19 15:03:35 TRACE SCircle:199 - moveTo(248.0, 127.0): done
2013-10-19 15:03:35 TRACE SPoint:99 - setX(248.0): done.
2013-10-19 15:03:35 TRACE SPoint:133 - setY(-2097.0): [clipping Y UP to 50.0] done.
2013-10-19 15:03:35 TRACE SCircle:199 - moveTo(248.0, -2097.0): done
2013-10-19 15:03:35 TRACE SPoint:99 - setX(248.0): done.
2013-10-19 15:03:35 TRACE SPoint:133 - setY(131.0): done.
2013-10-19 15:03:35 TRACE SCircle:199 - moveTo(248.0, 131.0): done
2013-10-19 15:03:35 TRACE SPoint:99 - setX(248.0): done.
2013-10-19 15:03:35 TRACE SPoint:133 - setY(135.0): done.
2013-10-19 15:03:35 TRACE SCircle:199 - moveTo(248.0, 135.0): done
I am aware this is not a "proper" bug report, but I am currently unable to debug this further (and it is obviously very annoying!).
As said I tried a very small program dragging a Circle around, but that does NOT show the malfunction.
Can someone suggest how to better trace the error so it can be fixed?