edu.neu.ccs.gui
Class PlotTool

java.lang.Object
  |
  +--edu.neu.ccs.gui.PlotTool
All Implemented Interfaces:
Cloneable, Serializable

public class PlotTool
extends Object
implements Cloneable, Serializable

Encapsulates the transform between world and image coordinates for use in plotting data graphs. Provides functions to plot or mark an array of Point2D data or an array of such Point2D arrays. Automatically handles the painting of axes, grid lines, and tick marks on the axes.

The "world" coordinate space refers to the coordinate space inhabited by the data arrays or functions that are to be plotted. The "image" coordinate space refers to the coordinate space of the graphics context on which the plots are painted.

Since:
1.0
See Also:
Serialized Form

Field Summary
protected  Rectangle2D.Double imageBounds
          Bounding rectangle of the image coordinate space.
protected  XInterval imageXRange
          The x-interval in image coordinates.
protected  XInterval imageYRange
          The y-interval in image coordinates.
protected  int inset
          Number of pixels in image coordinate units to inset the transform of the world coordinates.
protected  AffineTransform inverseMapping
          The inverse of the world to image transform.
protected  Transform1D inverseXMapping
          The inverse of the x-component of the world to image transform.
protected  Transform1D inverseYMapping
          The inverse of the y-component of the world to image transform.
protected  Line2D.Double L
          Helper for line computation.
protected  AffineTransform mapping
          The world to image transform.
protected  Point2D.Double P
          Helper for point computation.
protected  boolean preservesShape
          Whether or not to preserve geometric shape.
protected  Point2D.Double Q
          Helper for point computation.
protected  Point2D.Double scale
          The absolute value of the x and y scale factors.
protected  Rectangle2D.Double worldBounds
          Bounding rectangle of the world coordinate space.
protected  XInterval worldXRange
          The x-interval in world coordinates.
protected  XInterval worldYRange
          The y-interval in world coordinates.
protected  Transform1D xMapping
          The x-component of the world to image transform.
protected  Transform1D yMapping
          The y-component of the world to image transform.
 
Constructor Summary
PlotTool()
          Constructs a plot tool with the default parameters.
PlotTool(Rectangle2D w, Rectangle2D i)
          Constructs a plot tool for use with the given world and image coordinate spaces.
PlotTool(Rectangle2D w, Rectangle2D i, boolean eq)
          Constructs a plot tool for use with the given world and image coordinate spaces, with the given policy regarding the preservation of geometric shape.
PlotTool(Rectangle2D w, Rectangle2D i, boolean eq, int in)
          Constructs a plot tool for use with the given world and image coordinate spaces, with the given policy regarding the preservation of geometric shape, and the given image inset.
 
Method Summary
 PlotTool autoAxes(Graphics2D g)
          Plots black axes of thickness 3 in given graphics context.
 PlotTool autoGridLines(Graphics2D g)
          Plots grid lines appropriate for the world to image transform in the given graphics context, using the default thickness and the default color for grid lines.
 Point2D autoSpacing(int minPixel)
          Returns a Point2D object encapsulating an appropriate spacing for grid lines and tick marks in world coordinates.
 PlotTool autoTickMarks(Graphics2D g)
          Plots tick marks appropriate for the world to image transform in the given graphics context, using the default thickness and the default color for tick marks.
static double findSpacing(double minimumDelta)
          Returns the smallest double that has one of the three forms 10k, 2*10k, or 5*10k, and is greater than or equal to the absolute value of the given minimum.
 Rectangle2D getImageBounds()
          Returns a clone of the image coordinate bounds.
 int getInset()
          Return the image inset.
 AffineTransform getInverseTransform()
          Returns a clone of the inverse of the world bounds to image bounds two-dimensional transform.
 Transform1D getInverseXTransform()
          Returns a clone of the inverse of the x component of the world to image transform.
 Transform1D getInverseYTransform()
          Returns a clone of the inverse of the y component of the world to image transform.
 AffineTransform getTransform()
          Returns a clone of the world bounds to image bounds two-dimensional transform.
 Rectangle2D getWorldBounds()
          Returns a clone of the world coordinate bounds.
 Transform1D getXTransform()
          Returns a clone of the x component of the world to image transform.
 Transform1D getYTransform()
          Return a clone of the y component of the world to image transform.
 Point2D inverseScale(Point2D source)
          Returns the point produced by transforming the given point using the inverse of the world to image transform.
 Point2D inverseScale(Point2D source, Point2D target)
          Scales the given source Point2D using the inverse of the world to image transform and sets the target Point2D to the transformed value.
 double inverseXScale(double x)
          Returns the result of scaling the given value using the x component of the inverse of the world to image transform.
 double inverseYScale(double y)
          Returns the result of scaling the given value using the y component of the inverse of the world to image transform.
