Skip to content

Commit eac55c6

Browse files
author
Arun Prasaad
committed
Fix warnings, language and formatting
1 parent 61c8259 commit eac55c6

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

src/main/java/ihm/SokobanPanel.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package ihm;
22

33
import java.awt.Graphics;
4-
54
import java.awt.Image;
65
import java.io.File;
76
import java.io.IOException;
87
import java.util.EnumMap;
98
import java.util.Map;
9+
import java.util.logging.Level;
10+
import java.util.logging.Logger;
1011

1112
import javax.imageio.ImageIO;
1213
import javax.swing.JPanel;
@@ -17,8 +18,8 @@
1718
import static ihm.SokobanWindow.IMAGE_SIZE;
1819

1920

20-
@SuppressWarnings("serial")
2121
public class SokobanPanel extends JPanel {
22+
private static final Logger LOGGER = Logger.getLogger(SokobanPanel.class.getName());
2223

2324
private static EnumMap<TileType, Image > images;
2425

@@ -27,29 +28,28 @@ public class SokobanPanel extends JPanel {
2728
public SokobanPanel(Controller controller) {
2829
this.controller = controller;
2930
try {
30-
images = new EnumMap<TileType, Image >(
31-
Map.of(
32-
TileType.FLOOR, ImageIO.read( new File( "img/Vide.jpg" )),
33-
TileType.WALL, ImageIO.read( new File( "img/Mur.jpg" )),
34-
TileType.UNSTORED_BOX, ImageIO.read( new File( "img/Caisse.jpg" )),
35-
TileType.STORED_BOX, ImageIO.read( new File( "img/CaisseRangee.jpg" )),
36-
TileType.STORAGE_AREA, ImageIO.read( new File( "img/Rangement.jpg" )),
37-
TileType.WORKER_ON_FLOOR, ImageIO.read( new File( "img/Joueur.jpg" )),
38-
TileType.OUTSIDE, ImageIO.read( new File( "img/Background.jpg" )),
39-
TileType.WORKER_IN_STORAGE_AREA, ImageIO.read( new File( "img/JoueurRangement.jpg" ))
40-
)
41-
);
31+
images = new EnumMap<>( Map.of(
32+
TileType.FLOOR, ImageIO.read(new File( "img/Vide.jpg")),
33+
TileType.WALL, ImageIO.read(new File( "img/Mur.jpg")),
34+
TileType.UNSTORED_BOX, ImageIO.read(new File( "img/Caisse.jpg")),
35+
TileType.STORED_BOX, ImageIO.read(new File( "img/CaisseRangee.jpg")),
36+
TileType.STORAGE_AREA, ImageIO.read(new File( "img/Rangement.jpg")),
37+
TileType.WORKER_ON_FLOOR, ImageIO.read(new File( "img/Joueur.jpg")),
38+
TileType.OUTSIDE, ImageIO.read(new File( "img/Background.jpg")),
39+
TileType.WORKER_IN_STORAGE_AREA, ImageIO.read(new File( "img/JoueurRangement.jpg"))
40+
));
4241
}
4342
catch( IOException e ) {
44-
e.printStackTrace();
43+
LOGGER.log(Level.SEVERE, "Error loading game images", e);
4544
}
4645
}
46+
4747
@Override
4848
public void paint( Graphics g ) {
4949
super.paint( g );
50-
// Le côté métier raisonne en [ligne, colonne]
51-
// Le côté IHM raisonne en [x, y]
52-
// Donc x <=> colonne et y <=> ligne
50+
// Business logic uses [row, column] coordinates
51+
// UI uses [x, y] coordinates
52+
// So x <=> column and y <=> row
5353
for(int l = 0; l < controller.warehouse.getLines(); l++ ) {
5454
for(int c = 0; c < controller.warehouse.getColumns(); c++ ) {
5555
g.drawImage( images.get( controller.warehouse.getCase( l, c).getContent()), c * IMAGE_SIZE, l * IMAGE_SIZE, IMAGE_SIZE, IMAGE_SIZE, null );

0 commit comments

Comments
 (0)