edu.umd.cs.jazz.event
Class ZSelectionEventHandler

java.lang.Object
  |
  +--edu.umd.cs.jazz.event.ZEventHandler
        |
        +--edu.umd.cs.jazz.event.ZSelectionEventHandler

public class ZSelectionEventHandler
extends ZEventHandler

ZSelectionEventHandler provides event handlers for basic selection interaction. Click to select/unselect an item. Shift-click to extend the selection. Click-and-drag on the background to marquee select. Drag a selected item to move all of the selected items.


Field Summary
protected  int deleteKey
           
protected  ZNode marquee
           
protected  java.awt.geom.Point2D pressPt
           
protected  java.util.Vector prevMotionSelection
           
protected  java.awt.geom.Point2D prevPt
           
protected  java.awt.geom.Point2D pt
           
protected  int scaleDownKey
           
protected  int scaleUpKey
           
protected  ZNode selectionLayer
           
protected  ZNode selNode
           
protected  int translateDownKey
           
protected  int translateLeftKey
           
protected  int translateRightKey
           
protected  int translateUpKey
           
 
Fields inherited from class edu.umd.cs.jazz.event.ZEventHandler
activated, component, keyAdapter, mouseAdapter, mouseMotionAdapter, surface
 
Constructor Summary
ZSelectionEventHandler(java.awt.Component c, ZSurface v, ZNode selectionLayer)
          Constructs a new ZSelectionEventHandler.
 
Method Summary
 void deactivate()
          Deactivates this event handler.
protected  ZNode getTopNode(ZNode node)
          Return the ancestor node whose parent is layer.
 void keyPressed(java.awt.event.KeyEvent e)
          Key press event handler
 void mouseDragged(java.awt.event.MouseEvent e)
          Mouse drag event handler
 void mousePressed(java.awt.event.MouseEvent e)
          Mouse press event handler
 void mouseReleased(java.awt.event.MouseEvent e)
          Mouse release event handler
protected  void preScale(ZNode node, float dz, float x, float y)
          Scale the node using preConcatenation which will result in the scale happening in global coordinates.
protected  void preTranslate(ZNode node, float dx, float dy)
          Translate the node using preConcatenation which will result in the translate happening in global coordinates.
protected  void selectGroupNode(ZNode node)
          select a group of items by putting a rectangle around all items in the group.
 void setSelectionLayer(ZNode node)
          Specify the node that the selection "marquee" should be put on.
protected  void unselectAll(ZCamera camera, ZNode layer)
          Unselect all selected items, also remove any 'grouping rectangles' from selected groups of items.
 
Methods inherited from class edu.umd.cs.jazz.event.ZEventHandler
activate, getCamera, getComponent, getSurface, keyReleased, keyTyped, mouseMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pt

protected java.awt.geom.Point2D pt

prevMotionSelection

protected java.util.Vector prevMotionSelection

selNode

protected ZNode selNode

prevPt

protected java.awt.geom.Point2D prevPt

pressPt

protected java.awt.geom.Point2D pressPt

marquee

protected ZNode marquee

selectionLayer

protected ZNode selectionLayer

scaleUpKey

protected int scaleUpKey

scaleDownKey

protected int scaleDownKey

translateLeftKey

protected int translateLeftKey

translateRightKey

protected int translateRightKey

translateUpKey

protected int translateUpKey

translateDownKey

protected int translateDownKey

deleteKey

protected int deleteKey
Constructor Detail

ZSelectionEventHandler

public ZSelectionEventHandler(java.awt.Component c,
                              ZSurface v,
                              ZNode selectionLayer)
Constructs a new ZSelectionEventHandler.
Parameters:
c - The component that this event handler listens to events on
v - The camera that is selected within
Method Detail

deactivate

public void deactivate()
Deactivates this event handler. This results in all selected objects becoming unselected
Overrides:
deactivate in class ZEventHandler

setSelectionLayer

public void setSelectionLayer(ZNode node)
Specify the node that the selection "marquee" should be put on. The marquee is the rectangle that the user drags around to select things within.

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Key press event handler
Parameters:
e - The event.
Overrides:
keyPressed in class ZEventHandler

unselectAll

protected void unselectAll(ZCamera camera,
                           ZNode layer)
Unselect all selected items, also remove any 'grouping rectangles' from selected groups of items.

selectGroupNode

protected void selectGroupNode(ZNode node)
select a group of items by putting a rectangle around all items in the group.
Parameters:
node - The node whose descendants are the items in the grouped.

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Mouse press event handler
Parameters:
e - The event.
Overrides:
mousePressed in class ZEventHandler

getTopNode

protected ZNode getTopNode(ZNode node)
Return the ancestor node whose parent is layer.
Parameters:
- node a node.

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Mouse drag event handler
Parameters:
e - The event.
Overrides:
mouseDragged in class ZEventHandler

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Mouse release event handler
Parameters:
e - The event.
Overrides:
mouseReleased in class ZEventHandler

preScale

protected void preScale(ZNode node,
                        float dz,
                        float x,
                        float y)
Scale the node using preConcatenation which will result in the scale happening in global coordinates.

preTranslate

protected void preTranslate(ZNode node,
                            float dx,
                            float dy)
Translate the node using preConcatenation which will result in the translate happening in global coordinates.