static Rectangle2D makeBoundsRectangle2D(Point2D[] data)
          Return the smallest rectangle containing the data in the given Point2D array and return null if no data is supplied.
static Rectangle2D makeBoundsRectangle2D(Point2D[][] data)
          Return the smallest rectangle containing the data in the given array of Point2D arrays and return null if no data is supplied.
 void markData(Graphics2D g, Point2D[][] data, Paint[] color, PlotMark plotmark)
          Transforms the points of the given array of arrays using the world to image transform and marks the resulting points in the given graphics context using the given Paint array to paint the marks for the corresponding sub array of the data.
 void markData(Graphics2D g, Point2D[][] data, Paint[] color, PlotMark[] plotmarks)
          Transforms the points of the given array of arrays using the world to image transform and marks the resulting points in the given graphics context using the given Paint array and the given plot mark array to paint the marks for the corresponding sub array of the data.
 void markData(Graphics2D g, Point2D[][] data, Paint color, PlotMark plotmark)
          Transforms the points of the given array of arrays using the world to image transform and marks the resulting points in the given graphics context using the given color or Paint to paint the marks.
 void markData(Graphics2D g, Point2D[] data, Paint color, PlotMark plotmark)
          Transforms the points of the given array using the world to image transform and marks the resulting points in the given graphics context using the given color or Paint to paint the marks.
 PlotTool plotAxes(Graphics2D g, Paint color, int thick)
          Plots axes in the given graphics context using the given color or Paint and the given line thickness.
 void plotData(Graphics2D g, Point2D[][] data, Paint color)
          Transforms the points of the given array of arrays using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint to draw the lines.
 void plotData(Graphics2D g, Point2D[][] data, Paint[] color)
          Transforms the points of the given array of arrays using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint to draw the lines.
 void plotData(Graphics2D g, Point2D[][] data, Paint[] color, Stroke s)
          Transforms the points of the given array of arrays using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint and the given Stroke to draw the lines.
 void plotData(Graphics2D g, Point2D[][] data, Paint color, Stroke s)
          Transforms the points of the given array of arrays using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint and the given Stroke to draw the lines.
 void plotData(Graphics2D g, Point2D[] data, Paint color)
          Transforms the points of the given array using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint to draw the lines.
 void plotData(Graphics2D g, Point2D[] data, Paint color, Stroke s)
          Transforms the points of the given array using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint and the given Stroke to draw the lines.
 PlotTool plotGridLines(Graphics2D g, Paint color, Point2D delta)
          Plots vertical and horizontal grid lines of thickness 1 using the given color or Paint and the given grid spacing values encapsulated as a Point2D object.
 void plotHGridLine(Graphics2D g, double yPosition)
          Plots a horizontal grid line corresponding to the given y position in world coordinates, in the given graphics context.
 PlotTool plotHGridLines(Graphics2D g, Paint color, double delta)
          Plots a sequence of horizontal grid lines of thickness 1 using the given color or Paint and the given y grid spacing value.
 void plotHTickMark(Graphics2D g, double yPosition, int ticksize)
          Plots a horizontal tick line corresponding to the given y position in world coordinates, in the given graphics context using the given tick size.
 PlotTool plotHTickMarks(Graphics2D g, Paint color, double delta, int ticksize)
          Plots a sequence of horizontal tick marks of thickness 1 using the given color or Paint, y grid spacing value, and tick mark length.
 PlotTool plotTickMarks(Graphics2D g, Paint color, Point2D delta, int ticksize)
          Plots vertical and horizontal tick marks of thickness 1 using the given color or Paint, grid spacing values encapsulated as a Point2D object, and tick mark length.
 void plotVGridLine(Graphics2D g, double xPosition)
          Plots a vertical grid line corresponding to the given x position in world coordinates, in the given graphics context.
 PlotTool plotVGridLines(Graphics2D g, Paint color, double delta)
          Plots a sequence of vertical grid lines of thickness 1 using the given color or Paint and the given x grid spacing value.
 void plotVTickMark(Graphics2D g, double xPosition, int ticksize)
          Plots a vertical tick line corresponding to the given x position in world coordinates, in the given graphics context using the given tick size.
 PlotTool plotVTickMarks(Graphics2D g, Paint color, double delta, int ticksize)
          Plots a sequence of vertical tick marks of thickness 1 using the given color or Paint, x grid spacing value, and tick mark length.
 boolean preservesShape()
          Returns whether or not this tool preserves geometric shape.
 Point2D scale(Point2D source)
          Returns the point produced by transforming the given point using the world to image transform.
 Point2D scale(Point2D source, Point2D target)
          Scales the given source Point2D using the world to image transform and sets the target Point2D to the transformed value.
 PlotTool setImageBounds(Rectangle2D i)
          Sets the image coordinate bounds to the given bounds.
 PlotTool setInset(int in)
          Sets the image inset to the given value in image pixel units.
 PlotTool setPlotTool(PlotTool other)
          Sets the world coordinate space, the image coordinate space, the shape preservation policy and the image inset for this plot tool to the respective values for the given plot tool.
 PlotTool setPlotTool(Rectangle2D w, Rectangle2D i, boolean eq, int in)
          Sets the world coordinate space, the image coordinate space, the shape preservation policy and the image inset for this plot tool to the given values.
 PlotTool setPreservesShape(boolean eq)
          Sets the geometric shape preservation policy to the given value.
