|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsource.ucregents.playground.Utility
public final class Utility
A class of commonly used, misc, helper methods.
Field Summary | |
---|---|
static java.lang.String |
ResourcePath
|
static java.lang.String |
SoundPath
|
Constructor Summary | |
---|---|
Utility()
|
Method Summary | |
---|---|
static java.awt.Color |
ApplyAlpha(java.awt.Color c,
int alpha)
Creates and returns a new Color identical in all ways except that it's alpha value is set to the one specified |
static boolean |
areParallel(javax.vecmath.Vector2d firstVector,
javax.vecmath.Vector2d secondVector)
Checks to see if 2 vectors are Approximately parallel |
static java.applet.AudioClip |
cacheSound(java.lang.String filename)
Gets a Sound and caches it if not yet cached. |
static java.lang.String |
Capitalize(java.lang.String s)
Capitalizes the beginning of a string. |
static java.lang.Object |
CreateInstanceOf(java.lang.Class<?> c,
java.lang.Class<?> assignableFrom)
Creates an instance of the specified class. |
static void |
FocusOn(javax.swing.JInternalFrame comp)
Focuses on a JInternalFrame |
static java.awt.image.BufferedImage |
GetBufferedImage(java.lang.String filename)
|
static java.lang.String |
getDefaultImageName()
Return the filename of the default image. |
static java.awt.Color |
getRandomColor()
Gets a Random color with values between 25 and 225 for each RGB Value |
static javax.vecmath.Vector2d |
getUnitVectorX()
Gets the Unit vector in the X direction |
static javax.vecmath.Vector2d |
getUnitVectorY()
Gets the Unit vector in the Y direction |
static javax.vecmath.Vector2d |
getZeroVector()
Gets the Zero vector |
static void |
HandleEvent(int type,
int subtype,
BaseEntity b)
Execute all UserEvents associated with a given Base Entity. |
static void |
HandleEvents(int type,
int subtype,
java.util.Vector<BaseEntity> ents)
Loop through all entities and execute any events bound to a certain type and subtype. |
static java.awt.geom.Point2D.Double |
parsePoint2D_Double(java.lang.String stringToParse)
Parses a Point2D.Double from a string |
static void |
PlaySound(java.lang.String filename)
Plays a sound in a new thread. |
static boolean |
RandomBoolean()
Gets a Random Boolean value |
static double |
RandomDouble()
|
static double |
RandomDouble(double min,
double max)
|
static int |
RandomInt(int max)
|
static int |
RandomInt(int min,
int max)
|
static javax.vecmath.Vector2d |
VectorDivision(javax.vecmath.Vector2d v1,
double scalar)
Divides a vector by a scalar |
static javax.vecmath.Vector2d |
VectorMultiplication(javax.vecmath.Vector2d v1,
double scalar)
Multiplies a vector by a scalar |
static javax.vecmath.Vector2d |
VectorScale(javax.vecmath.Vector2d v1,
double scalar)
Scales a vector by a scalar |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ResourcePath
public static final java.lang.String SoundPath
Constructor Detail |
---|
public Utility()
Method Detail |
---|
public static java.awt.Color ApplyAlpha(java.awt.Color c, int alpha)
c
- The color to apply the alpha to.alpha
- The alpha value to apply to the Color. Normal values from 0 -
255
public static boolean areParallel(javax.vecmath.Vector2d firstVector, javax.vecmath.Vector2d secondVector)
firstVector
- The first Vector2DsecondVector
- The second Vector2D
public static java.applet.AudioClip cacheSound(java.lang.String filename)
filename
- The sound to cache
public static java.lang.String Capitalize(java.lang.String s)
s
- The string to capitalize
public static java.lang.Object CreateInstanceOf(java.lang.Class<?> c, java.lang.Class<?> assignableFrom)
c
- The class to instantiateassignableFrom
- An optional class that will do check to ensure that the class to instantiate is or extends this parameter
public static void FocusOn(javax.swing.JInternalFrame comp)
comp
- The frame to focus onpublic static java.awt.image.BufferedImage GetBufferedImage(java.lang.String filename)
filename
- The filename of the image
public static java.lang.String getDefaultImageName()
public static java.awt.Color getRandomColor()
public static javax.vecmath.Vector2d getUnitVectorX()
public static javax.vecmath.Vector2d getUnitVectorY()
public static javax.vecmath.Vector2d getZeroVector()
public static void HandleEvent(int type, int subtype, BaseEntity b)
type
- Corresponds to the event id (e.g. MouseEvent.BUTTON_PRESSED)subtype
- Corresponds to the specific key or button associated with the
event (e.g. MouseEvent.BUTTON1)b
- The object on which to execute the eventspublic static void HandleEvents(int type, int subtype, java.util.Vector<BaseEntity> ents)
type
- Corresponds to the event id (e.g. MouseEvent.BUTTON_PRESSED)subtype
- Corresponds to the specific key or button associated with the
event (e.g. MouseEvent.BUTTON1)ents
- Execute appropriate events with each entity in this vectorpublic static java.awt.geom.Point2D.Double parsePoint2D_Double(java.lang.String stringToParse)
stringToParse
- The string to parse
public static void PlaySound(java.lang.String filename)
filename
- The filename of the sound.public static boolean RandomBoolean()
public static double RandomDouble()
public static double RandomDouble(double min, double max)
min
- The minimum double value to return. The value is the minimum
and included in the resultmax
- The maximum double value to return. The value is the maximum
and excluded from the result
public static int RandomInt(int max)
max
- The maximum int value to return. The value is the maximum and
excluded from the result
public static int RandomInt(int min, int max)
min
- The minimum int value to return. The value is the minimum and
included in the resultmax
- The maximum int value to return. The value is the maximum and
excluded from the result
public static javax.vecmath.Vector2d VectorDivision(javax.vecmath.Vector2d v1, double scalar)
v1
- The vectorscalar
- The scalar
public static javax.vecmath.Vector2d VectorMultiplication(javax.vecmath.Vector2d v1, double scalar)
v1
- The vectorscalar
- The scalar
public static javax.vecmath.Vector2d VectorScale(javax.vecmath.Vector2d v1, double scalar)
v1
- The vectorscalar
- The scalar
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |