diff options
Diffstat (limited to 'src/ch/epfl/maze/graphics')
-rw-r--r-- | src/ch/epfl/maze/graphics/Animation.java | 9 | ||||
-rw-r--r-- | src/ch/epfl/maze/graphics/Display.java | 12 | ||||
-rw-r--r-- | src/ch/epfl/maze/graphics/GraphicComponent.java | 8 |
3 files changed, 2 insertions, 27 deletions
diff --git a/src/ch/epfl/maze/graphics/Animation.java b/src/ch/epfl/maze/graphics/Animation.java index ce80c78..a00b6b2 100644 --- a/src/ch/epfl/maze/graphics/Animation.java +++ b/src/ch/epfl/maze/graphics/Animation.java | |||
@@ -22,7 +22,6 @@ import java.util.TreeMap; | |||
22 | * | 22 | * |
23 | * @author Pacien TRAN-GIRARD | 23 | * @author Pacien TRAN-GIRARD |
24 | */ | 24 | */ |
25 | |||
26 | public final class Animation { | 25 | public final class Animation { |
27 | 26 | ||
28 | /** | 27 | /** |
@@ -62,7 +61,6 @@ public final class Animation { | |||
62 | * @param animals The {@code List} of animals that will be shown on the first | 61 | * @param animals The {@code List} of animals that will be shown on the first |
63 | * frame | 62 | * frame |
64 | */ | 63 | */ |
65 | |||
66 | public Animation(List<Animal> animals) { | 64 | public Animation(List<Animal> animals) { |
67 | mGraphMap = new TreeMap<Integer, GraphicComponent>(); | 65 | mGraphMap = new TreeMap<Integer, GraphicComponent>(); |
68 | mImages = new HashMap<String, BufferedImage>(); | 66 | mImages = new HashMap<String, BufferedImage>(); |
@@ -94,7 +92,6 @@ public final class Animation { | |||
94 | * @param id Unique identifier for animal | 92 | * @param id Unique identifier for animal |
95 | * @param action Action that animal needs to perform | 93 | * @param action Action that animal needs to perform |
96 | */ | 94 | */ |
97 | |||
98 | public void update(Animal animal, int id, Action action) { | 95 | public void update(Animal animal, int id, Action action) { |
99 | // sanity checks | 96 | // sanity checks |
100 | if (action == null) { | 97 | if (action == null) { |
@@ -123,7 +120,6 @@ public final class Animation { | |||
123 | * | 120 | * |
124 | * @param id Identifier of animal to kill | 121 | * @param id Identifier of animal to kill |
125 | */ | 122 | */ |
126 | |||
127 | public void updateDying(int id) { | 123 | public void updateDying(int id) { |
128 | GraphicComponent graphComp = mGraphMap.get(id); | 124 | GraphicComponent graphComp = mGraphMap.get(id); |
129 | if (graphComp != null) { | 125 | if (graphComp != null) { |
@@ -135,7 +131,6 @@ public final class Animation { | |||
135 | * Notifies the animation that updates were done, and that it can start | 131 | * Notifies the animation that updates were done, and that it can start |
136 | * animating from now. | 132 | * animating from now. |
137 | */ | 133 | */ |
138 | |||
139 | public void doneUpdating() { | 134 | public void doneUpdating() { |
140 | mDone = false; | 135 | mDone = false; |
141 | } | 136 | } |
@@ -149,7 +144,6 @@ public final class Animation { | |||
149 | * @param targetWindow The window on which the graphic components will be painted | 144 | * @param targetWindow The window on which the graphic components will be painted |
150 | * (assumed non-null) | 145 | * (assumed non-null) |
151 | */ | 146 | */ |
152 | |||
153 | public void paint(float dt, Graphics2D g, ImageObserver targetWindow) { | 147 | public void paint(float dt, Graphics2D g, ImageObserver targetWindow) { |
154 | mRatio += dt; | 148 | mRatio += dt; |
155 | if (mRatio > 1) { | 149 | if (mRatio > 1) { |
@@ -181,7 +175,6 @@ public final class Animation { | |||
181 | * | 175 | * |
182 | * @return <b>true</b> if the animation is done, <b>false</b> otherwise | 176 | * @return <b>true</b> if the animation is done, <b>false</b> otherwise |
183 | */ | 177 | */ |
184 | |||
185 | public boolean isDone() { | 178 | public boolean isDone() { |
186 | return mDone; | 179 | return mDone; |
187 | } | 180 | } |
@@ -192,7 +185,6 @@ public final class Animation { | |||
192 | * number of frames will still be painted to prevent the screen from | 185 | * number of frames will still be painted to prevent the screen from |
193 | * flashing. | 186 | * flashing. |
194 | */ | 187 | */ |
195 | |||
196 | public void reset(List<Animal> animals) { | 188 | public void reset(List<Animal> animals) { |
197 | mGraphMap.clear(); | 189 | mGraphMap.clear(); |
198 | if (animals != null) { | 190 | if (animals != null) { |
@@ -225,7 +217,6 @@ public final class Animation { | |||
225 | * @param animal Animal whose image needs to be loaded or returned | 217 | * @param animal Animal whose image needs to be loaded or returned |
226 | * @return The buffered image of the animal | 218 | * @return The buffered image of the animal |
227 | */ | 219 | */ |
228 | |||
229 | private BufferedImage loadImage(Animal animal) { | 220 | private BufferedImage loadImage(Animal animal) { |
230 | // path = "img/superclass/class.png" | 221 | // path = "img/superclass/class.png" |
231 | String superClassName = animal.getClass().getSuperclass().getSimpleName(); | 222 | String superClassName = animal.getClass().getSuperclass().getSimpleName(); |
diff --git a/src/ch/epfl/maze/graphics/Display.java b/src/ch/epfl/maze/graphics/Display.java index 2fddcf1..baacefa 100644 --- a/src/ch/epfl/maze/graphics/Display.java +++ b/src/ch/epfl/maze/graphics/Display.java | |||
@@ -17,7 +17,6 @@ import java.util.Map; | |||
17 | /** | 17 | /** |
18 | * Handles the display of a {@code Simulation} on a window. | 18 | * Handles the display of a {@code Simulation} on a window. |
19 | */ | 19 | */ |
20 | |||
21 | public final class Display implements Runnable { | 20 | public final class Display implements Runnable { |
22 | 21 | ||
23 | /* constants */ | 22 | /* constants */ |
@@ -58,7 +57,6 @@ public final class Display implements Runnable { | |||
58 | * | 57 | * |
59 | * @param simulation A {@code Simulation} to display | 58 | * @param simulation A {@code Simulation} to display |
60 | */ | 59 | */ |
61 | |||
62 | public Display(Simulation simulation) { | 60 | public Display(Simulation simulation) { |
63 | // sanity check | 61 | // sanity check |
64 | if (simulation == null) { | 62 | if (simulation == null) { |
@@ -124,7 +122,6 @@ public final class Display implements Runnable { | |||
124 | * | 122 | * |
125 | * @param debug The new debug value | 123 | * @param debug The new debug value |
126 | */ | 124 | */ |
127 | |||
128 | public void setDebug(boolean debug) { | 125 | public void setDebug(boolean debug) { |
129 | mDebug = debug; | 126 | mDebug = debug; |
130 | mShowGrid = debug; | 127 | mShowGrid = debug; |
@@ -135,7 +132,6 @@ public final class Display implements Runnable { | |||
135 | /** | 132 | /** |
136 | * Creates frame window. | 133 | * Creates frame window. |
137 | */ | 134 | */ |
138 | |||
139 | private void createWindow() { | 135 | private void createWindow() { |
140 | // actual window | 136 | // actual window |
141 | mFrame = new JFrame("Maze solver simulation"); | 137 | mFrame = new JFrame("Maze solver simulation"); |
@@ -163,7 +159,6 @@ public final class Display implements Runnable { | |||
163 | /** | 159 | /** |
164 | * Creates canvas. | 160 | * Creates canvas. |
165 | */ | 161 | */ |
166 | |||
167 | private void createCanvas() { | 162 | private void createCanvas() { |
168 | // actual canvas | 163 | // actual canvas |
169 | mCanvas = new Canvas(); | 164 | mCanvas = new Canvas(); |
@@ -183,7 +178,6 @@ public final class Display implements Runnable { | |||
183 | /** | 178 | /** |
184 | * Creates menu. | 179 | * Creates menu. |
185 | */ | 180 | */ |
186 | |||
187 | private void createMenu() { | 181 | private void createMenu() { |
188 | // creates menu bar | 182 | // creates menu bar |
189 | mMenuBar = new JMenuBar(); | 183 | mMenuBar = new JMenuBar(); |
@@ -371,7 +365,6 @@ public final class Display implements Runnable { | |||
371 | * | 365 | * |
372 | * @param g The graphics on which the labyrinth will be drawn | 366 | * @param g The graphics on which the labyrinth will be drawn |
373 | */ | 367 | */ |
374 | |||
375 | private void drawLabyrinth(Graphics2D g) { | 368 | private void drawLabyrinth(Graphics2D g) { |
376 | World world = mSimulation.getWorld(); | 369 | World world = mSimulation.getWorld(); |
377 | 370 | ||
@@ -405,7 +398,6 @@ public final class Display implements Runnable { | |||
405 | * @param width Width of graphics | 398 | * @param width Width of graphics |
406 | * @param height Height of graphics | 399 | * @param height Height of graphics |
407 | */ | 400 | */ |
408 | |||
409 | private void drawAnimation(float dt, Graphics2D g, int width, int height) { | 401 | private void drawAnimation(float dt, Graphics2D g, int width, int height) { |
410 | // clears background | 402 | // clears background |
411 | g.setColor(BACKGROUND_COLOR); | 403 | g.setColor(BACKGROUND_COLOR); |
@@ -448,7 +440,6 @@ public final class Display implements Runnable { | |||
448 | * | 440 | * |
449 | * @param dt The elapsed time between two frames | 441 | * @param dt The elapsed time between two frames |
450 | */ | 442 | */ |
451 | |||
452 | private void animate(float dt) { | 443 | private void animate(float dt) { |
453 | Graphics2D g = null; | 444 | Graphics2D g = null; |
454 | try { | 445 | try { |
@@ -475,7 +466,6 @@ public final class Display implements Runnable { | |||
475 | /** | 466 | /** |
476 | * Runs the animation main loop. | 467 | * Runs the animation main loop. |
477 | */ | 468 | */ |
478 | |||
479 | private void mainLoop() { | 469 | private void mainLoop() { |
480 | long before = System.nanoTime(); | 470 | long before = System.nanoTime(); |
481 | while (mRunning) { | 471 | while (mRunning) { |
@@ -508,7 +498,6 @@ public final class Display implements Runnable { | |||
508 | /** | 498 | /** |
509 | * Computes the {@code Simulation}'s next move. | 499 | * Computes the {@code Simulation}'s next move. |
510 | */ | 500 | */ |
511 | |||
512 | private void nextMove() { | 501 | private void nextMove() { |
513 | synchronized (mLock) { | 502 | synchronized (mLock) { |
514 | if (mRunning) { | 503 | if (mRunning) { |
@@ -516,4 +505,5 @@ public final class Display implements Runnable { | |||
516 | } | 505 | } |
517 | } | 506 | } |
518 | } | 507 | } |
508 | |||
519 | } | 509 | } |
diff --git a/src/ch/epfl/maze/graphics/GraphicComponent.java b/src/ch/epfl/maze/graphics/GraphicComponent.java index e49a542..44b4b1f 100644 --- a/src/ch/epfl/maze/graphics/GraphicComponent.java +++ b/src/ch/epfl/maze/graphics/GraphicComponent.java | |||
@@ -13,7 +13,6 @@ import java.awt.image.ImageObserver; | |||
13 | /** | 13 |