Class NavDecorations


  • public class NavDecorations
    extends java.lang.Object
    Utility class supplying visual feedback decorations for two-dimensional plot navigation.
    Since:
    18 Feb 2014
    Author:
    Mark Taylor
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Decoration center​(javax.swing.Icon icon, java.awt.Point p)
      Utility function to center a symmetric icon at a point.
      static Decoration center1d​(javax.swing.Icon icon, boolean isY, java.awt.Point p, java.awt.Rectangle bounds)
      Utility function to center one of the 1-dimensional zoom icons about a given point on its axis.
      static BandDecoration createBandDecoration​(java.awt.Point p1, java.awt.Point p2, boolean xuse, boolean yuse, java.awt.Rectangle bounds)
      Returns a decoration appropriate for a 2d frame zoom.
      static Decoration createCenterDecoration​(java.awt.Point p)
      Returns a simple marker at a point.
      static Decoration createDragDecoration​(java.awt.Point p, double xfact, double yfact, boolean xuse, boolean yuse, java.awt.Rectangle bounds)
      Returns a decoration appropriate for a 2d drag zoom.
      static Decoration createWheelDecoration​(java.awt.Point p, double xfact, double yfact, boolean xuse, boolean yuse, java.awt.Rectangle bounds)
      Returns a decoration appropriate for a 2d wheel zoom.
      static void drawArrow​(java.awt.Graphics g, int x0, int y0, int x1, int y1)
      Draws a line with an arrow head at one end.
      static java.awt.Graphics2D prepareGraphics​(java.awt.Graphics g)
      Sets graphics context ready for navigation decorations.
      • Methods inherited from class java.lang.Object

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

      • createCenterDecoration

        public static Decoration createCenterDecoration​(java.awt.Point p)
        Returns a simple marker at a point.
        Parameters:
        p - position
        Returns:
        position marker centered at p
      • createWheelDecoration

        public static Decoration createWheelDecoration​(java.awt.Point p,
                                                       double xfact,
                                                       double yfact,
                                                       boolean xuse,
                                                       boolean yuse,
                                                       java.awt.Rectangle bounds)
        Returns a decoration appropriate for a 2d wheel zoom.
        Parameters:
        p - reference point
        xfact - X direction zoom factor
        yfact - Y direction zoom factor
        xuse - true if X zoom is in effect
        yuse - true if Y zoom is in effect
        bounds - plot region bounds
        Returns:
        marker centered at p
      • createDragDecoration

        public static Decoration createDragDecoration​(java.awt.Point p,
                                                      double xfact,
                                                      double yfact,
                                                      boolean xuse,
                                                      boolean yuse,
                                                      java.awt.Rectangle bounds)
        Returns a decoration appropriate for a 2d drag zoom.
        Parameters:
        p - reference point
        xfact - X direction zoom factor
        yfact - Y direction zoom factor
        xuse - true if X zoom is in effect
        yuse - true if Y zoom is in effect
        bounds - plot region bounds
        Returns:
        marker centered at p
      • createBandDecoration

        public static BandDecoration createBandDecoration​(java.awt.Point p1,
                                                          java.awt.Point p2,
                                                          boolean xuse,
                                                          boolean yuse,
                                                          java.awt.Rectangle bounds)
        Returns a decoration appropriate for a 2d frame zoom. The returned object has a target rectangle associated with it, which makes sense for this kind of decoration.
        Parameters:
        p1 - drag start point
        p2 - drag (current) end point
        xuse - true if X zoom is in effect
        yuse - true if Y zoom is in effect
        bounds - plot region bounds
        Returns:
        frame decoration with target rectangle
      • center

        public static Decoration center​(javax.swing.Icon icon,
                                        java.awt.Point p)
        Utility function to center a symmetric icon at a point. The icon must correctly report its dimensions for this to work.
        Parameters:
        icon - icon
        p - central point
        Returns:
        centered decoration
      • center1d

        public static Decoration center1d​(javax.swing.Icon icon,
                                          boolean isY,
                                          java.awt.Point p,
                                          java.awt.Rectangle bounds)
        Utility function to center one of the 1-dimensional zoom icons about a given point on its axis. The icon must correctly report its dimensions for this to work.
        Parameters:
        icon - icon
        isY - false for X axis annotation, true for Y axis annotation
        p - reference point
        bounds - plot bounds
        Returns:
        centered decoration
      • drawArrow

        public static void drawArrow​(java.awt.Graphics g,
                                     int x0,
                                     int y0,
                                     int x1,
                                     int y1)
        Draws a line with an arrow head at one end.
        Parameters:
        g - graphics context
        x0 - start X coordinate
        y0 - start Y coordinate
        x1 - end (arrow) X coordinate
        y1 - end (arrow) Y coordinate
      • prepareGraphics

        public static java.awt.Graphics2D prepareGraphics​(java.awt.Graphics g)
        Sets graphics context ready for navigation decorations. The colour is modified as appropriate. The result is a new graphics context, which does not need to be reset (and should be disposed) when the caller is finished with it.
        Parameters:
        g - supplied graphics context
        Returns:
        new, adjusted graphics context based on g