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 SummaryConstructors Constructor Description AbstractViewInputHandler()
 - 
Method SummaryAll 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.Objectclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface gov.nasa.worldwind.awt.ViewInputHandleraddAnimator, goTo, isAnimating, stopAnimators
 
- 
 
- 
- 
- 
Field Detail- 
wwdprotected WorldWindow wwd 
 - 
attributesprotected ViewInputAttributes attributes 
 - 
mouseActionMapprotected ViewInputAttributes.ActionAttributesMap mouseActionMap 
 - 
keyActionMapprotected ViewInputAttributes.ActionAttributesMap keyActionMap 
 - 
keyModsActionMapprotected ViewInputAttributes.DeviceModifierMap keyModsActionMap 
 - 
mouseModsActionMapprotected ViewInputAttributes.DeviceModifierMap mouseModsActionMap 
 - 
mouseWheelModsActionMapprotected ViewInputAttributes.DeviceModifierMap mouseWheelModsActionMap 
 - 
enableSmoothingprotected boolean enableSmoothing 
 - 
lockHeadingprotected boolean lockHeading 
 - 
stopOnFocusLostprotected boolean stopOnFocusLost 
 - 
wwdFocusOwnerprotected boolean wwdFocusOwner 
 - 
mouseDownPointprotected java.awt.Point mouseDownPoint 
 - 
lastMousePointprotected java.awt.Point lastMousePoint 
 - 
mousePointprotected java.awt.Point mousePoint 
 - 
selectedPositionprotected Position selectedPosition 
 - 
mouseDownModelviewprotected Matrix mouseDownModelview 
 - 
mouseDownProjectionprotected Matrix mouseDownProjection 
 - 
mouseDownViewportprotected java.awt.Rectangle mouseDownViewport 
 - 
keyEventStateprotected KeyEventState keyEventState 
 - 
dragSlopeFactorprotected double dragSlopeFactor 
 - 
perFrameInputIntervalprotected long perFrameInputInterval 
 - 
lastPerFrameInputTimeprotected long lastPerFrameInputTime 
 - 
DEFAULT_DRAG_SLOPE_FACTORprotected static final double DEFAULT_DRAG_SLOPE_FACTOR - See Also:
- Constant Field Values
 
 - 
DEFAULT_PER_FRAME_INPUT_INTERVALprotected static final long DEFAULT_PER_FRAME_INPUT_INTERVAL - See Also:
- Constant Field Values
 
 - 
GENERATE_EVENTSprotected static final java.lang.String GENERATE_EVENTS - See Also:
- Constant Field Values
 
 - 
QUERY_EVENTSprotected static final java.lang.String QUERY_EVENTS - See Also:
- Constant Field Values
 
 - 
SCALE_FUNC_EYE_ALTITUDEprotected static final java.lang.String SCALE_FUNC_EYE_ALTITUDE - See Also:
- Constant Field Values
 
 - 
SCALE_FUNC_EYE_ALTITUDE_EXPprotected static final java.lang.String SCALE_FUNC_EYE_ALTITUDE_EXP - See Also:
- Constant Field Values
 
 - 
SCALE_FUNC_ZOOMprotected static final java.lang.String SCALE_FUNC_ZOOM - See Also:
- Constant Field Values
 
 - 
SCALE_FUNC_ZOOM_EXPprotected static final java.lang.String SCALE_FUNC_ZOOM_EXP - See Also:
- Constant Field Values
 
 - 
modifierListprotected int[] modifierList 
 - 
NUM_MODIFIERSprotected final int NUM_MODIFIERS - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getWorldWindowpublic WorldWindow getWorldWindow() Return theWorldWindowthis ViewInputHandler is listening to for input events, and will modify in response to those events- Specified by:
- getWorldWindowin interface- ViewInputHandler
- Returns:
- the WorldWindowthis ViewInputHandler is listening to, and will modify in response to events.
 
 - 
setWorldWindowpublic 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 interface- ViewInputHandler
- Parameters:
- newWorldWindow- the- WorldWindowto listen on, and modify in response to events.
 
 - 
getAttributespublic ViewInputAttributes getAttributes() Returns the values that are used to transform raw input events into view movments.- Specified by:
- getAttributesin interface- ViewInputHandler
- Returns:
- values that are be used to transform raw input into view movement.
 
 - 
setAttributespublic 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 interface- ViewInputHandler
- Parameters:
- attributes- values that will be used to transform raw input into view movement.
- Throws:
- java.lang.IllegalArgumentException- if- attributesis null.
- See Also:
- ViewInputAttributes
 
 - 
