|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectij.IJ
public class IJ
This class consists of static utility methods.
Nested Class Summary | |
---|---|
static interface |
IJ.ExceptionHandler
|
Field Summary | |
---|---|
static int |
ALL_KEYS
|
static char |
angstromSymbol
|
static int |
CANCELED
|
static boolean |
debugMode
|
static char |
degreeSymbol
|
static boolean |
hideProcessStackDialog
|
static char |
micronSymbol
|
static java.lang.String |
URL
|
Constructor Summary | |
---|---|
IJ()
|
Method Summary | |
---|---|
static void |
addEventListener(IJEventListener listener)
|
static boolean |
altKeyDown()
Returns true if the alt key is down. |
static java.lang.String |
append(java.lang.String string,
java.lang.String path)
Appends a string to the end of a file. |
static void |
beep()
Emits an audio beep. |
static boolean |
controlKeyDown()
Returns true if the control key is down. |
static ImagePlus |
createImage(java.lang.String title,
java.lang.String type,
int width,
int height,
int depth)
Creates a new imagePlus. |
static long |
currentMemory()
Returns the amount of memory currently being used by ImageJ. |
static java.lang.String |
d2s(double n)
Converts a number to a formatted string using 2 digits to the right of the decimal point. |
static java.lang.String |
d2s(double n,
int decimalPlaces)
Converts a number to a rounded formatted string. |
static void |
deleteRows(int row1,
int row2)
Deletes 'row1' through 'row2' of the "Results" window. |
static void |
doCommand(java.lang.String command)
Starts executing a menu command in a separete thread and returns immediately. |
static int |
doWand(int x,
int y)
Equivalent to clicking on the current image at (x,y) with the wand tool. |
static int |
doWand(int x,
int y,
double tolerance,
java.lang.String mode)
Traces the boundary of the area with pixel values within 'tolerance' of the value of the pixel at the starting location. |
static void |
error(java.lang.String msg)
Displays a message in a dialog box titled "ImageJ". |
static void |
error(java.lang.String title,
java.lang.String msg)
Displays a message in a dialog box with the specified title. |
static boolean |
escapePressed()
Returns true if the Esc key was pressed since the
last ImageJ command started to execute or since resetEscape() was called. |
static java.lang.String |
freeMemory()
Runs the garbage collector and returns a string something like "64K of 256MB (25%)" that shows how much of the available memory is in use. |
static java.applet.Applet |
getApplet()
Returns the Applet that created this ImageJ or null if running as an application. |
static java.lang.ClassLoader |
getClassLoader()
Returns an instance of the class loader ImageJ uses to run plugins. |
static java.lang.String |
getDirectory(java.lang.String title)
Returns the path to the home ("user.home"), startup, ImageJ, plugins, macros, luts, temp, current or image directory if title is "home", "startup",
"imagej", "plugins", "macros", "luts", "temp", "current" or "image", otherwise,
displays a dialog and returns the path to the directory selected by the user. |
static ImagePlus |
getImage()
Returns a reference to the active image. |
static ImageJ |
getInstance()
Returns a reference to the "ImageJ" frame. |
static double |
getNumber(java.lang.String prompt,
double defaultValue)
Allows the user to enter a number in a dialog box. |
static java.awt.Dimension |
getScreenSize()
Returns the size, in pixels, of the primary display. |
static java.lang.String |
getString(java.lang.String prompt,
java.lang.String defaultString)
Allows the user to enter a string in a dialog box. |
static TextPanel |
getTextPanel()
Returns a reference to the "Results" window TextPanel. |
static java.lang.String |
getToolName()
Returns the name of the current tool. |
static java.lang.String |
getVersion()
Returns the ImageJ version number as a string. |
static void |
handleException(java.lang.Throwable e)
Displays a stack trace. |
static boolean |
is64Bit()
Returns true if ImageJ is running a 64-bit version of Java. |
static boolean |
isJava14()
Returns true if ImageJ is running on a Java 1.4 or greater JVM. |
static boolean |
isJava15()
Returns true if ImageJ is running on a Java 1.5 or greater JVM. |
static boolean |
isJava16()
Returns true if ImageJ is running on a Java 1.6 or greater JVM. |
static boolean |
isJava17()
Returns true if ImageJ is running on a Java 1.7 or greater JVM. |
static boolean |
isJava2()
Always returns true. |
static boolean |
isLinux()
Returns true if ImageJ is running on Linux. |
static boolean |
isMacintosh()
Returns true if this machine is a Macintosh. |
static boolean |
isMacOSX()
Returns true if this machine is a Macintosh running OS X. |
static boolean |
isMacro()
Returns true if a macro is running, or if the run(), open() or newImage() method is executing. |
static boolean |
isResultsWindow()
Returns true if the "Results" window is open. |
static boolean |
isVista()
Returns true if ImageJ is running on Windows Vista. |
static boolean |
isWindows()
Returns true if this machine is running Windows. |
static void |
log(java.lang.String s)
|
static boolean |
macroRunning()
Returns true if the run(), open() or newImage() method is executing. |
static void |
makeLine(double x1,
double y1,
double x2,
double y2)
Creates a straight line selection using double coordinates. |
static void |
makeLine(int x1,
int y1,
int x2,
int y2)
Creates a straight line selection. |
static void |
makeOval(int x,
int y,
int width,
int height)
Creates an elliptical selection. |
static void |
makePoint(int x,
int y)
Creates a point selection. |
static void |
makeRectangle(int x,
int y,
int width,
int height)
Creates a rectangular selection. |
static long |
maxMemory()
Returns the maximum amount of memory available to ImageJ or zero if ImageJ is unable to determine this limit. |
static void |
newImage(java.lang.String title,
java.lang.String type,
int width,
int height,
int depth)
Opens a new image. |
static void |
noImage()
Displays a "no images are open" dialog box. |
static void |
notifyEventListeners(int eventID)
|
static void |
open()
Displays a file open dialog box and then opens the tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text file selected by the user. |
static void |
open(java.lang.String path)
Opens and displays a tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text file. |
static void |
open(java.lang.String path,
int n)
Opens and displays the nth image in the specified tiff stack. |
static java.lang.String |
openAsString(java.lang.String path)
Opens a text file as a string. |
static ImagePlus |
openImage()
Opens an image using a file open dialog and returns it as an ImagePlus object. |
static ImagePlus |
openImage(java.lang.String path)
Opens the specified file as a tiff, bmp, dicom, fits, pgm, gif or jpeg image and returns an ImagePlus object if successful. |
static ImagePlus |
openImage(java.lang.String path,
int n)
Opens the nth image of the specified tiff stack. |
static java.lang.String |
openUrlAsString(java.lang.String url)
Opens a URL and returns the contents as a string. |
static void |
outOfMemory(java.lang.String name)
Displays an "out of memory" message to the "Log" window. |
static void |
redirectErrorMessages()
Causes IJ.error() output to be temporarily redirected to the "Log" window. |
static void |
redirectErrorMessages(boolean redirect)
Set 'true' and IJ.error() output will be redirected to the "Log" window. |
static boolean |
redirectingErrorMessages()
Returns the state of the 'redirectErrorMessages' flag. |
static void |
register(java.lang.Class c)
Adds the specified class to a Vector to keep it from being garbage collected, which would cause the classes static fields to be reset. |
static void |
removeEventListener(IJEventListener listener)
|
static void |
resetEscape()
This method sets the Esc key to the "up" position. |
static void |
resetMinAndMax()
Resets the minimum and maximum displayed pixel values to be the same as the min and max pixel values. |
static void |
resetThreshold()
Disables thresholding. |
static void |
run(ImagePlus imp,
java.lang.String command,
java.lang.String options)
Runs an ImageJ command using the specified image and options. |
static void |
run(java.lang.String command)
Runs an ImageJ command. |
static void |
run(java.lang.String command,
java.lang.String options)
Runs an ImageJ command, with options that are passed to the GenericDialog and OpenDialog classes. |
static java.lang.String |
runMacro(java.lang.String macro)
Runs the macro contained in the string macro . |
static java.lang.String |
runMacro(java.lang.String macro,
java.lang.String arg)
Runs the macro contained in the string macro . |
static java.lang.String |
runMacroFile(java.lang.String name)
Runs the specified macro file. |
static java.lang.String |
runMacroFile(java.lang.String name,
java.lang.String arg)
Runs the specified macro or script file in the current thread. |
static java.lang.Object |
runPlugIn(ImagePlus imp,
java.lang.String className,
java.lang.String arg)
Runs the specified plugin using the specified image. |
static java.lang.Object |
runPlugIn(java.lang.String className,
java.lang.String arg)
Runs the specified plugin and returns a reference to it. |
static void |
save(ImagePlus imp,
java.lang.String path)
Saves the specified image, lookup table or selection to the specified file path. |
static void |
save(java.lang.String path)
Saves the current image, lookup table, selection or text window to the specified file path. |
static void |
saveAs(ImagePlus imp,
java.lang.String format,
java.lang.String path)
|
static void |
saveAs(java.lang.String format,
java.lang.String path)
|
static java.lang.String |
saveString(java.lang.String string,
java.lang.String path)
Saves a string as a file. |
static void |
selectWindow(int id)
For IDs less than zero, activates the image with the specified ID. |
static void |
selectWindow(java.lang.String title)
Activates the window with the specified title. |
static void |
setBackgroundColor(int red,
int green,
int blue)
Sets the background color. |
static void |
setColumnHeadings(java.lang.String headings)
Clears the "Results" window and sets the column headings to those in the tab-delimited 'headings' String. |
static void |
setExceptionHandler(IJ.ExceptionHandler handler)
Installs a custom exception handler that overrides the handleException() method. |
static void |
setForegroundColor(int red,
int green,
int blue)
Sets the foreground color. |
static void |
setInputEvent(java.awt.event.InputEvent e)
|
static void |
setKeyDown(int key)
|
static void |
setKeyUp(int key)
|
static void |
setMinAndMax(double min,
double max)
Sets the minimum and maximum displayed pixel values. |
static void |
setMinAndMax(double min,
double max,
int channels)
Sets the minimum and maximum displayed pixel values on the specified RGB channels, where 4=red, 2=green and 1=blue. |
static void |
setPasteMode(java.lang.String mode)
Sets the transfer mode used by the Edit/Paste command, where mode is "Copy", "Blend", "Average", "Difference", "Transparent", "Transparent2", "AND", "OR", "XOR", "Add", "Subtract", "Multiply", or "Divide". |
static void |
setSlice(int slice)
Switches to the specified stack slice, where 1<='slice'<=stack-size. |
static void |
setTextPanel(TextPanel tp)
TextWindow calls this method with a null argument when the "Results" window is closed. |
static void |
setThreshold(double lowerThreshold,
double upperThresold)
Sets the lower and upper threshold levels and displays the image using red to highlight thresholded pixels. |
static void |
setThreshold(double lowerThreshold,
double upperThreshold,
java.lang.String displayMode)
Sets the lower and upper threshold levels and displays the image using the specified displayMode ("Red", "Black & White", "Over/Under" or "No Update"). |
static void |
setTool(int id)
Switches to the specified tool, where id = Toolbar.RECTANGLE (0), Toolbar.OVAL (1), etc. |
static boolean |
setTool(java.lang.String name)
Switches to the specified tool, where 'name' is "rect", "elliptical", "brush", etc. |
static int |
setupDialog(ImagePlus imp,
int flags)
Displays a "Process all images?" dialog. |
static boolean |
shiftKeyDown()
Returns true if the shift key is down. |
static void |
showMessage(java.lang.String msg)
Displays a message in a dialog box titled "Message". |
static void |
showMessage(java.lang.String title,
java.lang.String msg)
Displays a message in a dialog box with the specified title. |
static boolean |
showMessageWithCancel(java.lang.String title,
java.lang.String msg)
Displays a message in a dialog box with the specified title. |
static void |
showProgress(double progress)
Updates the progress bar, where 0<=progress<=1.0. |
static void |
showProgress(int currentIndex,
int finalIndex)
Updates the progress bar, where the length of the bar is set to ( currentValue+1)/finalValue of the maximum bar length. |
static void |
showStatus(java.lang.String s)
Displays a message in the ImageJ status bar. |
static void |
showTime(ImagePlus imp,
long start,
java.lang.String str)
|
static void |
showTime(ImagePlus imp,
long start,
java.lang.String str,
int nslices)
|
static boolean |
spaceBarDown()
Returns true if the space bar is down. |
static void |
suppressPluginNotFoundError()
Temporarily suppress "plugin not found" errors. |
static boolean |
versionLessThan(java.lang.String version)
Displays an error message and returns false if the ImageJ version is less than the one specified. |
static void |
wait(int msecs)
Delays 'msecs' milliseconds. |
static void |
write(java.lang.String s)
Deprecated. replaced by IJ.log() |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String URL
public static final int ALL_KEYS
public static boolean debugMode
public static boolean hideProcessStackDialog
public static final char micronSymbol
public static final char angstromSymbol
public static final char degreeSymbol
public static final int CANCELED
Constructor Detail |
---|
public IJ()
Method Detail |
---|
public static ImageJ getInstance()
public static java.lang.String runMacro(java.lang.String macro)
macro
.
Returns any string value returned by the macro, null if the macro
does not return a value, or "[aborted]" if the macro was aborted
due to an error. The equivalent macro function is eval().
public static java.lang.String runMacro(java.lang.String macro, java.lang.String arg)
macro
.
The optional string argument can be retrieved in the
called macro using the getArgument() macro function.
Returns any string value returned by the macro, null if the macro
does not return a value, or "[aborted]" if the macro was aborted
due to an error.
public static java.lang.String runMacroFile(java.lang.String name, java.lang.String arg)
name
is a full path. ".txt" is
added if name
does not have an extension.
The optional string argument (arg
) can be retrieved in the called
macro or script (v1.42k or later) using the getArgument() function.
Returns any string value returned by the macro, or null. Scripts always return null.
The equivalent macro function is runMacro().
public static java.lang.String runMacroFile(java.lang.String name)
public static java.lang.Object runPlugIn(ImagePlus imp, java.lang.String className, java.lang.String arg)
public static java.lang.Object runPlugIn(java.lang.String className, java.lang.String arg)
public static void doCommand(java.lang.String command)
public static void run(java.lang.String command)
public static void run(java.lang.String command, java.lang.String options)
public static void run(ImagePlus imp, java.lang.String command, java.lang.String options)
public static boolean macroRunning()
public static boolean isMacro()
public static java.applet.Applet getApplet()
public static void showStatus(java.lang.String s)
public static void write(java.lang.String s)
public static void log(java.lang.String s)
public static void setColumnHeadings(java.lang.String headings)
public static boolean isResultsWindow()
public static void deleteRows(int row1, int row2)
public static TextPanel getTextPanel()
public static void setTextPanel(TextPanel tp)
public static void noImage()
public static void outOfMemory(java.lang.String name)
public static void showProgress(double progress)
public static void showProgress(int currentIndex, int finalIndex)
currentValue+1)/finalValue
of the maximum bar length.
The bar is erased if currentValue>=finalValue
.
The bar is updated only if more than 90 ms have passed since the last call.
Does nothing if the ImageJ window is not present.
public static void showMessage(java.lang.String msg)
public static void showMessage(java.lang.String title, java.lang.String msg)
public static void error(java.lang.String msg)
public static void error(java.lang.String title, java.lang.String msg)
public static boolean showMessageWithCancel(java.lang.String title, java.lang.String msg)
public static double getNumber(java.lang.String prompt, double defaultValue)
public static java.lang.String getString(java.lang.String prompt, java.lang.String defaultString)
public static void wait(int msecs)
public static void beep()
public static java.lang.String freeMemory()
public static long currentMemory()
public static long maxMemory()
public static void showTime(ImagePlus imp, long start, java.lang.String str)
public static void showTime(ImagePlus imp, long start, java.lang.String str, int nslices)
public static java.lang.String d2s(double n)
public static java.lang.String d2s(double n, int decimalPlaces)
public static void register(java.lang.Class c)
public static boolean spaceBarDown()
public static boolean controlKeyDown()
public static boolean altKeyDown()
public static boolean shiftKeyDown()
public static void setKeyDown(int key)
public static void setKeyUp(int key)
public static void setInputEvent(java.awt.event.InputEvent e)
public static boolean isMacintosh()
public static boolean isMacOSX()
public static boolean isWindows()
public static boolean isJava2()
public static boolean isJava14()
public static boolean isJava15()
public static boolean isJava16()
public static boolean isJava17()
public static boolean isLinux()
public static boolean isVista()
public static boolean is64Bit()
public static boolean versionLessThan(java.lang.String version)
public static int setupDialog(ImagePlus imp, int flags)
public static void makeRectangle(int x, int y, int width, int height)
public static void makeOval(int x, int y, int width, int height)
public static void makeLine(int x1, int y1, int x2, int y2)
public static void makePoint(int x, int y)
public static void makeLine(double x1, double y1, double x2, double y2)
public static void setMinAndMax(double min, double max)
public static void setMinAndMax(double min, double max, int channels)
public static void resetMinAndMax()
public static void setThreshold(double lowerThreshold, double upperThresold)
public static void setThreshold(double lowerThreshold, double upperThreshold, java.lang.String displayMode)
displayMode
("Red", "Black & White", "Over/Under" or "No Update").
public static void resetThreshold()
public static void selectWindow(int id)
public static void selectWindow(java.lang.String title)
public static void setForegroundColor(int red, int green, int blue)
public static void setBackgroundColor(int red, int green, int blue)
public static void setTool(int id)
public static boolean setTool(java.lang.String name)
public static java.lang.String getToolName()
public static int doWand(int x, int y)
public static int doWand(int x, int y, double tolerance, java.lang.String mode)
public static void setPasteMode(java.lang.String mode)
public static ImagePlus getImage()
public static void setSlice(int slice)
public static java.lang.String getVersion()
public static java.lang.String getDirectory(java.lang.String title)
title
is "home", "startup",
"imagej", "plugins", "macros", "luts", "temp", "current" or "image", otherwise,
displays a dialog and returns the path to the directory selected by the user.
Returns null if the specified directory is not found or the user
cancels the dialog box. Also aborts the macro if the user cancels
the dialog box.
public static void open()
public static void open(java.lang.String path)
public static void open(java.lang.String path, int n)
public static ImagePlus openImage(java.lang.String path)
public static ImagePlus openImage(java.lang.String path, int n)
public static ImagePlus openImage()
public static java.lang.String openUrlAsString(java.lang.String url)
public static void save(java.lang.String path)
public static void save(ImagePlus imp, java.lang.String path)
public static void saveAs(java.lang.String format, java.lang.String path)
public static void saveAs(ImagePlus imp, java.lang.String format, java.lang.String path)
public static java.lang.String saveString(java.lang.String string, java.lang.String path)
public static java.lang.String append(java.lang.String string, java.lang.String path)
public static java.lang.String openAsString(java.lang.String path)
public static ImagePlus createImage(java.lang.String title, java.lang.String type, int width, int height, int depth)
Type
should contain "8-bit", "16-bit", "32-bit" or "RGB".
In addition, it can contain "white", "black" or "ramp" (the default is "white"). Width
and height
specify the width and height of the image in pixels.
Depth
specifies the number of stack slices.
public static void newImage(java.lang.String title, java.lang.String type, int width, int height, int depth)
Type
should contain "8-bit", "16-bit", "32-bit" or "RGB".
In addition, it can contain "white", "black" or "ramp" (the default is "white"). Width
and height
specify the width and height of the image in pixels.
Depth
specifies the number of stack slices.
public static boolean escapePressed()
Esc
key was pressed since the
last ImageJ command started to execute or since resetEscape() was called.
public static void resetEscape()
Esc
key to the "up" position.
The Executer class calls this method when it runs
an ImageJ command in a separate thread.
public static void redirectErrorMessages()
public static void redirectErrorMessages(boolean redirect)
public static boolean redirectingErrorMessages()
public static void suppressPluginNotFoundError()
public static java.lang.ClassLoader getClassLoader()
public static java.awt.Dimension getScreenSize()
public static void handleException(java.lang.Throwable e)
public static void setExceptionHandler(IJ.ExceptionHandler handler)
public static void addEventListener(IJEventListener listener)
public static void removeEventListener(IJEventListener listener)
public static void notifyEventListeners(int eventID)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |