public class WWUtil
extends java.lang.Object
Constructor and Description |
---|
WWUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
alignComponent(java.awt.Component parent,
java.awt.Component child,
java.lang.String alignment) |
static int |
compareVersion(java.lang.String va,
java.lang.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 java.awt.Color |
computeContrastingColor(java.awt.Color color) |
static java.lang.Boolean |
convertNumericStringToBoolean(java.lang.String s)
Converts a specified string to a boolean value.
|
static java.lang.Boolean |
convertStringToBoolean(java.lang.String s)
Converts a specified string to a boolean value.
|
static java.lang.Double |
convertStringToDouble(java.lang.String s)
Converts a specified string to a floating point value.
|
static java.lang.Integer |
convertStringToInteger(java.lang.String s)
Converts a specified string to an integer value.
|
static java.lang.Long |
convertStringToLong(java.lang.String s)
Converts a specified string to a long integer value.
|
static void |
convertUTMCoordinatesToGeographic(int zone,
java.lang.String hemisphere,
java.nio.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,
java.lang.String[] keys,
boolean forceOverwrite)
Copies only values of the specified
keys from srcList to another destList . |
static java.awt.Color |
decodeColorABGR(java.lang.String encodedString)
Decodes a hexadecimal string in the form aabbggrr, 0xaabbggrr or #aabbggrr to a color.
|
static java.awt.Color |
decodeColorRGBA(java.lang.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 java.lang.String |
encodeColorABGR(java.awt.Color color)
Creates a hexadecimal string representation of a
Color in the form 0xaabbggrr. |
static java.lang.String |
encodeColorRGBA(java.awt.Color color)
Creates a hexadecimal string representation of a
Color in the form 0xrrggbbaa. |
static java.lang.String |
extractExceptionReason(java.lang.Throwable t)
Extracts an error message from the exception object
|
static void |
generateTriStripNormals(java.nio.FloatBuffer vertices,
java.nio.IntBuffer indices,
java.nio.FloatBuffer normals)
Generates average normal vectors for the vertices of a triangle strip.
|
static java.awt.Color |
interpolateColor(double amount,
java.awt.Color color1,
java.awt.Color color2)
Returns the component-wise linear interpolation of
color1 and color2 . |
static java.lang.Object |
invokePropertyMethod(java.lang.Object parent,
java.lang.String propertyName,
java.lang.String propertyValue)
Uses reflection to invoke a set method for a specified property.
|
static boolean |
isEmpty(java.util.List<?> list)
Determine whether an
List is null or empty. |
static boolean |
isEmpty(java.lang.Object s)
Determine whether an object reference is null or a reference to an empty string.
|
protected static boolean |
isKMLTimeShift(java.lang.String timeString) |
static java.awt.Color |
makeColorBrighter(java.awt.Color color) |
static java.awt.Color |
makeColorDarker(java.awt.Color color) |
static java.lang.Double |
makeDouble(java.lang.String s)
Parses a string to a double value if the string can be parsed as a double.
|
static java.lang.Double |
makeDoubleForLocale(java.lang.String s)
Parses a string to a double value using the current locale if the string can be parsed as a double.
|
static java.lang.Integer |
makeInteger(java.lang.String s)
Parses a string to an integer value if the string can be parsed as a integer.
|
static java.lang.Long |
makeLong(java.lang.String s)
Parses a string to a long value if the string can be parsed as a long.
|
static java.awt.Color |
makeRandomColor(java.awt.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 java.awt.Color |
makeRandomColor(java.awt.Color color,
java.awt.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(java.nio.DoubleBuffer buffer)
Normalizes the specified buffer of geographic tuples.
|
static java.lang.Long |
parseTimeString(java.lang.String timeString)
Parse a date/time string and return its equivalent in milliseconds (using same time coordinate system as
System.currentTimeMillis()).
|
static java.lang.String |
removeWhiteSpace(java.lang.String inputString)
Eliminates all white space in a specified string.
|
static java.lang.String |
stripLeadingPeriod(java.lang.String s)
Strips leading period from a string (Example: input -> ".ext", output -> "ext")
|
static java.lang.CharSequence |
trimCharSequence(java.lang.CharSequence charSequence)
Returns a sub sequence of the specified
CharSequence , with leading and trailing whitespace omitted. |
public static void alignComponent(java.awt.Component parent, java.awt.Component child, java.lang.String alignment)
public static int compareVersion(java.lang.String va, java.lang.String vb)
va
- the first version stringvb
- the second version stringpublic static java.awt.Color computeContrastingColor(java.awt.Color color)
public static java.lang.Boolean convertNumericStringToBoolean(java.lang.String s)
s
- the string to convert.java.lang.IllegalArgumentException
- if the string is null.public static java.lang.Boolean convertStringToBoolean(java.lang.String s)
s
- the string to convert.java.lang.IllegalArgumentException
- if the string is null.public static java.lang.Double convertStringToDouble(java.lang.String s)
s
- the string to convert.java.lang.IllegalArgumentException
- if the string is null.public static java.lang.Integer convertStringToInteger(java.lang.String s)
s
- the string to convert.java.lang.IllegalArgumentException
- if the string is null.public static java.lang.Long convertStringToLong(java.lang.String s)
s
- the string to convert.java.lang.IllegalArgumentException
- if the string is null.public static void convertUTMCoordinatesToGeographic(int zone, java.lang.String hemisphere, java.nio.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.java.lang.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, java.lang.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 java.awt.Color decodeColorABGR(java.lang.String encodedString)
encodedString
- String to decode.java.lang.IllegalArgumentException
- If the specified string is null.decodeColorRGBA(String)
,
encodeColorABGR(java.awt.Color)
public static java.awt.Color decodeColorRGBA(java.lang.String encodedString)
encodedString
- String to decode.java.lang.IllegalArgumentException
- If the specified string is null.(String)
,
encodeColorRGBA(java.awt.Color)
public static double[] defaultMinMix()
public static java.lang.String encodeColorABGR(java.awt.Color color)
Color
in the form 0xaabbggrr.color
- Color to encode.java.lang.IllegalArgumentException
- If the specified color is null.decodeColorABGR(String)
,
encodeColorRGBA(java.awt.Color)
public static java.lang.String encodeColorRGBA(java.awt.Color color)
Color
in the form 0xrrggbbaa.color
- Color to encode.java.lang.IllegalArgumentException
- If the specified color is null.decodeColorRGBA(String)
,
encodeColorABGR(java.awt.Color)
public static java.lang.String extractExceptionReason(java.lang.Throwable t)
t
- Exception instancepublic static void generateTriStripNormals(java.nio.FloatBuffer vertices, java.nio.IntBuffer indices, java.nio.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.java.lang.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 java.awt.Color interpolateColor(double amount, java.awt.Color color1, java.awt.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.java.lang.IllegalArgumentException
- if either color1
or color2
are null
.public static java.lang.Object invokePropertyMethod(java.lang.Object parent, java.lang.String propertyName, java.lang.String propertyValue) throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException, java.lang.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
.java.lang.IllegalArgumentException
- if the parent object or the property name is null.java.lang.NoSuchMethodException
- if no set method exists for the property name.java.lang.reflect.InvocationTargetException
- if the set method throws an exception.java.lang.IllegalAccessException
- if the set method is inaccessible due to access control.public static boolean isEmpty(java.util.List<?> list)
List
is null or empty.list
- the list to examine.public static boolean isEmpty(java.lang.Object s)
s
- the reference to examine.String
.protected static boolean isKMLTimeShift(java.lang.String timeString)
public static java.awt.Color makeColorBrighter(java.awt.Color color)
public static java.awt.Color makeColorDarker(java.awt.Color color)
public static java.lang.Double makeDouble(java.lang.String s)
s
- the string to parse.public static java.lang.Double makeDoubleForLocale(java.lang.String s)
s
- the string to parse.public static java.lang.Integer makeInteger(java.lang.String s)
s
- the string to parse.public static java.lang.Long makeLong(java.lang.String s)
s
- the string to parse.public static java.awt.Color makeRandomColor(java.awt.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 java.awt.Color makeRandomColor(java.awt.Color color, java.awt.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(java.nio.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.java.lang.IllegalArgumentException
- if buffer
is null, or if the number of remaining elements in
buffer
is not a multiple of two.public static java.lang.Long parseTimeString(java.lang.String timeString)
timeString
- the date/time string to parse.public static java.lang.String removeWhiteSpace(java.lang.String inputString)
inputString
- the string to remove white space from.public static java.lang.String stripLeadingPeriod(java.lang.String s)
s
- String to test, must not be nullpublic static java.lang.CharSequence trimCharSequence(java.lang.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.java.lang.IllegalArgumentException
- if the charSequence is null.