public class WWUtil extends Object
Constructor and Description |
---|
WWUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
alignComponent(Component parent,
Component child,
String alignment) |
static int |
compareVersion(String va,
String vb)
Compares two version strings, e.g., 1.3.0, and returns 0 if they match, -1 if the first string is less than the
second, and 1 if the first string is greater than the second.
|
static Color |
computeContrastingColor(Color color) |
static Boolean |
convertNumericStringToBoolean(String s)
Converts a specified string to a boolean value.
|
static Boolean |
convertStringToBoolean(String s)
Converts a specified string to a boolean value.
|
static Double |
convertStringToDouble(String s)
Converts a specified string to a floating point value.
|
static Integer |
convertStringToInteger(String s)
Converts a specified string to an integer value.
|
static Long |
convertStringToLong(String s)
Converts a specified string to a long integer value.
|
static void |
convertUTMCoordinatesToGeographic(int zone,
String hemisphere,
DoubleBuffer buffer)
Converts the specified buffer of UTM tuples to geographic coordinates, according to the specified UTM zone and
hemisphere.
|
static void |
copyValues(AVList srcList,
AVList destList,
String[] keys,
boolean forceOverwrite)
Copies only values of the specified
keys from srcList to another destList . |
static Color |
decodeColorABGR(String encodedString)
Decodes a hexadecimal string in the form aabbggrr, 0xaabbggrr or #aabbggrr to a color.
|
static Color |
decodeColorRGBA(String encodedString)
Decodes a hexadecimal string in the form rrggbbaa, rrggbbaa or #rrggbbaa to a color.
|
static double[] |
defaultMinMix()
Creates a two-element array of default min and max values, typically used to initialize extreme values searches.
|
static String |
encodeColorABGR(Color color)
Creates a hexadecimal string representation of a
Color in the form 0xaabbggrr. |
static String |
encodeColorRGBA(Color color)
Creates a hexadecimal string representation of a
Color in the form 0xrrggbbaa. |
static String |
extractExceptionReason(Throwable t)
Extracts an error message from the exception object
|
static void |
generateTriStripNormals(FloatBuffer vertices,
IntBuffer indices,
FloatBuffer normals)
Generates average normal vectors for the vertices of a triangle strip.
|
static Color |
interpolateColor(double amount,
Color color1,
Color color2)
Returns the component-wise linear interpolation of
color1 and color2 . |
static Object |
invokePropertyMethod(Object parent,
String propertyName,
String propertyValue)
Uses reflection to invoke a set method for a specified property.
|
static boolean |
isEmpty(List<?> list)
Determine whether an
List is null or empty. |
static boolean |
isEmpty(Object s)
Determine whether an object reference is null or a reference to an empty string.
|
protected static boolean |
isKMLTimeShift(String timeString) |
static Color |
makeColorBrighter(Color color) |
static Color |
makeColorDarker(Color color) |
static Double |
makeDouble(String s)
Parses a string to a double value if the string can be parsed as a double.
|
static Double |
makeDoubleForLocale(String s)
Parses a string to a double value using the current locale if the string can be parsed as a double.
|
static Integer |
makeInteger(String s)
Parses a string to an integer value if the string can be parsed as a integer.
|
static Long |
makeLong(String s)
Parses a string to a long value if the string can be parsed as a long.
|
static Color |
makeRandomColor(Color color)
Generates a random
Color by scaling each of the red, green and blue components of a specified color with
independent random numbers. |
static Color |
makeRandomColor(Color color,
Color darkestColor,
int maxAttempts)
Generates a random
Color by scaling each of the red, green and blue components of a specified color with
independent random numbers. |
static void |
normalizeGeographicCoordinates(DoubleBuffer buffer)
Normalizes the specified buffer of geographic tuples.
|
static Long |
parseTimeString(String timeString)
Parse a date/time string and return its equivalent in milliseconds (using same time coordinate system as
System.currentTimeMillis()).
|
static String |
removeWhiteSpace(String inputString)
Eliminates all white space in a specified string.
|
static String |
stripLeadingPeriod(String s)
Strips leading period from a string (Example: input -> ".ext", output -> "ext")
|
static CharSequence |
trimCharSequence(CharSequence charSequence)
Returns a sub sequence of the specified
CharSequence , with leading and trailing whitespace omitted. |
public static void alignComponent(Component parent, Component child, String alignment)
public static int compareVersion(String va, String vb)
va
- the first version stringvb
- the second version stringpublic static Boolean convertNumericStringToBoolean(String s)
s
- the string to convert.IllegalArgumentException
- if the string is null.public static Boolean convertStringToBoolean(String s)
s
- the string to convert.IllegalArgumentException
- if the string is null.public static Double convertStringToDouble(String s)
s
- the string to convert.IllegalArgumentException
- if the string is null.public static Integer convertStringToInteger(String s)
s
- the string to convert.IllegalArgumentException
- if the string is null.public static Long convertStringToLong(String s)
s
- the string to convert.IllegalArgumentException
- if the string is null.public static void convertUTMCoordinatesToGeographic(int zone, String hemisphere, DoubleBuffer buffer)
(easting,
northing)
. Each UTM tuple is replaced with its corresponding geographic location in the order
(longitude, latitude)
. Geographic locations are expressed in degrees. Tuples are replaced starting
at the buffer's position and ending at its limit.zone
- the UTM zone.hemisphere
- the UTM hemisphere, either AVKey.NORTH
or AVKey.SOUTH
.buffer
- the buffer of UTM tuples to convert.IllegalArgumentException
- if zone
is outside the range 1-60, if hemisphere
is
null, if hemisphere
is not one of AVKey.NORTH
or AVKey.SOUTH
, if buffer
is
null, or if the number of remaining elements in buffer
is not a
multiple of two.public static void copyValues(AVList srcList, AVList destList, String[] keys, boolean forceOverwrite)
keys
from srcList
to another destList
.
The forceOverwrite
controls what to do if the destination list already contains values for specified
keys
. If forceOverwrite
is set to true, the existing value wills be overwritten.srcList
- The source list. May not be null
.destList
- The destination list. May not be null
.forceOverwrite
- Allow overwrite existing values in the destination listkeys
- Array of keys
public static Color decodeColorABGR(String encodedString)
encodedString
- String to decode.IllegalArgumentException
- If the specified string is null.decodeColorRGBA(String)
,
encodeColorABGR(java.awt.Color)
public static Color decodeColorRGBA(String encodedString)
encodedString
- String to decode.IllegalArgumentException
- If the specified string is null.(String)
,
encodeColorRGBA(java.awt.Color)
public static double[] defaultMinMix()
public static String encodeColorABGR(Color color)
Color
in the form 0xaabbggrr.color
- Color to encode.IllegalArgumentException
- If the specified color is null.decodeColorABGR(String)
,
encodeColorRGBA(java.awt.Color)
public static String encodeColorRGBA(Color color)
Color
in the form 0xrrggbbaa.color
- Color to encode.IllegalArgumentException
- If the specified color is null.decodeColorRGBA(String)
,
encodeColorABGR(java.awt.Color)
public static String extractExceptionReason(Throwable t)
t
- Exception instancepublic static void generateTriStripNormals(FloatBuffer vertices, IntBuffer indices, FloatBuffer normals)
vertices
- the triangle strip vertices.indices
- the indices identifying the triangle strip from the specified vertices.normals
- a buffer to accept the output normals. The buffer must be allocated and all its values must be
initialized to 0. The buffer's size limit must be at least as large as that of the specified
vertex buffer.IllegalArgumentException
- if any of the specified buffers are null or the limit of the normal
buffer is less than that of the vertex buffer.public static Color interpolateColor(double amount, Color color1, Color color2)
color1
and color2
. Each of the RGBA
components in the colors are interpolated according to the function: (1 - amount) * c1 + amount *
c2
, where c1 and c2 are components of color1
and color2
, respectively. The
interpolation factor amount
defines the weight given to each value, and is clamped to the range [0,
1].amount
- the interpolation factor.color1
- the first color.color2
- the second color.color1
and color2
if amount
is 0 or less, or a color equivalent
to color2
if amount
is 1 or more.IllegalArgumentException
- if either color1
or color2
are null
.public static Object invokePropertyMethod(Object parent, String propertyName, String propertyValue) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
String
argument, a single double
argument, a single int
argument or a single long
argument. If it does, the method is
called with the specified property value argument.parent
- the object on which to set the property.propertyName
- the name of the property.propertyValue
- the value to give the property. Specify double, int and long values in a
String
.IllegalArgumentException
- if the parent object or the property name is null.NoSuchMethodException
- if no set method exists for the property name.InvocationTargetException
- if the set method throws an exception.IllegalAccessException
- if the set method is inaccessible due to access control.public static boolean isEmpty(List<?> list)
List
is null or empty.list
- the list to examine.public static boolean isEmpty(Object s)
s
- the reference to examine.String
.protected static boolean isKMLTimeShift(String timeString)
public static Double makeDouble(String s)
s
- the string to parse.public static Double makeDoubleForLocale(String s)
s
- the string to parse.public static Integer makeInteger(String s)
s
- the string to parse.public static Long makeLong(String s)
s
- the string to parse.public static Color makeRandomColor(Color color)
Color
by scaling each of the red, green and blue components of a specified color with
independent random numbers. The alpha component is not scaled and is copied to the new color. The returned color
can be any value between white (0x000000aa) and black (0xffffffaa).
Unless there's a reason to use a specific input color, the best color to use is white.color
- the color to generate a random color from. If null, the color white (0x000000aa) is used.public static Color makeRandomColor(Color color, Color darkestColor, int maxAttempts)
Color
by scaling each of the red, green and blue components of a specified color with
independent random numbers. The alpha component is not scaled and is copied to the new color. The returned color
can be any value between white (0x000000aa) and a specified darkest color.
Unless there's a reason to use a specific input color, the best color to use is white.color
- the color to generate a random color from. If null, the color white (0x000000aa) is used.darkestColor
- the darkest color allowed. If any of the generated color's components are less than the
corresponding component in this color, new colors are generated until one satisfies this
requirement, up to the specified maximum number of attempts.maxAttempts
- the maximum number of attempts to create a color lighter than the specified darkestColor. If
this limit is reached, the last color generated is returned.public static void normalizeGeographicCoordinates(DoubleBuffer buffer)
(longitude, latitude)
. Each geographic tuple is normalized to the
range +-90 latitude and +-180 longitude and replaced with its normalized values. Geographic locations are
expressed in degrees. Tuples are replaced starting at the buffer's position and ending at its limit.buffer
- the buffer of geographic tuples to convert.IllegalArgumentException
- if buffer
is null, or if the number of remaining elements in
buffer
is not a multiple of two.public static Long parseTimeString(String timeString)
timeString
- the date/time string to parse.public static String removeWhiteSpace(String inputString)
inputString
- the string to remove white space from.public static String stripLeadingPeriod(String s)
s
- String to test, must not be nullpublic static CharSequence trimCharSequence(CharSequence charSequence)
CharSequence
, with leading and trailing whitespace omitted. If
the CharSequence has length zero, this returns a reference to the CharSequence. If the CharSequence represents
and empty character sequence, this returns an empty CharSequence.charSequence
- the CharSequence to trim.IllegalArgumentException
- if the charSequence is null.