|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--ptolemy.plot.PlotBox | +--ptolemy.plot.Histogram
A histogram plotter. The plot can be configured and data can be provided either through a file with commands or through direct invocation of the public methods of the class. To read a file or a URL, use the read() method.
When calling the public methods, in most cases the changes will not be visible until paint() has been called. To request that this be done, call repaint(). One exception is addPoint(), which makes the affect of the new point visible immediately if the plot is visible on the screen.
The ASCII format for the file 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 those supported by the base class, plus a few more. The commands are case insensitive, but are usually capitalized. The number of data sets to be plotted does not need to be specified. Data sets are added as needed. Each dataset is identified with a color (see the base class).
The appearance of the histogram can be altered by the following commands:
Bars: width Bars: width, offsetThe width is a real number specifying the width of the bars as a fraction of the bin width. It usually has a value less than or equal to one, and defaults to 0.5. The offset is a real number specifying how much the bar of the i < /i>th data set is offset from the previous one. This allows bars to "peek out" from behind the ones in front. It defaults to 0.15. Note that the frontmost data set will be the first one.
The width of each bin of the histogram can be specified using:
BinWidth: widthThis is given in whatever units the data has. By default, each bin is centered at x = nw, where w is the width of the bin and n is an integer. That bin represents values in the range (x - w/2, x + w/2). The alignment of the bins can be changed with the following command:
BinOffset: offsetIf this method is used with argument o, then each bin is centered at x = nw + o, and represents values in the range (x - w/2 + o, x + w/2 + o). So for example, if o = w/2, then each bin represents values from nw to (n + 1)w) for some integer n. The default offset is 0.5, half the default bin width.
To specify data to be plotted, start a data set with the following command:
DataSet: stringHere, string is a label that will appear in the legend. It is not necessary to enclose the string in quotation marks. To start a new dataset without giving it a name, use:
DataSet:In this case, no item will appear in the legend. New datasets are plotted behind the previous ones. The data itself is given by a sequence of numbers, one per line. The numbers are specified as strings that can be parsed by the Double parser in Java. It is also possible to specify the numbers using all the formats accepted by the Plot class, so that the same data may be plotted by both classes. The x data is ignored, and only the y data is used to calculate the histogram.
Inner classes inherited from class ptolemy.plot.PlotBox |
PlotBox.DragListener,
PlotBox.ZoomListener |
Field Summary | |
protected int |
_currentdataset
|
protected java.util.Vector |
_histogram
|
protected boolean |
_painted
|
protected java.util.Vector |
_points
|
Fields inherited from class ptolemy.plot.PlotBox |
_background,
_bottomPadding,
_colors,
_documentBase,
_foreground,
_grid,
_height,
_leftPadding,
_LOG10SCALE,
_lrx,
_lry,
_PADDING,
_rangesGivenByZooming,
_rightPadding,
_topPadding,
_ulx,
_uly,
_usecolor,
_width,
_wrap,
_xBottom,
_xhighgiven,
_xlog,
_xlowgiven,
_xMax,
_xMin,
_xRangeGiven,
_xscale,
_xTop,
_yBottom,
_yhighgiven,
_ylog,
_ylowgiven,
_yMax,
_yMin,
_yRangeGiven,
_yscale,
_yTop |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
Constructor Summary | |
Histogram()
|
Method Summary | |
protected void |
_checkDatasetIndex(int dataset)
Check the argument to ensure that it is a valid data set index. |
protected void |
_drawBar(java.awt.Graphics graphics,
int dataset,
long xpos,
long ypos,
boolean clip)
Draw bar from the specified point to the y axis. |
protected void |
_drawPlot(java.awt.Graphics graphics,
boolean clearfirst)
Draw the axes and then plot the histogram. |
protected boolean |
_parseLine(java.lang.String line)
Parse a line that gives plotting information. |
protected void |
_write(java.io.PrintWriter output)
Write plot information to the specified output stream. |
void |
addLegend(int dataset,
java.lang.String legend)
Add a legend (displayed at the upper right) for the specified data set with the specified string. |
void |
addPoint(int dataset,
double value)
In the specified data set, add the specified value to the histogram. |
void |
addPoint(int dataset,
double x,
double y,
boolean connected)
In the specified data set, add the specified y value to the histogram. |
void |
clear(boolean format)
Clear the plot of all data points. |
void |
samplePlot()
Create a sample plot. |
void |
setBars(double width,
double offset)
Set the width and offset of the bars. |
void |
setBinOffset(double offset)
Set the offset of the bins, in whatever units the data are given. |
void |
setBinWidth(double width)
Set the width of the bins, in whatever units the data are given. |
Methods inherited from class ptolemy.plot.PlotBox |
_drawPoint,
_help,
_setButtonsVisibility,
_writeOldSyntax,
addXTick,
addYTick,
export,
fillPlot,
getColor,
getColorByName,
getDataurl,
getDocumentBase,
getGrid,
getLegend,
getMinimumSize,
getPreferredSize,
getTitle,
getXLabel,
getXLog,
getXRange,
getXTicks,
getYLabel,
getYLog,
getYRange,
getYTicks,
init,
paint,
parseFile,
parseFile,
read,
read,
setBackground,
setBounds,
setButtons,
setColor,
setDataurl,
setDocumentBase,
setForeground,
setGrid,
setLabelFont,
setSize,
setTitle,
setTitleFont,
setWrap,
setXLabel,
setXLog,
setXRange,
setYLabel,
setYLog,
setYRange,
update,
write,
write,
writeOldSyntax,
zoom |
Methods inherited from class java.awt.Panel |
addNotify |
Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
countComponents,
deliverEvent,
doLayout,
findComponentAt,
findComponentAt,
getAlignmentX,
getAlignmentY,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getInsets,
getLayout,
getMaximumSize,
insets,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paintComponents,
paramString,
preferredSize,
print,
printComponents,
processContainerEvent,
processEvent,
remove,
remove,
removeAll,
removeContainerListener,
removeNotify,
setCursor,
setFont,
setLayout,
validate,
validateTree |
Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addPropertyChangeListener,
addPropertyChangeListener,
bounds,
checkImage,
checkImage,
coalesceEvents,
contains,
contains,
createImage,
createImage,
disable,
disableEvents,
dispatchEvent,
enable,
enable,
enableEvents,
enableInputMethods,
firePropertyChange,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentOrientation,
getCursor,
getDropTarget,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputContext,
getInputMethodRequests,
getLocale,
getLocation,
getLocation,
getLocationOnScreen,
getName,
getParent,
getPeer,
getSize,
getSize,
getToolkit,
getTreeLock,
getWidth,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
hide,
imageUpdate,
inside,
isDisplayable,
isDoubleBuffered,
isEnabled,
isFocusTraversable,
isLightweight,
isOpaque,
isShowing,
isValid,
isVisible,
keyDown,
keyUp,
list,
list,
list,
location,
lostFocus,
mouseDown,
mouseDrag,
mouseEnter,
mouseExit,
mouseMove,
mouseUp,
move,
nextFocus,
paintAll,
postEvent,
prepareImage,
prepareImage,
printAll,
processComponentEvent,
processFocusEvent,
processInputMethodEvent,
processKeyEvent,
processMouseEvent,
processMouseMotionEvent,
remove,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
resize,
resize,
setBounds,
setComponentOrientation,
setDropTarget,
setEnabled,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setVisible,
show,
show,
size,
toString,
transferFocus |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected int _currentdataset
protected java.util.Vector _points
protected java.util.Vector _histogram
protected boolean _painted
Constructor Detail |
public Histogram()
Method Detail |
public void addLegend(int dataset, java.lang.String legend)
dataset
- The dataset index.legend
- The label for the dataset.public void addPoint(int dataset, double value)
dataset
- The data set index.value
- The new value.public void addPoint(int dataset, double x, double y, boolean connected)
dataset
- The data set index.x
- Ignored.y
- The Y position of the new point.connected
- Ignoredpublic void clear(boolean format)
format
- If true, clear the format controls as well.public void samplePlot()
public void setBars(double width, double offset)
width
- The width of the bars.offset
- The offset per data set.public void setBinOffset(double offset)
offset
- The bin offset.public void setBinWidth(double width)
width
- The width of the bins.protected void _checkDatasetIndex(int dataset)
dataset
- The data set index.protected void _drawBar(java.awt.Graphics graphics, int dataset, long xpos, long ypos, boolean clip)
graphics
- The graphics context.dataset
- The index of the dataset.xpos
- The x position.ypos
- The y position.clip
- If true, then do not draw outside the range.protected void _drawPlot(java.awt.Graphics graphics, boolean clearfirst)
wait()
to prevent it plotting
points before the axes have been first drawn. If the second
argument is true, clear the display first.
This method is called by paint(). To cause it to be called you
would normally call repaint(), which eventually causes paint() to
be called.graphics
- The graphics context.clearfirst
- If true, clear the plot before proceeding.protected boolean _parseLine(java.lang.String line)
line
- A command line.protected void _write(java.io.PrintWriter output)
output
- A buffered print writer.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |