# Class NavDecorations

java.lang.Object
uk.ac.starlink.ttools.plot2.geom.NavDecorations

public class NavDecorations extends Object
Utility class supplying visual feedback decorations for two-dimensional plot navigation.

Since:
  18 Feb 2014
Author:
  Mark Taylor

## Method Summary

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

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### createCenterDecoration

public static Decoration createCenterDecoration(Point p)
Returns a simple marker at a point.

Parameters:
  `p` - position
Returns:
  position marker centered at `p`

### createWheelDecoration

public static Decoration createWheelDecoration(Point p, double xfact, double yfact, boolean xuse, boolean yuse, 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(Point p, double xfact, double yfact, boolean xuse, boolean yuse, 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(Point p1, Point p2, boolean xuse, boolean yuse, 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(Icon icon, 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(Icon icon, boolean isY, Point p, 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(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 Graphics2D prepareGraphics(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`