aboutsummaryrefslogtreecommitdiff
path: root/src/esieequest/view/app/UserInterface.java
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-05-18 17:53:00 +0200
committerPacien TRAN-GIRARD2014-05-18 17:53:00 +0200
commitdb373254f918ef75062698757e6cd6e13e26289f (patch)
treee1975b38b06c88f469f3f3e2e0d9cf515778f9f1 /src/esieequest/view/app/UserInterface.java
parent0d4651e54f40f4dad929c419e92e37a15926f7be (diff)
downloadesieequest-db373254f918ef75062698757e6cd6e13e26289f.tar.gz
Format code (100 chars line)
Diffstat (limited to 'src/esieequest/view/app/UserInterface.java')
-rw-r--r--src/esieequest/view/app/UserInterface.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java
index 220afc1..90a99c2 100644
--- a/src/esieequest/view/app/UserInterface.java
+++ b/src/esieequest/view/app/UserInterface.java
@@ -231,13 +231,15 @@ abstract class UserInterface implements Viewable, ActionListener {
231 231
232 this.leftButton = new JButton(Text.TURN_LEFT_BUTTON.toString()); 232 this.leftButton = new JButton(Text.TURN_LEFT_BUTTON.toString());
233 this.leftButton.setToolTipText(Text.TURN_LEFT_TOOLTIP.toString()); 233 this.leftButton.setToolTipText(Text.TURN_LEFT_TOOLTIP.toString());
234 this.leftButton.setActionCommand(Command.TURN.name() + Text.COMMAND_SEPARATOR.toString() + Orientation.LEFT.name()); 234 this.leftButton.setActionCommand(Command.TURN.name() + Text.COMMAND_SEPARATOR.toString()
235 + Orientation.LEFT.name());
235 this.bottomControlPanel.add(this.leftButton, BorderLayout.WEST); 236 this.bottomControlPanel.add(this.leftButton, BorderLayout.WEST);
236 this.controlButtons.add(this.leftButton); 237 this.controlButtons.add(this.leftButton);
237 238
238 this.rightButton = new JButton(Text.TURN_RIGHT_BUTTON.toString()); 239 this.rightButton = new JButton(Text.TURN_RIGHT_BUTTON.toString());
239 this.rightButton.setToolTipText(Text.TURN_RIGHT_TOOLTIP.toString()); 240 this.rightButton.setToolTipText(Text.TURN_RIGHT_TOOLTIP.toString());
240 this.rightButton.setActionCommand(Command.TURN.name() + Text.COMMAND_SEPARATOR.toString() + Orientation.RIGHT.name()); 241 this.rightButton.setActionCommand(Command.TURN.name() + Text.COMMAND_SEPARATOR.toString()
242 + Orientation.RIGHT.name());
241 this.bottomControlPanel.add(this.rightButton, BorderLayout.EAST); 243 this.bottomControlPanel.add(this.rightButton, BorderLayout.EAST);
242 this.controlButtons.add(this.rightButton); 244 this.controlButtons.add(this.rightButton);
243 245
@@ -323,7 +325,8 @@ abstract class UserInterface implements Viewable, ActionListener {
323 * the name of the image 325 * the name of the image
324 */ 326 */
325 private void setIllustration(final String imageName) { 327 private void setIllustration(final String imageName) {
326 final URL imageURL = this.getClass().getClassLoader().getResource(imageName + UserInterface.ILLUSTRATION_EXT); 328 final URL imageURL = this.getClass().getClassLoader().getResource(
329 imageName + UserInterface.ILLUSTRATION_EXT);
327 final StretchIcon imageIcon; 330 final StretchIcon imageIcon;
328 if (imageURL == null) { 331 if (imageURL == null) {
329 imageIcon = new StretchIcon(this.generatePlaceholderImage(imageName), true); 332 imageIcon = new StretchIcon(this.generatePlaceholderImage(imageName), true);
@@ -342,7 +345,8 @@ abstract class UserInterface implements Viewable, ActionListener {
342 * @return the Image 345 * @return the Image
343 */ 346 */
344 private Image generatePlaceholderImage(final String text) { 347 private Image generatePlaceholderImage(final String text) {
345 final BufferedImage bufferedImage = new BufferedImage(240, 135, BufferedImage.TYPE_BYTE_BINARY); 348 final BufferedImage bufferedImage = new BufferedImage(240, 135,
349 BufferedImage.TYPE_BYTE_BINARY);
346 final Graphics graphics = bufferedImage.getGraphics(); 350 final Graphics graphics = bufferedImage.getGraphics();
347 graphics.drawString(text, 5, 10 + 5); 351 graphics.drawString(text, 5, 10 + 5);
348 return bufferedImage; 352 return bufferedImage;
@@ -418,11 +422,12 @@ abstract class UserInterface implements Viewable, ActionListener {
418 } 422 }
419 423
420 @Override 424 @Override
421 public void updateLocation(final Room room, final Direction direction, final Side side, final boolean canGoBack) { 425 public void updateLocation(final Room room, final Direction direction, final Side side,
426 final boolean canGoBack) {
422 this.setIllustration(room.name() + Text.FILENAME_SEPARATOR.toString() + direction.name()); 427 this.setIllustration(room.name() + Text.FILENAME_SEPARATOR.toString() + direction.name());
423 this.backButton.setEnabled(canGoBack); 428 this.backButton.setEnabled(canGoBack);
424 this.forwardButton.setEnabled(side.hasDoor()); 429 this.forwardButton.setEnabled(side.hasDoor());
425 this.actionButton.setEnabled(side.hasCharacter() || side.getInventory().getSize() > 0); 430 this.actionButton.setEnabled(side.hasCharacter() || (side.getInventory().getSize() > 0));
426 431
427 this.echo(room.getInformations()); 432 this.echo(room.getInformations());
428 } 433 }
@@ -440,7 +445,8 @@ abstract class UserInterface implements Viewable, ActionListener {
440 445
441 for (final Item item : inventory.getItems().values()) { 446 for (final Item item : inventory.getItems().values()) {
442 final JButton button = new JButton(item.getName()); 447 final JButton button = new JButton(item.getName());
443 button.setActionCommand(Command.USE.name() + Text.COMMAND_SEPARATOR.toString() + item.getName()); 448 button.setActionCommand(Command.USE.name() + Text.COMMAND_SEPARATOR.toString()
449 + item.getName());
444 button.addActionListener(this); 450 button.addActionListener(this);
445 this.inventoryPanel.add(button); 451 this.inventoryPanel.add(button);
446 } 452 }