rvl.awt
Class Plot

java.lang.Object
  |
  +--java.awt.Component
        |
        +--rvl.awt.Plot
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
IntPlot

public class Plot
extends java.awt.Component

See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  java.awt.Color[] defaultColor
           
protected  int defaultDotSize
           
protected  java.awt.Color[][] dotColor
           
protected  int[][] dotSize
           
protected  double h0
           
protected  double h1
           
protected  double hMax
           
protected  double hMin
           
protected  java.awt.Color[][] lineColor
           
protected  double mh
           
protected  double mv
           
protected  boolean needsRescaling
           
protected  boolean sameScale
           
protected  java.awt.Color scaleColor
           
protected  java.awt.Font scaleFont
           
protected  boolean swap
           
protected  java.lang.String[] title
           
protected  double v0
           
protected  double v1
           
protected  double vMax
           
protected  double vMin
           
protected  double[][] x
           
protected  java.lang.String[] xAxisLab
           
protected  boolean xCustomLab
           
protected  double xMax
           
protected  double xMin
           
protected  double[] xTick
           
protected  java.lang.String[] xTickLab
           
protected  double[][] y
           
protected  java.lang.String[] yAxisLab
           
protected  boolean yCustomLab
           
protected  double yMax
           
protected  double yMin
           
protected  double[] yTick
           
protected  java.lang.String[] yTickLab
           
 
Fields inherited from class java.awt.Component
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
 
Constructor Summary
Plot(double[][] x, double[][] y)
          General constructor: Plots y[0][] vs x[0][], y[2][] vs x[1][], ...
Plot(double[] x, double[] y)
          Constructor for a simple plot of one variable against another.
Plot(double[] x, double[][] y)
          Constructor for a multiple plot of several y[]s, all with same x[].
 
Method Summary
 java.awt.Dimension getMinimumSize()
           
 java.awt.Dimension getPreferredSize()
           
 double[][] getXData()
           
 double[][] getYData()
           
protected  boolean isBad(double x)
           
 java.awt.Dimension minimumSize()
           
 void paint(java.awt.Graphics g)
           
 java.awt.Dimension preferredSize()
           
protected  void rescale()
          Set values if xMin, xMax, yMin, yMax
 void setAxisLabels(java.lang.String[] xLab, java.lang.String[] yLab)
          Set axis labels.
 void setAxisLabels(java.lang.String xLab, java.lang.String yLab)
          Set single-line axis labels.
 void setData(double[][] x, double[][] y)
          Set data and rescale the plot (see constructor for details).
 void setData(double[][] x, double[][] y, boolean rescale)
          Set data to be plotted (see constructor for details)
 void setData(double[] x, double[] y)
          Set data for one set of x values and one set of y values; and rescale the plot.
 void setData(double[] x, double[][] y)
          Set data for one set of x values and several sets of y values; and rescale the plot.
 void setData(double[] x, double[][] y, boolean rescale)
          Set data for one set of x values and several sets of y values.
 void setData(double[] x, double[] y, boolean rescale)
          Set data for one set of x values and one set of y values.
 void setDefaultColor(java.awt.Color[] color)
          Set default sequence of colors to cycle through
 void setDefaultDotSize(int size)
          Set default size of dots (width, in pixels)
 void setDotColor(java.awt.Color color)
          Set dot color (same color for all points)
 void setDotColor(java.awt.Color[] color)
          Set dot colors (constant color for each data set)
 void setDotColor(java.awt.Color[][] color)
          Set dot colors (potentially individual for each point)
 void setDotMode(boolean mode)
          Enable or disable plotting of symbols at all points
 void setDotSize(int size)
          Set dot size (same size for all points)
 void setDotSize(int[] size)
          Set dot sizes (constant size for each data set)
 void setDotSize(int[][] size)
          Set dot sizes (potentially individual for each point)
 void setLineColor(java.awt.Color color)
          Set line color (constant color for all curves)
 void setLineColor(java.awt.Color[] color)
          Set line colors (constant color for each data set)
 void setLineColor(java.awt.Color[][] color)
          Set line colors (potentially individual for each point)
 void setLineMode(boolean mode)
          Enable or disable plotting of lines for all data.
 void setSameScale(boolean flag)
          Enable/disable provision to keep scale constants equal
 void setScaleColor(java.awt.Color color)
          set Colors of axes
 void setTickMode(boolean xHasThem, boolean yHasThem)
          Enable or disable default tick marks and labels for each axis.
 void setTitle(java.lang.String title)
          Set a one-line title.
 void setTitle(java.lang.String[] title)
          Set title.
 void setTranspose(boolean swap)
          Enable/disable transposing the plot
 void setXData(double[][] x)
          Set x data and rescale the plot
 void setXData(double[][] x, boolean rescale)
          Set x data to be plotted
 void setXTicks(double[] tick, java.lang.String[] tickLab)
          Set tick positions and labels for the x variable.
 void setYData(double[][] y)
          Set y data and rescale the plot
 void setYData(double[][] y, boolean rescale)
          Set y data to be plotted
 void setYTicks(double[] tick, java.lang.String[] tickLab)
          Set tick positions and labels for the y variable.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

protected double[][] x

y

protected double[][] y

defaultDotSize

protected int defaultDotSize

dotSize

protected int[][] dotSize

defaultColor

protected java.awt.Color[] defaultColor

dotColor

protected java.awt.Color[][] dotColor

lineColor

protected java.awt.Color[][] lineColor

scaleColor

protected java.awt.Color scaleColor

xTick

protected double[] xTick

yTick

protected double[] yTick

xTickLab

protected java.lang.String[] xTickLab

yTickLab

protected java.lang.String[] yTickLab

title

protected java.lang.String[] title

xAxisLab

protected java.lang.String[] xAxisLab

yAxisLab

protected java.lang.String[] yAxisLab

xCustomLab

protected boolean xCustomLab

yCustomLab

protected boolean yCustomLab

sameScale

protected boolean sameScale

xMin

protected double xMin

xMax

protected double xMax

yMin

protected double yMin

yMax

protected double yMax

h0

protected double h0

v0

protected double v0

h1

protected double h1

v1

protected double v1

mh

protected double mh

mv

protected double mv

hMin

protected double hMin

hMax

protected double hMax

vMin

protected double vMin

vMax

protected double vMax

scaleFont

protected java.awt.Font scaleFont

needsRescaling

protected boolean needsRescaling

swap

protected boolean swap
Constructor Detail

Plot

public Plot(double[] x,
            double[] y)
Constructor for a simple plot of one variable against another.

Plot

public Plot(double[] x,
            double[][] y)
Constructor for a multiple plot of several y[]s, all with same x[].

Plot

public Plot(double[][] x,
            double[][] y)
General constructor: Plots y[0][] vs x[0][], y[2][] vs x[1][], ...

However, if x.length != y.length, array indices are modded-out. For example, suppose x.length = 2 and y.length = 5, then plots are of (x[0],y[0]), (x[1],y[1]), (x[0],y[2]), (x[1],y[3]), (x[0],y[4]).

Method Detail

setData

public void setData(double[][] x,
                    double[][] y,
                    boolean rescale)
Set data to be plotted (see constructor for details)
Parameters:
x - Arrays of x values
y - Arrays of y values
rescale - If true, the scaling of the plot is changed to fit the data; otherwise, the same scale is used.
See Also:
#Plot(double x[][], double y[][])

setData

public void setData(double[][] x,
                    double[][] y)
Set data and rescale the plot (see constructor for details). Same as setData (x, y, true)
Parameters:
x - Arrays of x values
y - Arrays of y values
See Also:
setData(double x[][], double y[][], boolean rescale)

setData

public void setData(double[] x,
                    double[][] y,
                    boolean rescale)
Set data for one set of x values and several sets of y values.
Parameters:
x - Array of x values
y - Arrays of y values
rescale - If true, the scaling of the plot is changed to fit the data; otherwise, the same scale is used.

setData

public void setData(double[] x,
                    double[][] y)
Set data for one set of x values and several sets of y values; and rescale the plot.
Parameters:
x - Array of x values
y - Arrays of y values

setData

public void setData(double[] x,
                    double[] y,
                    boolean rescale)
Set data for one set of x values and one set of y values.
Parameters:
x - Array of x values
y - Array of y values
rescale - If true, the scaling of the plot is changed to fit the data; otherwise, the same scale is used.

setData

public void setData(double[] x,
                    double[] y)
Set data for one set of x values and one set of y values; and rescale the plot.
Parameters:
x - Array of x values
y - Array of y values

getXData

public double[][] getXData()
Returns:
the x arrays

setXData

public void setXData(double[][] x,
                     boolean rescale)
Set x data to be plotted
Parameters:
x - Arrays of x values
rescale - If true, the scaling of the plot is changed to fit the data; otherwise, the same scale is used.

setXData

public void setXData(double[][] x)
Set x data and rescale the plot
Parameters:
x - Arrays of x values

getYData

public double[][] getYData()
Returns:
the y arrays

setYData

public void setYData(double[][] y,
                     boolean rescale)
