piccolo2d / piccolo2d.java

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

adding PHandle #233

Closed mro closed 9 years ago

mro commented 9 years ago

Originally reported on Google Code with ID 233

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?
After Adding PHandle to a pNode as a child and after applying PDragEventHandler the
anchor point is moving too fast.It should not move that fast.What should i do to slow
down it?   

What version of the product are you using? On what operating system?
windows xp

Please provide any additional information below.

PPath circle = PPath.createEllipse((float) (pointOne.getX() + pointTwo.getX()) / 2,
                (float) (pointOne.getY() + pointTwo.getY()) / 2, 7, 7);

final PLocator circleLocator = new PLocator() {
            public double locateX() {
                return circle.getFullBoundsReference().getCenter2D().getX();
            }

            public double locateY() {
                return circle.getFullBoundsReference().getCenter2D().getX();
            }
        };

         PHandle pHandle = new PHandle(circleLocator);

        circle.addChild(pHandle);
        pHandle.addInputEventListener(new PDragEventHandler());

Reported by vijay.rokde@uniken.com on 2011-12-13 12:51:40

mro commented 9 years ago
Vijay,

Your locator has a few defects:

1) You are returning the "X" coordinate in the locateY() method.
2) You should be returning *local* coordinates, not "full bounds" coordinates.

Your locator should look like:

        final PLocator locator = new PLocator() {
            public double locateX() {
                double x = circle.getBounds().getCenter2D().getX();

                return x;
            }
            public double locateY() {
                double y = circle.getBounds().getCenter2D().getY();
                return y;
            }
        };

Reported by atdixon on 2011-12-18 20:31:29