piccolo2d / piccolo2d.java

Structured 2D Graphics Framework
http://piccolo2d.org
Other
51 stars 14 forks source link

PSwingEventHandler doesn't dispatch events to nodes at extreme scales #235

Closed mro closed 9 years ago

mro commented 9 years ago

Originally reported on Google Code with ID 235

User John Marteens reported an error where a Swing component (within a PSwing) does
not get mouse events when that component is within a node lineage that has extreme
scale transforms.

For example, if a PSwing is within a parent node with scale = 0.001, events are not
fired for the component. (I've reproduced this particular case on Win7/64bit Java).

John provided a suggested patch that fixes his particular case:

=== PSwingEventHandler ===
...
       if (currentNode instanceof PSwing && pickedNode.isDescendentOf(canvas.getRoot()))
{

           final PSwing swing = (PSwing) currentNode;
           final PNode grabNode = pickedNode;

           point = new Point(mEvent.getX(), mEvent.getY());
//jmes 20111230 replaced
//            cameraToLocal(pSwingMouseEvent.getPath().getTopCamera(), point, grabNode);
           Point2D.Double pt2D = new Point2D.Double(mEvent.getX(), mEvent.getY());
           cameraToLocal(pSwingMouseEvent.getPath().getTopCamera(), pt2D, grabNode);
           point.setLocation(pt2D);
//jmes 20111230 end replaced
           prevPoint = (Point) point.clone();
=== END ===

Essentially, the integer Point object does not survive the cameraToLocal math. John
found that using a Point2D.Double fixes his particular problem.

Does anyone see anything wrong with his solution?

Reported by atdixon on 2012-01-07 19:20:21

mro commented 9 years ago

Reported by atdixon on 2012-01-07 19:28:11

mro commented 9 years ago
Committed revision 1160. Please review/verify.

Reported by atdixon on 2012-01-07 19:29:43

mro commented 9 years ago
Committed revision 1161. (This is the TRUNK fix.)

Reported by atdixon on 2012-01-07 19:42:28

mro commented 9 years ago

Reported by heuermh on 2013-11-26 17:42:21