isEnableSmoothingpublic boolean isEnableSmoothing() Returns whether the ViewInputHandler will smooth view movements in response to input events.- Specified by:
- isEnableSmoothingin interface- ViewInputHandler
- Returns:
- true if the view will movements are smoothed; false otherwise.
 
 - 
setEnableSmoothingpublic 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 interface- ViewInputHandler
- Parameters:
- enable- true to smooth view movements; false otherwise.
 
 - 
isLockHeadingpublic boolean isLockHeading() Returns whether the view's heading should stay the same unless explicitly changed.- Specified by:
- isLockHeadingin interface- ViewInputHandler
- Returns:
- true if the view's heading will stay the same unless explicity changed; false otherwise.
 
 - 
setLockHeadingpublic 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 interface- ViewInputHandler
- Parameters:
- lock- true if the view's heading should stay the same unless explicity changed; false otherwise.
 
 - 
isStopOnFocusLostpublic boolean isStopOnFocusLost() Returns whether the view will stop when the WorldWindow looses focus.- Specified by:
- isStopOnFocusLostin interface- ViewInputHandler
- Returns:
- true if the view will stop when the WorldWindow looses focus; false otherwise.
 
 - 
setStopOnFocusLostpublic void setStopOnFocusLost(boolean stop) Sets whether the view should stop when the WorldWindow looses focus.- Specified by:
- setStopOnFocusLostin interface- ViewInputHandler
- Parameters:
- stop- true if the view should stop when the WorldWindow looses focus; false otherwise.
 
 - 
getDragSlopeFactorpublic 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 interface- ViewInputHandler
- Returns:
- factor dampening view movement when a mouse drag event would cause an abrupt transition.
- See Also:
- setDragSlopeFactor(double)
 
 - 
setDragSlopeFactorpublic 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 interface- ViewInputHandler
- 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- if- factoris less than zero.
 
 - 
getPerFrameInputIntervalprotected long getPerFrameInputInterval() 
 - 
setPerFrameInputIntervalprotected void setPerFrameInputInterval(long milliseconds) 
 - 
getViewprotected View getView() 
 - 
isWorldWindowFocusOwnerprotected boolean isWorldWindowFocusOwner() 
 - 
setWorldWindowFocusOwnerprotected void setWorldWindowFocusOwner(boolean focusOwner) 
 - 
getMousePointprotected java.awt.Point getMousePoint() 
 - 
getLastMousePointprotected java.awt.Point getLastMousePoint() 
 - 
updateMousePointprotected void updateMousePoint(java.awt.event.MouseEvent e) 
 - 
getSelectedPositionprotected Position getSelectedPosition() 
 - 
setSelectedPositionprotected void setSelectedPosition(Position position) 
 - 
computeSelectedPositionprotected Position computeSelectedPosition() 
 - 
onStopViewprotected void onStopView() 
 - 
keyTypedpublic void keyTyped(java.awt.event.KeyEvent e) - Specified by:
- keyTypedin interface- java.awt.event.KeyListener
 
 - 
keyPressedpublic void keyPressed(java.awt.event.KeyEvent e) - Specified by:
- keyPressedin interface- java.awt.event.KeyListener
 
 - 
keyReleasedpublic void keyReleased(java.awt.event.KeyEvent e) - Specified by:
- keyReleasedin interface- java.awt.event.KeyListener
 
 - 
handleKeyPressedprotected void handleKeyPressed(java.awt.event.KeyEvent e) 
 - 
handleKeyReleasedprotected void handleKeyReleased(java.awt.event.KeyEvent e) 
 - 
mouseClickedpublic void mouseClicked(java.awt.event.MouseEvent e) - Specified by:
- mouseClickedin interface- java.awt.event.MouseListener
 
 - 
mousePressedpublic void mousePressed(java.awt.event.MouseEvent e) - Specified by:
- mousePressedin interface- java.awt.event.MouseListener
 
 - 
mouseReleasedpublic void mouseReleased(java.awt.event.MouseEvent e) - Specified by:
- mouseReleasedin interface- java.awt.event.MouseListener
 
 - 
mouseEnteredpublic void mouseEntered(java.awt.event.MouseEvent e) - Specified by:
- mouseEnteredin interface- java.awt.event.MouseListener
 
 - 
mouseExitedpublic void mouseExited(java.awt.event.MouseEvent e) - Specified by:
- mouseExitedin interface- java.awt.event.MouseListener
 
 - 