protected  PlotTool setTransforms()
          Creates an affine transform suitable for transforming points in the world coordinate space to points in the image coordinate space, either by best fit or by preserving the shape of the geometry.
 PlotTool setWorldBounds(Point2D[] data)
          Set the world coordinate bounds to the smallest rectangle that contains the Point2D array data.
 PlotTool setWorldBounds(Point2D[][] data)
          Set the world coordinate bounds to the smallest rectangle that contains the Point2D array of array data.
 PlotTool setWorldBounds(Rectangle2D w)
          Sets the world coordinate bounds to the given bounds.
 void storeImageBounds(Rectangle2D i)
          Stores the given image coordinate bounds.
protected  void storeInset(int in)
          Stores the given inset value.
protected  void storePreservesShape(boolean ps)
          Stores the given shape preservation policy.
protected  void storeWorldBounds(Rectangle2D w)
          Stores the given world coordinate bounds.
 int xMaxIndex(double delta)
          Returns the maximum index for vertical grid or tick lines given the spacing along the x axis in world coordinates.
 int xMinIndex(double delta)
          Returns the minimum index for vertical grid or tick lines given the spacing along the x axis in world coordinates.
 double xScale(double x)
          Returns the result of scaling the given value using the x component of the world to image transform.
 int yMaxIndex(double delta)
          Returns the maximum index for horizontal grid or tick lines given the spacing along the y axis in world coordinates.
 int yMinIndex(double delta)
          Returns the minimum index for horizontal grid or tick lines given the spacing along the y axis in world coordinates.
 double yScale(double y)
          Returns the result of scaling the given value using the y component of the world to image transform.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

worldBounds

protected Rectangle2D.Double worldBounds
Bounding rectangle of the world coordinate space.


imageBounds

protected Rectangle2D.Double imageBounds
Bounding rectangle of the image coordinate space.


preservesShape

protected boolean preservesShape
Whether or not to preserve geometric shape.


inset

protected int inset
Number of pixels in image coordinate units to inset the transform of the world coordinates.


mapping

protected AffineTransform mapping
The world to image transform.


xMapping

protected Transform1D xMapping
The x-component of the world to image transform.


yMapping

protected Transform1D yMapping
The y-component of the world to image transform.


inverseMapping

protected AffineTransform inverseMapping
The inverse of the world to image transform.


inverseXMapping

protected Transform1D inverseXMapping
The inverse of the x-component of the world to image transform.


inverseYMapping

protected Transform1D inverseYMapping
The inverse of the y-component of the world to image transform.


worldXRange

