ini.trakem2.utils
Class Utils

java.lang.Object
  extended by ini.trakem2.utils.Utils
All Implemented Interfaces:
ij.plugin.PlugIn

public class Utils
extends java.lang.Object
implements ij.plugin.PlugIn

Utils class: stores generic widely used methods. In particular, those for logging text messages (for debugging) and also some math and memory utilities.


Field Summary
static boolean debug
           
static boolean debug_clip
           
static boolean debug_event
           
static boolean debug_mouse
           
static boolean debug_sql
           
static boolean debug_thing
           
static double FL_ERROR
          The error to use in floating-point or double floating point literal comparisons.
static boolean java3d
           
static java.lang.String last_dir
          The path of the directory from which images have been recently loaded.
static java.lang.String last_file
          The path of the last opened file.
static java.lang.String version
           
 
Constructor Summary
Utils()
           
 
Method Summary
static void addEnablerListener(java.awt.Checkbox master, java.awt.Component[] enable, java.awt.Component[] disable)
          A helper for GenericDialog checkboxes to control other the enabled state of other GUI elements in the same dialog.
static void addLayerChoice(java.lang.String label, Layer selected, ij.gui.GenericDialog gd)
           
static void addLayerRangeChoices(Layer selected, ij.gui.GenericDialog gd)
           
static void addLayerRangeChoices(Layer first, Layer last, ij.gui.GenericDialog gd)
           
static boolean addPlugIns(javax.swing.JPopupMenu popup, java.lang.String menu, Project project, java.util.concurrent.Callable<Displayable> active)
          Returns false if none to add.
static javax.swing.JMenu addPlugIns(java.lang.String menu, Project project, java.util.concurrent.Callable<Displayable> active)
          Returns null if none to add.
static void addRGBColorSliders(ij.gui.GenericDialog gd, java.awt.Color color)
           
static java.lang.String asHexRGBColor(java.awt.Color color)
           
static void asHexRGBColor(java.lang.StringBuilder sb, java.awt.Color color)
           
static java.util.List<java.lang.Long> asList(long[] ids)
           
static java.util.List<java.lang.Long> asList(long[] ids, int first, int length)
           
static java.lang.String caller(java.lang.Object called)
          Returns a String representation of the class of the object one step before in the stack trace.
static boolean check(java.lang.String msg)
           
static boolean checkYN(java.lang.String msg)
           
static java.io.File chooseFile(java.lang.String name, java.lang.String extension)
           
static java.io.File chooseFile(java.lang.String default_dir, java.lang.String name, java.lang.String extension)
          Select a file from the file system, for saving purposes.
static java.lang.String cleanString(java.lang.String s)
          Converts sequences of spaces into single space, and trims the ends.
static ij.process.ImageProcessor convertTo(ij.process.ImageProcessor ip, int type, boolean scaling)
          Converts the ImageProcessor to an ImageProcessor of the given type, or the same if of equal type.
static double[] copy(double[] a, int new_length)
          Will make a new double[] array, then fit in it as many points from the given array as possible according to the desired new length.
static double[] copy(double[] a, int first, int new_length)
           
static long[] copy(long[] a, int new_length)
           
static long[] copy(long[] a, int first, int new_length)
           
static ij.process.ImageProcessor createProcessor(int type, int width, int height)
           
static ij.measure.ResultsTable createResultsTable(java.lang.String title, java.lang.String[] columns)
          Creates a new ResultsTable with the given window title and column titles, and 2 decimals of precision, or if one exists for the given window title, returns it.
static java.io.InputStream createStream(java.lang.String path_or_url)
           
static java.lang.String cutNumber(double d, int n_decimals)
           
static java.lang.String cutNumber(double d, int n_decimals, boolean remove_trailing_zeros)
          remove_trailing_zeros will leave at least one zero after the comma if appropriate.
static java.lang.String d2s(double d, int n_decimals)
           
static void debug(java.lang.String msg)
           
static void debugDialog()
           
static void debugMouse(java.lang.String msg)
           
static void destroy(ControlWindow master)
          Destroy house keeping threads.
static void drawPoint(java.awt.Graphics g, int x, int y)
           
static boolean ensure(java.io.File f)
          Ensure the file can be written to.
