public class PNavigationEventHandler extends PBasicInputEventHandler
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
PNavigationEventHandler()
Constructs a Navigation Event Handler that will only accepts left mouse
clicks.
|
Modifier and Type | Method and Description |
---|---|
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.
|
acceptsEvent, getEventFilter, keyboardFocusGained, keyboardFocusLost, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseReleased, mouseWheelRotated, mouseWheelRotatedByBlock, paramString, processEvent, setEventFilter
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
public PNavigationEventHandler()
public void keyPressed(PInputEvent event)
keyPressed
in class PBasicInputEventHandler
event
- event representing the key presspublic void mousePressed(PInputEvent event)
mousePressed
in class PBasicInputEventHandler
event
- 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 nodepublic List getNeighbors()
public boolean nodeIsNeighborInDirection(PNode node, int direction)
node
- the node being testeddirection
- the direction in which we're testingpublic void sortNodesByDistanceFromPoint(List nodes, Point2D point)
nodes
- list of nodes to be sortedpoint
- point from which distance is being computedprotected 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 lastpublic 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 forprotected void fillViewWhiteSpace(PCamera camera)
camera
- the camera to be transformedCopyright © 1995-2013 Piccolo2D. All Rights Reserved.