protected XInterval worldXRange
The x-interval in world coordinates.


worldYRange

protected XInterval worldYRange
The y-interval in world coordinates.


imageXRange

protected XInterval imageXRange
The x-interval in image coordinates.


imageYRange

protected XInterval imageYRange
The y-interval in image coordinates.


scale

protected Point2D.Double scale
The absolute value of the x and y scale factors.


P

protected transient Point2D.Double P
Helper for point computation.


Q

protected transient Point2D.Double Q
Helper for point computation.


L

protected transient Line2D.Double L
Helper for line computation.

Constructor Detail

PlotTool

public PlotTool()
Constructs a plot tool with the default parameters.


PlotTool

public PlotTool(Rectangle2D w,
                Rectangle2D i)
Constructs a plot tool for use with the given world and image coordinate spaces.

Parameters:
w - the desired world coordinate bounds
i - the desired image coordinate bounds

PlotTool

public PlotTool(Rectangle2D w,
                Rectangle2D i,
                boolean eq)
Constructs a plot tool for use with the given world and image coordinate spaces, with the given policy regarding the preservation of geometric shape.

Parameters:
w - the desired world coordinate bounds
i - the desired image coordinate bounds
eq - whether or not the transform preserves geometric shape

PlotTool

public PlotTool(Rectangle2D w,
                Rectangle2D i,
                boolean eq,
                int in)
Constructs a plot tool for use with the given world and image coordinate spaces, with the given policy regarding the preservation of geometric shape, and the given image inset.

Parameters:
w - the desired world coordinate bounds
i - the desired image coordinate bounds
eq - whether or not the transform preserves geometric shape
in - the desired inset in image pixel units
Method Detail

setPlotTool

public PlotTool setPlotTool(PlotTool other)
Sets the world coordinate space, the image coordinate space, the shape preservation policy and the image inset for this plot tool to the respective values for the given plot tool.

Parameters:
other - the object to be copied
Returns:
a reference to this plot tool

setPlotTool

public PlotTool setPlotTool(Rectangle2D w,
                            Rectangle2D i,
                            boolean eq,
                            int in)
Sets the world coordinate space, the image coordinate space, the shape preservation policy and the image inset for this plot tool to the given values.

Parameters:
w - the desired world coordinate bounds
i - the desired image coordinate bounds
eq - whether or not the transform preserves geometric shape
in - the desired inset in image pixel units
Returns:
a reference to this plot tool

setWorldBounds

public PlotTool setWorldBounds(Rectangle2D w)
Sets the world coordinate bounds to the given bounds.

Parameters:
w - the new world coordinate bounds
Returns:
a reference to this plot tool

getWorldBounds

public Rectangle2D getWorldBounds()
Returns a clone of the world coordinate bounds.


setWorldBounds

public PlotTool setWorldBounds(Point2D[] data)
Set the world coordinate bounds to the smallest rectangle that contains the Point2D array data.

Parameters:
data - the array data to enclose in the bounds
Returns:
a reference to this plot tool

setWorldBounds

public PlotTool setWorldBounds(Point2D[][] data)
Set the world coordinate bounds to the smallest rectangle that contains the Point2D array of array data.

Parameters:
data - the array of array data to enclose in the bounds
Returns:
a reference to this plot tool

makeBoundsRectangle2D

public static Rectangle2D makeBoundsRectangle2D(Point2D[] data)
Return the smallest rectangle containing the data in the given Point2D array and return null if no data is supplied.

Parameters:
data - the Point2D array

makeBoundsRectangle2D

public static Rectangle2D makeBoundsRectangle2D(Point2D[][] data)
Return the smallest rectangle containing the data in the given array of Point2D arrays and return null if no data is supplied.

Parameters:
data - the Point2D array

setImageBounds

public PlotTool setImageBounds(Rectangle2D i)
Sets the image coordinate bounds to the given bounds.

Parameters:
i - the new image coordinate bounds
Returns:
a reference to this plot tool

getImageBounds

public Rectangle2D getImageBounds()
Returns a clone of the image coordinate bounds.


setPreservesShape

public PlotTool setPreservesShape(boolean eq)
Sets the geometric shape preservation policy to the given value.

Parameters:
eq - whether or not this tool preserves geometric shape
Returns:
a reference to this plot tool

