Package ptolemy.plot

Class PlotBox

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, javax.accessibility.Accessible, PlotBoxInterface
    Direct Known Subclasses:
    Histogram, Plot

    public class PlotBox
    extends javax.swing.JPanel
    implements java.awt.print.Printable, PlotBoxInterface
    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, 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:

    • Cntrl-c: Export the plot to the clipboard (in PlotML).
    • D: Dump the plot to standard output (in PlotML).
    • E: Export the plot to standard output in EPS format.
    • F: Fill the plot.
    • H or ?: Display a simple help message.
    • Cntrl-D or Q: quit
    These commands are provided in a menu by the PlotFrame class. Note that exporting to the clipboard is not allowed in applets (it used to be), so this will result in an error message.

    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: 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 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.14159
     
    Tick 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: on
     
    The 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: on
    or
    YLog: on
    should appear before any data. Also, the value of the XTicks, YTicks, XRange or YRange directives should be in log units. So,
    XTicks: 1K 3
    will display the string
    1K
    at 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: 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
     
    Finally, the rather specialized command
     Wrap: on
     
    enables 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.

    Since:
    Ptolemy II 0.2
    Version:
    $Id$
    Author:
    Edward A. Lee, Christopher Brooks, Contributors: Jun Wu (jwu@inin.com.au), William Wu, Robert Kroeger, Tom Peachey, Bert Rodiers, Dirk Bueche
    See Also:
    Serialized Form
    Pt.AcceptedRating:
    Yellow (cxh)
    Pt.ProposedRating:
    Yellow (cxh)
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      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.
      • Nested classes/interfaces inherited from class javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field 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.
      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.
      • Fields inherited from class javax.swing.JComponent

        listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
      • Fields inherited from class java.awt.Component

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
      • Fields inherited from interface java.awt.print.Printable

        NO_SUCH_PAGE, PAGE_EXISTS
    • Constructor Summary

      Constructors 
      Constructor Description
      PlotBox()
      Construct a plot box with a default configuration.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method 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. 
      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.
      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 exportImage​(java.io.OutputStream out, java.lang.String formatName)
      Export an image of the plot in the specified format.
      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.awt.Rectangle rectangle)
      Set the plot rectangle inside the axes.
      void setPlotRectangle​(java.lang.Object rectangle)
      Set the plot rectangle.
      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.
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
      • Methods inherited from class javax.swing.JComponent

        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
      • Methods inherited from class java.awt.Container

        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
      • Methods inherited from class java.awt.Component

        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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • PTPLOT_RELEASE

        public static final java.lang.String PTPLOT_RELEASE
        The version of PtPlot.
        See Also:
        Constant Field Values
      • _yMax

        protected transient volatile double _yMax
        The maximum y value of the range of the data to be plotted.
      • _yMin

        protected transient volatile double _yMin
        The minimum y value of the range of the data to be plotted.
      • _xMax

        protected transient volatile double _xMax
        The maximum x value of the range of the data to be plotted.
      • _xMin

        protected transient volatile double _xMin
        The minimum y value of the range of the data to be plotted.
      • _padding

        protected volatile double _padding
        The factor we pad by so that we don't plot points on the axes.
      • _plotImage

        protected transient java.awt.image.BufferedImage _plotImage
        An offscreen buffer for improving plot performance.
      • _xRangeGiven

        protected transient boolean _xRangeGiven
        True if the x range have been given.
      • _yRangeGiven

        protected transient boolean _yRangeGiven
        True if the y range have been given.
      • _rangesGivenByZooming

        protected transient boolean _rangesGivenByZooming
        True if the ranges were given by zooming.
      • _xlowgiven

        protected double _xlowgiven
        The given X and Y ranges. If they have been given the top and bottom of the x and y ranges. This is different from _xMin and _xMax, which actually represent the range of data that is plotted. This represents the range specified (which may be different due to zooming).
      • _xhighgiven

        protected double _xhighgiven
        The given X and Y ranges. If they have been given the top and bottom of the x and y ranges. This is different from _xMin and _xMax, which actually represent the range of data that is plotted. This represents the range specified (which may be different due to zooming).
      • _ylowgiven

        protected double _ylowgiven
        The given X and Y ranges. If they have been given the top and bottom of the x and y ranges. This is different from _xMin and _xMax, which actually represent the range of data that is plotted. This represents the range specified (which may be different due to zooming).
      • _yhighgiven

        protected double _yhighgiven
        The given X and Y ranges. If they have been given the top and bottom of the x and y ranges. This is different from _xMin and _xMax, which actually represent the range of data that is plotted. This represents the range specified (which may be different due to zooming).
      • _xBottom

        protected double _xBottom
        The minimum X value registered so for, for auto ranging.
      • _xTop

        protected double _xTop
        The maximum X value registered so for, for auto ranging.
      • _yBottom

        protected double _yBottom
        The minimum Y value registered so for, for auto ranging.
      • _yTop

        protected double _yTop
        The maximum Y value registered so for, for auto ranging.
      • _xlog

        protected boolean _xlog
        Whether to draw the axes using a logarithmic scale.
      • _ylog

        protected boolean _ylog
        Whether to draw the axes using a logarithmic scale.
      • _LOG10SCALE

        protected static final double _LOG10SCALE
        For use in calculating log base 10. A log times this is a log base 10.
      • _grid

        protected boolean _grid
        Whether to draw a background grid.
      • _wrap

        protected boolean _wrap
        Whether to wrap the X axis.
      • _wrapHigh

        protected double _wrapHigh
        The high range of the X axis for wrapping.
      • _wrapLow

        protected double _wrapLow
        The low range of the X axis for wrapping.
      • _background

        protected java.awt.Color _background
        Color of the background, settable from HTML.
      • _foreground

        protected java.awt.Color _foreground
        Color of the foreground, settable from HTML.
      • _topPadding

        protected int _topPadding
        Top padding. Derived classes can increment these to make space around the plot.
      • _bottomPadding

        protected int _bottomPadding
        Bottom padding. Derived classes can increment these to make space around the plot.
      • _rightPadding

        protected int _rightPadding
        Right padding. Derived classes can increment these to make space around the plot.
      • _leftPadding

        protected int _leftPadding
        Left padding. Derived classes can increment these to make space around the plot.
      • _ulx

        protected int _ulx
        The x value of the upper left corner of the plot rectangle in pixels. Given a mouse click at x0, to convert to data coordinates, use: (_xMin + (x0 - _ulx) / _xscale).
      • _uly

        protected int _uly
        The y value of the upper left corner of the plot rectangle in pixels. Given a mouse click at y0, to convert to data coordinates, use: (_yMax - (y0 - _uly) / _yscale).
      • _lrx

        protected int _lrx
        The x value of the lower right corner of the plot rectangle in pixels.
      • _lry

        protected int _lry
        The y value of the lower right corner of the plot rectangle in pixels.
      • _specifiedPlotRectangle

        protected java.awt.Rectangle _specifiedPlotRectangle
        User specified plot rectangle, null if none specified.
        See Also:
        setPlotRectangle(Rectangle)
      • _yscale

        protected double _yscale
        Scaling used for the vertical axis in plotting points. The units are pixels/unit, where unit is the units of the Y axis.
      • _xscale

        protected double _xscale
        Scaling used for the horizontal axis in plotting points. The units are pixels/unit, where unit is the units of the X axis.
      • _usecolor

        protected volatile boolean _usecolor
        Indicator whether to use _colors.
      • _colors

        protected static java.awt.Color[] _colors
        The default colors, by data set. There are 11 colors so that combined with the 10 marks of the Plot class, we can distinguish 110 distinct data sets.
      • _width

        protected int _width
        Width and height of component in pixels.
      • _height

        protected int _height
        Width and height of component in pixels.
      • _preferredWidth

        protected int _preferredWidth
        Width and height of component in pixels.
      • _preferredHeight

        protected int _preferredHeight
        Width and height of component in pixels.
      • _documentBase

        public java.net.URL _documentBase
        The document base we use to find the _filespec. NOTE: Use of this variable is deprecated. But it is made available to derived classes for backward compatibility. FIXME: Sun's appletviewer gives an exception if this is protected. Why?? So we make it temporarily public.
    • Constructor Detail

      • PlotBox

        public PlotBox()
        Construct a plot box with a default configuration.
    • Method Detail

      • addCaptionLine

        public void addCaptionLine​(java.lang.String captionLine)
        Add a line to the caption (displayed at below graph) .
        Specified by:
        addCaptionLine in interface PlotBoxInterface
        Parameters:
        captionLine - The string to be added.
        See Also:
        getCaptions()
      • addLegend

        public 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. Short strings generally fit better than long strings. If the string is empty, or the argument is null, then no legend is added.
        Specified by:
        addLegend in interface PlotBoxInterface
        Parameters:
        dataset - The dataset index.
        legend - The label for the dataset.
        See Also:
        renameLegend(int, String)
      • addXTick

        public void addXTick​(java.lang.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.

        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

        1K
        at the 1000 mark.
        Specified by:
        addXTick in interface PlotBoxInterface
        Parameters:
        label - The label for the tick mark.
        position - The position on the X axis.
      • addYTick

        public void addYTick​(java.lang.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.

        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

        1K
        at the 1000 mark.
        Specified by:
        addYTick in interface PlotBoxInterface
        Parameters:
        label - The label for the tick mark.
        position - The position on the Y axis.
      • clear

        public void clear​(boolean axes)
        If the argument is true, clear the axes. I.e., set all parameters controlling the axes to their initial conditions. For the change to take effect, call repaint(). If the argument is false, do nothing.
        Specified by:
        clear in interface PlotBoxInterface
        Parameters:
        axes - If true, clear the axes parameters.
      • clearLegends

        public void clearLegends()
        Clear all legends. This will show up on the next redraw.
        Specified by:
        clearLegends in interface PlotBoxInterface
      • deferIfNecessary

        public void deferIfNecessary​(java.lang.Runnable action)
        If this method is called in the event thread, then simply execute the specified action. Otherwise, if there are already deferred actions, then add the specified one to the list. Otherwise, create a list of deferred actions, if necessary, and request that the list be processed in the event dispatch thread. Note that it does not work nearly as well to simply schedule the action yourself on the event thread because if there are a large number of actions, then the event thread will not be able to keep up. By grouping these actions, we avoid this problem. This method is not synchronized, so the caller should be.
        Specified by:
        deferIfNecessary in interface PlotBoxInterface
        Parameters:
        action - The Runnable object to execute.
      • destroy

        public void destroy()
        Destroy the plotter. This method is usually called by PlotApplet.destroy(). It does various cleanups to reduce memory usage.
        Specified by:
        destroy in interface PlotBoxInterface
      • export

        public void export​(java.io.OutputStream out)
        Export a EPS description of the plot. If the argument is null, then the description goes to the clipboard. Otherwise, it goes to the specified file. To send it to standard output, use System.out as an argument.
        Parameters:
        out - An output stream to which to send the description.
      • exportImage

        public java.awt.image.BufferedImage exportImage()
        Create a BufferedImage and draw this plot to it. The size of the returned image matches the current 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.
        Returns:
        An image filled by the plot.
      • exportImage

        public 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. The plot is rendered using anti-aliasing.
        Parameters:
        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.
        Returns:
        An image containing the plot.
      • exportImage

        public 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. The plot is rendered using anti-aliasing. This can be used to paint a number of different plots onto a single buffered image. This method can be used, for example, by a servlet to produce an image, rather than requiring an applet to instantiate a PlotBox.
        Parameters:
        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.
        Returns:
        The modified bufferedImage.
      • exportImage

        public java.awt.image.BufferedImage exportImage​(java.awt.image.BufferedImage bufferedImage)
        Draw this plot onto the provided image. This method does not paint the background, so the plot is transparent. The plot fills the image, and is rendered using anti-aliasing. This method can be used to overlay multiple plots on the same image, although you must use care to ensure that the axes and other labels are identical. Hence, it is usually better to simply combine data sets into a single plot.
        Parameters:
        bufferedImage - The image onto which to render the plot.
        Returns:
        The modified bufferedImage.
      • exportLatex

        public void exportLatex​(java.io.File directory)
        Export a Latex description of the plot.
        Parameters:
        directory - An directory to which to export the Latex.
      • exportImage

        public void exportImage​(java.io.OutputStream out,
                                java.lang.String formatName)
        Export an image of the plot in the specified format. If the specified format is not supported, then pop up a message window apologizing.
        Parameters:
        out - An output stream to which to send the description.
        formatName - A format name, such as "gif" or "png".
      • fillPlot

        public void fillPlot()
        Rescale so that the data that is currently plotted just fits. This is done based on the protected variables _xBottom, _xTop, _yBottom, and _yTop. It is up to derived classes to ensure that variables are valid. This method calls repaint(), which eventually causes the display to be updated.
        Specified by:
        fillPlot in interface PlotBoxInterface
      • getColorByName

        public static java.awt.Color getColorByName​(java.lang.String name)
        Convert a color name into a Color. Currently, only a very limited set of color names is supported: black, white, red, green, and blue.
        Parameters:
        name - A color name, or null if not found.
        Returns:
        An instance of Color.
      • getDataurl

        @Deprecated
        public java.lang.String getDataurl()
        Deprecated.
        Use read() instead.
        Get the file specification that was given by setDataurl().
        Specified by:
        getDataurl in interface PlotBoxInterface
        Returns:
        the file specification
        See Also:
        setDataurl(String)
      • getDocumentBase

        @Deprecated
        public java.net.URL getDocumentBase()
        Deprecated.
        Use read() instead.
        Get the document base that was set by setDocumentBase().
        Specified by:
        getDocumentBase in interface PlotBoxInterface
        Returns:
        the document base.
        See Also:
        setDocumentBase(URL)
      • getLegend

        public java.lang.String getLegend​(int dataset)
        Get the legend for a dataset, or null if there is none. The legend would have been set by addLegend().
        Specified by:
        getLegend in interface PlotBoxInterface
        Parameters:
        dataset - The dataset index.
        Returns:
        The legend label, or null if there is none.
      • getLegendDataset

        public 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().
        Specified by:
        getLegendDataset in interface PlotBoxInterface
        Parameters:
        legend - The String naming the legend
        Returns:
        The legend dataset, or -1 if not found.
        Since:
        Ptplot 5.2p1
      • getPlotRectangle

        public java.awt.Rectangle getPlotRectangle()
        Get the current plot rectangle. Note that Rectangle returned by this method is calculated from the values of _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().
        Specified by:
        getPlotRectangle in interface PlotBoxInterface
        Returns:
        Rectangle
        See Also:
        setPlotRectangle(Rectangle)
      • getPreferredSize

        public java.awt.Dimension getPreferredSize()
        Get the preferred size of this component. This is simply the dimensions specified by setSize(), if this has been called, or the default width and height otherwise (500 by 300).
        Overrides:
        getPreferredSize in class javax.swing.JComponent
        Returns:
        The preferred size.
      • getTitle

        public java.lang.String getTitle()
        Get the title of the graph, or an empty string if there is none.
        Specified by:
        getTitle in interface PlotBoxInterface
        Returns:
        The title.
        See Also:
        setTitle(String)
      • getXAutoRange

        public double[] getXAutoRange()
        Get the range for X values of the data points registered so far. Usually, derived classes handle managing the range by checking each new point against the current range.
        Specified by:
        getXAutoRange in interface PlotBoxInterface
        Returns:
        An array of two doubles where the first element is the minimum and the second element is the maximum.
        See Also:
        getXRange()
      • getXLabel

        public java.lang.String getXLabel()
        Get the label for the X (horizontal) axis, or null if none has been set.
        Specified by:
        getXLabel in interface PlotBoxInterface
        Returns:
        The X label.
        See Also:
        setXLabel(String)
      • getXLog

        public boolean getXLog()
        Return whether the X axis is drawn with a logarithmic scale.
        Specified by:
        getXLog in interface PlotBoxInterface
        Returns:
        True if the X axis is logarithmic.
        See Also:
        setXLog(boolean)
      • getXRange

        public double[] getXRange()
        Get the X range. If 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.
        Specified by:
        getXRange in interface PlotBoxInterface
        Returns:
        An array of two doubles where the first element is the minimum and the second element is the maximum.
        See Also:
        getXAutoRange(), setXRange(double, double)
      • getXTicks

        public java.util.Vector[] getXTicks()
        Get the X ticks that have been specified, or null if none. The return value is an array with two vectors, the first of which specifies the X tick locations (as instances of Double), and the second of which specifies the corresponding labels.
        Specified by:
        getXTicks in interface PlotBoxInterface
        Returns:
        The X ticks.
      • getYAutoRange

        public double[] getYAutoRange()
        Get the range for Y values of the data points registered so far. Usually, derived classes handle managing the range by checking each new point against the range.
        Specified by:
        getYAutoRange in interface PlotBoxInterface
        Returns:
        An array of two doubles where the first element is the minimum and the second element is the maximum.
        See Also:
        getYRange()
      • getYLabel

        public java.lang.String getYLabel()
        Get the label for the Y (vertical) axis, or null if none has been set.
        Specified by:
        getYLabel in interface PlotBoxInterface
        Returns:
        The Y label.
        See Also:
        setYLabel(String)
      • getYLog

        public boolean getYLog()
        Return whether the Y axis is drawn with a logarithmic scale.
        Specified by:
        getYLog in interface PlotBoxInterface
        Returns:
        True if the Y axis is logarithmic.
        See Also:
        setYLog(boolean)
      • getYRange

        public double[] getYRange()
        Get the Y range. If 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.
        Specified by:
        getYRange in interface PlotBoxInterface
        Returns:
        An array of two doubles where the first element is the minimum and the second element is the maximum.
        See Also:
        getYAutoRange(), setYRange(double, double)
      • getYTicks

        public java.util.Vector[] getYTicks()
        Get the Y ticks that have been specified, or null if none. The return value is an array with two vectors, the first of which specifies the Y tick locations (as instances of Double), and the second of which specifies the corresponding labels.
        Specified by:
        getYTicks in interface PlotBoxInterface
        Returns:
        The Y ticks.
      • init

        @Deprecated
        public void init()
        Deprecated.
        Initialize the component, creating the fill button and parsing an input file, if one has been specified. This is deprecated. Call setButtons() and read() instead.
        Specified by:
        init in interface PlotBoxInterface
      • paintComponent

        public void paintComponent​(java.awt.Graphics graphics)
        Paint the component contents, which in this base class is only the axes.
        Overrides:
        paintComponent in class javax.swing.JComponent
        Parameters:
        graphics - The graphics context.
      • parseFile

        @Deprecated
        public 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.
        Syntactic sugar for parseFile(filespec, documentBase).
        Specified by:
        parseFile in interface PlotBoxInterface
        Parameters:
        filespec - The file to be read.
      • parseFile

        @Deprecated
        public void parseFile​(java.lang.String filespec,
                              java.net.URL documentBase)
        Deprecated.
        Use read() instead.
        Open up the input file, which could be stdin, a URL, or a file.
        Specified by:
        parseFile in interface PlotBoxInterface
        Parameters:
        filespec - The file to be read.
        documentBase - The base of the URL
      • print

        public int print​(java.awt.Graphics graphics,
                         java.awt.print.PageFormat format,
                         int index)
                  throws java.awt.print.PrinterException
        Print the plot to a printer, represented by the specified graphics object.
        Specified by:
        print in interface java.awt.print.Printable
        Parameters:
        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.
        Returns:
        PAGE_EXISTS if the page is rendered successfully, or NO_SUCH_PAGE if pageIndex specifies a non-existent page.
        Throws:
        java.awt.print.PrinterException - If the print job is terminated.
      • read

        public void read​(java.io.InputStream in)
                  throws java.io.IOException
        Read commands and/or plot data from an input stream in the old (non-XML) file syntax. To update the display, call repaint(), or make the plot visible with setVisible(true).

        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));
          
        Specified by:
        read in interface PlotBoxInterface
        Parameters:
        in - The input stream.
        Throws:
        java.io.IOException - If the stream cannot be read.
      • read

        public void read​(java.lang.String command)
        Read a single line command provided as a string. The commands can be any of those in the ASCII file format.
        Specified by:
        read in interface PlotBoxInterface
        Parameters:
        command - A command.
      • removeLegend

        public void removeLegend​(int dataset)
        Remove the legend (displayed at the upper right) for the specified data set. If the dataset is not found, nothing will occur. The PlotBox must be repainted in order for this to take effect.
        Specified by:
        removeLegend in interface PlotBoxInterface
        Parameters:
        dataset - The dataset index.
      • renameLegend

        public void renameLegend​(int dataset,
                                 java.lang.String newName)
        Rename a legend.
        Specified by:
        renameLegend in interface PlotBoxInterface
        Parameters:
        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.
        See Also:
        addLegend(int, String)
      • resetAxes

        public void resetAxes()
        Reset the X and Y axes to the ranges that were first specified using setXRange() and setYRange(). If these methods have not been called, then reset to the default ranges. This method calls repaint(), which eventually causes the display to be updated.
        Specified by:
        resetAxes in interface PlotBoxInterface
      • samplePlot

        public void samplePlot()
        Do nothing in this base class. Derived classes might want to override this class to give an example of their use.
        Specified by:
        samplePlot in interface PlotBoxInterface
      • setAutomaticRescale

        public void setAutomaticRescale​(boolean automaticRescale)
        Set automatic rescale. Automatic rescaling is enabled when automaticRescale equals true and disabled when automaticRescale equals false.
        Specified by:
        setAutomaticRescale in interface PlotBoxInterface
        Parameters:
        automaticRescale - The boolean that specifies whether plots should be automatic rescaled.
      • setBackground

        public void setBackground​(java.awt.Color background)
        Set the background color.
        Overrides:
        setBackground in class javax.swing.JComponent
        Parameters:
        background - The background color.
      • setBackground

        public void setBackground​(java.lang.Object background)
        Set the background color. This is syntactic sugar for use in implementations that separate the graphical display from the computational engine. Implements the PlotBoxInterface.
        Specified by:
        setBackground in interface PlotBoxInterface
        Parameters:
        background - The background Color.
      • setBounds

        public void setBounds​(int x,
                              int y,
                              int width,
                              int height)
        Move and resize this component. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height. This overrides the base class method to make a record of the new size.
        Overrides:
        setBounds in class java.awt.Component
        Parameters:
        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.
      • setButtons

        public void setButtons​(boolean visible)
        If the argument is true, make a fill button visible at the upper right. This button auto-scales the plot. NOTE: The button may infringe on the title space, if the title is long. In an application, it is preferable to provide a menu with the fill command. This way, when printing the plot, the printed plot will not have a spurious button. Thus, this method should be used only by applets, which normally do not have menus. This method should only be called from within the event dispatch thread, since it interacts with swing.
        Specified by:
        setButtons in interface PlotBoxInterface
        Parameters:
        visible - If true, make the fill button appear.
        See Also:
        destroy()
      • setCaptions

        public void setCaptions​(java.util.Vector captionStrings)
        Set the strings of the caption.
        Specified by:
        setCaptions in interface PlotBoxInterface
        Parameters:
        captionStrings - A Vector where each element contains a String that is one line of the caption.
        See Also:
        getCaptions(), clearCaptions()
      • setColor

        public void setColor​(boolean useColor)
        If the argument is false, draw the plot without using color (in black and white). Otherwise, draw it in color (the default).
        Specified by:
        setColor in interface PlotBoxInterface
        Parameters:
        useColor - False to draw in back and white.
        See Also:
        getColor()
      • setColors

        public void setColors​(java.awt.Color[] colors)
        Set the point colors. Note that the default colors have been carefully selected to maximize readability and that it is easy to use colors that result in a very ugly plot.
        Parameters:
        colors - Array of colors to use in succession for data sets.
        See Also:
        getColors()
      • setDataurl

        @Deprecated
        public void setDataurl​(java.lang.String filespec)
        Deprecated.
        Use read() instead.
        Set the file to read when init() is called.
        Specified by:
        setDataurl in interface PlotBoxInterface
        Parameters:
        filespec - the file to be read
        See Also:
        getDataurl()
      • setDocumentBase

        @Deprecated
        public void setDocumentBase​(java.net.URL documentBase)
        Deprecated.
        Use read() instead.
        Set the document base to used when init() is called to read a URL.
        Specified by:
        setDocumentBase in interface PlotBoxInterface
        Parameters:
        documentBase - The document base to be used.
        See Also:
        getDocumentBase()
      • setForeground

        public void setForeground​(java.awt.Color foreground)
        Set the foreground color.
        Overrides:
        setForeground in class javax.swing.JComponent
        Parameters:
        foreground - The foreground color.
      • setForeground

        public void setForeground​(java.lang.Object foreground)
        Set the foreground color. Implements the PlotBoxInterface.
        Specified by:
        setForeground in interface PlotBoxInterface
        Parameters:
        foreground - The foreground Color.
      • setGrid

        public void setGrid​(boolean grid)
        Control whether the grid is drawn.
        Specified by:
        setGrid in interface PlotBoxInterface
        Parameters:
        grid - If true, a grid is drawn.
        See Also:
        getGrid()
      • setLabelFont

        public void setLabelFont​(java.lang.String name)
        Set the label font, which is used for axis labels and legend labels. The font names understood are those understood by java.awt.Font.decode().
        Specified by:
        setLabelFont in interface PlotBoxInterface
        Parameters:
        name - A font name.
      • setPlotRectangle

        public void setPlotRectangle​(java.awt.Rectangle rectangle)
        Set the plot rectangle inside the axes. This method can be used to create two plots that share the same axes.
        Parameters:
        rectangle - Rectangle space inside axes.
        See Also:
        getPlotRectangle()
      • setSize

        public void setSize​(int width,
                            int height)
        Set the size of the plot. This overrides the base class to make it work. In particular, it records the specified size so that getMinimumSize() and getPreferredSize() return the specified value. However, it only works if the plot is placed in its own JPanel. This is because the JPanel asks the contained component for its preferred size before determining the size of the panel. If the plot is placed directly in the content pane of a JApplet, then, mysteriously, this method has no effect.
        Specified by:
        setSize in interface PlotBoxInterface
        Overrides:
        setSize in class java.awt.Component
        Parameters:
        width - The width, in pixels.
        height - The height, in pixels.
      • setTimedRepaint

        public void setTimedRepaint​(boolean timedRepaint)
        Set repainting with a certain fixed refresh rate. This timed repainting is enabled when timedRepaint equals true and disabled when timedRepaint equals false.
        Specified by:
        setTimedRepaint in interface PlotBoxInterface
        Parameters:
        timedRepaint - The boolean that specifies whether repainting should happen with a certain fixed refresh rate.
      • setTitle

        public void setTitle​(java.lang.String title)
        Set the title of the graph.
        Specified by:
        setTitle in interface PlotBoxInterface
        Parameters:
        title - The title.
        See Also:
        getTitle()
      • setTitleFont

        public void setTitleFont​(java.lang.String name)
        Set the title font. The font names understood are those understood by java.awt.Font.decode().
        Specified by:
        setTitleFont in interface PlotBoxInterface
        Parameters:
        name - A font name.
      • setWrap

        public void setWrap​(boolean wrap)
        Specify whether the X axis is wrapped. If it is, then X values that are out of range are remapped to be in range using modulo arithmetic. The X range is determined by the most recent call to setXRange() (or the most recent zoom). If the X range has not been set, then use the default X range, or if data has been plotted, then the current fill range.
        Specified by:
        setWrap in interface PlotBoxInterface
        Parameters:
        wrap - If true, wrapping of the X axis is enabled.
      • setXLabel

        public void setXLabel​(java.lang.String label)
        Set the label for the X (horizontal) axis.
        Specified by:
        setXLabel in interface PlotBoxInterface
        Parameters:
        label - The label.
        See Also:
        getXLabel()
      • setXLog

        public void setXLog​(boolean xlog)
        Specify whether the X axis is drawn with a logarithmic scale. If you would like to have the X axis drawn with a logarithmic axis, then setXLog(true) should be called before adding any data points.
        Specified by:
        setXLog in interface PlotBoxInterface
        Parameters:
        xlog - If true, logarithmic axis is used.
        See Also:
        getXLog()
      • 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 the plot is drawn. If min and max are identical, then the range is arbitrarily spread by 1.

        Note that if setXLog(boolean) has been called, then the min and max values should be in log units.

        Specified by:
        setXRange in interface PlotBoxInterface
        Parameters:
        min - The left extent of the range.
        max - The right extent of the range.
        See Also:
        getXRange()
      • setYLabel

        public void setYLabel​(java.lang.String label)
        Set the label for the Y (vertical) axis.
        Specified by:
        setYLabel in interface PlotBoxInterface
        Parameters:
        label - The label.
        See Also:
        getYLabel()
      • setYLog

        public void setYLog​(boolean ylog)
        Specify whether the Y axis is drawn with a logarithmic scale. If you would like to have the Y axis drawn with a logarithmic axis, then setYLog(true) should be called before adding any data points.
        Specified by:
        setYLog in interface PlotBoxInterface
        Parameters:
        ylog - If true, logarithmic axis is used.
        See Also:
        getYLog()
      • 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 the plot is drawn. If min and max are identical, then the range is arbitrarily spread by 0.1.

        Note that if setYLog(boolean) has been called, then the min and max values should be in log units.

        Specified by:
        setYRange in interface PlotBoxInterface
        Parameters:
        min - The bottom extent of the range.
        max - The top extent of the range.
        See Also:
        getYRange()
      • write

        public void write​(java.io.OutputStream out)
        Write the current data and plot configuration to the specified stream in PlotML syntax. PlotML is an XML extension for plot data. The written information is includes a reference to the PlotML dtd on the the Ptolemy website. The output is buffered, and is flushed and but not closed before exiting. Derived classes should override writeFormat and writeData rather than this method.
        Specified by:
        write in interface PlotBoxInterface
        Parameters:
        out - An output stream.
      • write

        public void write​(java.io.OutputStream out,
                          java.lang.String dtd)
        Write the current data and plot configuration to the specified stream in PlotML syntax. PlotML is an XML scheme for plot data. The URL (relative or absolute) for the DTD is given as the second argument. If that argument is null, then the PlotML PUBLIC DTD is referenced, resulting in a file that can be read by a PlotML parser without any external file references, as long as that parser has local access to the DTD. The output is buffered, and is flushed but not closed before exiting. Derived classes should override writeFormat and writeData rather than this method.
        Specified by:
        write in interface PlotBoxInterface
        Parameters:
        out - An output stream.
        dtd - The reference (URL) for the DTD, or null to use the PUBLIC DTD.
      • write

        public void write​(java.io.Writer out,
                          java.lang.String dtd)
        Write the current data and plot configuration to the specified stream in PlotML syntax. PlotML is an XML scheme for plot data. The URL (relative or absolute) for the DTD is given as the second argument. If that argument is null, then the PlotML PUBLIC DTD is referenced, resulting in a file that can be read by a PlotML parser without any external file references, as long as that parser has local access to the DTD. The output is buffered, and is flushed before exiting.
        Specified by:
        write in interface PlotBoxInterface
        Parameters:
        out - An output writer.
        dtd - The reference (URL) for the DTD, or null to use the PUBLIC DTD.
      • writeData

        public void writeData​(java.io.PrintWriter output)
        Write plot data information to the specified output stream in PlotML. In this base class, there is no data to write, so this method returns without doing anything.
        Specified by:
        writeData in interface PlotBoxInterface
        Parameters:
        output - A buffered print writer.
      • writeFormat

        public void writeFormat​(java.io.PrintWriter output)
        Write plot format information to the specified output stream in PlotML. Derived classes should override this method to first call the parent class method, then add whatever additional format information they wish to add to the stream.
        Specified by:
        writeFormat in interface PlotBoxInterface
        Parameters:
        output - A buffered print writer.
      • writeOldSyntax

        @Deprecated
        public void writeOldSyntax​(java.io.OutputStream out)
        Deprecated.
        Write the current data and plot configuration to the specified stream in the old PtPlot syntax. The output is buffered, and is flushed and closed before exiting. Derived classes should override _writeOldSyntax() rather than this method.
        Specified by:
        writeOldSyntax in interface PlotBoxInterface
        Parameters:
        out - An output stream.
      • zoom

        public void zoom​(double lowx,
                         double lowy,
                         double highx,
                         double highy)
        Zoom in or out to the specified rectangle. This method calls repaint().
        Specified by:
        zoom in interface PlotBoxInterface
        Parameters:
        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.
      • _automaticRescale

        protected boolean _automaticRescale()
        Return whether rescaling of the plot should happen automatic.
        Returns:
        True when rescaling of the plot should happen automatic.
      • _drawPlot

        protected void _drawPlot​(java.awt.Graphics graphics,
                                 boolean clearfirst)
        Draw the axes using the current range, label, and title information. If the second argument is true, clear the display before redrawing. This method is called by paintComponent(). To cause it to be called you would normally call repaint(), which eventually causes paintComponent() to be called.

        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.

        Parameters:
        graphics - The graphics context.
        clearfirst - If true, clear the plot before proceeding.
      • _drawPlot

        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. If the second argument is true, clear the display before redrawing. This method is called by paintComponent(). To cause it to be called you would normally call repaint(), which eventually causes paintComponent() to be called.

        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.

        Parameters:
        graphics - The graphics context.
        clearfirst - If true, clear the plot before proceeding.
        drawRect - A specification of the size.
      • _drawPoint

        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. 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. 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.
        Parameters:
        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.
      • _exportLatexPlotData

        protected java.lang.String _exportLatexPlotData()
        Return Latex plot data. This base class returns nothing.
        Returns:
        A string suitable for inclusion in Latex.
      • _help

        protected void _help()
        Display basic information in its own window.
      • _parseLine

        protected boolean _parseLine​(java.lang.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. It is not synchronized, so its caller should be.
        Parameters:
        line - A line of text.
        Returns:
        True if the line was recognized.
      • _resetScheduledTasks

        protected void _resetScheduledTasks()
        Reset a scheduled redraw tasks. This base class does nothing. Derived classes should define the correct behavior.
      • _scheduledRedraw

        protected void _scheduledRedraw()
        Perform a scheduled redraw. This base class does nothing. Derived classes should define the correct behavior.
      • _setButtonsVisibility

        @Deprecated
        protected void _setButtonsVisibility​(boolean visibility)
        Deprecated.
        Use #setButtons(boolean) instead.
        Set the visibility of the Fill button.
        Parameters:
        visibility - True if the fill button is to be visible.
      • _setPadding

        protected void _setPadding​(double padding)
        Set the padding multiple. The plot rectangle can be "padded" in each direction -x, +x, -y, and +y. If the padding is set to 0.05 (and the padding is used), then there is 10% more length on each axis than set by the setXRange() and setYRange() methods, 5% in each direction.
        Parameters:
        padding - The padding multiple.
      • _timedRepaint

        protected boolean _timedRepaint()
        Return whether repainting happens by a timed thread.
        Returns:
        True when repainting happens by a timer thread.
      • _writeOldSyntax

        @Deprecated
        protected void _writeOldSyntax​(java.io.PrintWriter output)
        Deprecated.
        Write plot information to the specified output stream in the old PtPlot syntax. Derived classes should override this method to first call the parent class method, then add whatever additional information they wish to add to the stream. It is not synchronized, so its caller should be.
        Parameters:
        output - A buffered print writer.
      • zoomEqual

        public void zoomEqual()
        Zoom to that equal interval widths are on x and y axis. For example, a miss-scaled circle will look circular afterwords.