Package gov.nasa.worldwind.awt
Interface ViewInputHandler
-
- All Superinterfaces:
java.util.EventListener,java.awt.event.FocusListener,java.awt.event.KeyListener,java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.awt.event.MouseWheelListener
- All Known Implementing Classes:
AbstractViewInputHandler,BasicViewInputHandler,FlyViewInputHandler,OrbitViewInputHandler
public interface ViewInputHandler extends java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.event.FocusListener
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddAnimator(Animator animator)Add anAnimatorto thisViewInputHandler.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.ViewInputAttributesgetAttributes()Returns the values that are used to transform raw input events into view movments.doublegetDragSlopeFactor()Returns thefactorthat dampens view movement when the user pans drags the cursor in a way that could cause an abrupt transition.WorldWindowgetWorldWindow()Return theWorldWindowthis ViewInputHandler is listening to for input events, and will modify in response to those eventsvoidgoTo(Position lookAtPos, double elevation)Animate to the specified position.booleanisAnimating()Determine if there are any animations active in theView.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.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.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.voidstopAnimators()Stops any animations that are active in thisViewvoidviewApplied()Called just after the view applies its state and computes its internal transforms.
-
-
-
Method Detail
-
getWorldWindow
WorldWindow getWorldWindow()
Return theWorldWindowthis ViewInputHandler is listening to for input events, and will modify in response to those events- Returns:
- the
WorldWindowthis ViewInputHandler is listening to, and will modify in response to events.
-
setWorldWindow
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.- Parameters:
newWorldWindow- theWorldWindowto listen on, and modify in response to events.
-
getAttributes
ViewInputAttributes getAttributes()
Returns the values that are used to transform raw input events into view movments.- Returns:
- values that are be used to transform raw input into view movement.
-
setAttributes
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.- Parameters:
attributes- values that will be used to transform raw input into view movement.- Throws:
java.lang.IllegalArgumentException- ifattributesis null.- See Also:
ViewInputAttributes
-
isEnableSmoothing
boolean isEnableSmoothing()
Returns whether the ViewInputHandler will smooth view movements in response to input events.- Returns:
- true if the view will movements are smoothed; false otherwise.
-
setEnableSmoothing
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.- Parameters:
enable- true to smooth view movements; false otherwise.
-
isLockHeading
boolean isLockHeading()
Returns whether the view's heading should stay the same unless explicitly changed.- Returns:
- true if the view's heading will stay the same unless explicity changed; false otherwise.
-
setLockHeading
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.- Parameters:
lock- true if the view's heading should stay the same unless explicity changed; false otherwise.
-
isStopOnFocusLost
boolean isStopOnFocusLost()
Returns whether the view will stop when the WorldWindow looses focus.- Returns:
- true if the view will stop when the WorldWindow looses focus; false otherwise.
-
setStopOnFocusLost
void setStopOnFocusLost(boolean stop)
Sets whether the view should stop when the WorldWindow looses focus.- Parameters:
stop- true if the view should stop when the WorldWindow looses focus; false otherwise.
-
getDragSlopeFactor
double getDragSlopeFactor()
Returns thefactorthat dampens view movement when the user pans drags the cursor in a way that could cause an abrupt transition.- Returns:
- factor dampening view movement when a mouse drag event would cause an abrupt transition.
- See Also:
setDragSlopeFactor(double)
-
setDragSlopeFactor
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.- 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.
-
computeDragSlope
double computeDragSlope(java.awt.Point point1, java.awt.Point point2, Vec4 vec1, Vec4 vec2)Compute 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.- 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.
-
goTo
void goTo(Position lookAtPos, double elevation)
Animate to the specified position. The implementation is expected to animate theViewto look at the given position from the given elevation.- Parameters:
lookAtPos- The position to animate the view to look at.elevation- The elevation to look at thepositionfrom.
-
stopAnimators
void stopAnimators()
Stops any animations that are active in thisView
-
isAnimating
boolean isAnimating()
Determine if there are any animations active in theView.- Returns:
- true if there are active animations, false otherwise.
-
addAnimator
void addAnimator(Animator animator)
Add anAnimatorto thisViewInputHandler. This method does not start theAnimator. Starting theAnimatoris the responsibility of the application. This method is here primarily for use by theView. Applications should callView.addAnimator(gov.nasa.worldwind.animation.Animator)to add an animtion to the view.- Parameters:
animator- theAnimatorto be added
-
apply
void apply()
Implementations are expected to apply any changes to theViewstate prior to the View setting the modelview matrix for rendering the current frame.
-
viewApplied
void viewApplied()
Called just after the view applies its state and computes its internal transforms.
-
-