static boolean ensure(java.lang.String filepath)
           
static boolean equalContent(java.util.Collection<?> a, java.util.Collection<?> b)
          If both are null will throw an error.
static boolean equalContent(java.util.Map<?,?> a, java.util.Map<?,?> b)
          If both are null will throw an error.
static ij.process.FloatProcessor fastConvertToFloat(ij.process.ByteProcessor ip)
          A method that circumvents the findMinAndMax when creating a float processor from an existing processor.
static ij.process.FloatProcessor fastConvertToFloat(ij.process.ImageProcessor ip)
           
static ij.process.FloatProcessor fastConvertToFloat(ij.process.ImageProcessor ip, int type)
          A method that circumvents the findMinAndMax when creating a float processor from an existing processor.
static ij.process.FloatProcessor fastConvertToFloat(ij.process.ShortProcessor ip)
          A method that circumvents the findMinAndMax when creating a float processor from an existing processor.
static ij.ImagePlus[] findAllOpenImages()
          Scan the WindowManager for all open images, including stacks.
static ij.ImagePlus[] findOpenImages()
          Scan the WindowManager for non-stack images
static ij.ImagePlus[] findOpenStacks()
          Scan the WindowManager for open stacks.
static java.lang.String fixDir(java.lang.String path)
          Convert a D:\\this\that\there to D://this/that/there/ Notice it adds an ending backslash.
static int[] get4Ints(int hex)
           
static java.lang.String getCharacter(int i)
          1 A, 2 B, 3 C --- 26 - z, 27 AA, 28 AB, 29 AC --- 26*27 AAA
static int getControlModifier()
          The CTRL key functionality is passed over to the COMMAND key (aka META key) in a MacOSX.
static double getCos(double x1, double y1, double x2, double y2)
          The cosinus between two vectors (in polar coordinates), by means of the dot product.
static java.awt.Dimension getDimensions(java.lang.String text, java.awt.Font font)
          Get the width and height of single-line text.
static java.lang.Object getField(java.lang.Object ob, java.lang.Class<?> c, java.lang.String field_name)
          Get by reflection a private or protected field in the given object.
static java.lang.Object getField(java.lang.Object ob, java.lang.String field_name)
           
static java.lang.String[] getHexRGBColor(java.awt.Color color)
           
static java.awt.Color getRGBColorFromHex(java.lang.String hex)
           
static int indexOf(java.lang.Object needle, java.lang.Object[] haystack)
           
static void invokeLater(java.lang.Runnable r)
          Invoke in the context of the event dispatch thread.
static boolean isControlDown(java.awt.event.InputEvent e)
          The CTRL key functionality is passed over to the COMMAND key (aka META key) in a MacOSX.
static boolean isPopupTrigger(java.awt.event.MouseEvent me)
          OS-agnostic diagnosis of whether the click was for the contextual popup menu.
static boolean isTrakEM2Subfile(java.io.File f)
          Returns true if the file cannonical path contains "/trakem2." (adjusted for Windows as well).
static boolean isTrakEM2Subpath(java.lang.String path)
          Returns true if the path contains "/trakem2." (adjusted for Windows as well).
static boolean isValidIdentifier(java.lang.String s)
           
static Bureaucrat launchTPlugIn(java.awt.event.KeyEvent ke, java.lang.String menu, Project project, Displayable active)
          Returns null if no plugin was launched.
static void log(java.lang.Object ob)
           
static void log(java.lang.String msg)
          Intended for the user to see.
static void log(java.lang.String msg, java.lang.Object ob)
          Pretty-print the object, for example arrays as [0, 1, 2].
static void log2(java.lang.Object... ob)
           
static void log2(java.lang.Object ob)
          Pretty-print the object, for example arrays as [0, 1, 2].
static void log2(java.lang.String msg)
          Intended for developers: prints to terminal.
static void log2(java.lang.String msg, java.lang.Object ob)
          Pretty-print the object, for example arrays as [0, 1, 2].
static void log2(java.lang.String msg, java.lang.Object ob1, java.lang.Object... ob)
           
static void logAll(java.lang.String msg)
          Print in all printable places: log window, System.out.println, and status bar.
static void logMany2(java.lang.Object... ob)
           
static int luminance(java.awt.Color c)
          0.3 * R + 0.6 * G + 0.1 * B
static java.lang.String makeValidIdentifier(java.lang.String s)
          user=> (def pat #"\b[a-zA-Z]+[\w]*\b") #'user/pat user=>(re-seq pat "abc def 1a334") ("abc" "def") user=> (re-seq pat "abc def a334") ("abc" "def" "a334") Then concatenate all good words with underscores.
static boolean matches(java.lang.String pattern, java.lang.String s)
           
static java.awt.Color mix(java.awt.Color c1, java.awt.Color c2)
          Mix colors visually: red + green = yellow, etc.
static java.util.concurrent.ThreadPoolExecutor newFixedThreadPool(int n_proc)
          Creates a new fixed thread pool whose threads are in the same ThreadGroup as the Thread that calls this method.
static java.util.concurrent.ThreadPoolExecutor newFixedThreadPool(int n_proc, java.lang.String namePrefix)
           
static java.util.concurrent.ThreadPoolExecutor newFixedThreadPool(java.lang.String namePrefix)
          Creates a new fixed thread pool with as many threads as CPUs, and whose threads are in the same ThreadGroup as the Thread that calls this method.
static java.lang.String now()
          Returns the time as HH:MM:SS
static java.lang.String openTextFile(java.lang.String path)
           
static char[] openTextFileChars(java.lang.String path)
           
static java.lang.String[] openTextFileLines(java.lang.String path)
          Returns the file found at path as an array of lines, or null if not found.
static void paint(Pipe pipe, java.util.Map<Layer,ij.process.ImageProcessor> slices, int value, float scale)
          Paints an approximation of the pipe into the set of slices.
static void printCaller(java.lang.Object called_object)
          Find out which method from which class called the method where the printCaller is used; for debugging purposes.
static void printCaller(java.lang.Object called_object, int lines)
           
static java.lang.String removeExtension(java.lang.String path)
           
static boolean removeFile(java.io.File f)
          Remove the file, or if it's a directory, recursively go down subdirs and remove all contents, but will stop on encountering a non-hidden file that is not an empty dir.
static boolean removePrefixedFiles(java.io.File parent, java.lang.String prefix, java.util.ArrayList<java.lang.String> removed_paths)
          Returns true if all files and their subdirectories, recursively, under parent folder have been removed.
static void restoreMenuBar()
          Restore ImageJ's MenuBar
static void revalidateComponent(java.awt.Component c)
          Like calling pack() on a Frame but on a Component.
static void reverse(double[] a)
          Reverse in place an array of doubles.
static void reverse(long[] a)
          Reverse in place an array of longs.
 void run(java.lang.String arg)
           
static boolean saveToFile(java.io.File f, java.lang.String contents)
           
static boolean saveToFile(java.lang.String name, java.lang.String extension, java.lang.String contents)
           
static java.lang.String[] selectFile(java.lang.String title_msg)
          Returns null or the selected directory and file.
static void setDebug(boolean debug)
           
static void setDebugMouse(boolean debug_mouse)
           
static void setDebugSQL(boolean debug_sql)
           
static void setEnabled(java.awt.Container root, boolean b)
          Recursively enable/disable all components of the @param root Container.
static void setField(java.lang.Object ob, java.lang.Class<?> c, java.lang.String field_name, java.lang.Object value)
           
static void setup(ControlWindow master)
          Initialize house keeping threads.
static void showAllTables(java.util.HashMap<java.lang.Class<?>,ij.measure.ResultsTable> ht)
           
static void showMessage(java.lang.String msg)
           
static void showMessage(java.lang.String title, java.lang.String msg)
           
static void showMessageT(java.lang.String msg)
          Runs the showMessage in a separate Thread.
static void showProgress(double p)
           
static void showStatus(java.lang.String msg)
           
static void showStatus(java.lang.String msg, boolean focus)
           
static void sleep(long miliseconds)
           
static double[] toDouble(int[] a, int len)
           
static int[] toInt(double[] a, int len)
           
static java.lang.String toString(java.lang.Object ob)
          Print an object; if it's an array, print each element, recursively, as [0, 1, 2] or [[0, 1, 2], [3, 4, 5]], etc, same for Iterable and Map objects.
static java.lang.String trim(java.lang.CharSequence sb)
           
static void updateComponent(java.awt.Component c)
          Repaint the given Component on the swing repaint thread (aka "SwingUtilities.invokeLater").
static void wait(java.util.Collection<java.util.concurrent.Future<?>> fus)
           
static boolean wrongImageJVersion()
           
static java.lang.String zeroPad(int i, int n_digits)
          Zero-pad a number, so that '1' becomes '001' if n_digits is 3.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static java.lang.String version

debug

public static boolean debug

debug_mouse

public static boolean debug_mouse

debug_sql

public static boolean debug_sql

debug_event

public static boolean debug_event

debug_clip

public static boolean debug_clip

debug_thing

public static boolean debug_thing

FL_ERROR

public static final double FL_ERROR
The error to use in floating-point or double floating point literal comparisons.

See Also:
Constant Field Values

last_dir

public static java.lang.String last_dir
The path of the directory from which images have been recently loaded.


last_file

public static java.lang.String last_file
The path of the last opened file.


java3d

public static final boolean java3d
Constructor Detail

Utils

public Utils()
Method Detail

debug

public static void debug(java.lang.String msg)

debugMouse

public static void debugMouse(java.lang.String msg)

setup

public static final void setup(ControlWindow master)
Initialize house keeping threads.


destroy

public static final void destroy(ControlWindow master)
Destroy house keeping threads.


log

public static final void log(java.lang.String msg)
Intended for the user to see.


logAll

public static final void logAll(java.lang.String msg)
Print in all printable places: log window, System.out.println, and status bar.


log2

public static final void log2(java.lang.String msg)
Intended for developers: prints to terminal.


log2

public static final void log2(java.lang.Object ob)
Pretty-print the object, for example arrays as [0, 1, 2].


log2

public static final void log2(java.lang.String msg,
                              java.lang.Object ob)
Pretty-print the object, for example arrays as [0, 1, 2].


log2

public static final void log2(java.lang.String msg,
                              java.lang.Object ob1,
                              java.lang.Object... ob)

log

public static final void log(java.lang.Object ob)

log

public static final void log(java.lang.String msg,
                             java.lang.Object ob)
Pretty-print the object, for example arrays as [0, 1, 2].


log2

public static final void log2(java.lang.Object... ob)

logMany2

public static final void logMany2(java.lang.Object... ob)

toString

public static final java.lang.String toString(java.lang.Object ob)
Print an object; if it's an array, print each element, recursively, as [0, 1, 2] or [[0, 1, 2], [3, 4, 5]], etc, same for Iterable and Map objects.


setDebug

public static void setDebug(boolean debug)

setDebugMouse

public static void setDebugMouse(boolean debug_mouse)

setDebugSQL

public static void setDebugSQL(boolean debug_sql)

printCaller

public static final void printCaller(java.lang.Object called_object)
Find out which method from which class called the method where the printCaller is used; for debugging purposes.


printCaller

public static final void printCaller(java.lang.Object called_object,
                                     int lines)

caller

public static final java.lang.String caller(java.lang.Object called)
Returns a String representation of the class of the object one step before in the stack trace.


restoreMenuBar

public static final void restoreMenuBar()
Restore ImageJ's MenuBar


showMessage

public static final void showMessage(java.lang.String msg)

showMessage

public static final void showMessage(java.lang.String title,
                                     java.lang.String msg)

showMessageT

public static final void showMessageT(java.lang.String msg)
Runs the showMessage in a separate Thread.


showStatus

public static final void showStatus(java.lang.String msg,
                                    boolean focus)

showStatus

public static final void showStatus(java.lang.String msg)

showProgress

public static final void showProgress(double p)

debugDialog

public static void debugDialog()

findOpenStacks

public static ij.ImagePlus[] findOpenStacks()
Scan the WindowManager for open stacks.


findOpenImages

public static ij.ImagePlus[] findOpenImages()
Scan the WindowManager for non-stack images


findAllOpenImages

public static ij.ImagePlus[] findAllOpenImages()
Scan the WindowManager for all open images, including stacks.


cutNumber

public static java.lang.String cutNumber(double d,
                                         int n_decimals)

cutNumber

public static final java.lang.String cutNumber(double d,
                                               int n_decimals,
                                               boolean remove_trailing_zeros)
remove_trailing_zeros will leave at least one zero after the comma if appropriate.


zeroPad

public static final java.lang.String zeroPad(int i,
                                             int n_digits)
Zero-pad a number, so that '1' becomes '001' if n_digits is 3.


check

public static final boolean check(java.lang.String msg)

checkYN

public static final boolean checkYN(java.lang.String msg)

d2s

public static final java.lang.String d2s(double d,
                                         int n_decimals)

getHexRGBColor

public static final java.lang.String[] getHexRGBColor(java.awt.Color color)

asHexRGBColor

public static final java.lang.String asHexRGBColor(java.awt.Color color)

asHexRGBColor

public static final void asHexRGBColor(java.lang.StringBuilder sb,
                                       java.awt.Color color)

getRGBColorFromHex

public static final java.awt.Color getRGBColorFromHex(java.lang.String hex)

get4Ints

public static final int[] get4Ints(int hex)

run

public void run(java.lang.String arg)
Specified by:
run in interface ij.plugin.PlugIn

chooseFile

public static final java.io.File chooseFile(java.lang.String name,
                                            java.lang.String extension)

chooseFile

public static final java.io.File chooseFile(java.lang.String default_dir,
                                            java.lang.String name,
                                            java.lang.String extension)
Select a file from the file system, for saving purposes. Prompts for overwritting if the file exists, unless the ControlWindow.isGUIEnabled() returns false (i.e. there is no GUI).


selectFile

public static final java.lang.String[] selectFile(java.lang.String title_msg)
Returns null or the selected directory and file.


saveToFile

public static final boolean saveToFile(java.io.File f,
                                       java.lang.String contents)

saveToFile

public static final boolean saveToFile(java.lang.String name,
                                       java.lang.String extension,
                                       java.lang.String contents)

cleanString

public static final java.lang.String cleanString(java.lang.String s)
Converts sequences of spaces into single space, and trims the ends.


openTextFile

public static final java.lang.String openTextFile(java.lang.String path)

openTextFileLines

public static final java.lang.String[] openTextFileLines(java.lang.String path)
Returns the file found at path as an array of lines, or null if not found.


openTextFileChars

public static final char[] openTextFileChars(java.lang.String path)

getCos

public static final double getCos(double x1,
                                  double y1,
                                  double x2,
                                  double y2)
The cosinus between two vectors (in polar coordinates), by means of the dot product.


removeExtension

public static final java.lang.String removeExtension(java.lang.String path)

addEnablerListener

public static final void addEnablerListener(java.awt.Checkbox master,
                                            java.awt.Component[] enable,
                                            java.awt.Component[] disable)
A helper for GenericDialog checkboxes to control other the enabled state of other GUI elements in the same dialog.


wrongImageJVersion

public static final boolean wrongImageJVersion()

addLayerRangeChoices

public static final void addLayerRangeChoices(Layer selected,
                                              ij.gui.GenericDialog gd)

addLayerRangeChoices

public static final void addLayerRangeChoices(Layer first,
                                              Layer last,
                                              ij.gui.GenericDialog gd)

addLayerChoice

public static final void addLayerChoice(java.lang.String label,
                                        Layer selected,
                                        ij.gui.GenericDialog gd)

addRGBColorSliders

public static final void addRGBColorSliders(ij.gui.GenericDialog gd,
                                            java.awt.Color color)

convertTo

public static final ij.process.ImageProcessor convertTo(ij.process.ImageProcessor ip,
                                                        int type,
                                                        boolean scaling)
Converts the ImageProcessor to an ImageProcessor of the given type, or the same if of equal type.


copy

public static final double[] copy(double[] a,
                                  int new_length)
Will make a new double[] array, then fit in it as many points from the given array as possible according to the desired new length. If the new length is shorter that a.length, it will shrink and crop from the end; if larger, the extra spaces will be set with zeros.


copy

public static final long[] copy(long[] a,
                                int new_length)

copy

public static final double[] copy(double[] a,
                                  int first,
                                  int new_length)

copy

public static final long[] copy(long[] a,
                                int first,
                                int new_length)

reverse

public static final void reverse(double[] a)
Reverse in place an array of doubles.


reverse

public static final void reverse(long[] a)
Reverse in place an array of longs.


toDouble

public static final double[] toDouble(int[] a,
                                      int len)

toInt

public static final int[] toInt(double[] a,
                                int len)

isPopupTrigger

public static final boolean isPopupTrigger(java.awt.event.MouseEvent me)
OS-agnostic diagnosis of whether the click was for the contextual popup menu.


updateComponent

public static final void updateComponent(java.awt.Component c)
Repaint the given Component on the swing repaint thread (aka "SwingUtilities.invokeLater").


revalidateComponent

public static final void revalidateComponent(java.awt.Component c)
Like calling pack() on a Frame but on a Component.


now

public static final java.lang.String now()
Returns the time as HH:MM:SS


sleep

public static final void sleep(long miliseconds)

mix

public static final java.awt.Color mix(java.awt.Color c1,
                                       java.awt.Color c2)
Mix colors visually: red + green = yellow, etc.


getCharacter

public static final java.lang.String getCharacter(int i)
1 A, 2 B, 3 C --- 26 - z, 27 AA, 28 AB, 29 AC --- 26*27 AAA


getField

public static final java.lang.Object getField(java.lang.Object ob,
                                              java.lang.String field_name)

getField

public static final java.lang.Object getField(java.lang.Object ob,
                                              java.lang.Class<?> c,
                                              java.lang.String field_name)
Get by reflection a private or protected field in the given object.


setField

public static final void setField(java.lang.Object ob,
                                  java.lang.Class<?> c,
                                  java.lang.String field_name,
                                  java.lang.Object value)

fastConvertToFloat

public static final ij.process.FloatProcessor fastConvertToFloat(ij.process.ByteProcessor ip)
A method that circumvents the findMinAndMax when creating a float processor from an existing processor. Ignores color calibrations and does no scaling at all.


fastConvertToFloat

public static final ij.process.FloatProcessor fastConvertToFloat(ij.process.ShortProcessor ip)
A method that circumvents the findMinAndMax when creating a float processor from an existing processor. Ignores color calibrations and does no scaling at all.


fastConvertToFloat

public static final ij.process.FloatProcessor fastConvertToFloat(ij.process.ImageProcessor ip,
                                                                 int type)
A method that circumvents the findMinAndMax when creating a float processor from an existing processor. Ignores color calibrations and does no scaling at all.


fastConvertToFloat

public static final ij.process.FloatProcessor fastConvertToFloat(ij.process.ImageProcessor ip)

createResultsTable

public static final ij.measure.ResultsTable createResultsTable(java.lang.String title,
                                                               java.lang.String[] columns)
Creates a new ResultsTable with the given window title and column titles, and 2 decimals of precision, or if one exists for the given window title, returns it.


createProcessor

public static final ij.process.ImageProcessor createProcessor(int type,
                                                              int width,
                                                              int height)

paint

public static void paint(Pipe pipe,
                         java.util.Map<Layer,ij.process.ImageProcessor> slices,
                         int value,
                         float scale)
Paints an approximation of the pipe into the set of slices.


matches

public static final boolean matches(java.lang.String pattern,
                                    java.lang.String s)

isValidIdentifier

public static final boolean isValidIdentifier(java.lang.String s)

makeValidIdentifier

public static final java.lang.String makeValidIdentifier(java.lang.String s)
user=> (def pat #"\b[a-zA-Z]+[\w]*\b") #'user/pat user=>(re-seq pat "abc def 1a334") ("abc" "def") user=> (re-seq pat "abc def a334") ("abc" "def" "a334") Then concatenate all good words with underscores. Returns null when nothing valid is found in 's'.


indexOf

public static final int indexOf(java.lang.Object needle,
                                java.lang.Object[] haystack)

removeFile

public static final boolean removeFile(java.io.File f)
Remove the file, or if it's a directory, recursively go down subdirs and remove all contents, but will stop on encountering a non-hidden file that is not an empty dir.


isTrakEM2Subfile

public static boolean isTrakEM2Subfile(java.io.File f)
                                throws java.lang.Exception
Returns true if the file cannonical path contains "/trakem2." (adjusted for Windows as well).

Throws:
java.lang.Exception

isTrakEM2Subpath

public static boolean isTrakEM2Subpath(java.lang.String path)
Returns true if the path contains "/trakem2." (adjusted for Windows as well).


removePrefixedFiles

public static final boolean removePrefixedFiles(java.io.File parent,
                                                java.lang.String prefix,
                                                java.util.ArrayList<java.lang.String> removed_paths)
Returns true if all files and their subdirectories, recursively, under parent folder have been removed. For safety reasons, this function will return false immediately if the parent file path does not include a lowercase "trakem2." in it. If removed_paths is not null, all removed full paths are added to it. Returns false if some files could not be removed.


getControlModifier

public static final int getControlModifier()
The CTRL key functionality is passed over to the COMMAND key (aka META key) in a MacOSX.


isControlDown

public static final boolean isControlDown(java.awt.event.InputEvent e)
The CTRL key functionality is passed over to the COMMAND key (aka META key) in a MacOSX.


drawPoint

public static final void drawPoint(java.awt.Graphics g,
                                   int x,
                                   int y)

trim

public static final java.lang.String trim(java.lang.CharSequence sb)

wait

public static final void wait(java.util.Collection<java.util.concurrent.Future<?>> fus)

fixDir

public static final java.lang.String fixDir(java.lang.String path)
Convert a D:\\this\that\there to D://this/that/there/ Notice it adds an ending backslash.


newFixedThreadPool

public static final java.util.concurrent.ThreadPoolExecutor newFixedThreadPool(int n_proc)
Creates a new fixed thread pool whose threads are in the same ThreadGroup as the Thread that calls this method. This allows for the threads to be interrupted when the caller thread's group is interrupted.


newFixedThreadPool

public static final java.util.concurrent.ThreadPoolExecutor newFixedThreadPool(java.lang.String namePrefix)
Creates a new fixed thread pool with as many threads as CPUs, and whose threads are in the same ThreadGroup as the Thread that calls this method.


newFixedThreadPool

public static final java.util.concurrent.ThreadPoolExecutor newFixedThreadPool(int n_proc,
                                                                               java.lang.String namePrefix)

equalContent

public static final boolean equalContent(java.util.Collection<?> a,
                                         java.util.Collection<?> b)
If both are null will throw an error.


equalContent

public static final boolean equalContent(java.util.Map<?,?> a,
                                         java.util.Map<?,?> b)
If both are null will throw an error.


addPlugIns

public static final boolean addPlugIns(javax.swing.JPopupMenu popup,
                                       java.lang.String menu,
                                       Project project,
                                       java.util.concurrent.Callable<Displayable> active)
Returns false if none to add.


addPlugIns

public static final javax.swing.JMenu addPlugIns(java.lang.String menu,
                                                 Project project,
                                                 java.util.concurrent.Callable<Displayable> active)
Returns null if none to add.


launchTPlugIn

public static final Bureaucrat launchTPlugIn(java.awt.event.KeyEvent ke,
                                             java.lang.String menu,
                                             Project project,
                                             Displayable active)
Returns null if no plugin was launched. To launch a plugin, it needs a Utils.getControlModifier + 1,2,3,4... up to 9.

Parameters:
active - may be null.

getDimensions

public static final java.awt.Dimension getDimensions(java.lang.String text,
                                                     java.awt.Font font)
Get the width and height of single-line text.


createStream

public static final java.io.InputStream createStream(java.lang.String path_or_url)
                                              throws java.lang.Exception
Throws:
java.lang.Exception

asList

public static final java.util.List<java.lang.Long> asList(long[] ids)

asList

public static final java.util.List<java.lang.Long> asList(long[] ids,
                                                          int first,
                                                          int length)

setEnabled

public static void setEnabled(java.awt.Container root,
                              boolean b)
Recursively enable/disable all components of the @param root Container.


ensure

public static final boolean ensure(java.lang.String filepath)

ensure

public static final boolean ensure(java.io.File f)
Ensure the file can be written to. Will create parent directories if necessary.


luminance

public static final int luminance(java.awt.Color c)
0.3 * R + 0.6 * G + 0.1 * B


invokeLater

public static final void invokeLater(java.lang.Runnable r)
Invoke in the context of the event dispatch thread.


showAllTables

public static final void showAllTables(java.util.HashMap<java.lang.Class<?>,ij.measure.ResultsTable> ht)