Package gov.nasa.worldwind.awt
Class AbstractViewInputHandler
- java.lang.Object
-
- gov.nasa.worldwind.awt.AbstractViewInputHandler
-
- All Implemented Interfaces:
ViewInputHandler,java.awt.event.FocusListener,java.awt.event.KeyListener,java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.awt.event.MouseWheelListener,java.beans.PropertyChangeListener,java.util.EventListener
- Direct Known Subclasses:
BasicViewInputHandler
public abstract class AbstractViewInputHandler extends java.lang.Object implements ViewInputHandler, java.beans.PropertyChangeListener
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AbstractViewInputHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapply()Implementations are expected to apply any changes to theViewstate prior to the View setting the modelview matrix for rendering the current frame.doublecomputeDragSlope(java.awt.Point point1, java.awt.Point point2, Vec4 vec1, Vec4 vec2)Compute the drag slope the given screen and world coordinates.protected Vec4computeSelectedPointAt(java.awt.Point point)protected PositioncomputeSelectedPosition()protected static java.awt.PointconstrainToSourceBounds(java.awt.Point point, java.lang.Object source)protected doubleevaluateScaleFuncEyeAltitude()protected doubleevaluateScaleFuncZoom()voidfocusGained(java.awt.event.FocusEvent e)voidfocusLost(java.awt.event.FocusEvent e)ViewInputAttributesgetAttributes()Returns the values that are used to transform raw input events into view movments.protected LatLongetChangeInLocation(java.awt.Point point1, java.awt.Point point2, Vec4 vec1, Vec4 vec2)doublegetDragSlopeFactor()Returns thefactorthat dampens view movement when the user pans drags the cursor in a way that could cause an abrupt transition.protected java.awt.PointgetLastMousePoint()java.awt.PointgetMouseDownPoint()protected java.awt.PointgetMousePoint()protected longgetPerFrameInputInterval()protected doublegetScaledValue(double minValue, double maxValue, java.lang.String scaleFunc)protected doublegetScaleValue(double minValue, double maxValue, double value, double range, boolean isExp)protected doublegetScaleValueElevation(ViewInputAttributes.DeviceAttributes deviceAttributes, ViewInputAttributes.ActionAttributes actionAttributes)protected PositiongetSelectedPosition()protected ViewgetView()WorldWindowgetWorldWindow()Return theWorldWindowthis ViewInputHandler is listening to for input events, and will modify in response to those eventsprotected voidhandleFocusGained(java.awt.event.FocusEvent e)protected voidhandleFocusLost(java.awt.event.FocusEvent e)protected voidhandleKeyPressed(java.awt.event.KeyEvent e)protected voidhandleKeyReleased(java.awt.event.KeyEvent e)protected voidhandleMouseClicked(java.awt.event.MouseEvent e)protected voidhandleMouseDragged(java.awt.event.MouseEvent e)protected voidhandleMouseMoved(java.awt.event.MouseEvent e)protected voidhandleMousePressed(java.awt.event.MouseEvent e)protected voidhandleMouseReleased(java.awt.event.MouseEvent e)protected voidhandleMouseWheelMoved(java.awt.event.MouseWheelEvent e)protected booleanhandlePerFrameAnimation(java.lang.String target)protected booleanhandlePerFrameKeyState(KeyEventState keys, java.lang.String target)protected booleanhandlePerFrameMouseState(KeyEventState keys, java.lang.String target)protected voidhandlePropertyChange(java.beans.PropertyChangeEvent e)booleanisEnableSmoothing()Returns whether the ViewInputHandler will smooth view movements in response to input events.booleanisLockHeading()Returns whether the view's heading should stay the same unless explicitly changed.booleanisStopOnFocusLost()Returns whether the view will stop when the WorldWindow looses focus.protected booleanisWorldWindowFocusOwner()voidkeyPressed(java.awt.event.KeyEvent e)voidkeyReleased(java.awt.event.KeyEvent e)voidkeyTyped(java.awt.event.KeyEvent e)voidmouseClicked(java.awt.event.MouseEvent e)voidmouseDragged(java.awt.event.MouseEvent e)voidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmouseMoved(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)voidmouseWheelMoved(java.awt.event.MouseWheelEvent e)protected voidonStopView()voidpropertyChange(java.beans.PropertyChangeEvent e)protected doublerawInputToChangeInValue(double rawInput, ViewInputAttributes.DeviceAttributes deviceAttributes, ViewInputAttributes.ActionAttributes actionAttributes, java.lang.String scaleFunc)voidsetAttributes(ViewInputAttributes attributes)Sets the values that will be used to transform raw input events into view movements.voidsetDragSlopeFactor(double factor)Sets thefactorthat dampens view movement when a mouse drag event would cause an abrupt transition.voidsetEnableSmoothing(boolean enable)Sets whether the ViewInputHandler should smooth view movements in response to input events.voidsetLockHeading(boolean lock)Sets whether the view's heading should stay the same unless explicitly changed.voidsetMouseDownPoint(java.awt.Point mouseDownPoint)protected voidsetMouseDownView(View mouseDownView)protected voidsetPerFrameInputInterval(long milliseconds)protected voidsetSelectedPosition(Position position)voidsetStopOnFocusLost(boolean stop)Sets whether the view should stop when the WorldWindow looses focus.voidsetWorldWindow(WorldWindow newWorldWindow)Sets theWorldWindowthis ViewInputHandler should listen to for input events, and should modify in response to those events.protected voidsetWorldWindowFocusOwner(boolean focusOwner)protected voidupdateMousePoint(java.awt.event.MouseEvent e)voidviewApplied()Called just after the view applies its state and computes its internal transforms.-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nasa.worldwind.awt.ViewInputHandler
addAnimator, goTo, isAnimating, stopAnimators
-
-
-
-
Field Detail
-
wwd
protected WorldWindow wwd
-
attributes
protected ViewInputAttributes attributes
-
mouseActionMap
protected ViewInputAttributes.ActionAttributesMap mouseActionMap
-
keyActionMap
protected ViewInputAttributes.ActionAttributesMap keyActionMap
-
keyModsActionMap
protected ViewInputAttributes.DeviceModifierMap keyModsActionMap
-
mouseModsActionMap
protected ViewInputAttributes.DeviceModifierMap mouseModsActionMap
-
mouseWheelModsActionMap
protected ViewInputAttributes.DeviceModifierMap mouseWheelModsActionMap
-
enableSmoothing
protected boolean enableSmoothing
-
lockHeading
protected boolean lockHeading
-
stopOnFocusLost
protected boolean stopOnFocusLost
-
wwdFocusOwner
protected boolean wwdFocusOwner
-
mouseDownPoint
protected java.awt.Point mouseDownPoint
-
lastMousePoint
protected java.awt.Point lastMousePoint
-
mousePoint
protected java.awt.Point mousePoint
-
selectedPosition
protected Position selectedPosition
-
mouseDownModelview
protected Matrix mouseDownModelview
-
mouseDownProjection
protected Matrix mouseDownProjection
-
mouseDownViewport
protected java.awt.Rectangle mouseDownViewport
-
keyEventState
protected KeyEventState keyEventState
-
dragSlopeFactor
protected double dragSlopeFactor
-
perFrameInputInterval
protected long perFrameInputInterval
-
lastPerFrameInputTime
protected long lastPerFrameInputTime
-
DEFAULT_DRAG_SLOPE_FACTOR
protected static final double DEFAULT_DRAG_SLOPE_FACTOR
- See Also:
- Constant Field Values
-
DEFAULT_PER_FRAME_INPUT_INTERVAL
protected static final long DEFAULT_PER_FRAME_INPUT_INTERVAL
- See Also:
- Constant Field Values
-
GENERATE_EVENTS
protected static final java.lang.String GENERATE_EVENTS
- See Also:
- Constant Field Values
-
QUERY_EVENTS
protected static final java.lang.String QUERY_EVENTS
- See Also:
- Constant Field Values
-
SCALE_FUNC_EYE_ALTITUDE
protected static final java.lang.String SCALE_FUNC_EYE_ALTITUDE
- See Also:
- Constant Field Values
-
SCALE_FUNC_EYE_ALTITUDE_EXP
protected static final java.lang.String SCALE_FUNC_EYE_ALTITUDE_EXP
- See Also:
- Constant Field Values
-
SCALE_FUNC_ZOOM
protected static final java.lang.String SCALE_FUNC_ZOOM
- See Also:
- Constant Field Values
-
SCALE_FUNC_ZOOM_EXP
protected static final java.lang.String SCALE_FUNC_ZOOM_EXP
- See Also:
- Constant Field Values
-
modifierList
protected int[] modifierList
-
NUM_MODIFIERS
protected final int NUM_MODIFIERS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getWorldWindow
public WorldWindow getWorldWindow()
Return theWorldWindowthis ViewInputHandler is listening to for input events, and will modify in response to those events- Specified by:
getWorldWindowin interfaceViewInputHandler- Returns:
- the
WorldWindowthis ViewInputHandler is listening to, and will modify in response to events.
-
setWorldWindow
public void setWorldWindow(WorldWindow newWorldWindow)
Sets theWorldWindowthis ViewInputHandler should listen to for input events, and should modify in response to those events. If the parameternewWorldWindowis null, then this ViewInputHandler will do nothing.- Specified by:
setWorldWindowin interfaceViewInputHandler- Parameters:
newWorldWindow- theWorldWindowto listen on, and modify in response to events.
-
getAttributes
public ViewInputAttributes getAttributes()
Returns the values that are used to transform raw input events into view movments.- Specified by:
getAttributesin interfaceViewInputHandler- Returns:
- values that are be used to transform raw input into view movement.
-
setAttributes
public void setAttributes(ViewInputAttributes attributes)
Sets the values that will be used to transform raw input events into view movements. ViewInputAttributes define a calibration value for each combination of device and action, and a general sensitivity value for each device.- Specified by:
setAttributesin interfaceViewInputHandler- Parameters:
attributes- values that will be used to transform raw input into view movement.- Throws:
java.lang.IllegalArgumentException- ifattributesis null.- See Also:
ViewInputAttributes
-
isEnableSmoothing
public boolean isEnableSmoothing()
Returns whether the ViewInputHandler will smooth view movements in response to input events.- Specified by:
isEnableSmoothingin interfaceViewInputHandler- Returns:
- true if the view will movements are smoothed; false otherwise.
-
setEnableSmoothing
public void setEnableSmoothing(boolean enable)
Sets whether the ViewInputHandler should smooth view movements in response to input events. A value of true will cause the ViewInputHandler to delegate decisions about whether to smooth a certain input event to itsViewInputAttributes. A value of false will disable all smoothing.- Specified by:
setEnableSmoothingin interfaceViewInputHandler- Parameters:
enable- true to smooth view movements; false otherwise.
-
isLockHeading
public boolean isLockHeading()
Returns whether the view's heading should stay the same unless explicitly changed.- Specified by:
isLockHeadingin interfaceViewInputHandler- Returns:
- true if the view's heading will stay the same unless explicity changed; false otherwise.
-
setLockHeading
public void setLockHeading(boolean lock)
Sets whether the view's heading should stay the same unless explicitly changed. For example, moving forward along a great arc would suggest a change in position and heading. If the heading had been locked, the ViewInputHandler will move forward in a way that doesn't change the heading.- Specified by:
setLockHeadingin interfaceViewInputHandler- Parameters:
lock- true if the view's heading should stay the same unless explicity changed; false otherwise.
-
isStopOnFocusLost
public boolean isStopOnFocusLost()
Returns whether the view will stop when the WorldWindow looses focus.- Specified by:
isStopOnFocusLostin interfaceViewInputHandler- Returns:
- true if the view will stop when the WorldWindow looses focus; false otherwise.
-
setStopOnFocusLost
public void setStopOnFocusLost(boolean stop)
Sets whether the view should stop when the WorldWindow looses focus.- Specified by:
setStopOnFocusLostin interfaceViewInputHandler- Parameters:
stop- true if the view should stop when the WorldWindow looses focus; false otherwise.
-
getDragSlopeFactor
public double getDragSlopeFactor()
Returns thefactorthat dampens view movement when the user pans drags the cursor in a way that could cause an abrupt transition.- Specified by:
getDragSlopeFactorin interfaceViewInputHandler- Returns:
- factor dampening view movement when a mouse drag event would cause an abrupt transition.
- See Also:
setDragSlopeFactor(double)
-
setDragSlopeFactor
public void setDragSlopeFactor(double factor)
Sets thefactorthat 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. Thisfactoris the amount of damping applied to the view movement in such cases. Settingfactorto zero will disable this behavior, while settingfactorto a positive value may dampen the effects of mouse dragging.- Specified by:
setDragSlopeFactorin interfaceViewInputHandler- Parameters:
factor- dampening view movement when a mouse drag event would cause an abrupt transition. Must be greater than or equal to zero.- Throws:
java.lang.IllegalArgumentException- iffactoris less than zero.
-
getPerFrameInputInterval
protected long getPerFrameInputInterval()
-
setPerFrameInputInterval
protected void setPerFrameInputInterval(long milliseconds)
-
getView
protected View getView()
-
isWorldWindowFocusOwner
protected boolean isWorldWindowFocusOwner()
-
setWorldWindowFocusOwner
protected void setWorldWindowFocusOwner(boolean focusOwner)
-
getMousePoint
protected java.awt.Point getMousePoint()
-
getLastMousePoint
protected java.awt.Point getLastMousePoint()
-
updateMousePoint
protected void updateMousePoint(java.awt.event.MouseEvent e)
-
getSelectedPosition
protected Position getSelectedPosition()
-
setSelectedPosition
protected void setSelectedPosition(Position position)
-
computeSelectedPosition
protected Position computeSelectedPosition()
-
onStopView
protected void onStopView()
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
- Specified by:
keyTypedin interfacejava.awt.event.KeyListener
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
- Specified by:
keyPressedin interfacejava.awt.event.KeyListener
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener
-
handleKeyPressed
protected void handleKeyPressed(java.awt.event.KeyEvent e)
-
handleKeyReleased
protected void handleKeyReleased(java.awt.event.KeyEvent e)
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressedin interfacejava.awt.event.MouseListener
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
-
handleMouseClicked
protected void handleMouseClicked(java.awt.event.MouseEvent e)
-
handleMousePressed
protected void handleMousePressed(java.awt.event.MouseEvent e)
-
handleMouseReleased
protected void handleMouseReleased(java.awt.event.MouseEvent e)
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener
-
handleMouseDragged
protected void handleMouseDragged(java.awt.event.MouseEvent e)
-
handleMouseMoved
protected void handleMouseMoved(java.awt.event.MouseEvent e)
-
mouseWheelMoved
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
- Specified by:
mouseWheelMovedin interfacejava.awt.event.MouseWheelListener
-
handleMouseWheelMoved
protected void handleMouseWheelMoved(java.awt.event.MouseWheelEvent e)
-
focusGained
public void focusGained(java.awt.event.FocusEvent e)
- Specified by:
focusGainedin interfacejava.awt.event.FocusListener
-
focusLost
public void focusLost(java.awt.event.FocusEvent e)
- Specified by:
focusLostin interfacejava.awt.event.FocusListener
-
handleFocusGained
protected void handleFocusGained(java.awt.event.FocusEvent e)
-
handleFocusLost
protected void handleFocusLost(java.awt.event.FocusEvent e)
-
apply
public void apply()
Description copied from interface:ViewInputHandlerImplementations are expected to apply any changes to theViewstate prior to the View setting the modelview matrix for rendering the current frame.- Specified by:
applyin interfaceViewInputHandler
-
viewApplied
public void viewApplied()
Description copied from interface:ViewInputHandlerCalled just after the view applies its state and computes its internal transforms.- Specified by:
viewAppliedin interfaceViewInputHandler
-
handlePerFrameKeyState
protected boolean handlePerFrameKeyState(KeyEventState keys, java.lang.String target)
-
handlePerFrameMouseState
protected boolean handlePerFrameMouseState(KeyEventState keys, java.lang.String target)
-
handlePerFrameAnimation
protected boolean handlePerFrameAnimation(java.lang.String target)
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener
-
handlePropertyChange
protected void handlePropertyChange(java.beans.PropertyChangeEvent e)
-
rawInputToChangeInValue
protected double rawInputToChangeInValue(double rawInput, ViewInputAttributes.DeviceAttributes deviceAttributes, ViewInputAttributes.ActionAttributes actionAttributes, java.lang.String scaleFunc)
-
getScaledValue
protected double getScaledValue(double minValue, double maxValue, java.lang.String scaleFunc)
-
evaluateScaleFuncEyeAltitude
protected double evaluateScaleFuncEyeAltitude()
-
evaluateScaleFuncZoom
protected double evaluateScaleFuncZoom()
-
getScaleValueElevation
protected double getScaleValueElevation(ViewInputAttributes.DeviceAttributes deviceAttributes, ViewInputAttributes.ActionAttributes actionAttributes)
-
getScaleValue
protected double getScaleValue(double minValue, double maxValue, double value, double range, boolean isExp)
-
computeSelectedPointAt
protected Vec4 computeSelectedPointAt(java.awt.Point point)
-
getChangeInLocation
protected LatLon getChangeInLocation(java.awt.Point point1, java.awt.Point point2, Vec4 vec1, Vec4 vec2)
-
computeDragSlope
public double computeDragSlope(java.awt.Point point1, java.awt.Point point2, Vec4 vec1, Vec4 vec2)Description copied from interface:ViewInputHandlerCompute the drag slope the given screen and world coordinates. The drag slope is the ratio of screen pixels to Cartesian distance moved, measured by the previous and current mouse points.- Specified by:
computeDragSlopein interfaceViewInputHandler- Parameters:
point1- The previous mouse coordinate.point2- The current mouse coordinate.vec1- The first cartesian world space coordinate.vec2- The second cartesion world space coordinate.- Returns:
- the ratio of screen pixels to Cartesian distance moved.
-
constrainToSourceBounds
protected static java.awt.Point constrainToSourceBounds(java.awt.Point point, java.lang.Object source)
-
getMouseDownPoint
public java.awt.Point getMouseDownPoint()
-
setMouseDownPoint
public void setMouseDownPoint(java.awt.Point mouseDownPoint)
-
setMouseDownView
protected void setMouseDownView(View mouseDownView)
-
-