public class PlotBox extends javax.swing.JPanel implements java.awt.print.Printable, PlotBoxInterface
A title, X and Y axis labels, tick marks, and a legend are all supported. Zooming in and out is supported. To zoom in, click and hold mouse button 1 and drag the mouse downwards to draw a box. To zoom out, click and hold mouse button1 and drag the mouse upward.
The box can be configured either through a file with commands or through direct invocation of the public methods of the class.
When calling the methods, in most cases the changes will not be visible until paintComponent() has been called. To request that this be done, call repaint().
A small set of key bindings are provided for convenience. They are:
At this time, the two export commands produce encapsulated postscript tuned for black-and-white printers. In the future, more formats may supported. Exporting to the clipboard and to standard output, in theory, is allowed for applets, unlike writing to a file. Thus, these key bindings provide a simple mechanism to obtain a high-resolution image of the plot from an applet, suitable for incorporation in a document. However, in some browsers, exporting to standard out triggers a security violation. You can use the JDK appletviewer instead.
To read commands from a file or URL, the preferred technique is to use one of the classes in the plotml package. That package supports both PlotML, an XML extension for plots, and a historical file format specific to ptplot. The historical file format is understood by the read() method in this class. The syntax of the historical format, documented below, is rudimentary, and will probably not be extended as ptplot evolves. Nonetheless, we document it here since it is directly supported by this class.
The historical format for the file allows 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: stringThese 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, maxThe 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 and padded slightly so that datapoints are not plotted on the axes.
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.14159Tick marks could also denote years, months, days of the week, etc.
The X and Y axes can use a logarithmic scale with the following commands:
XLog: on YLog: onThe grid labels represent powers of 10. Note that if a logarithmic scale is used, then the values must be positive. Non-positive values will be silently dropped. Note further that when using logarithmic axes that the log of input data is taken as the data is added to the plot. This means that
XLog: onor
YLog: onshould appear before any data. Also, the value of the XTicks, YTicks, XRange or YRange directives should be in log units. So,
XTicks: 1K 3will display the string
1Kat the 1000 mark.
By default, tick marks are connected by a light grey background grid. This grid can be turned off with the following command:
Grid: offIt can be turned back on with
Grid: onAlso, 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: offIt can be turned back on with
Color: onFinally, the rather specialized command
Wrap: onenables wrapping of the X (horizontal) axis, which means that if a point is added with X out of range, its X value will be modified modulo the range so that it lies in range. This command only has an effect if the X range has been set explicitly. It is designed specifically to support oscilloscope-like behavior, where the X value of points is increasing, but the display wraps it around to left. A point that lands on the right edge of the X range is repeated on the left edge to give a better sense of continuity. The feature works best when points do land precisely on the edge, and are plotted from left to right, increasing in X.
All of the above commands can also be invoked directly by calling the the corresponding public methods from some Java procedure.
This class uses features of JDK 1.2, and hence if used in an applet, it can only be viewed by a browser that supports JDK 1.2, or a plugin.
Modifier and Type | Class and Description |
---|---|
(package private) class |
PlotBox.ButtonListener |
(package private) class |
PlotBox.CommandListener
Handle key pressed events.
|
class |
PlotBox.DragListener
Draw the zoom box.
|
class |
PlotBox.MoveListener
Move the items in the plot.
|
class |
PlotBox.MoveMotionListener
Track how the mouse with button 3 pressed is moved.
|
class |
PlotBox.ZoomListener
Handle mouse pressed events to provide zoom functionality.
|
class |
PlotBox.ZoomListener2
Zoom with the mouse wheel.
|
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
protected java.awt.Color |
_background
Color of the background, settable from HTML.
|
protected int |
_bottomPadding
Bottom padding.
|
protected static java.awt.Color[] |
_colors
The default colors, by data set.
|
java.net.URL |
_documentBase
The document base we use to find the _filespec.
|
protected java.awt.Color |
_foreground
Color of the foreground, settable from HTML.
|
protected boolean |
_grid
Whether to draw a background grid.
|
protected int |
_height
Width and height of component in pixels.
|
protected int |
_leftPadding
Left padding.
|
protected static double |
_LOG10SCALE
For use in calculating log base 10.
|
protected int |
_lrx
The x value of the lower right corner of
the plot rectangle in pixels.
|
protected int |
_lry
The y value of the lower right corner of
the plot rectangle in pixels.
|
(package private) double |
_originalXhigh |
(package private) double |
_originalXlow |
(package private) boolean |
_originalXRangeGiven |
(package private) double |
_originalYhigh |
(package private) double |
_originalYlow |
(package private) boolean |
_originalYRangeGiven |
protected double |
_padding
The factor we pad by so that we don't plot points on the axes.
|
protected java.awt.image.BufferedImage |
_plotImage
An offscreen buffer for improving plot performance.
|
protected int |
_preferredHeight
Width and height of component in pixels.
|
protected int |
_preferredWidth
Width and height of component in pixels.
|
protected boolean |
_rangesGivenByZooming
True if the ranges were given by zooming.
|
protected int |
_rightPadding
Right padding.
|
protected java.awt.Rectangle |
_specifiedPlotRectangle
User specified plot rectangle, null if none specified.
|
protected int |
_topPadding
Top padding.
|
protected int |
_ulx
The x value of the upper left corner of the plot rectangle in pixels.
|
protected int |
_uly
The y value of the upper left corner of the plot rectangle in pixels.
|
protected boolean |
_usecolor
Indicator whether to use _colors.
|
protected int |
_width
Width and height of component in pixels.
|
protected boolean |
_wrap
Whether to wrap the X axis.
|
protected double |
_wrapHigh
The high range of the X axis for wrapping.
|
protected double |
_wrapLow
The low range of the X axis for wrapping.
|
protected double |
_xBottom
The minimum X value registered so for, for auto ranging.
|
protected double |
_xhighgiven
The given X and Y ranges.
|
protected boolean |
_xlog
Whether to draw the axes using a logarithmic scale.
|
protected double |
_xlowgiven
The given X and Y ranges.
|
protected double |
_xMax
The maximum x value of the range of the data to be plotted.
|
protected double |
_xMin
The minimum y value of the range of the data to be plotted.
|
protected boolean |
_xRangeGiven
True if the x range have been given.
|
protected double |
_xscale
Scaling used for the horizontal axis in plotting points.
|
protected double |
_xTop
The maximum X value registered so for, for auto ranging.
|
protected double |
_yBottom
The minimum Y value registered so for, for auto ranging.
|
protected double |
_yhighgiven
The given X and Y ranges.
|
protected boolean |
_ylog
Whether to draw the axes using a logarithmic scale.
|
protected double |
_ylowgiven
The given X and Y ranges.
|
protected double |
_yMax
The maximum y value of the range of the data to be plotted.
|
protected double |
_yMin
The minimum y value of the range of the data to be plotted.
|
protected boolean |
_yRangeGiven
True if the y range have been given.
|
protected double |
_yscale
Scaling used for the vertical axis in plotting points.
|
protected double |
_yTop
The maximum Y value registered so for, for auto ranging.
|
static java.lang.String |
PTPLOT_RELEASE
The version of PtPlot.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
PlotBox()
Construct a plot box with a default configuration.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
_automaticRescale()
Return whether rescaling of the plot should happen
automatic.
|
protected void |
_drawPlot(java.awt.Graphics graphics,
boolean clearfirst)
Draw the axes using the current range, label, and title information.
|
protected void |
_drawPlot(java.awt.Graphics graphics,
boolean clearfirst,
java.awt.Rectangle drawRect)
Draw the axes using the current range, label, and title information,
at the size of the specified rectangle.
|
protected void |
_drawPoint(java.awt.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.
|
protected java.lang.String |
_exportLatexPlotData()
Return Latex plot data.
|
protected void |
_help()
Display basic information in its own window.
|
protected boolean |
_parseLine(java.lang.String line)
Parse a line that gives plotting information.
|
protected void |
_resetScheduledTasks()
Reset a scheduled redraw tasks.
|
protected void |
_scheduledRedraw()
Perform a scheduled redraw.
|
protected void |
_setButtonsVisibility(boolean visibility)
Deprecated.
Use #setButtons(boolean) instead.
|
protected void |
_setPadding(double padding)
Set the padding multiple.
|
protected boolean |
_timedRepaint()
Return whether repainting happens by a timed thread.
|
protected void |
_writeOldSyntax(java.io.PrintWriter output)
Deprecated.
|
(package private) void |
_zoom(int x,
int y) |
(package private) void |
_zoomBox(int x,
int y) |
(package private) void |
_zoomStart(int x,
int y) |
void |
addCaptionLine(java.lang.String captionLine)
Add a line to the caption (displayed at below graph) .
|
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 |
addXTick(java.lang.String label,
double position)
Specify a tick mark for the X axis.
|
void |
addYTick(java.lang.String label,
double position)
Specify a tick mark for the Y axis.
|
void |
clear(boolean axes)
If the argument is true, clear the axes.
|
void |
clearCaptions()
Clear all the captions.
|
void |
clearLegends()
Clear all legends.
|
void |
deferIfNecessary(java.lang.Runnable action)
If this method is called in the event thread, then simply
execute the specified action.
|
void |
destroy()
Destroy the plotter.
|
void |
export(java.io.OutputStream out)
Export a EPS description of the plot.
|
java.awt.image.BufferedImage |
exportImage()
Create a BufferedImage and draw this plot to it.
|
java.awt.image.BufferedImage |
exportImage(java.awt.image.BufferedImage bufferedImage)
Draw this plot onto the provided image.
|
java.awt.image.BufferedImage |
exportImage(java.awt.image.BufferedImage bufferedImage,
java.awt.Rectangle rectangle,
java.awt.RenderingHints hints,
boolean transparent)
Draw this plot onto the specified image at the position of the
specified rectangle with the size of the specified rectangle.
|
void |
exportImage(java.io.OutputStream out,
java.lang.String formatName)
Export an image of the plot in the specified format.
|
java.awt.image.BufferedImage |
exportImage(java.awt.Rectangle rectangle)
Create a BufferedImage the size of the given rectangle and draw
this plot to it at the position specified by the rectangle.
|
void |
exportLatex(java.io.File directory)
Export a Latex description of the plot.
|
void |
fillPlot()
Rescale so that the data that is currently plotted just fits.
|
java.util.Vector |
getCaptions()
Get the captions.
|
boolean |
getColor()
Return whether the plot uses color.
|
static java.awt.Color |
getColorByName(java.lang.String name)
Convert a color name into a Color.
|
java.awt.Color[] |
getColors()
Get the point colors.
|
java.lang.String |
getDataurl()
Deprecated.
Use read() instead.
|
java.net.URL |
getDocumentBase()
Deprecated.
Use read() instead.
|
boolean |
getGrid()
Return whether the grid is drawn.
|
java.lang.String |
getLegend(int dataset)
Get the legend for a dataset, or null if there is none.
|
int |
getLegendDataset(java.lang.String legend)
Given a legend string, return the corresponding dataset or -1 if no
legend was added with that legend string
The legend would have been set by addLegend().
|
java.awt.Rectangle |
getPlotRectangle()
Get the current plot rectangle.
|
java.awt.Dimension |
getPreferredSize()
Get the preferred size of this component.
|
java.lang.String |
getTitle()
Get the title of the graph, or an empty string if there is none.
|
double[] |
getXAutoRange()
Get the range for X values of the data points registered so far.
|
java.lang.String |
getXLabel()
Get the label for the X (horizontal) axis, or null if none has
been set.
|
boolean |
getXLog()
Return whether the X axis is drawn with a logarithmic scale.
|
double[] |
getXRange()
Get the X range.
|
java.util.Vector[] |
getXTicks()
Get the X ticks that have been specified, or null if none.
|
double[] |
getYAutoRange()
Get the range for Y values of the data points registered so far.
|
java.lang.String |
getYLabel()
Get the label for the Y (vertical) axis, or null if none has
been set.
|
boolean |
getYLog()
Return whether the Y axis is drawn with a logarithmic scale.
|
double[] |
getYRange()
Get the Y range.
|
java.util.Vector[] |
getYTicks()
Get the Y ticks that have been specified, or null if none.
|
void |
init()
Deprecated.
|
void |
paintComponent(java.awt.Graphics graphics)
Paint the component contents, which in this base class is
only the axes.
|
void |
parseFile(java.lang.String filespec)
Deprecated.
Use read() to read the old file
format, or use one of the classes in the plotml package to
read the XML-based file format.
|
void |
parseFile(java.lang.String filespec,
java.net.URL documentBase)
Deprecated.
Use read() instead.
|
int |
print(java.awt.Graphics graphics,
java.awt.print.PageFormat format,
int index)
Print the plot to a printer, represented by the specified graphics
object.
|
void |
read(java.io.InputStream in)
Read commands and/or plot data from an input stream in the old
(non-XML) file syntax.
|
void |
read(java.lang.String command)
Read a single line command provided as a string.
|
void |
removeLegend(int dataset)
Remove the legend (displayed at the upper right) for the specified
data set.
|
void |
renameLegend(int dataset,
java.lang.String newName)
Rename a legend.
|
void |
resetAxes()
Reset the X and Y axes to the ranges that were first specified
using setXRange() and setYRange().
|
void |
samplePlot()
Do nothing in this base class.
|
void |
setAutomaticRescale(boolean automaticRescale)
Set automatic rescale.
|
void |
setBackground(java.awt.Color background)
Set the background color.
|
void |
setBackground(java.lang.Object background)
Set the background color.
|
void |
setBounds(int x,
int y,
int width,
int height)
Move and resize this component.
|
void |
setButtons(boolean visible)
If the argument is true, make a fill button visible at the upper
right.
|
void |
setCaptions(java.util.Vector captionStrings)
Set the strings of the caption.
|
void |
setColor(boolean useColor)
If the argument is false, draw the plot without using color
(in black and white).
|
void |
setColors(java.awt.Color[] colors)
Set the point colors.
|
void |
setColors(java.lang.Object[] colors)
Set the array of colors
Implements the
PlotBoxInterface . |
void |
setDataurl(java.lang.String filespec)
Deprecated.
Use read() instead.
|
void |
setDocumentBase(java.net.URL documentBase)
Deprecated.
Use read() instead.
|
void |
setForeground(java.awt.Color foreground)
Set the foreground color.
|
void |
setForeground(java.lang.Object foreground)
Set the foreground color.
|
void |
setGrid(boolean grid)
Control whether the grid is drawn.
|
void |
setLabelFont(java.lang.String name)
Set the label font, which is used for axis labels and legend labels.
|
void |
setPlotRectangle(java.lang.Object rectangle)
Set the plot rectangle.
|
void |
setPlotRectangle(java.awt.Rectangle rectangle)
Set the plot rectangle inside the axes.
|
void |
setSize(int width,
int height)
Set the size of the plot.
|
void |
setTimedRepaint(boolean timedRepaint)
Set repainting with a certain fixed refresh rate.
|
void |
setTitle(java.lang.String title)
Set the title of the graph.
|
void |
setTitleFont(java.lang.String name)
Set the title font.
|
void |
setWrap(boolean wrap)
Specify whether the X axis is wrapped.
|
void |
setXLabel(java.lang.String label)
Set the label for the X (horizontal) axis.
|
void |
setXLog(boolean xlog)
Specify whether the X axis is drawn with a logarithmic scale.
|
void |
setXRange(double min,
double max)
Set the X (horizontal) range of the plot.
|
void |
setYLabel(java.lang.String label)
Set the label for the Y (vertical) axis.
|
void |
setYLog(boolean ylog)
Specify whether the Y axis is drawn with a logarithmic scale.
|
void |
setYRange(double min,
double max)
Set the Y (vertical) range of the plot.
|
void |
write(java.io.OutputStream out)
Write the current data and plot configuration to the specified
stream in PlotML syntax.
|
void |
write(java.io.OutputStream out,
java.lang.String dtd)
Write the current data and plot configuration to the
specified stream in PlotML syntax.
|
void |
write(java.io.Writer out,
java.lang.String dtd)
Write the current data and plot configuration to the
specified stream in PlotML syntax.
|
void |
writeData(java.io.PrintWriter output)
Write plot data information to the specified output stream in PlotML.
|
void |
writeFormat(java.io.PrintWriter output)
Write plot format information to the specified output stream in PlotML.
|
void |
writeOldSyntax(java.io.OutputStream out)
Deprecated.
|
void |
zoom(double lowx,
double lowy,
double highx,
double highy)
Zoom in or out to the specified rectangle.
|
void |
zoomEqual()
Zoom to that equal interval widths are on x and y axis.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
repaint
public static final java.lang.String PTPLOT_RELEASE
protected transient volatile double _yMax
protected transient volatile double _yMin
protected transient volatile double _xMax
protected transient volatile double _xMin
protected volatile double _padding
protected transient java.awt.image.BufferedImage _plotImage
protected transient boolean _xRangeGiven
protected transient boolean _yRangeGiven
protected transient boolean _rangesGivenByZooming
protected double _xlowgiven
protected double _xhighgiven
protected double _ylowgiven
protected double _yhighgiven
protected double _xBottom
protected double _xTop
protected double _yBottom
protected double _yTop
protected boolean _xlog
protected boolean _ylog
protected static final double _LOG10SCALE
protected boolean _grid
protected boolean _wrap
protected double _wrapHigh
protected double _wrapLow
protected java.awt.Color _background
protected java.awt.Color _foreground
protected int _topPadding
protected int _bottomPadding
protected int _rightPadding
protected int _leftPadding
protected int _ulx
protected int _uly
protected int _lrx
protected int _lry
protected java.awt.Rectangle _specifiedPlotRectangle
setPlotRectangle(Rectangle)
protected double _yscale
protected double _xscale
protected volatile boolean _usecolor
protected static java.awt.Color[] _colors
protected int _width
protected int _height
protected int _preferredWidth
protected int _preferredHeight
public java.net.URL _documentBase
boolean _originalXRangeGiven
boolean _originalYRangeGiven
double _originalXlow
double _originalXhigh
double _originalYlow
double _originalYhigh
public void addCaptionLine(java.lang.String captionLine)
addCaptionLine
in interface PlotBoxInterface
captionLine
- The string to be added.getCaptions()
public void addLegend(int dataset, java.lang.String legend)
addLegend
in interface PlotBoxInterface
dataset
- The dataset index.legend
- The label for the dataset.renameLegend(int, String)
public void addXTick(java.lang.String label, double position)
Note that if setXLog(boolean)
has been called, then
the position value should be in log units.
So, addXTick("1K", 3) will display the string
1Kat the 1000 mark.
addXTick
in interface PlotBoxInterface
label
- The label for the tick mark.position
- The position on the X axis.public void addYTick(java.lang.String label, double position)
Note that if setYLog(boolean)
has been called, then
the position value should be in log units.
So, addYTick("1K", 3) will display the string
1Kat the 1000 mark.
addYTick
in interface PlotBoxInterface
label
- The label for the tick mark.position
- The position on the Y axis.public void clear(boolean axes)
clear
in interface PlotBoxInterface
axes
- If true, clear the axes parameters.public void clearCaptions()
clearCaptions
in interface PlotBoxInterface
setCaptions(Vector)
public void clearLegends()
clearLegends
in interface PlotBoxInterface
public void deferIfNecessary(java.lang.Runnable action)
deferIfNecessary
in interface PlotBoxInterface
action
- The Runnable object to execute.public void destroy()
destroy
in interface PlotBoxInterface
public void export(java.io.OutputStream out)
System.out
as an argument.out
- An output stream to which to send the description.public java.awt.image.BufferedImage exportImage()
public java.awt.image.BufferedImage exportImage(java.awt.Rectangle rectangle)
rectangle
- The size of the plot. This method can be used, for
example, by a servlet to produce an image, rather than
requiring an applet to instantiate a PlotBox.public java.awt.image.BufferedImage exportImage(java.awt.image.BufferedImage bufferedImage, java.awt.Rectangle rectangle, java.awt.RenderingHints hints, boolean transparent)
bufferedImage
- Image onto which the plot is drawn.rectangle
- The size and position of the plot in the image.hints
- Rendering hints for this plot.transparent
- Indicator that the background of the plot
should not be painted.public java.awt.image.BufferedImage exportImage(java.awt.image.BufferedImage bufferedImage)
bufferedImage
- The image onto which to render the plot.public void exportLatex(java.io.File directory)
directory
- An directory to which to export the Latex.public void exportImage(java.io.OutputStream out, java.lang.String formatName)
out
- An output stream to which to send the description.formatName
- A format name, such as "gif" or "png".public void fillPlot()
fillPlot
in interface PlotBoxInterface
public java.util.Vector getCaptions()
getCaptions
in interface PlotBoxInterface
addCaptionLine(String)
,
setCaptions(Vector)
public boolean getColor()
getColor
in interface PlotBoxInterface
setColor(boolean)
public java.awt.Color[] getColors()
getColors
in interface PlotBoxInterface
setColors(Color[])
public static java.awt.Color getColorByName(java.lang.String name)
name
- A color name, or null if not found.@Deprecated public java.lang.String getDataurl()
getDataurl
in interface PlotBoxInterface
setDataurl(String)
@Deprecated public java.net.URL getDocumentBase()
getDocumentBase
in interface PlotBoxInterface
setDocumentBase(URL)
public boolean getGrid()
getGrid
in interface PlotBoxInterface
setGrid(boolean)
public java.lang.String getLegend(int dataset)
getLegend
in interface PlotBoxInterface
dataset
- The dataset index.public int getLegendDataset(java.lang.String legend)
getLegendDataset
in interface PlotBoxInterface
legend
- The String naming the legendpublic java.awt.Rectangle getPlotRectangle()
_ulx
, _uly
,
_lrx
and _lry
. The value passed in by
setPlotRectangle() is not directly used, thus calling
getPlotRectangle() may not return the same rectangle that
was passed in with setPlotRectangle().getPlotRectangle
in interface PlotBoxInterface
setPlotRectangle(Rectangle)
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public java.lang.String getTitle()
getTitle
in interface PlotBoxInterface
setTitle(String)
public double[] getXAutoRange()
getXAutoRange
in interface PlotBoxInterface
getXRange()
public java.lang.String getXLabel()
getXLabel
in interface PlotBoxInterface
setXLabel(String)
public boolean getXLog()
getXLog
in interface PlotBoxInterface
setXLog(boolean)
public double[] getXRange()
setXRange(double, double)
has been
called, then this method returns the values passed in as
arguments to setXRange(double, double). If setXRange(double,
double) has not been called, then this method returns the
range of the data to be plotted, which might not be all of the
data due to zooming.getXRange
in interface PlotBoxInterface
getXAutoRange()
,
setXRange(double, double)
public java.util.Vector[] getXTicks()
getXTicks
in interface PlotBoxInterface
public double[] getYAutoRange()
getYAutoRange
in interface PlotBoxInterface
getYRange()
public java.lang.String getYLabel()
getYLabel
in interface PlotBoxInterface
setYLabel(String)
public boolean getYLog()
getYLog
in interface PlotBoxInterface
setYLog(boolean)
public double[] getYRange()
setYRange(double, double)
has been
called, then this method returns the values passed in as
arguments to setYRange(double, double). If setYRange(double,
double) has not been called, then this method returns the
range of the data to be plotted, which might not be all of the
data due to zooming.getYRange
in interface PlotBoxInterface
getYAutoRange()
,
setYRange(double, double)
public java.util.Vector[] getYTicks()
getYTicks
in interface PlotBoxInterface
@Deprecated public void init()
init
in interface PlotBoxInterface
public void paintComponent(java.awt.Graphics graphics)
paintComponent
in class javax.swing.JComponent
graphics
- The graphics context.@Deprecated public void parseFile(java.lang.String filespec)
parseFile
in interface PlotBoxInterface
filespec
- The file to be read.@Deprecated public void parseFile(java.lang.String filespec, java.net.URL documentBase)
parseFile
in interface PlotBoxInterface
filespec
- The file to be read.documentBase
- The base of the URLpublic int print(java.awt.Graphics graphics, java.awt.print.PageFormat format, int index) throws java.awt.print.PrinterException
print
in interface java.awt.print.Printable
graphics
- The context into which the page is drawn.format
- The size and orientation of the page being drawn.index
- The zero based index of the page to be drawn.java.awt.print.PrinterException
- If the print job is terminated.public void read(java.io.InputStream in) throws java.io.IOException
To read from standard input, use:
read(System.in);To read from a url, use:
read(url.openStream());To read a URL from within an applet, use:
URL url = new URL(getDocumentBase(), urlSpec); read(url.openStream());Within an application, if you have an absolute URL, use:
URL url = new URL(urlSpec); read(url.openStream());To read from a file, use:
read(new FileInputStream(filename));
read
in interface PlotBoxInterface
in
- The input stream.java.io.IOException
- If the stream cannot be read.public void read(java.lang.String command)
read
in interface PlotBoxInterface
command
- A command.public void removeLegend(int dataset)
removeLegend
in interface PlotBoxInterface
dataset
- The dataset index.public void renameLegend(int dataset, java.lang.String newName)
renameLegend
in interface PlotBoxInterface
dataset
- The dataset of the legend to be renamed.
If there is no dataset with this value, then nothing happens.newName
- The new name of legend.addLegend(int, String)
public void resetAxes()
resetAxes
in interface PlotBoxInterface
public void samplePlot()
samplePlot
in interface PlotBoxInterface
public void setAutomaticRescale(boolean automaticRescale)
setAutomaticRescale
in interface PlotBoxInterface
automaticRescale
- The boolean that specifies whether
plots should be automatic rescaled.public void setBackground(java.awt.Color background)
setBackground
in class javax.swing.JComponent
background
- The background color.public void setBackground(java.lang.Object background)
PlotBoxInterface
.setBackground
in interface PlotBoxInterface
background
- The background Color.public void setBounds(int x, int y, int width, int height)
setBounds
in class java.awt.Component
x
- The new x-coordinate of this component.y
- The new y-coordinate of this component.width
- The new width of this component.height
- The new height of this component.public void setButtons(boolean visible)
setButtons
in interface PlotBoxInterface
visible
- If true, make the fill button appear.destroy()
public void setCaptions(java.util.Vector captionStrings)
setCaptions
in interface PlotBoxInterface
captionStrings
- A Vector where each element contains a String
that is one line of the caption.getCaptions()
,
clearCaptions()
public void setColor(boolean useColor)
setColor
in interface PlotBoxInterface
useColor
- False to draw in back and white.getColor()
public void setColors(java.awt.Color[] colors)
colors
- Array of colors to use in succession for data sets.getColors()
public void setColors(java.lang.Object[] colors)
PlotBoxInterface
.setColors
in interface PlotBoxInterface
colors
- The array of Colors.getColors()
@Deprecated public void setDataurl(java.lang.String filespec)
setDataurl
in interface PlotBoxInterface
filespec
- the file to be readgetDataurl()
@Deprecated public void setDocumentBase(java.net.URL documentBase)
setDocumentBase
in interface PlotBoxInterface
documentBase
- The document base to be used.getDocumentBase()
public void setForeground(java.awt.Color foreground)
setForeground
in class javax.swing.JComponent
foreground
- The foreground color.public void setForeground(java.lang.Object foreground)
PlotBoxInterface
.setForeground
in interface PlotBoxInterface
foreground
- The foreground Color.public void setGrid(boolean grid)
setGrid
in interface PlotBoxInterface
grid
- If true, a grid is drawn.getGrid()
public void setLabelFont(java.lang.String name)
setLabelFont
in interface PlotBoxInterface
name
- A font name.public void setPlotRectangle(java.awt.Rectangle rectangle)
rectangle
- Rectangle space inside axes.getPlotRectangle()
public void setPlotRectangle(java.lang.Object rectangle)
PlotBoxInterface
.setPlotRectangle
in interface PlotBoxInterface
rectangle
- The Rectangle.getPlotRectangle()
public void setSize(int width, int height)
setSize
in interface PlotBoxInterface
setSize
in class java.awt.Component
width
- The width, in pixels.height
- The height, in pixels.public void setTimedRepaint(boolean timedRepaint)
setTimedRepaint
in interface PlotBoxInterface
timedRepaint
- The boolean that specifies whether
repainting should happen with a certain fixed refresh rate.public void setTitle(java.lang.String title)
setTitle
in interface PlotBoxInterface
title
- The title.getTitle()
public void setTitleFont(java.lang.String name)
setTitleFont
in interface PlotBoxInterface
name
- A font name.public void setWrap(boolean wrap)
setWrap
in interface PlotBoxInterface
wrap
- If true, wrapping of the X axis is enabled.public void setXLabel(java.lang.String label)
setXLabel
in interface PlotBoxInterface
label
- The label.getXLabel()
public void setXLog(boolean xlog)
setXLog
in interface PlotBoxInterface
xlog
- If true, logarithmic axis is used.getXLog()
public void setXRange(double min, double max)
Note that if setXLog(boolean)
has been called, then
the min and max values should be in log units.
setXRange
in interface PlotBoxInterface
min
- The left extent of the range.max
- The right extent of the range.getXRange()
public void setYLabel(java.lang.String label)
setYLabel
in interface PlotBoxInterface
label
- The label.getYLabel()
public void setYLog(boolean ylog)
setYLog
in interface PlotBoxInterface
ylog
- If true, logarithmic axis is used.getYLog()
public void setYRange(double min, double max)
Note that if setYLog(boolean)
has been called, then
the min and max values should be in log units.
setYRange
in interface PlotBoxInterface
min
- The bottom extent of the range.max
- The top extent of the range.getYRange()
public void write(java.io.OutputStream out)
write
in interface PlotBoxInterface
out
- An output stream.public void write(java.io.OutputStream out, java.lang.String dtd)
write
in interface PlotBoxInterface
out
- An output stream.dtd
- The reference (URL) for the DTD, or null to use the
PUBLIC DTD.public void write(java.io.Writer out, java.lang.String dtd)
write
in interface PlotBoxInterface
out
- An output writer.dtd
- The reference (URL) for the DTD, or null to use the
PUBLIC DTD.public void writeData(java.io.PrintWriter output)
writeData
in interface PlotBoxInterface
output
- A buffered print writer.public void writeFormat(java.io.PrintWriter output)
writeFormat
in interface PlotBoxInterface
output
- A buffered print writer.@Deprecated public void writeOldSyntax(java.io.OutputStream out)
writeOldSyntax
in interface PlotBoxInterface
out
- An output stream.public void zoom(double lowx, double lowy, double highx, double highy)
zoom
in interface PlotBoxInterface
lowx
- The low end of the new X range.lowy
- The low end of the new Y range.highx
- The high end of the new X range.highy
- The high end of the new Y range.protected boolean _automaticRescale()
protected void _drawPlot(java.awt.Graphics graphics, boolean clearfirst)
Note that this is synchronized so that points are not added by other threads while the drawing is occurring. This method should be called only from the event dispatch thread, consistent with swing policy.
graphics
- The graphics context.clearfirst
- If true, clear the plot before proceeding.protected void _drawPlot(java.awt.Graphics graphics, boolean clearfirst, java.awt.Rectangle drawRect)
Note that this is synchronized so that points are not added by other threads while the drawing is occurring. This method should be called only from the event dispatch thread, consistent with swing policy.
graphics
- The graphics context.clearfirst
- If true, clear the plot before proceeding.drawRect
- A specification of the size.protected void _drawPoint(java.awt.Graphics graphics, int dataset, long xpos, long ypos, boolean clip)
true
, states
that the point should not be drawn if
it is out of range.
Note that this method is not synchronized, so the caller should be.
Moreover this method should always be called from the event thread
when being used to write to the screen.graphics
- The graphics context.dataset
- The index of the data set.xpos
- The X position.ypos
- The Y position.clip
- If true, do not draw if out of range.protected java.lang.String _exportLatexPlotData()
protected void _help()
protected boolean _parseLine(java.lang.String line)
line
- A line of text.protected void _resetScheduledTasks()
protected void _scheduledRedraw()
@Deprecated protected void _setButtonsVisibility(boolean visibility)
visibility
- True if the fill button is to be visible.protected void _setPadding(double padding)
padding
- The padding multiple.protected boolean _timedRepaint()
@Deprecated protected void _writeOldSyntax(java.io.PrintWriter output)
output
- A buffered print writer.void _zoom(int x, int y)
public void zoomEqual()
void _zoomBox(int x, int y)
void _zoomStart(int x, int y)