Skip to content
Snippets Groups Projects
Commit 7aa7b495 authored by LABOUREL Arnaud's avatar LABOUREL Arnaud
Browse files

minor renaming

parent 64119975
No related branches found
No related tags found
1 merge request!2Simple
......@@ -58,13 +58,13 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
}
public List<Position> updateToNextGeneration() {
List<Position> result = activateFirefighters();
result.addAll(activateFires());
List<Position> result = updateFirefighters();
result.addAll(updateFires());
step++;
return result;
}
private List<Position> activateFires() {
private List<Position> updateFires() {
List<Position> result = new ArrayList<>();
if (step % 2 == 0) {
List<Position> newFirePositions = new ArrayList<>();
......@@ -83,7 +83,7 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
return step;
}
private List<Position> activateFirefighters() {
private List<Position> updateFirefighters() {
List<Position> result = new ArrayList<>();
List<Position> firefighterNewPositions = new ArrayList<>();
for (Position firefighterPosition : firefighterPositions) {
......
......@@ -12,7 +12,6 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
private void paintElementAtPosition(ViewElement element, Position position) {
paintSquare(position.row(), position.column(), element.color);
}
private int squareWidth;
private int squareHeight;
private int columnCount;
......@@ -20,19 +19,27 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
@Override
public void repaint(List<Pair<Position, ViewElement>> positionedElements) {
paint(positionedElements);
paintLines();
}
private void paint(List<Pair<Position, ViewElement>> positionedElements) {
for(Pair<Position, ViewElement> pair : positionedElements){
paintElementAtPosition(pair.getValue(), pair.getKey());
}
paintLines();
}
@Override
public void repaint(ViewElement[][] elements) {
paint(elements);
paintLines();
}
private void paint(ViewElement[][] elements) {
for(int column = 0; column < columnCount; column++)
for(int row = 0; row < rowCount; row++){
paintElementAtPosition(elements[row][column], new Position(row, column));
}
paintLines();
}
public int columnCount() {
......@@ -43,9 +50,6 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
return rowCount;
}
public FirefighterGrid(){
}
@Override
public void setDimensions(int columnCount, int rowCount, int squareWidth, int squareHeight) {
this.squareWidth = squareWidth;
......@@ -55,17 +59,22 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
}
private void paintLines(){
paintHorizontalLines();
paintVerticalLines();
}
private void paintVerticalLines() {
for(int column = 0; column < columnCount; column++)
getGraphicsContext2D().strokeLine(0, column*squareHeight, getWidth(), column*squareWidth);
getGraphicsContext2D().strokeLine(column*squareWidth, 0,column*squareWidth, getHeight());
}
private void paintHorizontalLines() {
for(int row = 0; row < rowCount; row++)
getGraphicsContext2D().strokeLine(row*squareHeight, 0,row*squareHeight, getHeight());
getGraphicsContext2D().strokeLine(0, row*squareHeight, getWidth(), row*squareHeight);
}
private void paintSquare(int row, int column, Color color){
getGraphicsContext2D().setFill(color);
getGraphicsContext2D().fillRect(row*squareHeight,column*squareWidth,squareHeight,squareWidth);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment