Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firefighter template
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LABOUREL Arnaud
Firefighter template
Commits
3c486887
Commit
3c486887
authored
1 year ago
by
LABOUREL Arnaud
Browse files
Options
Downloads
Patches
Plain Diff
refactoring grid
parent
7aa7b495
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#22279
passed
1 year ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/view/FirefighterGrid.java
+17
-0
17 additions, 0 deletions
src/main/java/view/FirefighterGrid.java
src/main/java/view/Grid.java
+1
-2
1 addition, 2 deletions
src/main/java/view/Grid.java
with
18 additions
and
2 deletions
src/main/java/view/FirefighterGrid.java
+
17
−
0
View file @
3c486887
...
@@ -19,10 +19,18 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
...
@@ -19,10 +19,18 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
@Override
@Override
public
void
repaint
(
List
<
Pair
<
Position
,
ViewElement
>>
positionedElements
)
{
public
void
repaint
(
List
<
Pair
<
Position
,
ViewElement
>>
positionedElements
)
{
clear
(
positionedElements
);
paint
(
positionedElements
);
paint
(
positionedElements
);
paintLines
();
paintLines
();
}
}
private
void
clear
(
List
<
Pair
<
Position
,
ViewElement
>>
positionedElements
)
{
for
(
Pair
<
Position
,
ViewElement
>
positionElement
:
positionedElements
)
{
Position
position
=
positionElement
.
getKey
();
clearSquare
(
position
.
row
(),
position
.
column
());
}
}
private
void
paint
(
List
<
Pair
<
Position
,
ViewElement
>>
positionedElements
)
{
private
void
paint
(
List
<
Pair
<
Position
,
ViewElement
>>
positionedElements
)
{
for
(
Pair
<
Position
,
ViewElement
>
pair
:
positionedElements
){
for
(
Pair
<
Position
,
ViewElement
>
pair
:
positionedElements
){
paintElementAtPosition
(
pair
.
getValue
(),
pair
.
getKey
());
paintElementAtPosition
(
pair
.
getValue
(),
pair
.
getKey
());
...
@@ -31,10 +39,15 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
...
@@ -31,10 +39,15 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
@Override
@Override
public
void
repaint
(
ViewElement
[][]
elements
)
{
public
void
repaint
(
ViewElement
[][]
elements
)
{
clear
();
paint
(
elements
);
paint
(
elements
);
paintLines
();
paintLines
();
}
}
private
void
clear
()
{
getGraphicsContext2D
().
clearRect
(
0
,
0
,
getWidth
(),
getHeight
());
}
private
void
paint
(
ViewElement
[][]
elements
)
{
private
void
paint
(
ViewElement
[][]
elements
)
{
for
(
int
column
=
0
;
column
<
columnCount
;
column
++)
for
(
int
column
=
0
;
column
<
columnCount
;
column
++)
for
(
int
row
=
0
;
row
<
rowCount
;
row
++){
for
(
int
row
=
0
;
row
<
rowCount
;
row
++){
...
@@ -77,4 +90,8 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
...
@@ -77,4 +90,8 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
getGraphicsContext2D
().
setFill
(
color
);
getGraphicsContext2D
().
setFill
(
color
);
getGraphicsContext2D
().
fillRect
(
row
*
squareHeight
,
column
*
squareWidth
,
squareHeight
,
squareWidth
);
getGraphicsContext2D
().
fillRect
(
row
*
squareHeight
,
column
*
squareWidth
,
squareHeight
,
squareWidth
);
}
}
private
void
clearSquare
(
int
row
,
int
column
){
getGraphicsContext2D
().
clearRect
(
row
*
squareHeight
,
column
*
squareWidth
,
squareHeight
,
squareWidth
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/view/Grid.java
+
1
−
2
View file @
3c486887
...
@@ -28,8 +28,7 @@ public interface Grid<E> {
...
@@ -28,8 +28,7 @@ public interface Grid<E> {
void
repaint
(
E
[][]
elements
);
void
repaint
(
E
[][]
elements
);
/**
/**
* Set the dimensions of the grid to the specified column count, row count, square width, and square height.
* Set the dimensions of the grid to the specified number of columns, number of rows, square width,
* This method adjusts the dimensions of the grid to the given number of columns, number of rows, square width,
* and square height.
* and square height.
*
*
* @param columnCount The new number of columns in the grid.
* @param columnCount The new number of columns in the grid.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment