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 an Animator to this ViewInputHandler.
      void apply()
      Implementations are expected to apply any changes to the View 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 the factor that dampens view movement when the user pans drags the cursor in a way that could cause an abrupt transition.
      WorldWindow getWorldWindow()
      Return the WorldWindow this ViewInputHandler is listening to for input events, and will modify in response to those events
      void goTo​(Position lookAtPos, double elevation)
      Animate to the specified position.
      boolean isAnimating()
      Determine if there are any animations active in the View.
      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 the factor 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 the WorldWindow 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 this View
      void viewApplied()
      Called just after the view applies its state and computes its internal transforms.
      • Methods inherited from interface java.awt.event.FocusListener

        focusGained, focusLost
      • Methods inherited from interface java.awt.event.KeyListener

        keyPressed, keyReleased, keyTyped
      • Methods inherited from interface java.awt.event.MouseListener

        mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased
      • Methods inherited from interface java.awt.event.MouseMotionListener

        mouseDragged, mouseMoved
      • Methods inherited from interface java.awt.event.MouseWheelListener

        mouseWheelMoved
    • Method Detail

      • getWorldWindow

        WorldWindow getWorldWindow()
        Return the WorldWindow 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 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.
        Parameters:
        newWorldWindow - the WorldWindow 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 - if attributes 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 its ViewInputAttributes. 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 the factor 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 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.
        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.
      • 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 the View 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 the position from.
      • stopAnimators

        void stopAnimators()
        Stops any animations that are active in this View
      • isAnimating

        boolean isAnimating()
        Determine if there are any animations active in the View.
        Returns:
        true if there are active animations, false otherwise.
      • apply

        void apply()
        Implementations are expected to apply any changes to the View 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.