Class CellComponent
java.lang.Object
webb.client.ui.screens.puzzlescreen.CellComponent
This class represents a single cell in the puzzle grid.
Allows us to not deal with coordinates and just use row and col.
This class handles the drawing of the cell logic class.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddraw(Graphics2D g2d) Draw the image for the cell, given the cell typeintgetCol()intgetGroup()getLogic()Get the logic data for the cellintgetRow()getType()protected booleanisInside(double x, double y) Checks to see if the mouse cords are inside the cellbooleanvoidonClick(boolean rightClick) Called when the cell is clickedprotected voidsetBounds(double x, double y, double width, double height) Set the bounds of the cell when we repaint the scene This is used so we can easily calculate if the mouse is inside the cellvoidsetGroup(int group) voidvoidvoidsetWall(int wall)
-
Constructor Details
-
CellComponent
public CellComponent(int col, int row) Create a new cell- Parameters:
col- Column of the cellrow- Row of the cell
-
-
Method Details
-
isInside
protected boolean isInside(double x, double y) Checks to see if the mouse cords are inside the cell- Parameters:
x- X cord of the mousey- Y cord of the mouse- Returns:
- True if the mouse is inside the cell
-
onClick
public void onClick(boolean rightClick) Called when the cell is clicked- Parameters:
rightClick- True if the right mouse button was clicked
-
getLogic
Get the logic data for the cell- Returns:
- the logic data class
-
draw
Draw the image for the cell, given the cell type- Parameters:
g2d- Graphics2D object to draw with
-
setBounds
protected void setBounds(double x, double y, double width, double height) Set the bounds of the cell when we repaint the scene This is used so we can easily calculate if the mouse is inside the cell- Parameters:
x- X cord of the celly- Y cord of the cellwidth- Width of the cellheight- Height of the cell
-
getGroup
public int getGroup() -
setWall
public void setWall(int wall) -
getType
-
setGroup
public void setGroup(int group) -
setType
-
getRow
public int getRow() -
getCol
public int getCol() -
setSolutionStar
public void setSolutionStar() -
isSolutionStar
public boolean isSolutionStar()
-