ij.util
Class Tools

java.lang.Object
  extended by ij.util.Tools

public class Tools
extends java.lang.Object

This class contains static utility methods.


Field Summary
static char[] hexDigits
          This array contains the 16 hex digits '0'-'F'.
 
Constructor Summary
Tools()
           
 
Method Summary
static java.lang.String c2hex(java.awt.Color c)
          Converts a Color to an 7 byte hex string starting with '#'.
static java.lang.String f2hex(float f)
          Converts a float to an 9 byte hex string starting with '#'.
static java.lang.String fixNewLines(java.lang.String s)
          Converts carriage returns to line feeds.
static int getDecimalPlaces(double n1, double n2)
          Returns the number of decimal places need to display two numbers.
static double[] getMinMax(double[] a)
           
static double[] getMinMax(float[] a)
           
static double parseDouble(java.lang.String s)
          Returns a double containg the value represented by the specified String.
static double parseDouble(java.lang.String s, double defaultValue)
          Returns a double containg the value represented by the specified String.
static java.lang.String[] split(java.lang.String str)
          Splits a string into substrings using the default delimiter set, which is " \t\n\r" (space, tab, newline and carriage-return).
static java.lang.String[] split(java.lang.String str, java.lang.String delim)
          Splits a string into substring using the characters contained in the second argument as the delimiter set.
static double[] toDouble(float[] a)
          Converts the float array 'a' to a double array.
static float[] toFloat(double[] a)
          Converts the double array 'a' to a float array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hexDigits

public static final char[] hexDigits
This array contains the 16 hex digits '0'-'F'.

Constructor Detail

Tools

public Tools()
Method Detail

c2hex

public static java.lang.String c2hex(java.awt.Color c)
Converts a Color to an 7 byte hex string starting with '#'.


f2hex

public static java.lang.String f2hex(float f)
Converts a float to an 9 byte hex string starting with '#'.


getMinMax

public static double[] getMinMax(double[] a)

getMinMax

public static double[] getMinMax(float[] a)

toDouble

public static double[] toDouble(float[] a)
Converts the float array 'a' to a double array.


toFloat

public static float[] toFloat(double[] a)
Converts the double array 'a' to a float array.


fixNewLines

public static java.lang.String fixNewLines(java.lang.String s)
Converts carriage returns to line feeds.


parseDouble

public static double parseDouble(java.lang.String s,
                                 double defaultValue)
Returns a double containg the value represented by the specified String.

Parameters:
s - the string to be parsed.
defaultValue - the value returned if s does not contain a parsable double
Returns:
The double value represented by the string argument or defaultValue if the string does not contain a parsable double

parseDouble

public static double parseDouble(java.lang.String s)
Returns a double containg the value represented by the specified String.

Parameters:
s - the string to be parsed.
Returns:
The double value represented by the string argument or Double.NaN if the string does not contain a parsable double

getDecimalPlaces

public static int getDecimalPlaces(double n1,
                                   double n2)
Returns the number of decimal places need to display two numbers.


split

public static java.lang.String[] split(java.lang.String str)
Splits a string into substrings using the default delimiter set, which is " \t\n\r" (space, tab, newline and carriage-return).


split

public static java.lang.String[] split(java.lang.String str,
                                       java.lang.String delim)
Splits a string into substring using the characters contained in the second argument as the delimiter set.