piccolo2d / piccolo2d.java

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

PSwing added to PCamera not working since PSwing r863 #237

Closed mro closed 8 months ago

mro commented 9 years ago

Originally reported on Google Code with ID 237

If i use PSwing code from r819 my PSwing added directly to the camera is working.

If i use any version more recent it is not working anymore.
This is because in the method listenForCanvas the test for PCamera as parent before
the test for PCanvas as parent is gone.

If i add the code of this method from r819 it work again.

Can you please update the source code to keep the test for PSwing added directly to
the camera ?

Julien Blaize

Reported by julien.blaize on 2012-04-11 07:43:07

mro commented 9 years ago
Julien, Thanks for submitting this. Can you clarify what the problem is. I looked at
r819 but I don't see any changes to a listenForCanvas method.

Reported by atdixon on 2012-04-23 03:37:52

mro commented 9 years ago
Hi,

if i look at PSwingNode r819 lines 610 to 615 are a test to see if the PSwingNode is
directly added to the camera.
In the latter revisions the test is gone, and so PSwingNode added to a PCamera doesn't
work anymore. If you copy the code from 610 to 615 in the latest PSwingNode revision
it works again.

Reported by julien.blaize on 2012-04-23 06:54:27

mro commented 9 years ago
Is this on svn trunk or branches/release-1.3?

Reported by heuermh on 2012-08-31 16:35:01

mro commented 9 years ago

Reported by heuermh on 2012-08-31 20:29:30

mro commented 9 years ago
Hi,
i checked and the part is missing in trunk latest version and in 1.3.1 branch (the
java part).

You can find the code i am talking about (r819 line 610-615) in the trunk revision.
I copy the code here if you can't find it.
this is the part in the if(parent instanceof PCamera).

  private void listenForCanvas(final PNode node) {
        // need to get the full tree for this node
        PNode p = node;
        while (p != null) {
            listenToNode(p);

            final PNode parent = p;
            if (parent instanceof PCamera) {
                final PCamera cam = (PCamera) parent;
                if (cam.getComponent() instanceof PSwingCanvas) {
                    updateCanvas((PSwingCanvas) cam.getComponent());
                }
            }
            else if (parent instanceof PLayer) {
                final PLayer player = (PLayer) parent;
                for (int i = 0; i < player.getCameraCount(); i++) {
                    final PCamera cam = player.getCamera(i);
                    if (cam.getComponent() instanceof PSwingCanvas) {
                        updateCanvas((PSwingCanvas) cam.getComponent());
                        break;
                    }
                }
            }
            p = p.getParent();
        }
    }

Reported by julien.blaize on 2012-09-03 08:00:42