preservesShape

public boolean preservesShape()
Returns whether or not this tool preserves geometric shape.


setInset

public PlotTool setInset(int in)
Sets the image inset to the given value in image pixel units.

Parameters:
in - the new image inset in image pixel units
Returns:
a reference to this plot tool

getInset

public int getInset()
Return the image inset.


getTransform

public AffineTransform getTransform()
Returns a clone of the world bounds to image bounds two-dimensional transform.


getXTransform

public Transform1D getXTransform()
Returns a clone of the x component of the world to image transform.


getYTransform

public Transform1D getYTransform()
Return a clone of the y component of the world to image transform.


getInverseTransform

public AffineTransform getInverseTransform()
Returns a clone of the inverse of the world bounds to image bounds two-dimensional transform.


getInverseXTransform

public Transform1D getInverseXTransform()
Returns a clone of the inverse of the x component of the world to image transform.


getInverseYTransform

public Transform1D getInverseYTransform()
Returns a clone of the inverse of the y component of the world to image transform.


scale

public Point2D scale(Point2D source,
                     Point2D target)
Scales the given source Point2D using the world to image transform and sets the target Point2D to the transformed value. This method signature follows the conventions for similar methods in the AffineTransform class.

Parameters:
source - the point to transform
target - the point to store transformed point or null if a new point should be created
Returns:
the given target point, transformed, or a new transformed point if the given target point was null

scale

public Point2D scale(Point2D source)
Returns the point produced by transforming the given point using the world to image transform.

Parameters:
source - the point to transform

xScale

public double xScale(double x)
Returns the result of scaling the given value using the x component of the world to image transform.


yScale

public double yScale(double y)
Returns the result of scaling the given value using the y component of the world to image transform.


inverseScale

public Point2D inverseScale(Point2D source,
                            Point2D target)
Scales the given source Point2D using the inverse of the world to image transform and sets the target Point2D to the transformed value. This method signature follows the conventions for similar methods in the AffineTransform class.

Parameters:
source - the point to transform
target - the point to store transformed point or null if a new point should be created
Returns:
the given target point, transformed, or a new transformed point if the given target point was null

inverseScale

public Point2D inverseScale(Point2D source)
Returns the point produced by transforming the given point using the inverse of the world to image transform.

Parameters:
source - the point to transform

inverseXScale

public double inverseXScale(double x)
Returns the result of scaling the given value using the x component of the inverse of the world to image transform.


inverseYScale

public double inverseYScale(double y)
Returns the result of scaling the given value using the y component of the inverse of the world to image transform.


plotData

public void plotData(Graphics2D g,
                     Point2D[] data,
                     Paint color)
Transforms the points of the given array using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint to draw the lines.


plotData

public void plotData(Graphics2D g,
                     Point2D[] data,
                     Paint color,
                     Stroke s)
Transforms the points of the given array using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint and the given Stroke to draw the lines.


plotData

public void plotData(Graphics2D g,
                     Point2D[][] data,
                     Paint color)
Transforms the points of the given array of arrays using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint to draw the lines.


plotData

public void plotData(Graphics2D g,
                     Point2D[][] data,
                     Paint color,
                     Stroke s)
Transforms the points of the given array of arrays using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint and the given Stroke to draw the lines.


plotData

public void plotData(Graphics2D g,
                     Point2D[][] data,
                     Paint[] color)
Transforms the points of the given array of arrays using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint to draw the lines.


plotData

public void plotData(Graphics2D g,
                     Point2D[][] data,
                     Paint[] color,
                     Stroke s)
Transforms the points of the given array of arrays using the world to image transform and plots a function of the resulting points in the given graphics context using the given color or Paint and the given Stroke to draw the lines.


markData

public void markData(Graphics2D g,
                     Point2D[] data,
                     Paint color,
                     PlotMark plotmark)
Transforms the points of the given array using the world to image transform and marks the resulting points in the given graphics context using the given color or Paint to paint the marks.


markData

public void markData(Graphics2D g,
                     Point2D[][] data,
                     Paint color,
                     PlotMark plotmark)
Transforms the points of the given array of arrays using the world to image transform and marks the resulting points in the given graphics context using the given color or Paint to paint the marks.


markData

