vooga.engine.overlay
Class OverlayBar

java.lang.Object
  extended by Sprite
      extended by vooga.engine.overlay.Overlay
          extended by vooga.engine.overlay.OverlayBar

public class OverlayBar
extends Overlay

The OverlayBar class displays a bar that grows or shrinks based on a Stat and a maximum indicated by the user. An example is included in OverlayExample. For an example see OverlayExample.java.


Constructor Summary
OverlayBar(java.util.Map<java.lang.String,java.lang.String> attributes, OverlayTracker tracker)
           
OverlayBar(Stat<java.lang.Integer> stat, int maxScore)
          Constructs an OverlayBar with the given Stat and maxScore.
 
Method Summary
 java.awt.Color getBackgroundColor()
          Returns the background color of the OverlayBar.
 java.awt.Color getColor()
          This method returns the color of the OverlayBar's fill.
 int getHeight()
          Returns the height of the OverlayBar.
 int getMaxLength()
          Returns the maximum length of the OverlayBar.
 int getMaxScore()
          Returns the maximum score for the OverlayBar, which determines the length of the OverlayBar relative to the current score.
 Stat<java.lang.Integer> getStat()
          Returns the Stat that the OverlayBar represents.
 void setBackgroundColor(java.awt.Color backgroundColor)
          Sets the backgroundColor of the OverlayBar.
 void setColor(java.awt.Color color)
          This method sets the color of the OverlayBar's fill.
 void setHeight(int height)
          Sets the height of the OverlayBar.
 void setMaxLength(int maxLength)
          Sets the maximum length of the OverlayBar.
 void setMaxScore(int maxScore)
          Sets the maximum score for the OverlayBar, which determines the length of the OverlayBar relative to the current score.
 void setStat(Stat<java.lang.Integer> stat)
          Sets the Stat the OverlayBar represents.
 void update(long t)
          Prints the bar on the screen by calling drawBar().
 
Methods inherited from class vooga.engine.overlay.Overlay
setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OverlayBar

public OverlayBar(Stat<java.lang.Integer> stat,
                  int maxScore)
Constructs an OverlayBar with the given Stat and maxScore.

Parameters:
stat - The statistic that the OverlayBar should represent.
maxScore - The maximum value the statistic can reach.

OverlayBar

public OverlayBar(java.util.Map<java.lang.String,java.lang.String> attributes,
                  OverlayTracker tracker)
Method Detail

update

public void update(long t)
Prints the bar on the screen by calling drawBar().


getColor

public java.awt.Color getColor()
This method returns the color of the OverlayBar's fill. This is the color of the rectangle that grows and shrinks based on the score.

Returns:
The color of the rectangle.

setColor

public void setColor(java.awt.Color color)
This method sets the color of the OverlayBar's fill. This sets the color of the rectangle that grows and shrinks based on the score.

Parameters:
color - The new color for the rectangle

getMaxLength

public int getMaxLength()
Returns the maximum length of the OverlayBar.

Returns:
The maximum length of the OverlayBar.

setMaxLength

public void setMaxLength(int maxLength)
Sets the maximum length of the OverlayBar. It must be greater than 0.

Parameters:
maxLength - The length the maximum should be set to.

getStat

public Stat<java.lang.Integer> getStat()
Returns the Stat that the OverlayBar represents.

Returns:
The Stat the OverlayBar represents.

setStat

public void setStat(Stat<java.lang.Integer> stat)
Sets the Stat the OverlayBar represents.

Parameters:
stat - The stat the OverlayBar should represent.

getMaxScore

public int getMaxScore()
Returns the maximum score for the OverlayBar, which determines the length of the OverlayBar relative to the current score.

Returns:
The maximum score for the OverlayBar.

setMaxScore

public void setMaxScore(int maxScore)
Sets the maximum score for the OverlayBar, which determines the length of the OverlayBar relative to the current score. Must be greater than 0.

Parameters:
maxScore - The score the maximum should be set to.

getBackgroundColor

public java.awt.Color getBackgroundColor()
Returns the background color of the OverlayBar.

Returns:
The background color of the OverlayBar.

setBackgroundColor

public void setBackgroundColor(java.awt.Color backgroundColor)
Sets the backgroundColor of the OverlayBar.

Parameters:
backgroundColor - The color the background color should be set to.

getHeight

public int getHeight()
Returns the height of the OverlayBar.

Returns:
The height of the OverlayBar.

setHeight

public void setHeight(int height)
Sets the height of the OverlayBar. Must be greater than 0.

Parameters:
height - The height the OverlayBar should be set to.