|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.umd.cs.piccolo.event.PBasicInputEventHandler
edu.umd.cs.piccolox.event.PNavigationEventHandler
public class PNavigationEventHandler
PNavigationEventHandler implements simple focus based navigation. Uses mouse button one or the arrow keys to set a new focus. Animates the canvas view to keep the focus node on the screen and at 100 percent scale with minimal view movement.
| Field Summary | |
|---|---|
static int |
EAST
The RIGHT direction on the screen. |
static int |
IN
The IN direction on the scene. |
static int |
NORTH
The UP direction on the screen. |
static int |
OUT
The OUT direction on the scene. |
static int |
SOUTH
The DOWN direction on the screen. |
static int |
WEST
The LEFT direction on the screen. |
| Constructor Summary | |
|---|---|
PNavigationEventHandler()
Constructs a Navigation Event Handler that will only accepts left mouse clicks. |
|
| Method Summary | |
|---|---|
protected PActivity |
animateCameraViewTransformTo(PCamera camera,
AffineTransform targetTransform,
int duration)
Animates the camera's view transform into the provided one over the duration provided. |
PActivity |
directCameraViewToFocus(PCamera camera,
PNode newFocus,
int duration)
Animates the Camera's view so that it contains the new focus node. |
protected void |
fillViewWhiteSpace(PCamera camera)
Instantaneously transforms the provided camera so that it does not contain any extra white space. |
PNode |
getNeighborInDirection(int direction)
Returns the nearest node in the given direction. |
List |
getNeighbors()
Returns all pickable nodes that are 1 hop away from the currently focused node. |
void |
keyPressed(PInputEvent event)
Processes key pressed events. |
void |
mousePressed(PInputEvent event)
Animates the camera to the node that has been pressed. |
void |
moveFocusDown(PInputEvent event)
Moves the focus in the downward direction. |
void |
moveFocusIn(PInputEvent event)
Moves the focus "into" the scene. |
void |
moveFocusLeft(PInputEvent event)
Moves the focus in the left direction. |
void |
moveFocusOut(PInputEvent event)
Moves the focus "out" of scene. |
void |
moveFocusRight(PInputEvent event)
Moves the focus in the right direction. |
void |
moveFocusToMouseOver(PInputEvent event)
Moves the focus to the mouse under the mouse. |
void |
moveFocusUp(PInputEvent event)
Moves the focus in the up direction. |
boolean |
nodeIsNeighborInDirection(PNode node,
int direction)
Returns true if the given node is a neighbor in the given direction relative to the current focus. |
void |
sortNodesByDistanceFromPoint(List nodes,
Point2D point)
Modifies the array so that it's sorted in ascending order based on the distance from the given point. |
| Methods inherited from class edu.umd.cs.piccolo.event.PBasicInputEventHandler |
|---|
acceptsEvent, getEventFilter, keyboardFocusGained, keyboardFocusLost, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseReleased, mouseWheelRotated, mouseWheelRotatedByBlock, paramString, processEvent, setEventFilter |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NORTH
public static final int SOUTH
public static final int EAST
public static final int WEST
public static final int IN
public static final int OUT
| Constructor Detail |
|---|
public PNavigationEventHandler()
| Method Detail |
|---|
public void keyPressed(PInputEvent event)
keyPressed in class PBasicInputEventHandlerevent - event representing the key presspublic void mousePressed(PInputEvent event)
mousePressed in class PBasicInputEventHandlerevent - event representing the mouse presspublic void moveFocusDown(PInputEvent event)
event - ignoredpublic void moveFocusIn(PInputEvent event)
event - ignoredpublic void moveFocusLeft(PInputEvent event)
event - ignoredpublic void moveFocusOut(PInputEvent event)
event - ignoredpublic void moveFocusRight(PInputEvent event)
event - ignoredpublic void moveFocusUp(PInputEvent event)
event - ignoredpublic void moveFocusToMouseOver(PInputEvent event)
event - mouse eventpublic PNode getNeighborInDirection(int direction)
direction - direction in which to look the nearest node
public List getNeighbors()
public boolean nodeIsNeighborInDirection(PNode node,
int direction)
node - the node being testeddirection - the direction in which we're testing
public void sortNodesByDistanceFromPoint(List nodes,
Point2D point)
nodes - list of nodes to be sortedpoint - point from which distance is being computed
protected PActivity animateCameraViewTransformTo(PCamera camera,
AffineTransform targetTransform,
int duration)
camera - camera being animatedtargetTransform - the transform to which the camera's transform will
be animatedduration - the number of milliseconds the animation should last
public PActivity directCameraViewToFocus(PCamera camera,
PNode newFocus,
int duration)
camera - The camera to be animatednewFocus - the node that will gain focusduration - number of milliseconds that animation should last for
protected void fillViewWhiteSpace(PCamera camera)
camera - the camera to be transformed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||