Package ij.util
Class Tools
java.lang.Object
ij.util.Tools
This class contains static utility methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char[]
This array contains the 16 hex digits '0'-'F'. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Converts a Color to an 7 byte hex string starting with '#'.static String
f2hex
(float f) Converts a float to an 9 byte hex string starting with '#'.static String
Converts carriage returns to line feeds.static int
getDecimalPlaces
(double n) Returns the number of decimal places needed to display a number, or -2 if exponential notation should be used.static int
getDecimalPlaces
(double n1, double n2) Returns the number of decimal places needed to display two numbers, or -2 if exponential notation should be used.static double[]
getMinMax
(double[] a) static double[]
getMinMax
(float[] a) static String
int2hex
(int i, int digits) Converts an int to a zero-padded hex string of fixed length 'digits'.static String
openFromIJJarAsString
(String path) Opens a text file in ij.jar as a String (example path: "/macros/Circle_Tool.txt").static double
Returns a double containg the value represented by the specifiedString
.static double
parseDouble
(String s, double defaultValue) Returns a double containg the value represented by the specifiedString
.static int[]
rank
(double[] values) Returns a sorted list of indices of the specified double array.static int[]
Returns a sorted list of indices of the specified String array.static String[]
Splits a string into substrings using the default delimiter set, which is " \t\n\r" (space, tab, newline and carriage-return).static String[]
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.
-
Field Details
-
hexDigits
public static final char[] hexDigitsThis array contains the 16 hex digits '0'-'F'.
-
-
Constructor Details
-
Tools
public Tools()
-
-
Method Details
-
c2hex
Converts a Color to an 7 byte hex string starting with '#'. -
f2hex
Converts a float to an 9 byte hex string starting with '#'. -
int2hex
Converts an int to a zero-padded hex string of fixed length 'digits'. If the number is too high, it gets truncated, keeping only the lowest 'digits' characters. -
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
Converts carriage returns to line feeds. -
parseDouble
Returns a double containg the value represented by the specifiedString
.- Parameters:
s
- the string to be parsed.defaultValue
- the value returned ifs
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
Returns a double containg the value represented by the specifiedString
.- 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 n) Returns the number of decimal places needed to display a number, or -2 if exponential notation should be used. -
getDecimalPlaces
public static int getDecimalPlaces(double n1, double n2) Returns the number of decimal places needed to display two numbers, or -2 if exponential notation should be used. -
split
Splits a string into substrings using the default delimiter set, which is " \t\n\r" (space, tab, newline and carriage-return). -
split
Splits a string into substring using the characters contained in the second argument as the delimiter set. -
rank
public static int[] rank(double[] values) Returns a sorted list of indices of the specified double array. Modified from: http://stackoverflow.com/questions/951848 by N.Vischer. -
rank
Returns a sorted list of indices of the specified String array. -
openFromIJJarAsString
Opens a text file in ij.jar as a String (example path: "/macros/Circle_Tool.txt").
-