public abstract class AbstractViewInputHandler extends java.lang.Object implements ViewInputHandler, java.beans.PropertyChangeListener
Constructor and Description |
---|
AbstractViewInputHandler() |
Modifier and Type | Method and Description |
---|---|
void |
apply()
Implementations are expected to apply any changes to the
View state prior to the View
setting the modelview matrix for rendering the current frame. |
double |
computeDragSlope(java.awt.Point point1,
java.awt.Point point2,
Vec4 vec1,
Vec4 vec2)
Compute the drag slope the given screen and world coordinates.
|
protected Vec4 |
computeSelectedPointAt(java.awt.Point point) |
protected Position |
computeSelectedPosition() |
protected static java.awt.Point |
constrainToSourceBounds(java.awt.Point point,
java.lang.Object source) |
protected double |
evaluateScaleFuncEyeAltitude() |
protected double |
evaluateScaleFuncZoom() |
void |
focusGained(java.awt.event.FocusEvent e) |
void |
focusLost(java.awt.event.FocusEvent e) |
ViewInputAttributes |
getAttributes()
Returns the values that are used to transform raw input events into view movments.
|
protected LatLon |
getChangeInLocation(java.awt.Point point1,
java.awt.Point point2,
Vec4 vec1,
Vec4 vec2) |
double |
getDragSlopeFactor()
Returns the
factor that dampens view movement when the user pans drags the cursor in a way that could
cause an abrupt transition. |
protected java.awt.Point |
getLastMousePoint() |
java.awt.Point |
getMouseDownPoint() |
protected java.awt.Point |
getMousePoint() |
protected long |
getPerFrameInputInterval() |
protected double |
getScaledValue(double minValue,
double maxValue,
java.lang.String scaleFunc) |
protected double |
getScaleValue(double minValue,
double maxValue,
double value,
double range,
boolean isExp) |
protected double |
getScaleValueElevation(ViewInputAttributes.DeviceAttributes deviceAttributes,
ViewInputAttributes.ActionAttributes actionAttributes) |
protected Position |
getSelectedPosition() |
protected View |
getView() |
WorldWindow |
getWorldWindow()
Return the
WorldWindow this ViewInputHandler is listening to for input events, and will modify in
response to those events |
protected void |
handleFocusGained(java.awt.event.FocusEvent e) |
protected void |
handleFocusLost(java.awt.event.FocusEvent e) |
protected void |
handleKeyPressed(java.awt.event.KeyEvent e) |
protected void |
handleKeyReleased(java.awt.event.KeyEvent e) |
protected void |
handleMouseClicked(java.awt.event.MouseEvent e) |
protected void |
handleMouseDragged(java.awt.event.MouseEvent e) |
protected void |
handleMouseMoved(java.awt.event.MouseEvent e) |
protected void |
handleMousePressed(java.awt.event.MouseEvent e) |
protected void |
handleMouseReleased(java.awt.event.MouseEvent e) |
protected void |
handleMouseWheelMoved(java.awt.event.MouseWheelEvent e) |
protected boolean |
handlePerFrameAnimation(java.lang.String target) |
protected boolean |
handlePerFrameKeyState(KeyEventState keys,
java.lang.String target) |
protected boolean |
handlePerFrameMouseState(KeyEventState keys,
java.lang.String target) |
protected void |
handlePropertyChange(java.beans.PropertyChangeEvent e) |
boolean |
isEnableSmoothing()
Returns whether the ViewInputHandler will smooth view movements in response to input events.
|
boolean |
isLockHeading()
Returns whether the view's heading should stay the same unless explicitly changed.
|
boolean |
isStopOnFocusLost()
Returns whether the view will stop when the WorldWindow looses focus.
|
protected boolean |
isWorldWindowFocusOwner() |
void |
keyPressed(java.awt.event.KeyEvent e) |
void |
keyReleased(java.awt.event.KeyEvent e) |
void |
keyTyped(java.awt.event.KeyEvent e) |
void |
mouseClicked(java.awt.event.MouseEvent e) |
void |
mouseDragged(java.awt.event.MouseEvent e) |
void |
mouseEntered(java.awt.event.MouseEvent e) |
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mouseMoved(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e) |
void |
mouseReleased(java.awt.event.MouseEvent e) |
void |
mouseWheelMoved(java.awt.event.MouseWheelEvent e) |
protected void |
onStopView() |
void |
propertyChange(java.beans.PropertyChangeEvent e) |
protected double |
rawInputToChangeInValue(double rawInput,
ViewInputAttributes.DeviceAttributes deviceAttributes,
ViewInputAttributes.ActionAttributes actionAttributes,
java.lang.String scaleFunc) |
void |
setAttributes(ViewInputAttributes attributes)
Sets the values that will be used to transform raw input events into view movements.
|
void |
setDragSlopeFactor(double factor)
Sets the
factor that dampens view movement when a mouse drag event would cause an abrupt
transition. |
void |
setEnableSmoothing(boolean enable)
Sets whether the ViewInputHandler should smooth view movements in response to input events.
|
void |
setLockHeading(boolean lock)
Sets whether the view's heading should stay the same unless explicitly changed.
|
void |
setMouseDownPoint(java.awt.Point mouseDownPoint) |
protected void |
setMouseDownView(View mouseDownView) |
protected void |
setPerFrameInputInterval(long milliseconds) |
protected void |
setSelectedPosition(Position position) |
void |
setStopOnFocusLost(boolean stop)
Sets whether the view should stop when the WorldWindow looses focus.
|
void |
setWorldWindow(WorldWindow newWorldWindow)
Sets the
WorldWindow this ViewInputHandler should listen to for input events, and should modify in
response to those events. |
protected void |
setWorldWindowFocusOwner(boolean focusOwner) |
protected void |
updateMousePoint(java.awt.event.MouseEvent e) |
void |
viewApplied()
Called just after the view applies its state and computes its internal transforms.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addAnimator, goTo, isAnimating, stopAnimators
protected ViewInputAttributes attributes
protected static final double DEFAULT_DRAG_SLOPE_FACTOR
protected static final long DEFAULT_PER_FRAME_INPUT_INTERVAL
protected double dragSlopeFactor
protected boolean enableSmoothing
protected static final java.lang.String GENERATE_EVENTS
protected ViewInputAttributes.ActionAttributesMap keyActionMap
protected KeyEventState keyEventState
protected ViewInputAttributes.DeviceModifierMap keyModsActionMap
protected java.awt.Point lastMousePoint
protected long lastPerFrameInputTime
protected boolean lockHeading
protected int[] modifierList
protected ViewInputAttributes.ActionAttributesMap mouseActionMap
protected Matrix mouseDownModelview
protected java.awt.Point mouseDownPoint
protected Matrix mouseDownProjection
protected java.awt.Rectangle mouseDownViewport
protected ViewInputAttributes.DeviceModifierMap mouseModsActionMap
protected java.awt.Point mousePoint
protected ViewInputAttributes.DeviceModifierMap mouseWheelModsActionMap
protected final int NUM_MODIFIERS
protected long perFrameInputInterval
protected static final java.lang.String QUERY_EVENTS
protected static final java.lang.String SCALE_FUNC_EYE_ALTITUDE
protected static final java.lang.String SCALE_FUNC_EYE_ALTITUDE_EXP
protected static final java.lang.String SCALE_FUNC_ZOOM
protected static final java.lang.String SCALE_FUNC_ZOOM_EXP
protected Position selectedPosition
protected boolean stopOnFocusLost
protected WorldWindow wwd
protected boolean wwdFocusOwner
public void apply()
ViewInputHandler
View
state prior to the View
setting the modelview matrix for rendering the current frame.apply
in interface ViewInputHandler
public double computeDragSlope(java.awt.Point point1, java.awt.Point point2, Vec4 vec1, Vec4 vec2)
ViewInputHandler
computeDragSlope
in interface ViewInputHandler
point1
- The previous mouse coordinate.point2
- The current mouse coordinate.vec1
- The first cartesian world space coordinate.vec2
- The second cartesion world space coordinate.protected Vec4 computeSelectedPointAt(java.awt.Point point)
protected Position computeSelectedPosition()
protected static java.awt.Point constrainToSourceBounds(java.awt.Point point, java.lang.Object source)
protected double evaluateScaleFuncEyeAltitude()
protected double evaluateScaleFuncZoom()
public void focusGained(java.awt.event.FocusEvent e)
focusGained
in interface java.awt.event.FocusListener
public void focusLost(java.awt.event.FocusEvent e)
focusLost
in interface java.awt.event.FocusListener
public ViewInputAttributes getAttributes()
getAttributes
in interface ViewInputHandler
protected LatLon getChangeInLocation(java.awt.Point point1, java.awt.Point point2, Vec4 vec1, Vec4 vec2)
public double getDragSlopeFactor()
factor
that dampens view movement when the user pans drags the cursor in a way that could
cause an abrupt transition.getDragSlopeFactor
in interface ViewInputHandler
setDragSlopeFactor(double)
protected java.awt.Point getLastMousePoint()
public java.awt.Point getMouseDownPoint()
protected java.awt.Point getMousePoint()
protected long getPerFrameInputInterval()
protected double getScaledValue(double minValue, double maxValue, java.lang.String scaleFunc)
protected double getScaleValue(double minValue, double maxValue, double value, double range, boolean isExp)
protected double getScaleValueElevation(ViewInputAttributes.DeviceAttributes deviceAttributes, ViewInputAttributes.ActionAttributes actionAttributes)
protected Position getSelectedPosition()
protected View getView()
public WorldWindow getWorldWindow()
WorldWindow
this ViewInputHandler is listening to for input events, and will modify in
response to those eventsgetWorldWindow
in interface ViewInputHandler
WorldWindow
this ViewInputHandler is listening to, and will modify in response to
events.protected void handleFocusGained(java.awt.event.FocusEvent e)
protected void handleFocusLost(java.awt.event.FocusEvent e)
protected void handleKeyPressed(java.awt.event.KeyEvent e)
protected void handleKeyReleased(java.awt.event.KeyEvent e)
protected void handleMouseClicked(java.awt.event.MouseEvent e)
protected void handleMouseDragged(java.awt.event.MouseEvent e)
protected void handleMouseMoved(java.awt.event.MouseEvent e)
protected void handleMousePressed(java.awt.event.MouseEvent e)
protected void handleMouseReleased(java.awt.event.MouseEvent e)
protected void handleMouseWheelMoved(java.awt.event.MouseWheelEvent e)
protected boolean handlePerFrameAnimation(java.lang.String target)
protected boolean handlePerFrameKeyState(KeyEventState keys, java.lang.String target)
protected boolean handlePerFrameMouseState(KeyEventState keys, java.lang.String target)
protected void handlePropertyChange(java.beans.PropertyChangeEvent e)
public boolean isEnableSmoothing()
isEnableSmoothing
in interface ViewInputHandler
public boolean isLockHeading()
isLockHeading
in interface ViewInputHandler
public boolean isStopOnFocusLost()
isStopOnFocusLost
in interface ViewInputHandler
protected boolean isWorldWindowFocusOwner()
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
mouseWheelMoved
in interface java.awt.event.MouseWheelListener
protected void onStopView()
public void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange
in interface java.beans.PropertyChangeListener
protected double rawInputToChangeInValue(double rawInput, ViewInputAttributes.DeviceAttributes deviceAttributes, ViewInputAttributes.ActionAttributes actionAttributes, java.lang.String scaleFunc)
public void setAttributes(ViewInputAttributes attributes)
setAttributes
in interface ViewInputHandler
attributes
- values that will be used to transform raw input into view movement.java.lang.IllegalArgumentException
- if attributes
is null.ViewInputAttributes
public void setDragSlopeFactor(double factor)
factor
that dampens view movement when a mouse drag event would cause an abrupt
transition. The drag slope is the ratio of screen pixels to Cartesian distance moved, measured by the previous
and current mouse points. As drag slope gets larger, it becomes more difficult to operate the view. This
typically happens while dragging over and around the horizon, where movement of a few pixels can cause the view
to move many kilometers. This factor
is the amount of damping applied to the view movement in such
cases. Setting factor
to zero will disable this behavior, while setting factor
to a
positive value may dampen the effects of mouse dragging.setDragSlopeFactor
in interface ViewInputHandler
factor
- dampening view movement when a mouse drag event would cause an abrupt transition. Must be greater
than or equal to zero.java.lang.IllegalArgumentException
- if factor
is less than zero.public void setEnableSmoothing(boolean enable)
ViewInputAttributes
. A value of false will disable all smoothing.setEnableSmoothing
in interface ViewInputHandler
enable
- true to smooth view movements; false otherwise.public void setLockHeading(boolean lock)
setLockHeading
in interface ViewInputHandler
lock
- true if the view's heading should stay the same unless explicity changed; false otherwise.public void setMouseDownPoint(java.awt.Point mouseDownPoint)
protected void setMouseDownView(View mouseDownView)
protected void setPerFrameInputInterval(long milliseconds)
protected void setSelectedPosition(Position position)
public void setStopOnFocusLost(boolean stop)
setStopOnFocusLost
in interface ViewInputHandler
stop
- true if the view should stop when the WorldWindow looses focus; false otherwise.public void setWorldWindow(WorldWindow newWorldWindow)
WorldWindow
this ViewInputHandler should listen to for input events, and should modify in
response to those events. If the parameter newWorldWindow
is null, then this ViewInputHandler
will do nothing.setWorldWindow
in interface ViewInputHandler
newWorldWindow
- the WorldWindow
to listen on, and modify in response to events.protected void setWorldWindowFocusOwner(boolean focusOwner)
protected void updateMousePoint(java.awt.event.MouseEvent e)
public void viewApplied()
ViewInputHandler
viewApplied
in interface ViewInputHandler