|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ascape.util.Utility
public class Utility
An class encapsulating various common utility functions. For now, just has some random number helper functions and a set of series for 2D arrays.
Field Summary | |
---|---|
static int[][][] |
uniqueSeries
A quick set of unique series up to 4 nodes. |
Constructor Summary | |
---|---|
Utility()
|
Method Summary | |
---|---|
static java.lang.String |
formatElapsedMillis(long time)
Formats a time in milleseconds (typically elapsed time) into a string with format "[d'd'] hh:mm:ss.mmmm". |
static java.lang.String |
formatToString(double num,
int decPlaces)
Returns the supplied number formatted as a string with the given number of decimal places fixed and padded with zeroes if needed. |
static java.lang.String |
getClassNameOnly(java.lang.Class c)
Given a class, returns the name of that class without qualifiers. |
static java.awt.Image |
magnifyImage(java.awt.Image image,
double magnificationFactorHeight,
double magnificationFactorWidth)
Positively scale an image. |
static void |
notImplemented()
Reports standard error and any other desired behavior when the user attempts to use an unimplemented method. |
static java.lang.String |
orderedQualifiers(java.lang.String string)
Removes qualifiers such as min and max from string, placing an appropriate order token at the end of the string. |
static java.lang.String |
padStringLeft(java.lang.String string,
int size)
Pads the string with spaces on the left to the supplied size. |
static java.lang.String |
padStringLeftWithZeros(java.lang.String string,
int size)
Pads the string with spaces on the left to the supplied size. |
static java.lang.String |
padStringRight(java.lang.String string,
int size)
Pads the string with spaces on the right to the supplied size. |
static double |
randomInRange(java.util.Random random,
double low,
double high)
Generate a double uniformly distributed across some range. |
static int |
randomInRange(java.util.Random random,
int low,
int high)
Generate an integer uniformly distributed across some range. |
static boolean |
randomIs(java.util.Random random)
Returns a random boolean value. |
static int |
randomToLimit(java.util.Random random,
int limit)
Generate an integer uniformly distributed across 0...limit - 1. |
static java.awt.Image |
reduceImage(java.awt.Image image,
double reductionFactorHeight,
double reductionFactorWidth)
Negatively scale an image. |
static java.lang.String |
removeQualifiers(java.lang.String string)
Removes qualifiers such as min and max from string. |
static double |
tanh(double x)
A function that returns the hyperbolic tangent of its argument. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int[][][] uniqueSeries
Constructor Detail |
---|
public Utility()
Method Detail |
---|
public static final int randomInRange(java.util.Random random, int low, int high)
random
- the random number stream to uselow
- the lowest number (inclusive) that the resulting int might behigh
- the hignest number (inclusive) that the resulting int might be
public static final double randomInRange(java.util.Random random, double low, double high)
random
- the random number stream to uselow
- the lowest number (inclusive) that the resulting double might behigh
- the highest number (exclusive) that the resulting double might be
public static final int randomToLimit(java.util.Random random, int limit)
random
- the random number stream to uselimit
- the maximum limit (exclusive) of the resulting int
public static final boolean randomIs(java.util.Random random)
random
- the random number stream to usepublic static void notImplemented()
public static java.lang.String formatElapsedMillis(long time)
public static java.lang.String removeQualifiers(java.lang.String string)
string
- the string to remove qualifiers frompublic static java.lang.String orderedQualifiers(java.lang.String string)
string
- the string to remove qualifiers frompublic static java.lang.String padStringRight(java.lang.String string, int size)
string
- the string to padsize
- the size to pad (or truncate) the string topublic static java.lang.String padStringLeft(java.lang.String string, int size)
string
- the string to padsize
- the size to pad (or truncate) the string topublic static java.lang.String padStringLeftWithZeros(java.lang.String string, int size)
string
- the string to padsize
- the size to pad (or truncate) the string topublic static java.lang.String formatToString(double num, int decPlaces)
formatToString(23.436765, 2) would return "23.44".
- Parameters:
num
- the number to formatdecPlaces
- the number of places to display
public static java.lang.String getClassNameOnly(java.lang.Class c)
public static double tanh(double x)
x
- the argumentpublic static java.awt.Image reduceImage(java.awt.Image image, double reductionFactorHeight, double reductionFactorWidth)
image
- The image to be scaledreductionFactorHeight
- Scale amount for height.reductionFactorWidth
- Scale amount for width.
public static java.awt.Image magnifyImage(java.awt.Image image, double magnificationFactorHeight, double magnificationFactorWidth)
image
- The image to be scaledmagnificationFactorHeight
- Scale amount for height.magnificationFactorWidth
- Scale amount for width.
|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |