ij.gui
Class Plot

java.lang.Object
  extended by ij.gui.Plot

public class Plot
extends java.lang.Object

This class is an image that line graphs can be drawn on.


Field Summary
static int BOTTOM_MARGIN
          the margin width below the plot frame
static int BOX
          Display points using an box-shaped mark.
static int CENTER
          Text justification.
static int CIRCLE
          Display points using a circle 5 pixels in diameter.
static int CROSS
          Display points using an cross-shaped mark.
static int DEFAULT_FLAGS
          the default flags
static int DOT
          Display points using a single pixel.
static int LEFT
          Text justification.
static int LEFT_MARGIN
          the margin width left of the plot frame (enough for 5-digit numbers such as unscaled 16-bit data
static int LINE
          Connect points with solid lines.
static int RIGHT
          Text justification.
static int RIGHT_MARGIN
          the margin width right of the plot frame
static int TOP_MARGIN
          the margin width above the plot frame
static int TRIANGLE
          Display points using an tiangular mark.
static int X
          Display points using an X-shaped mark.
static int X_FORCE2GRID
          flag for forcing frame to coincide with the grid/ticks in x direction (results in unused space)
static int X_GRID
          flag for drawing vertical grid lines for x-axis ticks
static int X_NUMBERS
          flag for numeric labels of x-axis ticks
static int X_TICKS
          flag for drawing x-axis ticks
static int Y_FORCE2GRID
          flag for forcing frame to coincide with the grid/ticks in y direction (results in unused space)
static int Y_GRID
          flag for drawing horizontal grid lines for y-axis ticks
static int Y_NUMBERS
          flag for numeric labels of x-axis ticks
static int Y_TICKS
          flag for drawing x-axis ticks
 
Constructor Summary
Plot(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel)
          This is a version of the constructor with no intial arrays.
Plot(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, double[] xValues, double[] yValues)
          This version of the constructor accepts double arrays.
Plot(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, double[] xValues, double[] yValues, int flags)
          This version of the constructor accepts double arrays and has a 'flags' argument.
Plot(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, float[] xValues, float[] yValues)
          Construct a new PlotWindow.
Plot(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, float[] xValues, float[] yValues, int flags)
          This version of the constructor has a 'flags' argument for controlling the appearance of ticks, grid, etc.
 
Method Summary
 void addErrorBars(double[] errorBars)
          Adds error bars to the plot.
 void addErrorBars(float[] errorBars)
          Adds error bars to the plot.
 void addLabel(double x, double y, java.lang.String label)
          Draws text at the specified location, where (0,0) is the upper left corner of the the plot frame and (1,1) is the lower right corner.
 void addPoints(double[] x, double[] y, int shape)
          Adds a set of points to the plot using double arrays.
 void addPoints(float[] x, float[] y, int shape)
          Adds a set of points to the plot or adds a curve if shape is set to LINE.
 void changeFont(java.awt.Font font)
          Obsolete; replaced by setFont().
 void draw()
          Draws the plot specified in the constructor.
 void drawLine(double x1, double y1, double x2, double y2)
           
 ImagePlus getImagePlus()
          Returns the plot as an ImagePlus.
 ImageProcessor getProcessor()
          Returns the plot as an ImageProcessor.
 void setColor(java.awt.Color c)
          Changes the drawing color.
 void setFont(java.awt.Font font)
          Sets the font.
 void setFrameSize(int width, int height)
          Sets the plot frame size in pixels.
 void setJustification(int justification)
          Sets the justification used by addLabel(), where justification is Plot.LEFT, Plot.CENTER or Plot.RIGHT.
 void setLimits(double xMin, double xMax, double yMin, double yMax)
          Sets the x-axis and y-axis range.
 void setLineWidth(int lineWidth)
          Changes the line width.
 void setSize(int width, int height)
          Sets the canvas size (i.e., size of the resulting ImageProcessor).
 PlotWindow show()
          Displays the plot in a PlotWindow and returns a reference to the PlotWindow.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
Text justification.

See Also:
Constant Field Values

CENTER

public static final int CENTER
Text justification.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Text justification.

See Also:
Constant Field Values

CIRCLE

public static final int CIRCLE
Display points using a circle 5 pixels in diameter.

See Also:
Constant Field Values

X

public static final int X
Display points using an X-shaped mark.

See Also:
Constant Field Values

BOX

public static final int BOX
Display points using an box-shaped mark.

See Also:
Constant Field Values

TRIANGLE

public static final int TRIANGLE
Display points using an tiangular mark.

See Also:
Constant Field Values

CROSS

public static final int CROSS
Display points using an cross-shaped mark.

See Also:
Constant Field Values

DOT

public static final int DOT
Display points using a single pixel.

See Also:
Constant Field Values

LINE

public static final int LINE
Connect points with solid lines.

See Also:
Constant Field Values

X_NUMBERS

public static final int X_NUMBERS
flag for numeric labels of x-axis ticks

See Also:
Constant Field Values

Y_NUMBERS

public static final int Y_NUMBERS
flag for numeric labels of x-axis ticks

See Also:
Constant Field Values

X_TICKS

public static final int X_TICKS
flag for drawing x-axis ticks

See Also:
Constant Field Values

Y_TICKS

public static final int Y_TICKS
flag for drawing x-axis ticks

See Also:
Constant Field Values

X_GRID

public static final int X_GRID
flag for drawing vertical grid lines for x-axis ticks

See Also:
Constant Field Values

Y_GRID

public static final int Y_GRID
flag for drawing horizontal grid lines for y-axis ticks

See Also:
Constant Field Values

X_FORCE2GRID

public static final int X_FORCE2GRID
flag for forcing frame to coincide with the grid/ticks in x direction (results in unused space)

See Also:
Constant Field Values

Y_FORCE2GRID

public static final int Y_FORCE2GRID
flag for forcing frame to coincide with the grid/ticks in y direction (results in unused space)

See Also:
Constant Field Values

DEFAULT_FLAGS

public static final int DEFAULT_FLAGS
the default flags

See Also:
Constant Field Values

LEFT_MARGIN

public static final int LEFT_MARGIN
the margin width left of the plot frame (enough for 5-digit numbers such as unscaled 16-bit data

See Also:
Constant Field Values

RIGHT_MARGIN

public static final int RIGHT_MARGIN
the margin width right of the plot frame

See Also:
Constant Field Values

TOP_MARGIN

public static final int TOP_MARGIN
the margin width above the plot frame

See Also:
Constant Field Values

BOTTOM_MARGIN

public static final int BOTTOM_MARGIN
the margin width below the plot frame

See Also:
Constant Field Values
Constructor Detail

Plot

public Plot(java.lang.String title,
            java.lang.String xLabel,
            java.lang.String yLabel,
            float[] xValues,
            float[] yValues)
Construct a new PlotWindow.

Parameters:
title - the window title
xLabel - the x-axis label
yLabel - the y-axis label
xValues - the x-coodinates, or null
yValues - the y-coodinates, or null

Plot

public Plot(java.lang.String title,
            java.lang.String xLabel,
            java.lang.String yLabel,
            double[] xValues,
            double[] yValues)
This version of the constructor accepts double arrays.


Plot

public Plot(java.lang.String title,
            java.lang.String xLabel,
            java.lang.String yLabel)
This is a version of the constructor with no intial arrays.


Plot

public Plot(java.lang.String title,
            java.lang.String xLabel,
            java.lang.String yLabel,
            float[] xValues,
            float[] yValues,
            int flags)
This version of the constructor has a 'flags' argument for controlling the appearance of ticks, grid, etc. The default is Plot.X_NUMBERS+Plot.Y_NUMBERS+Plot.X_GRID+Plot.Y_GRID.


Plot

public Plot(java.lang.String title,
            java.lang.String xLabel,
            java.lang.String yLabel,
            double[] xValues,
            double[] yValues,
            int flags)
This version of the constructor accepts double arrays and has a 'flags' argument.

Method Detail

setLimits

public void setLimits(double xMin,
                      double xMax,
                      double yMin,
                      double yMax)
Sets the x-axis and y-axis range.


setSize

public void setSize(int width,
                    int height)
Sets the canvas size (i.e., size of the resulting ImageProcessor). By default, the size is adjusted for the plot frame size specified in Edit>Options>Profile Plot Options.


setFrameSize

public void setFrameSize(int width,
                         int height)
Sets the plot frame size in pixels.


addPoints

public void addPoints(float[] x,
                      float[] y,
                      int shape)
Adds a set of points to the plot or adds a curve if shape is set to LINE.

Parameters:
x - the x-coodinates
y - the y-coodinates
shape - CIRCLE, X, BOX, TRIANGLE, CROSS, DOT or LINE

addPoints

public void addPoints(double[] x,
                      double[] y,
                      int shape)
Adds a set of points to the plot using double arrays. Must be called before the plot is displayed.


addErrorBars

public void addErrorBars(float[] errorBars)
Adds error bars to the plot.


addErrorBars

public void addErrorBars(double[] errorBars)
Adds error bars to the plot.


addLabel

public void addLabel(double x,
                     double y,
                     java.lang.String label)
Draws text at the specified location, where (0,0) is the upper left corner of the the plot frame and (1,1) is the lower right corner.


setJustification

public void setJustification(int justification)
Sets the justification used by addLabel(), where justification is Plot.LEFT, Plot.CENTER or Plot.RIGHT.


setColor

public void setColor(java.awt.Color c)
Changes the drawing color. For selecting the color of the data passed with the constructor, use setColor before draw. The frame and labels are always drawn in black.


setLineWidth

public void setLineWidth(int lineWidth)
Changes the line width.


drawLine

public void drawLine(double x1,
                     double y1,
                     double x2,
                     double y2)

setFont

public void setFont(java.awt.Font font)
Sets the font.


changeFont

public void changeFont(java.awt.Font font)
Obsolete; replaced by setFont().


draw

public void draw()
Draws the plot specified in the constructor.


getProcessor

public ImageProcessor getProcessor()
Returns the plot as an ImageProcessor.


getImagePlus

public ImagePlus getImagePlus()
Returns the plot as an ImagePlus.


show

public PlotWindow show()
Displays the plot in a PlotWindow and returns a reference to the PlotWindow.