Class 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 Detail

      • 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
      • 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
      • 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
    • Constructor Detail

      • AbstractViewInputHandler

        public AbstractViewInputHandler()
    • Method Detail

      • getWorldWindow

        public WorldWindow getWorldWindow()
        Return the WorldWindow this ViewInputHandler is listening to for input events, and will modify in response to those events
        Specified by:
        getWorldWindow in interface ViewInputHandler
        Returns:
        the WorldWindow this ViewInputHandler is listening to, and will modify in response to events.
      • setWorldWindow

        public void setWorldWindow​(WorldWindow newWorldWindow)
        Sets the 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.
        Specified by:
        setWorldWindow in interface ViewInputHandler
        Parameters:
        newWorldWindow - the WorldWindow to 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:
        getAttributes in interface ViewInputHandler
        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:
        setAttributes in interface ViewInputHandler
        Parameters:
        attributes - values that will be used to transform raw input into view movement.
        Throws:
        java.lang.IllegalArgumentException - if attributes is null.
        See Also:
        ViewInputAttributes
      • isEnableSmoothing

        public boolean isEnableSmoothing()
        Returns whether the ViewInputHandler will smooth view movements in response to input events.
        Specified by:
        isEnableSmoothing in interface ViewInputHandler
        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 its ViewInputAttributes. A value of false will disable all smoothing.
        Specified by:
        setEnableSmoothing in interface ViewInputHandler
        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:
        isLockHeading in interface ViewInputHandler
        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:
        setLockHeading in interface ViewInputHandler
        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:
        isStopOnFocusLost in interface ViewInputHandler
        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:
        setStopOnFocusLost in interface ViewInputHandler
        Parameters:
        stop - true if the view should stop when the WorldWindow looses focus; false otherwise.
      • getDragSlopeFactor

        public 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.
        Specified by:
        getDragSlopeFactor in interface ViewInputHandler
        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 the 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.
        Specified by:
        setDragSlopeFactor in 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 factor is 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:
        keyTyped in interface java.awt.event.KeyListener
      • keyPressed

        public void keyPressed​(java.awt.event.KeyEvent e)
        Specified by:
        keyPressed in interface java.awt.event.KeyListener
      • keyReleased

        public void keyReleased​(java.awt.event.KeyEvent e)
        Specified by:
        keyReleased in interface java.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:
        mouseClicked in interface java.awt.event.MouseListener
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent e)
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent e)
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent e)
        Specified by:
        mouseExited in interface java.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:
        mouseDragged in interface java.awt.event.MouseMotionListener
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent e)
        Specified by:
        mouseMoved in interface java.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:
        mouseWheelMoved in interface java.awt.event.MouseWheelListener
      • handleMouseWheelMoved

        protected void handleMouseWheelMoved​(java.awt.event.MouseWheelEvent e)
      • focusGained

        public void focusGained​(java.awt.event.FocusEvent e)
        Specified by:
        focusGained in interface java.awt.event.FocusListener
      • focusLost

        public void focusLost​(java.awt.event.FocusEvent e)
        Specified by:
        focusLost in interface java.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: ViewInputHandler
        Implementations are expected to apply any changes to the View state prior to the View setting the modelview matrix for rendering the current frame.
        Specified by:
        apply in interface ViewInputHandler
      • viewApplied

        public void viewApplied()
        Description copied from interface: ViewInputHandler
        Called just after the view applies its state and computes its internal transforms.
        Specified by:
        viewApplied in interface ViewInputHandler
      • 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:
        propertyChange in interface java.beans.PropertyChangeListener
      • handlePropertyChange

        protected void handlePropertyChange​(java.beans.PropertyChangeEvent e)
      • getScaledValue

        protected double getScaledValue​(double minValue,
                                        double maxValue,
                                        java.lang.String scaleFunc)
      • evaluateScaleFuncEyeAltitude

        protected double evaluateScaleFuncEyeAltitude()
      • evaluateScaleFuncZoom

        protected double evaluateScaleFuncZoom()
      • 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: ViewInputHandler
        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.
        Specified by:
        computeDragSlope in 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.
      • 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)