ch.aplu.jgamegrid
Class GGProgressBar

java.lang.Object
  extended by ch.aplu.jgamegrid.GGProgressBar

public class GGProgressBar
extends java.lang.Object

Class that implements a progress bar indicator. It consists of a rectangular frame with a filled color stick inside that indicates the current value. The value may be displayed as text centered in the middle of the frame. The bar may be horizonal (stick advances from left to right) or vertical (stick advances from bottom to top). The bar graphics is a dynamically generated GGBitmap used to create an Actor instance that is added to the game grid.


Constructor Summary
GGProgressBar(GameGrid gg, Location loc, int width, int height)
          Creates a horizontal progress bar with default properties.
GGProgressBar(GameGrid gg, Location loc, int width, int height, boolean isHorizontal)
          Creates a horizontal or vertical progress bar with default properties.
 
Method Summary
 void remove(boolean doRefresh)
          Removes the progress bar from the game grid.
 void setBgColor(java.awt.Color color)
          Sets the background color of the frame.
 void setFont(java.awt.Font font)
          Sets the font for the value/unit text.
 void setFrameColor(java.awt.Color color)
          Sets the border color of the frame.
 void setMax(double max)
          Sets the maximum value of the indicator.
 void setMin(double min)
          Sets the minimum value of the indicator.
 void setPattern(java.lang.String pattern)
          Sets the DecimalFormat pattern used to display the value.
 void setStripColor(java.awt.Color color)
          Sets the color of the indicator strip (filled rectangle).
 void setTextColor(java.awt.Color color)
          Sets the color of the text centered in the middle of the bar.
 void setUnit(java.lang.String unit)
          Sets the text displayed as unit.
 void setValue(double value)
          Sets the current value of the progress bar.
 void setValue(double value, boolean doRefresh)
          Sets the current value of the progress bar.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GGProgressBar

public GGProgressBar(GameGrid gg,
                     Location loc,
                     int width,
                     int height)
Creates a horizontal progress bar with default properties.
Defaults:
- frame color: black
- background color: white
- strip color: light gray
- text color: black
- minimum value: 0
- maximum value: 100
- unit: empty
- decimal format pattern "#"
- font for value/unit text: new Font("SansSerif", Font.BOLD, 12)

Parameters:
gg - the GameGrid reference where the bar is shown
loc - the location of the bar's center
width - the width (length) of the bar
height - the height of the bar

GGProgressBar

public GGProgressBar(GameGrid gg,
                     Location loc,
                     int width,
                     int height,
                     boolean isHorizontal)
Creates a horizontal or vertical progress bar with default properties.
Defaults:
- frame color: black
- background color: white
- strip color: light gray
- text color: black
- minimum value: 0
- maximum value: 100
- unit: empty
- decimal format pattern "#"
- font for value/unit text: new Font("SansSerif", Font.BOLD, 12)

Parameters:
gg - the GameGrid reference where the bar is shown
loc - the location of the bar's center
width - the width (length) of the bar
height - the height of the bar
isHorizontal - if true, a horizontal bar is shown; otherwise a vertical bar is shown
Method Detail

setBgColor

public void setBgColor(java.awt.Color color)
Sets the background color of the frame.
Default: white

Parameters:
color - the background color

setFrameColor

public void setFrameColor(java.awt.Color color)
Sets the border color of the frame.
Default: black

Parameters:
color - the color of the frame border

setStripColor

public void setStripColor(java.awt.Color color)
Sets the color of the indicator strip (filled rectangle).
Default: light gray

Parameters:
color - the color of the strip

setTextColor

public void setTextColor(java.awt.Color color)
Sets the color of the text centered in the middle of the bar.
Default: black

Parameters:
color - the text color

setMin

public void setMin(double min)
Sets the minimum value of the indicator.
Default: 0

Parameters:
min - the value for a strip length = 0.

setMax

public void setMax(double max)
Sets the maximum value of the indicator.
Default: 100

Parameters:
max - the value for a the full length strip.

setUnit

public void setUnit(java.lang.String unit)
Sets the text displayed as unit. If null, no value/unit text is shown.
Default: empty string.

Parameters:
unit - the unit string

setFont

public void setFont(java.awt.Font font)
Sets the font for the value/unit text. Default: new Font("SansSerif", Font.BOLD, 12)

Parameters:
font - the font for the value/unit text

setPattern

public void setPattern(java.lang.String pattern)
Sets the DecimalFormat pattern used to display the value. See the class java.text.DecimalFormat for more information.
Default: "#"

Parameters:
pattern - the format pattern used to create the decimal format for the value text

remove

public void remove(boolean doRefresh)
Removes the progress bar from the game grid. Calling setValue() will show it again.

Parameters:
doRefresh - if true, the game grid is refreshed

setValue

public void setValue(double value)
Sets the current value of the progress bar. Must be a value in [min..max] (inclusive). The image of the progress bar is constructed and a new actor is created and added to the game grid. (The actor classes used for the control are put on top of the paint order.) Then the game grid is refreshed.

Parameters:
value - the new value

setValue

public void setValue(double value,
                     boolean doRefresh)
Sets the current value of the progress bar. Must be a value in [min..max] (inclusive). The image of the progress bar is constructed and a new actor is created and added to the game grid. (The actor classes used for the control are put on top of the paint order.)

Parameters:
value - the new value
doRefresh - if true, the game grid is refreshed; otherwise it must be refreshed by another call (e.g. GamgeGrid.addActor(), GameGrid.refresh(), tetc.)