edu.neu.ccs.gui
Class PlotTool

java.lang.Object
  extended byedu.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.

As of 2.5.0, adjusted the algorithms to intelligently skip over data points that are not finite.

Version:
2.5.0
See Also:
Serialized Form

Field Summary
static Color DEFAULT_AXES_COLOR
          Default color for each of the axes.
static int DEFAULT_AXES_SIZE
          Default width for each of the axes.
static boolean DEFAULT_EQUALIZE
          Default value for the preservesShape property.
static Color DEFAULT_GRID_COLOR
          Default color for each of the grid lines.
static int DEFAULT_INSET
          Default image inset.
static Color DEFAULT_PLOT_COLOR
          Default color for plots.
static BasicStroke DEFAULT_STROKE
          Helper for strokes of thickness 1.
static Color DEFAULT_TICK_COLOR
          Default color for each of the tick marks.
static int DEFAULT_TICK_SIZE
          Default length for a tick mark.
static int DEFAULT_WINDOW_SIZE
          Default window size.
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.
static int MINIMUM_GRID_PIXELS
          Minimum pixel distance for automatic grid line painting.
static int MINIMUM_TICK_PIXELS
          Minimum pixel distance for automatic tick mark painting.
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 color or 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 color or 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 point arrays using the world to image transform and draws a line plot of each transformed 1-dimensional point array 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 point arrays using the world to image transform and draws a line plot of each transformed 1-dimensional point array in the given graphics context using the given color or Paint array to draw the lines.
 void plotData(Graphics2D g, Point2D[][] data, Paint[] color, Stroke s)
          Transforms the points of the given array of point arrays using the world to image transform and draws a line plot of each transformed 1-dimensional point array in the given graphics context using the given color or Paint array 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 point arrays using the world to image transform and draws a line plot of each transformed 1-dimensional point array 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 draws a line plot of the transformed 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 draws a line plot of the transformed 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, double xDelta, double yDelta)
          Plots vertical and horizontal grid lines of thickness 1 using the given color or Paint and the given grid spacing values.
 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, double xDelta, double yDelta, int ticksize)
          Plots vertical and horizontal tick marks of thickness 1 using the given color or Paint, the grid spacing values 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.
private  void readObject(ObjectInputStream in)
          Extends the default deserialization process to restore helper data members upon instantiation.
 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

DEFAULT_WINDOW_SIZE

public static final int DEFAULT_WINDOW_SIZE
Default window size. Used if null parameters are passed.

See Also:
Constant Field Values

DEFAULT_EQUALIZE

public static final boolean DEFAULT_EQUALIZE
Default value for the preservesShape property.

See Also:
Constant Field Values

DEFAULT_INSET

public static final int DEFAULT_INSET
Default image inset.

See Also:
Constant Field Values

DEFAULT_AXES_SIZE

public static final int DEFAULT_AXES_SIZE
Default width for each of the axes.

See Also:
Constant Field Values

MINIMUM_GRID_PIXELS

public static final int MINIMUM_GRID_PIXELS
Minimum pixel distance for automatic grid line painting.

See Also:
Constant Field Values

MINIMUM_TICK_PIXELS

public static final int MINIMUM_TICK_PIXELS
Minimum pixel distance for automatic tick mark painting.

See Also:
Constant Field Values

DEFAULT_TICK_SIZE

public static final int DEFAULT_TICK_SIZE
Default length for a tick mark.

See Also:
Constant Field Values

DEFAULT_PLOT_COLOR

public static final Color DEFAULT_PLOT_COLOR
Default color for plots.


DEFAULT_AXES_COLOR

public static final Color DEFAULT_AXES_COLOR
Default color for each of the axes.


DEFAULT_GRID_COLOR

public static final Color DEFAULT_GRID_COLOR
Default color for each of the grid lines.


DEFAULT_TICK_COLOR

public static final Color DEFAULT_TICK_COLOR
Default color for each of the tick marks.


DEFAULT_STROKE

public static final BasicStroke DEFAULT_STROKE
Helper for strokes of thickness 1.


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

readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Extends the default deserialization process to restore helper data members upon instantiation.

Parameters:
in - the deserialization input stream
Throws:
IOException
ClassNotFoundException

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.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

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.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

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 draws a line plot of the transformed points in the given graphics context using the given color or Paint to draw the lines.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

Parameters:
g - the graphics context
data - the data to transform and plot
color - the color or paint

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 draws a line plot of the transformed points in the given graphics context using the given color or Paint and the given Stroke to draw the lines.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

Parameters:
g - the graphics context
data - the data to transform and plot
color - the color or paint
s - the stroke for plotting the lines

plotData

public void plotData(Graphics2D g,
                     Point2D[][] data,
                     Paint color)

Transforms the points of the given array of point arrays using the world to image transform and draws a line plot of each transformed 1-dimensional point array in the given graphics context using the given color or Paint to draw the lines.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

Parameters:
g - the graphics context
data - the data to transform and plot
color - the color or paint

plotData

public void plotData(Graphics2D g,
                     Point2D[][] data,
                     Paint color,
                     Stroke s)

Transforms the points of the given array of point arrays using the world to image transform and draws a line plot of each transformed 1-dimensional point array in the given graphics context using the given color or Paint and the given Stroke to draw the lines.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

Parameters:
g - the graphics context
data - the data to transform and plot
color - the color or paint
s - the stroke for plotting the lines

plotData

public void plotData(Graphics2D g,
                     Point2D[][] data,
                     Paint[] color)

Transforms the points of the given array of point arrays using the world to image transform and draws a line plot of each transformed 1-dimensional point array in the given graphics context using the given color or Paint array to draw the lines.

The method cycles through the colors for successive line plots and will repeat colors if needed.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

Parameters:
g - the graphics context
data - the data to transform and plot
color - the color or paint array

plotData

public void plotData(Graphics2D g,
                     Point2D[][] data,
                     Paint[] color,
                     Stroke s)

Transforms the points of the given array of point arrays using the world to image transform and draws a line plot of each transformed 1-dimensional point array in the given graphics context using the given color or Paint array and the given Stroke to draw the lines.

The method cycles through the colors for successive line plots and will repeat colors if needed.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

Parameters:
g - the graphics context
data - the data to transform and plot
color - the color or paint array
s - the stroke for plotting 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.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

Parameters:
g - the graphics context
data - the data to transform and mark
color - the color or paint
plotmark - the mark to use

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.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

Parameters:
g - the graphics context
data - the data to transform and mark
color - the color or paint
plotmark - the mark to use

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 array to paint the marks for the corresponding sub array of the data.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

Parameters:
g - the graphics context
data - the data to transform and mark
color - the color or paint array
plotmark - the mark to use

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 color or Paint array and the given plot mark array to paint the marks for the corresponding sub array of the data.

As of 2.5.0, skips data points that are not finite as well as data points that are null.

Parameters:
g - the graphics context
data - the data to transform and mark
color - the color or paint array
plotmarks - the array of marks to use

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,
                              double xDelta,
                              double yDelta)
Plots vertical and horizontal grid lines of thickness 1 using the given color or Paint and the given grid spacing values.

Parameters:
g - the graphics context
color - the grid line color
xDelta - the x-spacing
yDelta - the y-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,
                              double xDelta,
                              double yDelta,
                              int ticksize)
Plots vertical and horizontal tick marks of thickness 1 using the given color or Paint, the grid spacing values and tick mark length.

Parameters:
g - the graphics context
color - the tick mark color
xDelta - the x-spacing
yDelta - the y-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 or is not finite.

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