simulation_MVC_Basic
Class Utility

java.lang.Object
  extended by simulation_MVC_Basic.Utility

public class Utility
extends java.lang.Object


Method Summary
static java.awt.geom.Rectangle2D getBoundingBox(java.lang.String theText, java.awt.Font f, java.awt.Graphics2D g)
          Returns a bounding box that encapsulates the passed text string, as rendered in the specified font in the specified graphics context.
static java.awt.Dimension getQuarterOfScreen()
          This method determines the dimensions of the screen that is being used by the VM and returns a dimension that is half the width and half the height.
static ShapeSprite getRandomShapeSprite(int width, int height)
          This method returns a sprite that is randomly chosen from among the "tubular", "sphere" and "tri-fold" versions.
static int getRandomValue(int val1, int val2)
          This method returns a displacement value from the range [MIN,...,MAX], where MIN and MAX are taken from the parameters, val1 and val2.
static ShapeSprite getShapeSprite(int width, int height)
          This method returns a "tubular" sprite.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRandomValue

public static int getRandomValue(int val1,
                                 int val2)
This method returns a displacement value from the range [MIN,...,MAX], where MIN and MAX are taken from the parameters, val1 and val2. MIN is assigned the value of the smaller parameter, and MAX is assigned the value of the larger. For instance, if the values -3, 3 are passed, then a value in the range [-3,3] is returned. If val1 == val2, the value val1 is returned.

Parameters:
val1 -
val2 -
Returns:
as described above

getQuarterOfScreen

public static java.awt.Dimension getQuarterOfScreen()
This method determines the dimensions of the screen that is being used by the VM and returns a dimension that is half the width and half the height.

Returns:
as described above

getShapeSprite

public static ShapeSprite getShapeSprite(int width,
                                         int height)
This method returns a "tubular" sprite.

Parameters:
width - the width of the game world
height - the width of the game world
Returns:
as desired above

getRandomShapeSprite

public static ShapeSprite getRandomShapeSprite(int width,
                                               int height)
This method returns a sprite that is randomly chosen from among the "tubular", "sphere" and "tri-fold" versions.

Parameters:
width - the width of the game world
height - the width of the game world
Returns:
as desired above

getBoundingBox

public static java.awt.geom.Rectangle2D getBoundingBox(java.lang.String theText,
                                                       java.awt.Font f,
                                                       java.awt.Graphics2D g)
Returns a bounding box that encapsulates the passed text string, as rendered in the specified font in the specified graphics context. The bounding box is anchored at (0,0)

Parameters:
theText - the string for which the bounding box is desired
f - the Font that will be used to render the text
g - the graphics context in which the font will be used
Returns:
as described above