|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectij.gui.Plot
public class Plot
This class creates an image that line graphs, scatter plots and plots of vector fields (arrows) can be drawn on and displayed. Note that the clone() operation is a shallow clone: objects like arrays, the plot objects, the ImagePlus etc. of the clone remain the same as those of the original.
Field Summary | |
---|---|
static int |
AUTO_POSITION
Legend positions |
static int |
BOTTOM_LEFT
Legend positions |
static int |
BOTTOM_MARGIN
Deprecated. Not a fixed value any more, use getDrawingFrame() to get the drawing area |
static int |
BOTTOM_RIGHT
Legend positions |
static int |
BOX
Display points using a square box-shaped mark. |
static int |
CENTER
Text justification. |
static int |
CIRCLE
Display points using a circle (5 pixels in diameter if line thickness<=1, otherwise 7). |
static int |
CONNECTED_CIRCLES
Draw black lines between the dots and a circle with the given color at each dot |
static int |
COPY_LABELS
Flag for copying from a template: copy text of axis labels |
static int |
COPY_LEGEND
Flag for copying from a template: copy legend |
static int |
COPY_SIZE
Flag for copying from a template: copy text of axis labels |
static int |
CROSS
Display points using an cross-shaped mark. |
static int |
DEFAULT_FLAGS
The default flags, will be modified by PlotWindow.noGridLines and PlotWindow.noTicks (see getDefaultFlags) |
static int |
DOT
Display points using a single pixel. |
static int |
LEFT
Text justification. |
static int |
LEFT_MARGIN
Deprecated. Not a fixed value any more, use getDrawingFrame() to get the drawing area |
static int |
LEGEND_BOTTOM_UP
Legend has its curves in bottom-to-top sequence (otherwise top to bottom) |
static int |
LEGEND_TRANSPARENT
Legend erases background (otherwise transparent) |
static int |
LINE
Connect points with solid lines. |
static int |
MIN_FRAMEHEIGHT
minimum width of frame area in plot |
static int |
MIN_FRAMEWIDTH
minimum width of frame area in plot |
static String |
PROPERTY_KEY
key in ImagePlus properties to access the plot behind an ImagePlus |
static int |
RIGHT
Text justification. |
static int |
RIGHT_MARGIN
Deprecated. Not a fixed value any more, use getDrawingFrame() to get the drawing area |
static int |
TOP_LEFT
Legend positions |
static int |
TOP_MARGIN
Deprecated. Not a fixed value any more, use getDrawingFrame() to get the drawing area |
static int |
TOP_RIGHT
Legend positions |
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 |
static int |
X_LOG_NUMBERS
flag for logarithmic x-axis |
static int |
X_LOG_TICKS
flag for ticks (major and minor, if space) on logarithmic x axis |
static int |
X_MINOR_TICKS
flag for drawing minor ticks on linear (non-logarithmic) x axis |
static int |
X_NUMBERS
flag for numeric labels of x-axis ticks |
static int |
X_RANGE
Flag for copying from a template: copy x axis range. |
static int |
X_TICKS
flag for drawing major ticks on linear (non-logarithmic) x axis |
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 |
static int |
Y_LOG_NUMBERS
flag for logarithmic y axis |
static int |
Y_LOG_TICKS
flag for ticks (major and minor, if space) on logarithmic y axis |
static int |
Y_MINOR_TICKS
flag for drawing minor ticks on linear (non-logarithmic) y axis |
static int |
Y_NUMBERS
flag for numeric labels of x-axis ticks |
static int |
Y_RANGE
Flag for copying from a template: copy y axis range |
static int |
Y_TICKS
flag for drawing major ticks on linear (non-logarithmic) y axis |
Constructor Summary | |
---|---|
Plot(String title,
String xLabel,
String yLabel)
This is a version of the constructor with no intial arrays. |
|
Plot(String title,
String xLabel,
String yLabel,
double[] xValues,
double[] yValues)
This version of the constructor accepts double arrays. |
|
Plot(String title,
String xLabel,
String yLabel,
double[] xValues,
double[] yValues,
int flags)
This version of the constructor accepts double arrays and has a 'flags' argument. |
|
Plot(String title,
String xLabel,
String yLabel,
float[] xValues,
float[] yValues)
Construct a new PlotWindow. |
|
Plot(String title,
String xLabel,
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. |
|
Plot(String title,
String xLabel,
String yLabel,
int flags)
This is a version of the constructor with no intial arrays. |
|
Plot(String dummy,
String title,
String xLabel,
String yLabel,
float[] xValues,
float[] yValues)
This is a constructor that works with JavaScript. |
Method Summary | |
---|---|
void |
add(String shape,
double[] x,
double[] y)
|
void |
addErrorBars(double[] errorBars)
Adds vertical error bars to the last data passed to the plot (via the constructor or addPoints). |
void |
addErrorBars(float[] errorBars)
Adds vertical error bars to the last data passed to the plot (via the constructor or addPoints). |
void |
addErrorBars(String dummy,
float[] errorBars)
This is a version of addErrorBars that works with JavaScript. |
void |
addHorizontalErrorBars(double[] xErrorBars)
Adds horizontal error bars to the last data passed to the plot (via the constructor or addPoints). |
void |
addLabel(double x,
double y,
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 |
addLegend(String labels)
Adds an automatically positioned legend, where 'labels' is a newline-delimited list of curve or point lables. |
void |
addLegend(String labels,
String options)
|
void |
addPoints(ArrayList x,
ArrayList y,
ArrayList z,
int shape)
Adds a set of points to the plot using double ArrayLists. |
void |
addPoints(ArrayList x,
ArrayList y,
int shape)
Adds a set of points to the plot using double ArrayLists. |
void |
addPoints(double[] x,
double[] y,
double[] errorBars,
int shape)
Adds a set of points to the plot or adds a curve if shape is set to LINE. |
void |
addPoints(double[] x,
double[] y,
int shape)
Adds a set of points to the plot using double arrays. |
void |
addPoints(float[] xValues,
float[] yValues,
float[] yErrorBars,
int shape,
String label)
Adds a set of points to the plot or adds a curve if shape is set to LINE. |
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 |
addPoints(String dummy,
float[] x,
float[] y,
int shape)
This a version of addPoints that works with JavaScript. |
void |
addText(String label,
double x,
double y)
|
void |
adjustCalibration(Calibration cal)
Adjusts a Calibration object to fit the current axes. |
static double |
calculateDistance(int x1,
int y1,
int x2,
int y2)
|
void |
changeFont(Font font)
Obsolete; replaced by setFont(). |
double |
descaleX(int x)
Converts pixels to calibrated coordinates. |
double |
descaleY(int y)
Converts pixels to calibrated coordinates. |
void |
dispose()
Releases the ImageProcessor and ImagePlus associated with the plot. |
void |
draw()
Draws the plot specified for the first time. |
void |
drawArrow(int x1,
int y1,
int x2,
int y2,
double size)
Adds an arrow from position 1 to 2 given in pixels; 'size' is the length of the arrowhead WARNING: Use as a public method is not supported any more because it is incompatible with rescaling |
void |
drawDottedLine(double x1,
double y1,
double x2,
double y2,
int step)
|
void |
drawLine(double x1,
double y1,
double x2,
double y2)
|
void |
drawNormalizedLine(double x1,
double y1,
double x2,
double y2)
Draws a line using a normalized 0-1, 0-1 coordinate system, with (0,0) at the top left and (1,1) at the lower right corner. |
void |
drawVectors(ArrayList x1,
ArrayList y1,
ArrayList x2,
ArrayList y2)
Adds a set of vectors to the plot using double ArrayLists. |
void |
drawVectors(double[] x1,
double[] y1,
double[] x2,
double[] y2)
Adds a set of points that will be drawn as ARROWs. |
static int |
getDefaultFlags()
The default flags, taking PlotWindow.noGridLines, PlotWindow.noTicks into account |
double[] |
getDoubleFromArrayList(ArrayList list)
|
Rectangle |
getDrawingFrame()
Returns the rectangle where the data are plotted. |
int |
getFlags()
Returns the flags that control the axes |
ImagePlus |
getImagePlus()
Returns the plot as an ImagePlus. |
double[] |
getLimits()
Returns the current limits as an array xMin, xMax, yMin, yMax. |
Dimension |
getMinimumSize()
The minimum plot size including borders, in pixels (at scale=1) |
ImageProcessor |
getProcessor()
Draws the plot (if not done before) in an ImageProcessor and returns the ImageProcessor with the plot. |
ResultsTable |
getResultsTable(boolean writeFirstXColumn)
Creates a ResultsTable with the data of the plot. |
Dimension |
getSize()
The size of the plot including borders with axis labels etc., in pixels |
String |
getTitle()
Returns the title of the image showing the plot (if any) or title of the plot |
float[] |
getXValues()
Get the x coordinates of the data set passed with the constructor (if not null) or otherwise of the data set of the first 'addPoints'. |
float[] |
getYValues()
Get the y coordinates of the data set passed with the constructor (if not null) or otherwise of the data set of the first 'addPoints'. |
boolean |
isFrozen()
|
ImagePlus |
makeHighResolution(String title,
float scale,
boolean antialiasedText,
boolean showIt)
Creates a new high-resolution plot by scaling it and displays that plot if showIt is true. |
double |
scaleXtoPxl(double x)
Converts calibrated coordinates to pixel coordinates. |
double |
scaleYtoPxl(double y)
Converts calibrated coordinates to pixel coordinates. |
void |
setAntialiasedText(boolean antialiasedText)
Determines whether to use antialiased text (default true) |
void |
setAxes(boolean xLog,
boolean yLog,
boolean xTicks,
boolean yTicks,
boolean xMinorTicks,
boolean yMinorTicks,
int tickLenght,
int minorTickLenght)
Sets the properties of the axes. |
void |
setAxisLabelFont(int style,
float size)
Sets the size of the x and y label font size and style. |
void |
setAxisXLog(boolean axisXLog)
Sets the X Axis format to Log or Linear. |
void |
setAxisYLog(boolean axisYLog)
Sets the Y Axis format to Log or Linear. |
void |
setColor(Color c)
Changes the drawing color for the next objects that will be added to the plot. |
void |
setColor(Color c,
Color c2)
Changes the drawing color for the next objects that will be added to the plot. |
void |
setColor(String color)
|
void |
setColor(String c1,
String c2)
|
void |
setFont(Font font)
Sets the font for all following drawLabel etc. |
void |
setFont(int style,
float size)
Sets the font size and style for all following drawLabel etc. |
void |
setFormatFlags(int flags)
Sets the flags that control the axes format. |
void |
setFrameSize(int width,
int height)
Sets the plot frame size in (unscaled) pixels. |
void |
setFrozen(boolean frozen)
Freezes or unfreezes the plot. |
void |
setImagePlus(ImagePlus imp)
Sets the ImagePlus where the plot will be displayed. |
void |
setJustification(int justification)
Sets the justification used by addLabel(), where justification
is Plot.LEFT, Plot.CENTER or Plot.RIGHT. |
void |
setLegend(String labels,
int flags)
Adds a legend. |
void |
setLimits(double xMin,
double xMax,
double yMin,
double yMax)
Sets the x-axis and y-axis range. |
void |
setLimitsToDefaults(boolean updateImg)
Sets the plot range to the initial value determined from minima&maxima or given by setLimits. |
void |
setLimitsToFit(boolean updateImg)
Sets the plot range to encompass all data. |
void |
setLineWidth(float lineWidth)
Changes the line width for the next objects that will be added to the plot. |
void |
setLineWidth(int lineWidth)
Changes the line width for the next objects that will be added to the plot. |
void |
setLogScaleX()
Sets log scale in x. |
void |
setLogScaleY()
|
void |
setMaxIntervals(int intervals)
Sets the maximum number of intervals in a plot. |
void |
setMinorTickLength(int minorTickLength)
Sets the length of the minor tick in pixels. |
void |
setPlotMaker(PlotMaker plotMaker)
|
void |
setPreviousMinMax()
reverts plot range to previous values and updates the image |
void |
setScale(float scale)
Sets the scale. |
void |
setSize(int width,
int height)
Sets the canvas size in unscaled pixels and sets the scale to 1.0. |
void |
setTickLength(int tickLength)
Sets the length of the major tick in pixels. |
void |
setXLabelFont(Font font)
Sets the xLabelFont; must not be mull. |
void |
setXMinorTicks(boolean xMinorTicks)
Sets whether to show minor ticks on the x axis (if linear). |
void |
setXTicks(boolean xTicks)
Sets whether to show major ticks at the x axis. |
void |
setXYLabels(String xLabel,
String yLabel)
Sets the labels of the x and y axes. |
void |
setYLabelFont(Font font)
Sets the yLabelFont; must not be null. |
void |
setYMinorTicks(boolean yMinorTicks)
Sets whether to show minor ticks on the y axis (if linear). |
void |
setYTicks(boolean yTicks)
Sets whether to show major ticks at the y axis. |
PlotWindow |
show()
Displays the plot in a PlotWindow and returns a reference to the PlotWindow. |
static int |
toShape(String str)
|
void |
updateImage()
Draws the plot again, ignored if the plot has not been drawn before or the plot is frozen If the ImagePlus exist, updates it and its calibration. |
void |
useTemplate(Plot plot)
Adjusts the format with another plot as a template, using the current (usually default) flags of this plot. |
void |
useTemplate(Plot plot,
int templateFlags)
Adjusts the format with another plot as a template. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int LEFT
public static final int CENTER
public static final int RIGHT
public static final int TOP_LEFT
public static final int TOP_RIGHT
public static final int BOTTOM_LEFT
public static final int BOTTOM_RIGHT
public static final int AUTO_POSITION
public static final int LEGEND_BOTTOM_UP
public static final int LEGEND_TRANSPARENT
public static final int CIRCLE
public static final int X
public static final int BOX
public static final int TRIANGLE
public static final int CROSS
public static final int DOT
public static final int LINE
public static final int CONNECTED_CIRCLES
public static final int X_NUMBERS
public static final int Y_NUMBERS
public static final int X_TICKS
public static final int Y_TICKS
public static final int X_GRID
public static final int Y_GRID
public static final int X_FORCE2GRID
public static final int Y_FORCE2GRID
public static final int X_MINOR_TICKS
public static final int Y_MINOR_TICKS
public static final int X_LOG_NUMBERS
public static final int Y_LOG_NUMBERS
public static final int X_LOG_TICKS
public static final int Y_LOG_TICKS
public static final int DEFAULT_FLAGS
public static final int X_RANGE
public static final int Y_RANGE
public static final int COPY_SIZE
public static final int COPY_LABELS
public static final int COPY_LEGEND
public static final int LEFT_MARGIN
public static final int RIGHT_MARGIN
public static final int TOP_MARGIN
public static final int BOTTOM_MARGIN
public static final int MIN_FRAMEWIDTH
public static final int MIN_FRAMEHEIGHT
public static final String PROPERTY_KEY
Constructor Detail |
---|
public Plot(String title, String xLabel, String yLabel, float[] xValues, float[] yValues)
title
- the window titlexLabel
- the x-axis labelyLabel
- the y-axis labelxValues
- the x-coodinates, or null. If null and yValues is not null, integers starting at 0 will be used for x.yValues
- the y-coodinates, or null for providing no data yet.public Plot(String title, String xLabel, String yLabel, double[] xValues, double[] yValues)
public Plot(String dummy, String title, String xLabel, String yLabel, float[] xValues, float[] yValues)
public Plot(String title, String xLabel, String yLabel)
public Plot(String title, String xLabel, String yLabel, int flags)
public Plot(String title, String xLabel, String yLabel, float[] xValues, float[] yValues, int flags)
public Plot(String title, String xLabel, String yLabel, double[] xValues, double[] yValues, int flags)
Method Detail |
---|
public String getTitle()
public void setLimits(double xMin, double xMax, double yMin, double yMax)
public double[] getLimits()
public void setSize(int width, int height)
public Dimension getSize()
public void setFrameSize(int width, int height)
public Dimension getMinimumSize()
public void useTemplate(Plot plot)
plot
may be null; then the call has no effect.
public void useTemplate(Plot plot, int templateFlags)
plot
may be null; then the call has no effect.
public void setScale(float scale)
public void setXYLabels(String xLabel, String yLabel)
public void setMaxIntervals(int intervals)
public void setTickLength(int tickLength)
public void setMinorTickLength(int minorTickLength)
public void setFormatFlags(int flags)
public int getFlags()
public void setAxisXLog(boolean axisXLog)
public void setAxisYLog(boolean axisYLog)
public void setXTicks(boolean xTicks)
public void setYTicks(boolean yTicks)
public void setXMinorTicks(boolean xMinorTicks)
public void setYMinorTicks(boolean yMinorTicks)
public void setAxes(boolean xLog, boolean yLog, boolean xTicks, boolean yTicks, boolean xMinorTicks, boolean yMinorTicks, int tickLenght, int minorTickLenght)
public void setLogScaleX()
public void setLogScaleY()
public static int getDefaultFlags()
public void addPoints(float[] xValues, float[] yValues, float[] yErrorBars, int shape, String label)
xValues
- the x coordinates, or null. If null, integers starting at 0 will be used for x.yValues
- the y coordinates (must not be null)yErrorBars
- error bars in y, may be nullshape
- CIRCLE, X, BOX, TRIANGLE, CROSS, DOT, LINE, CONNECTED_CIRCLESlabel
- Label for this curve or set of points, used for a legend and for listing the plotspublic void addPoints(float[] x, float[] y, int shape)
x
- the x coordinatesy
- the y coordinatesshape
- CIRCLE, X, BOX, TRIANGLE, CROSS, DOT, LINE, CONNECTED_CIRCLESpublic void addPoints(double[] x, double[] y, int shape)
public void addPoints(String dummy, float[] x, float[] y, int shape)
public void add(String shape, double[] x, double[] y)
public static int toShape(String str)
public void addPoints(ArrayList x, ArrayList y, int shape)
public void addPoints(double[] x, double[] y, double[] errorBars, int shape)
x
- the x-coodinatesy
- the y-coodinateserrorBars
- the vertical error bars, may be nullshape
- CIRCLE, X, BOX, TRIANGLE, CROSS, DOT or LINEpublic void addPoints(ArrayList x, ArrayList y, ArrayList z, int shape)
public double[] getDoubleFromArrayList(ArrayList list)
public void drawVectors(double[] x1, double[] y1, double[] x2, double[] y2)
x1
- the x-coodinates of the beginning of the arrowy1
- the y-coodinates of the beginning of the arrowx2
- the x-coodinates of the end of the arrowy2
- the y-coodinates of the end of the arrowpublic static double calculateDistance(int x1, int y1, int x2, int y2)
public void drawVectors(ArrayList x1, ArrayList y1, ArrayList x2, ArrayList y2)
public void addErrorBars(float[] errorBars)
public void addErrorBars(double[] errorBars)
public void addErrorBars(String dummy, float[] errorBars)
public void addHorizontalErrorBars(double[] xErrorBars)
public void addLabel(double x, double y, String label)
public void addText(String label, double x, double y)
public void addLegend(String labels)
public void addLegend(String labels, String options)
public void setLegend(String labels, int flags)
labels
- labels of the points or curves in the sequence of the data added, tab-delimited or linefeed-delimited.
The labels of the datasets will be set to these values. If null or not given, the labels set
previously (if any) will be used.flags
- Bitwise or of position (AUTO_POSITION, TOP_LEFT etc.), LEGEND_TRANSPARENT, and LEGEND_BOTTOM_UP if desired.
Updates the image (if it is shown already).public void setJustification(int justification)
justification
is Plot.LEFT, Plot.CENTER or Plot.RIGHT. Default is LEFT.
public void setColor(Color c)
setColor
before draw
.
The frame and labels are always drawn in black.
public void setColor(String color)
public void setColor(Color c, Color c2)
setColor
before draw
.
The frame and labels are always drawn in black.
public void setColor(String c1, String c2)
public void setLineWidth(int lineWidth)
public void setLineWidth(float lineWidth)
public void drawLine(double x1, double y1, double x2, double y2)
public void drawNormalizedLine(double x1, double y1, double x2, double y2)
public void drawDottedLine(double x1, double y1, double x2, double y2, int step)
public void setFont(Font font)
public void setFont(int style, float size)
style
to -1 to leave the style unchanged.
Call updateImage() thereafter to make the change visible (if the image is shown already).
public void setAxisLabelFont(int style, float size)
style
to -1 to leave the style unchanged.
Call updateImage() thereafter to make the change visible (if the image is shown already).
public void setXLabelFont(Font font)
public void setYLabelFont(Font font)
public void setAntialiasedText(boolean antialiasedText)
public void changeFont(Font font)
public float[] getXValues()
public float[] getYValues()
public void setLimitsToDefaults(boolean updateImg)
public void setLimitsToFit(boolean updateImg)
public void setPreviousMinMax()
public ImageProcessor getProcessor()
public ImagePlus getImagePlus()
public void setImagePlus(ImagePlus imp)
public void adjustCalibration(Calibration cal)
public PlotWindow show()
public void draw()
public void setFrozen(boolean frozen)
setFrozen(false)
.
public boolean isFrozen()
public void updateImage()
public Rectangle getDrawingFrame()
public ImagePlus makeHighResolution(String title, float scale, boolean antialiasedText, boolean showIt)
title
may be null, then a default title is used.
public void dispose()
public double descaleX(int x)
public double descaleY(int y)
public double scaleXtoPxl(double x)
public double scaleYtoPxl(double y)
public void drawArrow(int x1, int y1, int x2, int y2, double size)
public void setPlotMaker(PlotMaker plotMaker)
public ResultsTable getResultsTable(boolean writeFirstXColumn)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |