google-code-export / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
2 stars 1 forks source link

PBoundsHandle does not change cursor and installs action when mouse moves over #176

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a node and a selection handler that uses PBoundsHandle
2. Select the node
3. Move the cursor over any node

What is the expected output? What do you see instead?

Node is selected with 8 handles (this is OK) but when you move the mouse 
over any kind of handle, the cursor does not change and the expected 
action can not be done.
Instead the cursor is still the selection cursor and only moving the node 
is possible. 

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

1.2.1 and 1.3
Windows Vista

Please provide any additional information below.

The fault is in PBoundsHandle.
It happend from rev 599 to 705.
Code in 599 is working fine; code in 705 fails.

Original issue reported on code.google.com by tbit455...@aol.com on 20 Apr 2010 at 3:14

GoogleCodeExporter commented 9 years ago
Sorry

I have to correct step 3.

3 Move the cursor over any handle on the selected node

Original comment by tbit455...@aol.com on 20 Apr 2010 at 3:20

GoogleCodeExporter commented 9 years ago
The selection example
(examples/src/main/java/edu/umd/cs/piccolo/examples/SelectionExample.java) 
seems to
work fine for me with version 1.3 and svn trunk.

It uses PSelectionEventHandler to create the selection handles as follows

extras/src/main/java/edu/umd/cs/piccolox/event/PSelectionEventHandler.java:
    public void decorateSelectedNode(final PNode node) {
        PBoundsHandle.addBoundsHandlesTo(node);
    }

Might you be able to attach an example that demonstrates the problem?  Perhaps 
you
are using PBoundsHandle through a different code path.

Original comment by heue...@gmail.com on 20 Apr 2010 at 3:23

GoogleCodeExporter commented 9 years ago
I use a customized PSelectionHandler that overwrites decorateSelectedNode; 
maybe 
this is the problem? See code below:

/**
 * A selection event handler. The first selected node is the 'master' node.
 * Selected nodes are decorated by handles. The master node handles are marked
 * by using the DEFAULT_MASTER_COLOR color. All other selected node handles are
 * marked by using the DEFAULT_SLAVE_COLOR. If only one node is selected it is
 * automatically the 'master' node.
 *
 * @author Tom
 */
public class MyPSelectionEventHandler extends PSelectionEventHandler {
    private static final Logger logger = Logger.getLogger
("MyPSelectionEventHandler");
    /**
     * The color used by handles to mark the 'master' node.
     */
    public static final Color DEFAULT_MASTER_COLOR = Color.red;
    /**
     * The color used by handles to mark all other nodes then the 'master'.
     */
    public static final Color DEFAULT_SLAVE_COLOR = Color.green;

    private Color masterColor = DEFAULT_MASTER_COLOR;
    private Color slaveColor = DEFAULT_SLAVE_COLOR;

    {
        PHandle.DEFAULT_HANDLE_SIZE = 3.0f;
    }

    private PNode master = null;

    /**
     * Creates a new instance of MyPSelectionEventHandler
     * @param marqueeParent 
     * @param selectableParent
     */
    public MyPSelectionEventHandler(PNode marqueeParent, PNode selectableParent) {
        super(marqueeParent, selectableParent);
    }

    /**
     * Creates a new instance of MyPSelectionEventHandler
     * @param marqueeParent
     * @param selectableParents
     */
    public MyPSelectionEventHandler(PNode marqueeParent, List selectableParents) {
        super(marqueeParent, selectableParents);
    }

    /**
     *
     * @param node
     */
    @Override
    public void decorateSelectedNode(final PNode node) {
        // Decorate the first node as master node in masterColor
        if (getSelection().size() == 1) {
            PHandle.DEFAULT_COLOR = masterColor;
            master = node;
        }
        else {
            PHandle.DEFAULT_COLOR = slaveColor;
        }

        PHandle.DEFAULT_HANDLE_SHAPE = new Rectangle2D.Float(0f, 0f, 
PHandle.DEFAULT_HANDLE_SIZE, PHandle.DEFAULT_HANDLE_SIZE);
        PInnerBoundsHandle.addBoundsHandlesTo(node);
    }

    /**
     *
     * @param node
     */
    @Override
    public void undecorateSelectedNode(PNode node) {
        super.undecorateSelectedNode(node);
        if (node == master) {
            master = null;
        }
    }

    /**
     * Get the currently selected 'master' node.
     * @return the master node
     */
    public PNode getMaster() {
        logger.finer("MASTER=" + master);
        return master;
    }

    public Color getMasterColor() {
        return masterColor;
    }

    public void setMasterColor(final Color col) {
        masterColor = col;
    }

    public Color getSlaveColor() {
        return slaveColor;
    }

    public void setSlaveColor(Color slaveColor) {
        this.slaveColor = slaveColor;
    }
}

Original comment by tbit455...@aol.com on 20 Apr 2010 at 4:47

GoogleCodeExporter commented 9 years ago
Forget about this issue. It was a fault in my application ;-)

Original comment by tbit455...@aol.com on 7 May 2010 at 11:01

GoogleCodeExporter commented 9 years ago

Original comment by allain.lalonde on 7 May 2010 at 12:53