background
Class Background

java.lang.Object
  |
  +--background.Background
Direct Known Subclasses:
BaseballField, House, Intersection, Lake, Road, Tree

public abstract class Background
extends java.lang.Object

A "background" is a graphical image. Normally it is placed in the world (the complete picture) when the world is created, and remains constant. Every background that is constructed has an x- and y- coordinate, representing its upperleft-most position in the graphics system, as well as a width and height representing the maximum horizontal and vertical distance from the x and y, respectively.
PLEASE NOTE: No error checking is currently done to ensure positive width and height values.


Field Summary
protected  java.lang.String externalName
          Name by which this background icon is known to the world (for example, in a text input file).
protected  double height
           
protected  double width
           
protected  double xCoor
          xCoor and yCoor together represent the TOP-LEFT coordinate of the Background.
protected  double yCoor
           
 
Constructor Summary
Background(double x, double y, double w, double h)
          Initialize attributes for this Background
 
Method Summary
abstract  void draw(java.awt.Graphics2D g)
          Use the graphics system to draw the shapes representing this Background
 double getHeight()
          Returns the height of this Background
 java.lang.String getName()
          A name by which this background icon is known to the world (for example, in a text file).
 double getWidth()
          Returns the width of this Background
 double getX()
          Returns the x position of this Background
 double getY()
          Returns the y position of this Background
 void update(double timeMillies)
          Updates the background in some particular way.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xCoor

protected double xCoor
xCoor and yCoor together represent the TOP-LEFT coordinate of the Background.


yCoor

protected double yCoor

width

protected double width

height

protected double height

externalName

protected java.lang.String externalName
Name by which this background icon is known to the world (for example, in a text input file).

Constructor Detail

Background

public Background(double x,
                  double y,
                  double w,
                  double h)
Initialize attributes for this Background

Parameters:
x - x-coordinate of background in the world (leftmost position of background)
y - y-coordinate of background in the world (uppermost position of background)
w - width of the background object
h - height of the background object
Method Detail

getX

public double getX()
Returns the x position of this Background

Returns:
x-coordinate of the background's leftmost point

getY

public double getY()
Returns the y position of this Background

Returns:
y-coordinate of the background's uppermost point

getWidth

public double getWidth()
Returns the width of this Background

Returns:
width of the background

getHeight

public double getHeight()
Returns the height of this Background

Returns:
height of the background

update

public void update(double timeMillies)
Updates the background in some particular way. For now the background does not need to update itself. You can override this method if you like, (for example, to get the effect of rustling trees, changing house colors, deteriation of roads, etc. for your backgrounds).

Parameters:
timeMillies - the delay time in milliseconds

draw

public abstract void draw(java.awt.Graphics2D g)
Use the graphics system to draw the shapes representing this Background

Parameters:
g - the graphics system to use

getName

public java.lang.String getName()
A name by which this background icon is known to the world (for example, in a text file).