Class cam.visuals.plots.Plot

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----cam.visuals.plots.Plot

public class Plot
extends Canvas
An object which takes x and y data arrays and plots them. Various attributes of the plot can be set including axes type, grid lines, labels, and title. This class allows multiple plots to be "overlaid", each separate plot inheriting the current bounding box and labelling. The individual plots are accessed via a plot name.

Version:
Oct. 18, 1998
Author:
Mark Hoefer, Chris Anderson

Variable Index

 o CURVE
Plot Type : data points connected with line segments
 o CURVE_AND_POINTS
Plot Type : data points connected with line segments, and data points indicated with character marker.
 o FIXED
Label Format : fixed point
 o FLOATING
Axis Type : floating axis plotted
 o NONE
Axis Type : no axis plotted
 o PERIMETER
Axis Type : perimeter axis plotted
 o POINTS
Plot Type : data points indicated with character marker.
 o SCIENTIFIC
Label Format : scientific
 o XAXIS
Axis Type : only x-axis plotted

Constructor Index

 o Plot()
Creates a Plot instance and sets the bounding rectangle and defaults.

Method Index

 o changeData(String, double[], double[])
Changes the x and y data of a plot destructively.
 o clear()
Deletes all plots and resets defaults
 o getPlotChar(String)
Returns the current plot character.
 o getPlotColor(String)
Returns the current plot color.
 o getPlotNames()
Returns a string array containing the names of the plots.
 o getPlotType(String)
