Breakout Problem Set Javadocs

breakout
Class Board

java.lang.Object
  extended bybreakout.Board

public class Board
extends java.lang.Object

A class to manage lists of BreakoutComponents, provide simple autolayout functionality, and maintain information about the geometry of the gameboard.

A Board is housed in a BoardPanel, which manages the painting of the Board and its members.


Field Summary
static int BORDER
          The border autolayout keeps between the edge of the panel and where bricks start to appear.
static int PADDING
          The distance autolayout places between bricks.
 
Constructor Summary
Board(BoardPanel bp)
          Creates a new Board with the specified BoardPanel.
 
Method Summary
 void add(BreakoutComponent bc)
          Autolayout adder: Adds a BreakoutComponent to the board in the next available spot in the grid.
 void add(BreakoutComponent bc, java.awt.Point p)
          Explicit adder: Adds a BreakoutComponent to the Board at the specified Point.
 void addDefaultBallPaddle()
          Adds a BasicPaddle and BasicBall to the board in default locations.
 void addDefaultWalls()
          Adds four BasicWalls to the board, including the floor.
 void disableLayout()
          Disables autolayout in preparation for beginning the game.
 java.util.Iterator getAllComponents()
          Gives an Iterator for all the BreakoutComponents on the board.
 BoardPanel getBoardPanel()
          Gets the BoardPanel used to display this Board.
 int getHeight(boolean padding)
          Gets the height of the board, with or without the border padding.
 java.awt.Point getLowerLeft(boolean padding)
          Gets the lower-left point on the board, with or without the border padding.
 java.awt.Point getLowerRight(boolean padding)
          Gets the lower-right point on the board, with or without the border padding.
 java.util.Iterator getReboundingComponents()
          Gives an Iterator for all the BreakoutComponents on the board that implement Rebounding.
 java.awt.Point getUpperLeft(boolean padding)
          Gets the upper-left point on the board, with or without the border padding.
 java.awt.Point getUpperRight(boolean padding)
          Gets the upper-right point on the board, with or without the border padding.
 int getWidth(boolean padding)
          Gets the width of the board, with or without border padding.
 boolean hasBallInPlay()
          Tells if there are any Ball objects left on the Board.
 boolean hasBricksLeft()
          Tells if there are any Brick objects left on the Board.
 void removeReboundingElement(BreakoutComponent bc)
          Fully removes from the board a Rebounding BreakoutComponent which died during the bounce phase of the tick.
 void setBoardPanel(BoardPanel bp)
          Sets the BoardPanel for this Board.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PADDING

public static final int PADDING
The distance autolayout places between bricks.

See Also:
Constant Field Values

BORDER

public static final int BORDER
The border autolayout keeps between the edge of the panel and where bricks start to appear.

See Also:
Constant Field Values
Constructor Detail

Board

public Board(BoardPanel bp)
Creates a new Board with the specified BoardPanel. Autolayout is enabled at creation.

Parameters:
bp - the BoardPanel used to display this Board.
Method Detail

setBoardPanel

public void setBoardPanel(BoardPanel bp)
Sets the BoardPanel for this Board. Enables autolayout, if Board's noargs constructor was used.

Parameters:
bp - the BoardPanel used to display this Board.

getBoardPanel

public BoardPanel getBoardPanel()
Gets the BoardPanel used to display this Board.

Returns:
a label for the BoardPanel used to display this Board.

disableLayout

public void disableLayout()
Disables autolayout in preparation for beginning the game.


add

public void add(BreakoutComponent bc,
                java.awt.Point p)
Explicit adder: Adds a BreakoutComponent to the Board at the specified Point.

Please note that Board does no checking to see if this new BreakoutComponent or any further BreakoutComponents overlap.

Parameters:
bc - the BreakoutComponent to be added.
p - the Point representing the intended location of the object.

add

public void add(BreakoutComponent bc)
Autolayout adder: Adds a BreakoutComponent to the board in the next available spot in the grid. The size of the grid is decided by the largest independent dimensions of BreakoutComponents on this Board, with the addition of PADDING to the width and height of the final cell.

The Board will print an error message and ignore the new BreakoutComponent in the following cases: If a BoardPanel has not been set for this Board, attempting to add a BreakoutComponent to it will result in a RuntimeException.


addDefaultWalls

public void addDefaultWalls()
Adds four BasicWalls to the board, including the floor.


addDefaultBallPaddle

public void addDefaultBallPaddle()
Adds a BasicPaddle and BasicBall to the board in default locations.


removeReboundingElement

public void removeReboundingElement(BreakoutComponent bc)
Fully removes from the board a Rebounding BreakoutComponent which died during the bounce phase of the tick.

Parameters:
bc - The Rebounding/BreakoutComponent object that died.

getAllComponents

public java.util.Iterator getAllComponents()
Gives an Iterator for all the BreakoutComponents on the board.

Returns:
an Iterator for all the BreakoutComponents on the board.

getReboundingComponents

public java.util.Iterator getReboundingComponents()
Gives an Iterator for all the BreakoutComponents on the board that implement Rebounding.

Returns:
an Iterator for all the Rebounding components on the board.

hasBricksLeft

public boolean hasBricksLeft()
Tells if there are any Brick objects left on the Board.

Returns:
true if there are Bricks left; false otherwise.

hasBallInPlay

public boolean hasBallInPlay()
Tells if there are any Ball objects left on the Board.

Returns:
true if there are Balls left; false otherwise.

getUpperLeft

public java.awt.Point getUpperLeft(boolean padding)
Gets the upper-left point on the board, with or without the border padding.

Parameters:
padding - If true, returns the point where autolayout adds the first brick. Otherwise, returns the upperleftmost point of the BoardPanel.
Returns:
a new Point object representing the upper-left point specified.

getUpperRight

public java.awt.Point getUpperRight(boolean padding)
Gets the upper-right point on the board, with or without the border padding.

Parameters:
padding - If true, returns the point where autolayout thinks upper-right is. Otherwise, returns the upperrightmost point of the BoardPanel.
Returns:
a new Point object representing the upper-right point specified.

getLowerLeft

public java.awt.Point getLowerLeft(boolean padding)
Gets the lower-left point on the board, with or without the border padding.

Parameters:
padding - If true, returns the point where autolayout thinks lower-left is. Otherwise, returns the lowerleftmost point of the BoardPanel.
Returns:
a new Point object representing the lower-left point specified.

getLowerRight

public java.awt.Point getLowerRight(boolean padding)
Gets the lower-right point on the board, with or without the border padding.

Parameters:
padding - If true, returns the point where autolayout thinks lower-right is. Otherwise, returns the lowerrightmost point of the BoardPanel.
Returns:
a new Point object representing the lower-right point specified.

getHeight

public int getHeight(boolean padding)
Gets the height of the board, with or without the border padding.

Parameters:
padding - If true, returns the height autolayout uses. Otherwise, returns the height of the BoardPanel.
Returns:
the height specified.

getWidth

public int getWidth(boolean padding)
Gets the width of the board, with or without border padding.

Parameters:
padding - If true, returns the width autolayout uses. Otherwise, returns the width of the BoardPanel.
Returns:
the width specified.

Breakout Problem Set Javadocs