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
-
CURVE
- Plot Type : data points connected with line segments
-
CURVE_AND_POINTS
- Plot Type : data points connected with line segments, and data points
indicated with character marker.
-
FIXED
- Label Format : fixed point
-
FLOATING
- Axis Type : floating axis plotted
-
NONE
- Axis Type : no axis plotted
-
PERIMETER
- Axis Type : perimeter axis plotted
-
POINTS
- Plot Type : data points indicated with character marker.
-
SCIENTIFIC
-
Label Format : scientific
-
XAXIS
- Axis Type : only x-axis plotted
-
Plot()
- Creates a Plot instance and sets the bounding rectangle and defaults.
-
changeData(String, double[], double[])
- Changes the x and y data of a plot destructively.
-
clear()
- Deletes all plots and resets defaults
-
getPlotChar(String)
- Returns the current plot character.
-
getPlotColor(String)
- Returns the current plot color.
-
getPlotNames()
- Returns a string array containing the names of the plots.
-
getPlotType(String)
- Returns the current plot type (e.g.
-
getXMax()
- Returns the maximum X coordinate of the plot bounding box.
-
getXMin()
- Returns the minimum X coordinate of the plot bounding box.
-
getXTickScale()
- Returns the distance between the X coordinate tick marks.
-
getYMax()
- Returns the maximum Y coordinate of the plot bounding box.
-
getYMin()
- Returns the minimum Y coordinate of the plot bounding box.
-
getYTickScale()
- Returns the distance between the Y coordinate tick marks.
-
getZoomXmax()
- Returns maximum X coordinate of zoom box.
-
getZoomXmin()
- Returns minimum X coordinate of zoom box.
-
getZoomYmax()
- Returns maximum Y coordinate of zoom box.
-
getZoomYmin()
- Returns minimum Y coordinate of zoom box.
-
isAutoScalingOn()
-
-
isAutoTickScalingOn()
-
-
isAxisLabelsOn()
-
-
isBoundPointsOn()
-
-
isGridLinesOn()
-
-
isTickMarksOn()
-
-
isZoomRectangleOn()
-
-
paint(Graphics)
- Paints the plot into the input Graphics object
-
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.
-
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.
-
plot(double[], double[], Color, char, String, int)
- Plots the data with specified color, character and type.
-
plot(double[], double[], Color, String)
- Plots the data with specified color and associates a name with the plot.
-
plot(double[], double[], String)
- Plots the data and assocates a name with the plot.
-
plot(double[], String)
- Plots the y coordinates of the data with respect to their index, and associates a name
with the plot.
-
removePlot(String)
- Removes the named plot.
-
removeTitle()
- Removes the title from the plot.
-
rePlot()
- Induces a repainting of the plot.
-
setAutoScaling(boolean)
-
-
setAutoTickScaling(boolean)
-
-
setAxisLabels(String, String, Font, Color)
- Sets the axis labels.
-
setAxisType(int)
- Sets the type of axis used.
-
setBoundPointsInfo(Font, Color)
- Sets color and font for the drawing of the boundary points
-
setDrawAxisLabels(boolean)
-
-
setDrawBoundPoints(boolean)
-
-
setDrawTickMarks(boolean)
-
-
setDrawZoomRectangle(boolean)
-
-
setGridLines(boolean)
-
-
setPlotChar(String, char)
- Set the character constant used for plotting
-
setPlotColor(String, Color)
- Sets the plot color.
-
setPlotName(String, String)
- Changes the name of a plot
-
setPlotType(String, int)
- Sets the plot type.
-
setTickScale(double, double)
- Sets tick scale.
-
setTitle(String, Font, Color)
- Seets the title of the plot
-
setXbounds(double, double)
- Sets the minimum and maximum x coordinate of the bounding box.
-
setXlabelFormat(int)
- Sets the label format for the x coordinate.
-
setXlabelPrecision(int)
- Sets the x coordinate label precision
-
setXYBounds(double, double, double, double)
- Sets the coordinate bounds for the plot.
-
setYbounds(double, double)
- Sets the minimum and maximum y coordinate of the bounding box.
-
setYlabelFormat(int)
- Sets the label format for the y coordinate.
-
setYlabelPrecision(int)
- Sets the y coordinate label precision
-
setYmaxDefault(double)
- Sets the maximum y coordinate of the default bounding box.
-
setYminDefault(double)
- Sets the minimum y coordinate of the default bounding box.
-
zoom(double, double)
- This function zooms in the x and y directions of the bounding box
by the given percentage.
NONE
public static final int NONE
- Axis Type : no axis plotted
PERIMETER
public static final int PERIMETER
- Axis Type : perimeter axis plotted
FLOATING
public static final int FLOATING
- Axis Type : floating axis plotted
XAXIS
public static final int XAXIS
- Axis Type : only x-axis plotted
CURVE
public static final int CURVE
- Plot Type : data points connected with line segments
POINTS
public static final int POINTS
- Plot Type : data points indicated with character marker.
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.
SCIENTIFIC
public static final int SCIENTIFIC
- Label Format : scientific
FIXED
public static final int FIXED
- Label Format : fixed point
Plot
public Plot()
- Creates a Plot instance and sets the bounding rectangle and defaults.
getXTickScale
public double getXTickScale()
- Returns the distance between the X coordinate tick marks.
getYTickScale
public double getYTickScale()
- Returns the distance between the Y coordinate tick marks.
getXMin
public double getXMin()
- Returns the minimum X coordinate of the plot bounding box.
getYMin
public double getYMin()
- Returns the minimum Y coordinate of the plot bounding box.
getXMax
public double getXMax()
- Returns the maximum X coordinate of the plot bounding box.
getYMax
public double getYMax()
- Returns the maximum Y coordinate of the plot bounding box.
getPlotColor
public Color getPlotColor(String plotName)
- Returns the current plot color.
- Parameters:
- plotName - the name of the plot whose color is desired.
getPlotChar
public char getPlotChar(String plotName)
- Returns the current plot character.
- Parameters:
- plotName - the name of the plot whose plot character is desired.
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.
getPlotNames
public String[] getPlotNames()
- Returns a string array containing the names of the plots.
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.
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
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
setPlotColor
public boolean setPlotColor(String plotName,
Color c)
- Sets the plot color.
- Parameters:
- plotName - name of the target plot
- c - color
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
setBoundPointsInfo
public void setBoundPointsInfo(Font f,
Color c)
- Sets color and font for the drawing of the boundary points
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
setXlabelPrecision
public void setXlabelPrecision(int precision)
- Sets the x coordinate label precision
- Parameters:
- precision - number of digits used in the label
setYlabelPrecision
public void setYlabelPrecision(int precision)
- Sets the y coordinate label precision
- Parameters:
- precision - number of digits used in the label
setXlabelFormat
public void setXlabelFormat(int type)
- Sets the label format for the x coordinate.
- Parameters:
- type - one of Plot.FIXED or Plot.SCIENTIFIC
setYlabelFormat
public void setYlabelFormat(int type)
- Sets the label format for the y coordinate.
- Parameters:
- type - one of Plot.FIXED or Plot.SCIENTIFIC
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
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
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
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
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
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
removeTitle
public void removeTitle()
- Removes the title from the plot.
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
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
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
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
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
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
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
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
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
removePlot
public boolean removePlot(String plotName)
- Removes the named plot.
- Parameters:
- plotName - the target plot to be removed.
clear
public void clear()
- Deletes all plots and resets defaults
isZoomRectangleOn
public boolean isZoomRectangleOn()
isGridLinesOn
public boolean isGridLinesOn()
isBoundPointsOn
public boolean isBoundPointsOn()
isTickMarksOn
public boolean isTickMarksOn()
isAutoScalingOn
public boolean isAutoScalingOn()
isAxisLabelsOn
public boolean isAxisLabelsOn()
isAutoTickScalingOn
public boolean isAutoTickScalingOn()
setAutoTickScaling
public void setAutoTickScaling(boolean state)
setDrawZoomRectangle
public void setDrawZoomRectangle(boolean state)
setGridLines
public void setGridLines(boolean state)
setDrawBoundPoints
public void setDrawBoundPoints(boolean state)
setDrawTickMarks
public void setDrawTickMarks(boolean state)
setDrawAxisLabels
public void setDrawAxisLabels(boolean state)
setAutoScaling
public void setAutoScaling(boolean state)
rePlot
public void rePlot()
- Induces a repainting of the plot. Used to cause a Plot object
repaint after a Plot parameter change.
paint
public void paint(Graphics g)
- Paints the plot into the input Graphics object
- Parameters:
- g - input Graphics object
- Overrides:
- paint in class Canvas
getZoomXmin
public double getZoomXmin()
- Returns minimum X coordinate of zoom box. (In user coordinates.)
getZoomXmax
public double getZoomXmax()
- Returns maximum X coordinate of zoom box. (In user coordinates.)
getZoomYmin
public double getZoomYmin()
- Returns minimum Y coordinate of zoom box. (In user coordinates.)
getZoomYmax
public double getZoomYmax()
- Returns maximum Y coordinate of zoom box. (In user coordinates.)