Class PlaneNavigator

  • All Implemented Interfaces:
    Navigator<PlaneAspect>

    public class PlaneNavigator
    extends java.lang.Object
    implements Navigator<PlaneAspect>
    Navigator for use with plane plot.
    Since:
    4 Oct 2013
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      PlaneNavigator​(double zoomFactor, boolean xZoom, boolean yZoom, boolean xPan, boolean yPan, double xAnchor, double yAnchor)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      NavAction<PlaneAspect> click​(Surface surface, java.awt.Point pos, int ibutt, java.lang.Iterable<double[]> dposIt)
      Mouse click gesture.
      NavAction<PlaneAspect> drag​(Surface surface, java.awt.Point point, int ibutt, java.awt.Point origin)
      Drag gesture.
      NavAction<PlaneAspect> endDrag​(Surface surface, java.awt.Point pos, int ibutt, java.awt.Point origin)
      Terminating drag gesture.
      static boolean[] getAxisNavFlags​(Surface surface, java.awt.Point pos, boolean xFlag, boolean yFlag)
      Determines which axes navigation should be performed on.
      java.util.Map<Gesture,​java.lang.String> getNavOptions​(Surface surface, java.awt.Point pos)
      Returns a description of the available navigation gestures and the behaviour they cause when the mouse is positioned at a particular point.
      NavAction<PlaneAspect> wheel​(Surface surface, java.awt.Point pos, int wheelrot)
      Mouse wheel gesture.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PlaneNavigator

        public PlaneNavigator​(double zoomFactor,
                              boolean xZoom,
                              boolean yZoom,
                              boolean xPan,
                              boolean yPan,
                              double xAnchor,
                              double yAnchor)
        Constructor.
        Parameters:
        zoomFactor - amount of zoom for one mouse wheel click
        xZoom - true iff wheel operation will zoom in X direction
        yZoom - true iff wheel operation will zoom in Y direction
        xPan - true iff drag operation will pan in X direction
        yPan - true iff drag operation will pan in Y direction
        xAnchor - data value to pin X coordinate at during zooms; NaN for no anchor
        yAnchor - data value to pin Y coordinate at during zooms; NaN for no anchor
    • Method Detail

      • drag

        public NavAction<PlaneAspect> drag​(Surface surface,
                                           java.awt.Point point,
                                           int ibutt,
                                           java.awt.Point origin)
        Description copied from interface: Navigator
        Drag gesture.

        Drag gestures typically indicate panning, and in this case should preferably have the outcome that the same data position remains under the cursor before and after the pan (from origin to evt.getPoint()).

        Specified by:
        drag in interface Navigator<PlaneAspect>
        Parameters:
        surface - initial plot surface
        point - current mouse position
        ibutt - logical mouse button index of drag
        origin - starting point of the drag gesture
        Returns:
        navigation action indicated by the gesture, or null for no change
      • endDrag

        public NavAction<PlaneAspect> endDrag​(Surface surface,
                                              java.awt.Point pos,
                                              int ibutt,
                                              java.awt.Point origin)
        Description copied from interface: Navigator
        Terminating drag gesture. This method is invoked following a sequence of drags when the mouse button has been released.
        Specified by:
        endDrag in interface Navigator<PlaneAspect>
        Parameters:
        surface - initial plot surface
        pos - current mouse position
        ibutt - logical mouse button index of terminated drag
        origin - starting point of drag gesture
        Returns:
        navigation action indicated by the gesture, or null for no change
      • wheel

        public NavAction<PlaneAspect> wheel​(Surface surface,
                                            java.awt.Point pos,
                                            int wheelrot)
        Description copied from interface: Navigator
        Mouse wheel gesture.

        Wheel gestures usually indicate zooming, and in this case should preferably have the outcome that the same data position remains at the mouse position before and after the zoom.

        Specified by:
        wheel in interface Navigator<PlaneAspect>
        Parameters:
        surface - initial plot surface
        pos - current mouse position
        wheelrot - number of wheel rotation clicks
        Returns:
        navigation action indicated by the gesture, or null for no change
      • click

        public NavAction<PlaneAspect> click​(Surface surface,
                                            java.awt.Point pos,
                                            int ibutt,
                                            java.lang.Iterable<double[]> dposIt)
        Description copied from interface: Navigator
        Mouse click gesture.

        Note that other elements of the plotting system may intercept some mouse clicks for other purposes, so the navigator may not receive all clicks. For instance the topcat plot window currently intercepts button-1 clicks and interprets them as row selection requests. Typically this navigator method may only get invoked for modified or non-button-1 clicks.

        Implementation of this gesture may require identifying a data position from a screen position, which is not always trivial, for instance in a 3D plot one graphics position maps to a line of data positions. The dposIt argument can optionally be supplied to cope with such instances. If a data pos cannot be determined, null is returned. If dposIt is absent, the method will run quickly. If it's present, the method may or may not run slowly by iterating over the data points.

        Specified by:
        click in interface Navigator<PlaneAspect>
        Parameters:
        surface - initial plot surface
        pos - current mouse position
        ibutt - logical mouse button index
        dposIt - iterable over dataDimCount-element arrays representing all the data space positions plotted, or null
        Returns:
        navigation action indicated by the gesture, or null for no change
      • getNavOptions

        public java.util.Map<Gesture,​java.lang.String> getNavOptions​(Surface surface,
                                                                           java.awt.Point pos)
        Description copied from interface: Navigator
        Returns a description of the available navigation gestures and the behaviour they cause when the mouse is positioned at a particular point. The order of the returned list may be reflected in their presentation to users, so it is generally a good idea to use a LinkedHashMap.
        Specified by:
        getNavOptions in interface Navigator<PlaneAspect>
        Parameters:
        surface - plot surface
        pos - mouse position
        Returns:
        mapping of available gestures to short textual descriptions of their behaviour
      • getAxisNavFlags

        public static boolean[] getAxisNavFlags​(Surface surface,
                                                java.awt.Point pos,
                                                boolean xFlag,
                                                boolean yFlag)
        Determines which axes navigation should be performed on. Navigation may be active by default on zero or more axes, and if the position is within the plot bounds these defaults are used. However, if the position is outside the plot bounds and alongside one of the axes, this overrides any default.
        Parameters:
        surface - plotting surface
        pos - context position for mouse
        xFlag - whether navigation on X axis is active by default
        yFlag - whether navigation on Y axis is active by default
        Returns:
        2-element flag array; whether navigation should be performed on (X,Y) axis