handleMouseClickedprotected void handleMouseClicked(java.awt.event.MouseEvent e) 
 - 
handleMousePressedprotected void handleMousePressed(java.awt.event.MouseEvent e) 
 - 
handleMouseReleasedprotected void handleMouseReleased(java.awt.event.MouseEvent e) 
 - 
mouseDraggedpublic void mouseDragged(java.awt.event.MouseEvent e) - Specified by:
- mouseDraggedin interface- java.awt.event.MouseMotionListener
 
 - 
mouseMovedpublic void mouseMoved(java.awt.event.MouseEvent e) - Specified by:
- mouseMovedin interface- java.awt.event.MouseMotionListener
 
 - 
handleMouseDraggedprotected void handleMouseDragged(java.awt.event.MouseEvent e) 
 - 
handleMouseMovedprotected void handleMouseMoved(java.awt.event.MouseEvent e) 
 - 
mouseWheelMovedpublic void mouseWheelMoved(java.awt.event.MouseWheelEvent e) - Specified by:
- mouseWheelMovedin interface- java.awt.event.MouseWheelListener
 
 - 
handleMouseWheelMovedprotected void handleMouseWheelMoved(java.awt.event.MouseWheelEvent e) 
 - 
focusGainedpublic void focusGained(java.awt.event.FocusEvent e) - Specified by:
- focusGainedin interface- java.awt.event.FocusListener
 
 - 
focusLostpublic void focusLost(java.awt.event.FocusEvent e) - Specified by:
- focusLostin interface- java.awt.event.FocusListener
 
 - 
handleFocusGainedprotected void handleFocusGained(java.awt.event.FocusEvent e) 
 - 
handleFocusLostprotected void handleFocusLost(java.awt.event.FocusEvent e) 
 - 
applypublic 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 interface- ViewInputHandler
 
 - 
viewAppliedpublic void viewApplied() Description copied from interface:ViewInputHandlerCalled just after the view applies its state and computes its internal transforms.- Specified by:
- viewAppliedin interface- ViewInputHandler
 
 - 
handlePerFrameKeyStateprotected boolean handlePerFrameKeyState(KeyEventState keys, java.lang.String target) 
 - 
handlePerFrameMouseStateprotected boolean handlePerFrameMouseState(KeyEventState keys, java.lang.String target) 
 - 
handlePerFrameAnimationprotected boolean handlePerFrameAnimation(java.lang.String target) 
 - 
propertyChangepublic void propertyChange(java.beans.PropertyChangeEvent e) - Specified by:
- propertyChangein interface- java.beans.PropertyChangeListener
 
 - 
handlePropertyChangeprotected void handlePropertyChange(java.beans.PropertyChangeEvent e) 
 - 
rawInputToChangeInValueprotected double rawInputToChangeInValue(double rawInput, ViewInputAttributes.DeviceAttributes deviceAttributes, ViewInputAttributes.ActionAttributes actionAttributes, java.lang.String scaleFunc)
 - 
getScaledValueprotected double getScaledValue(double minValue, double maxValue, java.lang.String scaleFunc)
 - 
evaluateScaleFuncEyeAltitudeprotected double evaluateScaleFuncEyeAltitude() 
 - 
evaluateScaleFuncZoomprotected double evaluateScaleFuncZoom() 
 - 
getScaleValueElevationprotected double getScaleValueElevation(ViewInputAttributes.DeviceAttributes deviceAttributes, ViewInputAttributes.ActionAttributes actionAttributes) 
 - 
getScaleValueprotected double getScaleValue(double minValue, double maxValue, double value, double range, boolean isExp)
 - 
computeSelectedPointAtprotected Vec4 computeSelectedPointAt(java.awt.Point point) 
 - 
getChangeInLocationprotected LatLon getChangeInLocation(java.awt.Point point1, java.awt.Point point2, Vec4 vec1, Vec4 vec2) 
 - 
computeDragSlopepublic 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 interface- ViewInputHandler
- 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.
 
 - 
constrainToSourceBoundsprotected static java.awt.Point constrainToSourceBounds(java.awt.Point point, java.lang.Object source)
 - 
getMouseDownPointpublic java.awt.Point getMouseDownPoint() 
 - 
setMouseDownPointpublic void setMouseDownPoint(java.awt.Point mouseDownPoint) 
 - 
setMouseDownViewprotected void setMouseDownView(View mouseDownView) 
 
- 
 
-