Returns the current plot type (e.g.
 o getXMax()
Returns the maximum X coordinate of the plot bounding box.
 o getXMin()
Returns the minimum X coordinate of the plot bounding box.
 o getXTickScale()
Returns the distance between the X coordinate tick marks.
 o getYMax()
Returns the maximum Y coordinate of the plot bounding box.
 o getYMin()
Returns the minimum Y coordinate of the plot bounding box.
 o getYTickScale()
Returns the distance between the Y coordinate tick marks.
 o getZoomXmax()
Returns maximum X coordinate of zoom box.
 o getZoomXmin()
Returns minimum X coordinate of zoom box.
 o getZoomYmax()
Returns maximum Y coordinate of zoom box.
 o getZoomYmin()
Returns minimum Y coordinate of zoom box.
 o isAutoScalingOn()
 o isAutoTickScalingOn()
 o isAxisLabelsOn()
 o isBoundPointsOn()
 o isGridLinesOn()
 o isTickMarksOn()
 o isZoomRectangleOn()
 o paint(Graphics)
Paints the plot into the input Graphics object
 o plot(double[], char, String)
Plots the y coordinates of the data with respect to their index using charater markers and associates a name with the plot.
 o plot(double[], Color, char, String, int)
Plots the y coordinates of the data with respect to their index using charater markers and a specified color.
 o plot(double[], double[], Color, char, String, int)
Plots the data with specified color, character and type.
 o plot(double[], double[], Color, String)
Plots the data with specified color and associates a name with the plot.
 o plot(double[], double[], String)
Plots the data and assocates a name with the plot.
 o plot(double[], String)
Plots the y coordinates of the data with respect to their index, and associates a name with the plot.
 o removePlot(String)
Removes the named plot.
 o removeTitle()
Removes the title from the plot.
 o rePlot()
Induces a repainting of the plot.
 o setAutoScaling(boolean)
 o setAutoTickScaling(boolean)
 o setAxisLabels(String, String, Font, Color)
Sets the axis labels.
 o setAxisType(int)
Sets the type of axis used.
 o setBoundPointsInfo(Font, Color)
Sets color and font for the drawing of the boundary points
 o setDrawAxisLabels(boolean)
 o setDrawBoundPoints(boolean)
 o setDrawTickMarks(boolean)
 o setDrawZoomRectangle(boolean)
 o setGridLines(boolean)
 o setPlotChar(String, char)
Set the character constant used for plotting
 o setPlotColor(String, Color)
Sets the plot color.
 o setPlotName(String, String)
Changes the name of a plot
 o setPlotType(String, int)
Sets the plot type.
 o setTickScale(double, double)
Sets tick scale.
 o setTitle(String, Font, Color)
Seets the title of the plot
 o setXbounds(double, double)
Sets the minimum and maximum x coordinate of the bounding box.
 o setXlabelFormat(int)
Sets the label format for the x coordinate.
 o setXlabelPrecision(int)
Sets the x coordinate label precision
 o setXYBounds(double, double, double, double)
Sets the coordinate bounds for the plot.
 o setYbounds(double, double)
Sets the minimum and maximum y coordinate of the bounding box.
 o setYlabelFormat(int)
Sets the label format for the y coordinate.
 o setYlabelPrecision(int)
Sets the y coordinate label precision
 o setYmaxDefault(double)
Sets the maximum y coordinate of the default bounding box.
 o setYminDefault(double)
Sets the minimum y coordinate of the default bounding box.
 o zoom(double, double)
This function zooms in the x and y directions of the bounding box by the given percentage.

Variables

 o NONE
 public static final int NONE
Axis Type : no axis plotted

 o PERIMETER
 public static final int PERIMETER
Axis Type : perimeter axis plotted

 o FLOATING
 public static final int FLOATING
Axis Type : floating axis plotted

 o XAXIS
 public static final int XAXIS
Axis Type : only x-axis plotted

 o CURVE
 public static final int CURVE
Plot Type : data points connected with line segments

 o POINTS
 public static final int POINTS
Plot Type : data points indicated with character marker.

 o CURVE_AND_POINTS
 public static final int CURVE_AND_POINTS
Plot Type : data points connected with line segments, and data points indicated with character marker.

 o SCIENTIFIC
 public static final int SCIENTIFIC
Label Format : scientific

 o FIXED
 public static final int FIXED
Label Format : fixed point

Constructors

 o Plot
 public Plot()
Creates a Plot instance and sets the bounding rectangle and defaults.

Methods

 o getXTickScale
 public double getXTickScale()
Returns the distance between the X coordinate tick marks.

 o getYTickScale
 public double getYTickScale()
Returns the distance between the Y coordinate tick marks.

 o getXMin
 public double getXMin()
Returns the minimum X coordinate of the plot bounding box.

 o getYMin
 public double getYMin()
Returns the minimum Y coordinate of the plot bounding box.

 o getXMax
 public double getXMax()
Returns the maximum X coordinate of the plot bounding box.

 o getYMax
 public double getYMax()
Returns the maximum Y coordinate of the plot bounding box.

 o getPlotColor
 public Color getPlotColor(String plotName)
Returns the current plot color.

Parameters:
plotName - the name of the plot whose color is desired.
 o getPlotChar
 public char getPlotChar(String plotName)
Returns the current plot character.

Parameters:
plotName - the name of the plot whose plot character is desired.
 o getPlotType
 public int getPlotType(String plotName)
Returns the current plot type (e.g. Plot.CURVE, Plot.CURVE_AND_POINTS, etc).

Parameters:
plotName - the name of the plot whose plot character is desired.
 o getPlotNames
 public String[] getPlotNames()
Returns a string array containing the names of the plots.

 o changeData
 public boolean changeData(String plotName,
                           double xdata[],
                           double ydata[])
Changes the x and y data of a plot destructively.

Parameters:
plotName - the name of the plot targeted for a data change
xdata - x-component of the data to be plotted
ydata - y-component of the data to be plotted
Returns:
true if successful.
 o setPlotType
 public boolean setPlotType(String plotName,
                            int type)
Sets the plot type.

Parameters:
plotName - the name of the target plot
type - one of Plot.CURVE, Plot.POINTS, Plot.CURVE_AND_POINTS
 o setPlotName
 public boolean setPlotName(String plotName,
                            String newPlotName)
Changes the name of a plot

Parameters:
plotName - target plot's name
newPlotName - new name for target plot
Returns:
true if successful
 o setPlotColor
 public boolean setPlotColor(String plotName,
                             Color c)
Sets the plot color.

Parameters:
plotName - name of the target plot
c - color
 o setPlotChar
 public boolean setPlotChar(String plotName,
                            char ch)
Set the character constant used for plotting

Parameters:
plotName - name of the target plot
ch - plotting character to be used
Returns:
true if successful
 o setBoundPointsInfo
 public void setBoundPointsInfo(Font f,
                                Color c)
Sets color and font for the drawing of the boundary points

 o setTickScale
 public void setTickScale(double xScale,
                          double yScale)
Sets tick scale. The tick scale is the distance between tick marks

Parameters:
xScale - : distance between the x-tick marks
yScale - : distance between the y-tick marks
 o setXlabelPrecision
 public void setXlabelPrecision(int precision)
Sets the x coordinate label precision

Parameters:
precision - number of digits used in the label
 o setYlabelPrecision
 public void setYlabelPrecision(int precision)
Sets the y coordinate label precision

Parameters:
precision - number of digits used in the label
 o setXlabelFormat
 public void setXlabelFormat(int type)
Sets the label format for the x coordinate.

Parameters:
type - one of Plot.FIXED or Plot.SCIENTIFIC
 o setYlabelFormat
 public void setYlabelFormat(int type)
Sets the label format for the y coordinate.

Parameters:
type - one of Plot.FIXED or Plot.SCIENTIFIC
 o setXYBounds
 public void setXYBounds(double xmin,
                         double xmax,
                         double ymin,
                         double ymax)
Sets the coordinate bounds for the plot.

Parameters:
xmin - Minimum x coordinate
xmax - Maximum y coordinate
ymin - Minimum y coordinate
ymax - Maximum y coordinate
 o setXbounds
 public void setXbounds(double xmin,
                        double xmax)
Sets the minimum and maximum x coordinate of the bounding box.

Parameters:
xmin - the minimum x coordinate of the bounding box
xmax - the maximum x coordinate of the bounding box
 o setYbounds
 public void setYbounds(double Ymin,
                        double Ymax)
Sets the minimum and maximum y coordinate of the bounding box.

Parameters:
ymin - the minimum y coordinate of the bounding box
ymax - the maximum y coordinate of the bounding box
 o setYmaxDefault
 public void setYmaxDefault(double yMaxDef)
Sets the maximum y coordinate of the default bounding box.

Parameters:
yMaxDef - the maximum y coordinate of the bounding box
 o setYminDefault
 public void setYminDefault(double yMinDef)
Sets the minimum y coordinate of the default bounding box.

Parameters:
yMinDef - the minimum y coordinate of the bounding box
 o setTitle
 public void setTitle(String t,
                      Font f,
                      Color c)
Seets the title of the plot

Parameters:
t - the title
f - the font
c - the color c
 o removeTitle
 public void removeTitle()
Removes the title from the plot.

 o setAxisType
 public void setAxisType(int type)
Sets the type of axis used.

Parameters:
type - Axis type, one of Plot.NONE, Plot.PERIMETER, Plot.FLOATING, Plot.XAXIS
 o setAxisLabels
 public void setAxisLabels(String xLabel,
                           String yLabel,
                           Font f,
                           Color c)
Sets the axis labels.

Parameters:
xLabel - the x axis label
yLabel - the y axis label
f - the label font
c - the label color
 o zoom
 public void zoom(double xPercentage,
                  double yPercentage)
This function zooms in the x and y directions of the bounding box by the given percentage. >100 will zoom out, <100 will zoom in

 o plot
 public void plot(double xdata[],
                  double ydata[],
                  Color c,
                  char ch,
                  String plotName,
                  int type)
Plots the data with specified color, character and type.

Parameters:
xdata - the x coordinates of the data
ydata - the y coordinates of the data
c - the color used to plot the data
ch - the character used to indicate data points
plotName - the name of the plot associated with the data
type - the type of plot. One of Plot.CURVE, Plot.POINTS, Plot.CURVE_AND_POINTS
 o plot
 public void plot(double xdata[],
                  double ydata[],
                  String plotName)
Plots the data and assocates a name with the plot.

Parameters:
xdata - the x coordinates of the data
ydata - the y coordinates of the data
plotName - the name of the plot associated with the data
 o plot
 public void plot(double xdata[],
                  double ydata[],
                  Color c,
                  String plotName)
Plots the data with specified color and associates a name with the plot.

Parameters:
xdata - the x coordinates of the data
ydata - the y coordinates of the data
c - the color used to plot the data
plotName - the name of the plot associated with the data
 o plot
 public void plot(double ydata[],
                  String plotName)
Plots the y coordinates of the data with respect to their index, and associates a name with the plot.

Parameters:
ydata - the y coordinates of the data
plotName - the name of the plot associated with the data
 o plot
 public void plot(double ydata[],
                  char ch,
                  String plotName)
Plots the y coordinates of the data with respect to their index using charater markers and associates a name with the plot.

Parameters:
ydata - the y coordinates of the data
ch - the character used to indicate data points
plotName - the name of the plot associated with the data
 o plot
 public void plot(double ydata[],
                  Color c,
                  char ch,
                  String plotName,
                  int type)
Plots the y coordinates of the data with respect to their index using charater markers and a specified color.

Parameters:
xdata - the x coordinates of the data
ydata - the y coordinates of the data
c - the color used to plot the data
ch - the character used to indicate data points
plotName - the name of the plot associated with the data
type - the type of plot. One of Plot.CURVE, Plot.POINTS, Plot.CURVE_AND_POINTS
 o removePlot
 public boolean removePlot(String plotName)
Removes the named plot.

Parameters:
plotName - the target plot to be removed.
 o clear
 public void clear()
Deletes all plots and resets defaults

 o isZoomRectangleOn
 public boolean isZoomRectangleOn()
 o isGridLinesOn
 public boolean isGridLinesOn()
 o isBoundPointsOn
 public boolean isBoundPointsOn()
 o isTickMarksOn
 public boolean isTickMarksOn()
 o isAutoScalingOn
 public boolean isAutoScalingOn()
 o isAxisLabelsOn
 public boolean isAxisLabelsOn()
 o isAutoTickScalingOn
 public boolean isAutoTickScalingOn()
 o setAutoTickScaling
 public void setAutoTickScaling(boolean state)
 o setDrawZoomRectangle
 public void setDrawZoomRectangle(boolean state)
 o setGridLines
 public void setGridLines(boolean state)
 o setDrawBoundPoints
 public void setDrawBoundPoints(boolean state)
 o setDrawTickMarks
 public void setDrawTickMarks(boolean state)
 o setDrawAxisLabels
 public void setDrawAxisLabels(boolean state)
 o setAutoScaling
 public void setAutoScaling(boolean state)
 o rePlot
 public void rePlot()
Induces a repainting of the plot. Used to cause a Plot object repaint after a Plot parameter change.

 o paint
 public void paint(Graphics g)
Paints the plot into the input Graphics object

Parameters:
g - input Graphics object
Overrides:
paint in class Canvas
 o getZoomXmin
 public double getZoomXmin()
Returns minimum X coordinate of zoom box. (In user coordinates.)

 o getZoomXmax
 public double getZoomXmax()
Returns maximum X coordinate of zoom box. (In user coordinates.)

 o getZoomYmin
 public double getZoomYmin()
Returns minimum Y coordinate of zoom box. (In user coordinates.)

 o getZoomYmax
 public double getZoomYmax()
Returns maximum Y coordinate of zoom box. (In user coordinates.)