public void markData(Graphics2D g,
                     Point2D[][] data,
                     Paint[] color,
                     PlotMark plotmark)
Transforms the points of the given array of arrays using the world to image transform and marks the resulting points in the given graphics context using the given Paint array to paint the marks for the corresponding sub array of the data.


markData

public void markData(Graphics2D g,
                     Point2D[][] data,
                     Paint[] color,
                     PlotMark[] plotmarks)
Transforms the points of the given array of arrays using the world to image transform and marks the resulting points in the given graphics context using the given Paint array and the given plot mark array to paint the marks for the corresponding sub array of the data.


plotVGridLine

public void plotVGridLine(Graphics2D g,
                          double xPosition)
Plots a vertical grid line corresponding to the given x position in world coordinates, in the given graphics context.

Parameters:
g - the graphics context
xPosition - the x position in world coordinates

plotHGridLine

public void plotHGridLine(Graphics2D g,
                          double yPosition)
Plots a horizontal grid line corresponding to the given y position in world coordinates, in the given graphics context.

Parameters:
g - the graphics context
yPosition - the y position in world coordinates

plotVTickMark

public void plotVTickMark(Graphics2D g,
                          double xPosition,
                          int ticksize)
Plots a vertical tick line corresponding to the given x position in world coordinates, in the given graphics context using the given tick size.

Parameters:
g - the graphics context
xPosition - the x position in world coordinates
ticksize - the length of the tick mark

plotHTickMark

public void plotHTickMark(Graphics2D g,
                          double yPosition,
                          int ticksize)
Plots a horizontal tick line corresponding to the given y position in world coordinates, in the given graphics context using the given tick size.

Parameters:
g - the graphics context
yPosition - the y position in world coordinates
ticksize - the length of the tick mark

xMinIndex

public int xMinIndex(double delta)
Returns the minimum index for vertical grid or tick lines given the spacing along the x axis in world coordinates. The given spacing must be greater than or equal to 0.

Parameters:
delta - the spacing along the x axis in world coordinates

yMinIndex

public int yMinIndex(double delta)
Returns the minimum index for horizontal grid or tick lines given the spacing along the y axis in world coordinates. The given spacing must be greater than or equal to 0.

Parameters:
delta - the spacing along the y axis in world coordinates

xMaxIndex

public int xMaxIndex(double delta)
Returns the maximum index for vertical grid or tick lines given the spacing along the x axis in world coordinates. The given spacing must be greater than or equal to 0.

Parameters:
delta - the spacing along the x axis in world coordinates

yMaxIndex

public int yMaxIndex(double delta)
Returns the maximum index for horizontal grid or tick lines given the spacing along the y axis in world coordinates. The given spacing must be greater than or equal to 0.

Parameters:
delta - the spacing along the y axis in world coordinates

plotVGridLines

public PlotTool plotVGridLines(Graphics2D g,
                               Paint color,
                               double delta)
Plots a sequence of vertical grid lines of thickness 1 using the given color or Paint and the given x grid spacing value.

Parameters:
g - the graphics context
color - the grid line color
delta - the x grid spacing
Returns:
a reference to this plot tool

plotHGridLines

public PlotTool plotHGridLines(Graphics2D g,
                               Paint color,
                               double delta)
Plots a sequence of horizontal grid lines of thickness 1 using the given color or Paint and the given y grid spacing value.

Parameters:
g - the graphics context
color - the grid line color
delta - the y grid spacing
Returns:
a reference to this plot tool

plotGridLines

public PlotTool plotGridLines(Graphics2D g,
                              Paint color,
                              Point2D delta)
Plots vertical and horizontal grid lines of thickness 1 using the given color or Paint and the given grid spacing values encapsulated as a Point2D object.

Parameters:
g - the graphics context
color - the grid line color
delta - a Point2D encapsulating the grid spacing in the x and y directions
Returns:
a reference to this plot tool

plotVTickMarks

public PlotTool plotVTickMarks(Graphics2D g,
                               Paint color,
                               double delta,
                               int ticksize)
Plots a sequence of vertical tick marks of thickness 1 using the given color or Paint, x grid spacing value, and tick mark length.

Parameters:
g - the graphics context
color - the tick mark color
delta - the x tick mark spacing
ticksize - the length for each tick mark
Returns:
a reference to this plot tool

