All Packages Class Hierarchy This Package Previous Next Index
Class ptplot.PlotBox
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----ptplot.PlotBox
- public class PlotBox
- extends Panel
Construct a labeled box within which to place a data plot. A title,
X and Y axis labels, tick marks, and a legend are all supported.
Zooming in and out is supported. To zoom in, drag the mouse
downwards to draw a box. To zoom out, drag the mouse upward.
Zooming out stops automatically at the point where the data fills
the drawing rectangle.
The box can be configured either through a file with commands or
through direct invocation of the public methods of the class.
If a file is used, the file can be given as a URL through the
setDataurl
method. The file contains any number
commands, one per line. Unrecognized commands and commands with
syntax errors are ignored. Comments are denoted by a line starting
with a pound sign "#". The recognized commands include:
TitleText: string
XLabel: string
YLabel: string
These commands provide a title and labels for the X (horizontal) and Y
(vertical) axes.
A string is simply a sequence of characters, possibly
including spaces. There is no need here to surround them with
quotation marks, and in fact, if you do, the quotation marks will
be included in the labels.
The ranges of the X and Y axes can be optionally given by commands like:
XRange: min, max
YRange: min, max
The arguments min and max are numbers, possibly
including a sign and a decimal point. If they are not specified,
then the ranges are computed automatically from the data.
The tick marks for the axes are usually computed automatically from
the ranges. Every attempt is made to choose reasonable positions
for the tick marks regardless of the data ranges (powers of
ten multiplied by 1, 2, or 5 are used). However, they can also be
specified explicitly using commands like:
XTicks: label position, label position, ...
YTicks: label position, label position, ...
A label is a string that must be surrounded by quotation
marks if it contains any spaces. A position is a number
giving the location of the tick mark along the axis. For example,
a horizontal axis for a frequency domain plot might have tick marks
as follows:
XTicks: -PI -3.14159, -PI/2 -1.570795, 0 0, PI/2 1.570795, PI 3.14159
Tick marks could also denote years, months, days of the week, etc.
By default, tick marks are connected by a light grey background grid.
This grid can be turned off with the following command:
Grid: off
It can be turned back on with
Grid: on
Also, by default, the first ten data sets are shown each in a unique color.
The use of color can be turned off with the command:
Color: off
It can be turned back on with
Color: on
All of the above commands can also be invoked directly by calling the
the corresponding public methods from some Java procedure.
- Version:
- @(#)PlotBox.java 1.66 10/30/97
- Author:
- Edward A. Lee, Christopher Hylands
-
_background
-
-
_bottomPadding
-
-
_colors
-
-
_debug
-
-
_foreground
-
-
_graphics
-
-
_grid
-
-
_height
-
-
_leftPadding
-
-
_lrx
-
-
_lry
-
-
_rightPadding
-
-
_topPadding
-
-
_ulx
-
-
_uly
-
-
_usecolor
-
-
_width
-
-
_xBottom
-
-
_xMax
-
-
_xMin
-
-
_xRangeGiven
-
-
_xscale
-
-
_xTop
-
-
_yBottom
-
-
_yMax
-
-
_yMin
-
-
_yRangeGiven
-
-
_yscale
-
-
_yTop
-
-
PlotBox()
-
-
_drawPoint(Graphics, int, long, long, boolean)
- Put a mark corresponding to the specified dataset at the
specified x and y position.
-
_newFile()
- Hook for child classes to do any file preprocessing
-
_parseBinaryStream(DataInputStream)
- Hook to parse a binary stream.
-
_parseLine(String)
- Parse a line that gives plotting information.
-
_setButtonsVisibility(boolean)
- Set the visibility of the Fill button.
-
action(Event, Object)
-
Handle button presses to fill the plot.
Deprecated.
-
addLegend(int, String)
-
Add a legend (displayed at the upper right) for the specified
data set with the specified string.
-
addNotify()
- Create the peer of the plot box.
-
addXTick(String, double)
-
Specify a tick mark for the X axis.
-
addYTick(String, double)
-
Specify a tick mark for the Y axis.
-
drawPlot(Graphics, boolean)
- Draw the axes using the current range, label, and title information.
-
fillPlot()
- Rescales so that the data that is currently plotted just fits.
-
fillPlot(Graphics)
- Rescales so that the data that is currently plotted just fits.
-
getColorByName(String)
-
Convert a color name into a Color.
-
getDataurl()
- Get the dataurl.
-
getDocumentBase()
- Get the document base
-
getFontByName(String)
- Get the Font by name.
Deprecated.
-
getLegend(int)
-
Get the legend for a dataset.
-
getMinimumSize()
- Get the minimum size of this component.
-
getPreferredSize()
- Get the preferred size of this component.
-
init()
- Initialize the component, creating the fill button and setting
the colors.
-
minimumSize()
- The minimum size.
Deprecated.
-
mouseDown(Event, int, int)
- Set the starting point for an interactive zoom box.
Deprecated.
-
mouseDrag(Event, int, int)
- Draw a box for an interactive zoom box.
Deprecated.
-
mouseUp(Event, int, int)
- Zoom in or out based on the box that has been drawn.
Deprecated.
-
paint(Graphics)
-
Paint the component contents, which in this base class is
only the axes.
-
parseFile(String)
- Syntactic sugar for parseFile(dataurl, documentBase);
-
parseFile(String, URL)
- Open up the input file, which could be stdin, a URL or a file.
-
preferredSize()
- The preferred size.
Deprecated.
-
reshape(int, int, int, int)
- Reshape
-
resize(int, int)
-
Resize the plot.
Deprecated.
-
setBackground(Color)
- Set the background color.
-
setBinary(boolean)
- Set the binary flag to true if we are reading pxgraph format binary
data.
-
setDataurl(String)
- Set the dataurl.
-
setDebug(int)
- Set the debug value.
-
setDocumentBase(URL)
- Set the document base so that we can find the dataurl.
-
setForeground(Color)
- Set the foreground color.
-
setGrid(boolean)
- Control whether the grid is drawn.
-
setLabelFont(String)
- Set the label font, which is used for axis labels and legend labels.
-
setTitle(String)
- Set the title of the graph.
-
setTitleFont(String)
- Set the title font.
-
setXLabel(String)
-
Set the label for the X (horizontal) axis.
-
setXRange(double, double)
-
Set the X (horizontal) range of the plot.
-
setYLabel(String)
-
Set the label for the Y (vertical) axis.
-
setYRange(double, double)
- Set the Y (vertical) range of the plot.
_debug
protected int _debug
_graphics
protected Graphics _graphics
_yMax
protected double _yMax
_yMin
protected double _yMin
_xMax
protected double _xMax
_xMin
protected double _xMin
_xRangeGiven
protected boolean _xRangeGiven
_yRangeGiven
protected boolean _yRangeGiven
_xBottom
protected double _xBottom
_xTop
protected double _xTop
_yBottom
protected double _yBottom
_yTop
protected double _yTop
_grid
protected boolean _grid
_background
protected Color _background
_foreground
protected Color _foreground
_topPadding
protected int _topPadding
_bottomPadding
protected int _bottomPadding
_rightPadding
protected int _rightPadding
_leftPadding
protected int _leftPadding
_ulx
protected int _ulx
_uly
protected int _uly
_lrx
protected int _lrx
_lry
protected int _lry
_yscale
protected double _yscale
_xscale
protected double _xscale
_usecolor
protected boolean _usecolor
_colors
protected static Color _colors[]
_width
protected int _width
_height
protected int _height
PlotBox
public PlotBox()
action
public boolean action(Event evt,
Object arg)
- Note: action() is deprecated.
As of JDK1.1 in java.awt.component
but we need to compile under 1.0.2 for netscape3.x compatibility.
- Handle button presses to fill the plot. This rescales so that
the data that is currently plotted just fits.
- Overrides:
- action in class Component
addNotify
public void addNotify()
- Create the peer of the plot box.
- Overrides:
- addNotify in class Panel
addLegend
public void addLegend(int dataset,
String legend)
- Add a legend (displayed at the upper right) for the specified
data set with the specified string. Short strings generally
fit better than long strings. You must call
init()
before calling this method.
addXTick
public void addXTick(String label,
double position)
- Specify a tick mark for the X axis. The label given is placed
on the axis at the position given by position. If this
is called once or more, automatic generation of tick marks is
disabled. The tick mark will appear only if it is within the X
range.
addYTick
public void addYTick(String label,
double position)
- Specify a tick mark for the Y axis. The label given is placed
on the axis at the position given by position. If this
is called once or more, automatic generation of tick marks is
disabled. The tick mark will appear only if it is within the Y
range.
drawPlot
public synchronized void drawPlot(Graphics graphics,
boolean clearfirst)
- Draw the axes using the current range, label, and title information.
If the argument is true, clear the display before redrawing.
fillPlot
public synchronized void fillPlot()
- Rescales so that the data that is currently plotted just fits.
fillPlot
public synchronized void fillPlot(Graphics graphics)
- Rescales so that the data that is currently plotted just fits.
getFontByName
public Font getFontByName(String fullfontname)
- Note: getFontByName() is deprecated.
: As of JDK1.1, use Font.decode() instead.
We need to compile under JDK1.0.2, so we use this method.
- Get the Font by name.
getColorByName
public static Color getColorByName(String name)
- Convert a color name into a Color.
getDataurl
public String getDataurl()
- Get the dataurl.
getDocumentBase
public URL getDocumentBase()
- Get the document base
getLegend
public String getLegend(int dataset)
- Get the legend for a dataset.
getMinimumSize
public Dimension getMinimumSize()
- Get the minimum size of this component.
- Overrides:
- getMinimumSize in class Container
getPreferredSize
public Dimension getPreferredSize()
- Get the preferred size of this component.
- Overrides:
- getPreferredSize in class Container
init
public void init()
- Initialize the component, creating the fill button and setting
the colors. If the dataurl has been set, then parse that file.
minimumSize
public Dimension minimumSize()
- Note: minimumSize() is deprecated.
As of JDK1.1 in java.awt.component, but we need
to compile under 1.0.2 for netscape3.x compatibility.
- The minimum size.
- Overrides:
- minimumSize in class Container
mouseDown
public boolean mouseDown(Event evt,
int x,
int y)
- Note: mouseDown() is deprecated.
As of JDK1.1 in java.awt.component
but we need to compile under 1.0.2 for netscape3.x compatibility.
- Set the starting point for an interactive zoom box.
- Overrides:
- mouseDown in class Component
mouseDrag
public synchronized boolean mouseDrag(Event evt,
int x,
int y)
- Note: mouseDrag() is deprecated.
As of JDK1.1 in java.awt.component
but we need to compile under 1.0.2 for netscape3.x compatibility.
- Draw a box for an interactive zoom box.
Return a boolean indicating whether or not we have dealt with
the event.
- Overrides:
- mouseDrag in class Component
mouseUp
public synchronized boolean mouseUp(Event evt,
int x,
int y)
- Note: mouseUp() is deprecated.
As of JDK1.1 in java.awt.component
but we need to compile under 1.0.2 for netscape3.x compatibility.
- Zoom in or out based on the box that has been drawn.
- Overrides:
- mouseUp in class Component
paint
public void paint(Graphics graphics)
- Paint the component contents, which in this base class is
only the axes.
- Overrides:
- paint in class Container
parseFile
public void parseFile(String dataurl)
- Syntactic sugar for parseFile(dataurl, documentBase);
parseFile
public void parseFile(String dataurl,
URL documentBase)
- Open up the input file, which could be stdin, a URL or a file.
This code can be called from an application, which means that
getDocumentBase() might fail.
preferredSize
public Dimension preferredSize()
- Note: preferredSize() is deprecated.
As of JDK1.1 in java.awt.component, but we need
to compile under 1.0.2 for netscape3.x compatibility.
- The preferred size.
- Overrides:
- preferredSize in class Container
reshape
public void reshape(int x,
int y,
int width,
int height)
- Reshape
- Overrides:
- reshape in class Component
resize
public void resize(int width,
int height)
- Note: resize() is deprecated.
As of JDK1.1 in java.awt.component, but we need
to compile under 1.0.2 for netscape3.x compatibility.
- Resize the plot.
- Overrides:
- resize in class Component
setBackground
public void setBackground(Color background)
- Set the background color.
- Overrides:
- setBackground in class Component
setDebug
public void setDebug(int debug)
- Set the debug value. The higher the integer, the greater the
number of debugging messages printed to stdout. Useful values
are 10 - argument parsing, 20 - legend parsing, 101 - data point
debugging.
setForeground
public void setForeground(Color foreground)
- Set the foreground color.
- Overrides:
- setForeground in class Component
setBinary
public void setBinary(boolean binary)
- Set the binary flag to true if we are reading pxgraph format binary
data.
setDataurl
public void setDataurl(String dataurl)
- Set the dataurl.
setDocumentBase
public void setDocumentBase(URL documentBase)
- Set the document base so that we can find the dataurl.
setGrid
public void setGrid(boolean grid)
- Control whether the grid is drawn.
setLabelFont
public void setLabelFont(String fullfontname)
- Set the label font, which is used for axis labels and legend labels.
setTitle
public void setTitle(String title)
- Set the title of the graph. The title will appear on the subsequent
call to
paint()
or drawPlot()
.
setTitleFont
public void setTitleFont(String fullfontname)
- Set the title font.
setXLabel
public void setXLabel(String label)
- Set the label for the X (horizontal) axis. The label will
appear on the subsequent call to
paint()
or
drawPlot()
.
setXRange
public void setXRange(double min,
double max)
- Set the X (horizontal) range of the plot. If this is not done
explicitly, then the range is computed automatically from data
available when
paint()
or drawPlot()
are called. If min and max are identical, then the range is
arbitrarily spread by 1.
setYLabel
public void setYLabel(String label)
- Set the label for the Y (vertical) axis. The label will
appear on the subsequent call to
paint()
or
drawPlot()
.
setYRange
public void setYRange(double min,
double max)
- Set the Y (vertical) range of the plot. If this is not done
explicitly, then the range is computed automatically from data
available when
paint()
or drawPlot()
are called. If min and max are identical, then the range is
arbitrarily spread by 0.1.
_drawPoint
protected void _drawPoint(Graphics graphics,
int dataset,
long xpos,
long ypos,
boolean clip)
- Put a mark corresponding to the specified dataset at the
specified x and y position. The mark is drawn in the
current color. In this base class, a point is a
filled rectangle 6 pixels across. Note that marks greater than
about 6 pixels in size will not look very good since they will
overlap axis labels and may not fit well in the legend. The
clip argument, if
true
, states
that the point should not be drawn if
it is out of range.
_newFile
protected void _newFile()
- Hook for child classes to do any file preprocessing
_parseBinaryStream
protected void _parseBinaryStream(DataInputStream in) throws PlotDataException, IOException
- Hook to parse a binary stream.
- Throws: PlotDataException
- if there is a serious data format problem.
- Throws: IOException
- if an I/O error occurs.
_parseLine
protected boolean _parseLine(String line)
- Parse a line that gives plotting information. In this base
class, only lines pertaining to the title and labels are processed.
Everything else is ignored. Return true if the line is recognized.
_setButtonsVisibility
protected void _setButtonsVisibility(boolean vis)
- Set the visibility of the Fill button.
All Packages Class Hierarchy This Package Previous Next Index