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 void
addAnimator(Animator animator)
Add anAnimator
to thisViewInputHandler
.void
apply()
Implementations are expected to apply any changes to theView
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.ViewInputAttributes
getAttributes()
Returns the values that are used to transform raw input events into view movments.double
getDragSlopeFactor()
Returns thefactor
that dampens view movement when the user pans drags the cursor in a way that could cause an abrupt transition.WorldWindow
getWorldWindow()
Return theWorldWindow
this ViewInputHandler is listening to for input events, and will modify in response to those eventsvoid
goTo(Position lookAtPos, double elevation)
Animate to the specified position.boolean
isAnimating()
Determine if there are any animations active in theView
.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.void
setAttributes(ViewInputAttributes attributes)
Sets the values that will be used to transform raw input events into view movements.void
setDragSlopeFactor(double factor)
Sets thefactor
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
setStopOnFocusLost(boolean stop)
Sets whether the view should stop when the WorldWindow looses focus.void
setWorldWindow(WorldWindow newWorldWindow)
Sets theWorldWindow
this ViewInputHandler should listen to for input events, and should modify in response to those events.void
stopAnimators()
Stops any animations that are active in thisView
void
viewApplied()
Called just after the view applies its state and computes its internal transforms.
-
-
-
Method Detail
-
getWorldWindow
WorldWindow getWorldWindow()
Return theWorldWindow
this ViewInputHandler is listening to for input events, and will modify in response to those events- Returns:
- the
WorldWindow
this ViewInputHandler is listening to, and will modify in response to events.
-
setWorldWindow
void setWorldWindow(WorldWindow newWorldWindow)
Sets theWorldWindow
this ViewInputHandler should listen to for input events, and should modify in response to those events. If the parameternewWorldWindow
is null, then this ViewInputHandler will do nothing.- Parameters:
newWorldWindow
- theWorldWindow
to 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
- ifattributes
is 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 thefactor
that 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 thefactor
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. Thisfactor
is the amount of damping applied to the view movement in such cases. Settingfactor
to zero will disable this behavior, while settingfactor
to 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
- iffactor
is 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 theView
to 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 theposition
from.
-
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 anAnimator
to thisViewInputHandler
. This method does not start theAnimator
. Starting theAnimator
is 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
- theAnimator
to be added
-
apply
void apply()
Implementations are expected to apply any changes to theView
state 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.
-
-