plotHTickMarks

public PlotTool plotHTickMarks(Graphics2D g,
                               Paint color,
                               double delta,
                               int ticksize)
Plots a sequence of horizontal tick marks of thickness 1 using the given color or Paint, y grid spacing value, and tick mark length.

Parameters:
g - the graphics context
color - the tick mark color
delta - the y tick mark spacing
ticksize - the length for each tick mark
Returns:
a reference to this plot tool

plotTickMarks

public PlotTool plotTickMarks(Graphics2D g,
                              Paint color,
                              Point2D delta,
                              int ticksize)
Plots vertical and horizontal tick marks of thickness 1 using the given color or Paint, grid spacing values encapsulated as a Point2D object, and tick mark length.

Parameters:
g - the graphics context
color - the tick mark color
delta - a Point2D encapsulating the tick mark spacing in the x and y directions
ticksize - the length for each tick mark
Returns:
a reference to this plot tool

findSpacing

public static double findSpacing(double minimumDelta)
Returns the smallest double that has one of the three forms 10k, 2*10k, or 5*10k, and is greater than or equal to the absolute value of the given minimum. Returns 0.0 if the given minimum is equal to 0.0.

Parameters:
minimumDelta - the minimum value that could be returned

autoSpacing

public Point2D autoSpacing(int minPixel)
Returns a Point2D object encapsulating an appropriate spacing for grid lines and tick marks in world coordinates. The x and y values of the returned Point2D object will each have one of the three numeric forms: 10k, 2*10k, or 5*10k. If this plot tool is set to preserve geometric shape then the x and y values of the returned point will be equal.

Parameters:
minPixel - the minimum spacing in image pixel units
Returns:
a Point2D object encapsulating the appropriate spacing for grid lines and tick marks in world coordinates

autoGridLines

public PlotTool autoGridLines(Graphics2D g)
Plots grid lines appropriate for the world to image transform in the given graphics context, using the default thickness and the default color for grid lines.

Parameters:
g - the graphics context on which to plot
Returns:
a reference to this plot tool

autoTickMarks

public PlotTool autoTickMarks(Graphics2D g)
Plots tick marks appropriate for the world to image transform in the given graphics context, using the default thickness and the default color for tick marks.

Parameters:
g - the graphics context on which to plot
Returns:
a reference to this plot tool

plotAxes

public PlotTool plotAxes(Graphics2D g,
                         Paint color,
                         int thick)
Plots axes in the given graphics context using the given color or Paint and the given line thickness.

Parameters:
g - the graphics context on which to plot
color - the desired axes color
thick - the desired axes line thickness
Returns:
a reference to this plot tool

autoAxes

public PlotTool autoAxes(Graphics2D g)
Plots black axes of thickness 3 in given graphics context.

Parameters:
g - the graphics context on which to plot
Returns:
a reference to this plot tool

storeWorldBounds

protected void storeWorldBounds(Rectangle2D w)
Stores the given world coordinate bounds.

Parameters:
w - the new world coordinate bounds

storeImageBounds

public void storeImageBounds(Rectangle2D i)
Stores the given image coordinate bounds.

Parameters:
i - the new image coordinate bounds

storePreservesShape

protected void storePreservesShape(boolean ps)
Stores the given shape preservation policy.

Parameters:
ps - whether or not the transform preserves geometric shape

storeInset

protected void storeInset(int in)
Stores the given inset value.

Parameters:
in - the new image inset in image pixel units

setTransforms

protected PlotTool setTransforms()

Creates an affine transform suitable for transforming points in the world coordinate space to points in the image coordinate space, either by best fit or by preserving the shape of the geometry.

The affine transform will support the mathematician's convention for world coodinates:

This means that in practice:

The image of the world will be centered, that is, the center of the bounds rectangle for the world coordinate space will map to the center of the bounds rectangle for the image coordinate space.

If this plot tool is not set to preserve geometric shape, then the transform will map the bounds rectangle for the world coordinate space directly to the bounds rectangle for the image coordinate space.

The inset parameter is used to adjust the transform so that the world coordinate bounds maps to a subrectangle of the image coordinate bounds inset on all sides by the given number of pixels.

Returns:
a reference to this plot tool