Set y data to be plotted
Parameters:
y - Arrays of y values
rescale - If true, the scaling of the plot is changed to fit the data; otherwise, the same scale is used.

setYData

public void setYData(double[][] y)
Set y data and rescale the plot
Parameters:
y - Arrays of y values

setDotMode

public void setDotMode(boolean mode)
Enable or disable plotting of symbols at all points
Parameters:
mode - If true, all points be plotted with dots of default size and colors. If false, no symbols are plotted

setLineMode

public void setLineMode(boolean mode)
Enable or disable plotting of lines for all data.
Parameters:
mode - If true, each (x,y) pair of arrays will be connected with lines of default colors. If false, no lines are plotted.

setDotColor

public void setDotColor(java.awt.Color color)
Set dot color (same color for all points)

setDotColor

public void setDotColor(java.awt.Color[] color)
Set dot colors (constant color for each data set)
Parameters:
color - array of colors. The ith element specifies the color to be used in plotting the ith curve

setDotColor

public void setDotColor(java.awt.Color[][] color)
Set dot colors (potentially individual for each point)

setDotSize

public void setDotSize(int size)
Set dot size (same size for all points)

setDotSize

public void setDotSize(int[] size)
Set dot sizes (constant size for each data set)
Parameters:
size - array of sizes. The ith element specifies the size of dots to be used in plotting the ith curve

setDotSize

public void setDotSize(int[][] size)
Set dot sizes (potentially individual for each point)

setLineColor

public void setLineColor(java.awt.Color color)
Set line color (constant color for all curves)

setLineColor

public void setLineColor(java.awt.Color[] color)
Set line colors (constant color for each data set)

setLineColor

public void setLineColor(java.awt.Color[][] color)
Set line colors (potentially individual for each point)

setDefaultColor

public void setDefaultColor(java.awt.Color[] color)
Set default sequence of colors to cycle through

setDefaultDotSize

public void setDefaultDotSize(int size)
Set default size of dots (width, in pixels)

setScaleColor

public void setScaleColor(java.awt.Color color)
set Colors of axes

setTranspose

public void setTranspose(boolean swap)
Enable/disable transposing the plot
Parameters:
swap - If true, the x variable is the vertical coordinate and the y variable is horizontal.

setSameScale

public void setSameScale(boolean flag)
Enable/disable provision to keep scale constants equal
Parameters:
flag - If true, scaling is done so that both axes use the same number of pixels per unit scale value.

setAxisLabels

public void setAxisLabels(java.lang.String[] xLab,
                          java.lang.String[] yLab)
Set axis labels. The elements of each array are stacked vertically. When a label starts with "<" (">"), it is left- (right-) justified when used with the horizonal axis. Otherwise, it is centered.

setAxisLabels

public void setAxisLabels(java.lang.String xLab,
                          java.lang.String yLab)
Set single-line axis labels. When a label starts with "<" (">"), it is left- (right-) justified when used with the horizonal axis. Otherwise, it is centered.

setTitle

public void setTitle(java.lang.String[] title)
Set title. Elements are stacked vertically at the top of the plot. Justification rules are same as in setAxisLabels
See Also:
setAxisLabels(java.lang.String[], java.lang.String[])

setTitle

public void setTitle(java.lang.String title)
Set a one-line title. Justification rules are same as in setAxisLabels
See Also:
setAxisLabels

setTickMode

public void setTickMode(boolean xHasThem,
                        boolean yHasThem)
Enable or disable default tick marks and labels for each axis. An argument of true enables them and places tick marks at nice numbers. An argument of false disables both custom and default tick labeling for that axis.
See Also:
setXTicks, setYTicks

setXTicks

public void setXTicks(double[] tick,
                      java.lang.String[] tickLab)
Set tick positions and labels for the x variable. Calling this disables default tick labeling; to re-enable the default behavior, call setTicks();
See Also:
setTickMode

setYTicks

public void setYTicks(double[] tick,
                      java.lang.String[] tickLab)
Set tick positions and labels for the y variable. Calling this disables default tick labeling; to re-enable the default behavior, call setTicks();
See Also:
setTickMode

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Component

isBad

protected boolean isBad(double x)
Returns:
true for any kind of invalid double value

rescale

protected void rescale()
Set values if xMin, xMax, yMin, yMax

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class java.awt.Component

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class java.awt.Component

preferredSize

public java.awt.Dimension preferredSize()
Overrides:
preferredSize in class java.awt.Component

minimumSize

public java.awt.Dimension minimumSize()
Overrides:
minimumSize in class java.awt.Component