From b875e445308760afbc502517f3b4ab7aa979f2c9 Mon Sep 17 00:00:00 2001 From: Bennet Gerlach Date: Sun, 19 Jun 2011 19:31:55 +0200 Subject: pause panel and start turn panel now show player color git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@489 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/PausePanel.java | 9 ++-- src/jrummikub/view/impl/StartTurnPanel.java | 26 +++++----- src/jrummikub/view/impl/View.java | 73 ++++++++++++++--------------- 3 files changed, 56 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/jrummikub/view/impl/PausePanel.java b/src/jrummikub/view/impl/PausePanel.java index f9e99ad..ef7781b 100644 --- a/src/jrummikub/view/impl/PausePanel.java +++ b/src/jrummikub/view/impl/PausePanel.java @@ -1,5 +1,6 @@ package jrummikub.view.impl; +import java.awt.Color; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -40,9 +41,7 @@ class PausePanel extends JPanel { pauseLabel = new JLabel(); pauseLabel.setHorizontalAlignment(JLabel.CENTER); - pauseLabel.setHorizontalTextPosition(JLabel.CENTER); pauseLabel.setVerticalAlignment(JLabel.CENTER); - pauseLabel.setVerticalTextPosition(JLabel.CENTER); pauseLabel.putClientProperty("html.disable", Boolean.TRUE); add(pauseLabel); @@ -64,7 +63,11 @@ class PausePanel extends JPanel { } void setCurrentPlayerName(String playerName) { - pauseLabel.setText("Der Zug von " + playerName + " ist pausiert."); + pauseLabel.setText(playerName + "'s Zug ist pausiert."); + } + + void setCurrentPlayerColor(Color color) { + pauseLabel.setIcon(ImageUtil.createColorIcon(color, 12, 1)); } IEvent getEndPauseEvent() { diff --git a/src/jrummikub/view/impl/StartTurnPanel.java b/src/jrummikub/view/impl/StartTurnPanel.java index ccbaf91..46e5f0a 100644 --- a/src/jrummikub/view/impl/StartTurnPanel.java +++ b/src/jrummikub/view/impl/StartTurnPanel.java @@ -1,5 +1,6 @@ package jrummikub.view.impl; +import java.awt.Color; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -44,9 +45,7 @@ class StartTurnPanel extends JPanel { startTurnLabel = new JLabel(); startTurnLabel.setHorizontalAlignment(JLabel.CENTER); - startTurnLabel.setHorizontalTextPosition(JLabel.CENTER); startTurnLabel.setVerticalAlignment(JLabel.CENTER); - startTurnLabel.setVerticalTextPosition(JLabel.CENTER); startTurnLabel.putClientProperty("html.disable", Boolean.TRUE); add(startTurnLabel); @@ -71,6 +70,10 @@ class StartTurnPanel extends JPanel { startTurnLabel.setText(playerName + " ist jetzt an der Reihe."); } + void setCurrentPlayerColor(Color color) { + startTurnLabel.setIcon(ImageUtil.createColorIcon(color, 12, 1)); + } + void setInitialMeldError(int points) { startTurnLabel.setText("Es wurden weniger als " + points + " Punkte ausgelegt."); @@ -117,16 +120,15 @@ class StartTurnPanel extends JPanel { } switch (type) { - case START_TURN_PANEL: - startTurnButton.setText("Zug beginnen"); - buttonEvent = startTurnEvent; - break; - case INVALID_TURN_PANEL: - startTurnLabel - .setText("Es liegen ung\u00FCltige Serien auf dem Tisch."); - startTurnButton.setText("N\u00E4chster Spieler"); - buttonEvent = acknowledgeInvalidEvent; - break; + case START_TURN_PANEL: + startTurnButton.setText("Zug beginnen"); + buttonEvent = startTurnEvent; + break; + case INVALID_TURN_PANEL: + startTurnLabel.setText("Es liegen ung\u00FCltige Serien auf dem Tisch."); + startTurnButton.setText("N\u00E4chster Spieler"); + buttonEvent = acknowledgeInvalidEvent; + break; } } diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java index caac01f..4911de0 100644 --- a/src/jrummikub/view/impl/View.java +++ b/src/jrummikub/view/impl/View.java @@ -102,12 +102,12 @@ public class View extends JFrame implements IView { public ITablePanel getTablePanel() { return table; } - + @Override public ISidePanel getSidePanel() { return sidePanel; } - + @Override public IHandPanel getHandPanel() { return playerPanel.getHandPanel(); @@ -164,8 +164,7 @@ public class View extends JFrame implements IView { showSettingsPanel(false); showLoginPanel(false); showGameListPanel(false); - getHandPanel().setStones( - Collections.> emptyList()); + getHandPanel().setStones(Collections.> emptyList()); getTablePanel().setStoneSets( Collections.> emptyList()); setSelectedStones(Collections. emptyList()); @@ -330,8 +329,7 @@ public class View extends JFrame implements IView { table = new TablePanel(); mainLayer.add(table); - table.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0, - Color.BLACK)); + table.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0, Color.BLACK)); playerPanel = new PlayerPanel(); mainLayer.add(playerPanel); @@ -380,7 +378,8 @@ public class View extends JFrame implements IView { playerPanel.setBounds(0, tableHeight, width, playerPanelHeight); playerPanel.rescale(); - int sideWidth = sidePanel.isVisible() ? playerPanel.getLeftPanelWidth() + 1 : 0; + int sideWidth = sidePanel.isVisible() ? playerPanel.getLeftPanelWidth() + 1 + : 0; table.setBounds(sideWidth, 0, width - sideWidth, tableHeight); table.validate(); @@ -390,12 +389,11 @@ public class View extends JFrame implements IView { startTurnPanel.setBounds(0, tableHeight, width, playerPanelHeight); pausePanel.setBounds(0, tableHeight, width, playerPanelHeight); winPanel.setBounds(0, tableHeight, width, playerPanelHeight); - - - rescaleSubpanel(settingsPanel, 1 / 2.0, 1/ 2.0, 475, 300); - rescaleSubpanel(scorePanel, 3 / 4.0, 1/ 2.0, 450, 300); - rescaleSubpanel(loginPanel, 1 / 3.0, 1/ 3.0, 200, 200); - rescaleSubpanel(gameListPanel, 1 / 2.0, 1/ 2.0, 475, 300); + + rescaleSubpanel(settingsPanel, 1 / 2.0, 1 / 2.0, 475, 300); + rescaleSubpanel(scorePanel, 3 / 4.0, 1 / 2.0, 450, 300); + rescaleSubpanel(loginPanel, 1 / 3.0, 1 / 3.0, 200, 200); + rescaleSubpanel(gameListPanel, 1 / 2.0, 1 / 2.0, 475, 300); } private void rescaleSubpanel(JPanel sub, double widthFactor, @@ -449,7 +447,7 @@ public class View extends JFrame implements IView { public void showScorePanel(boolean show) { scorePanel.setVisible(show); } - + @Override public void showSidePanel(boolean show) { sidePanel.setVisible(show); @@ -476,6 +474,8 @@ public class View extends JFrame implements IView { @Override public void setCurrentPlayerColor(Color color) { playerPanel.setCurrentPlayerColor(color); + startTurnPanel.setCurrentPlayerColor(color); + pausePanel.setCurrentPlayerColor(color); } @Override @@ -510,24 +510,24 @@ public class View extends JFrame implements IView { @SuppressWarnings("unchecked") private List> createDecorationStones() { - Pair stoneJ = new Pair(new Stone( - -'J', StoneColor.BLACK), new Position(2.5f, 0)); - Pair stoneR = new Pair(new Stone( - -'R', StoneColor.ORANGE), new Position(3.5f, 0)); - Pair stoneu1 = new Pair(new Stone( - -'u', StoneColor.BLUE), new Position(4.5f, 0)); - Pair stonem1 = new Pair(new Stone( - -'m', StoneColor.RED), new Position(5.5f, 0)); - Pair stonem2 = new Pair(new Stone( - -'m', StoneColor.GREEN), new Position(6.5f, 0)); - Pair stonei = new Pair(new Stone( - -'i', StoneColor.VIOLET), new Position(7.5f, 0)); - Pair stonek = new Pair(new Stone( - -'k', StoneColor.AQUA), new Position(8.5f, 0)); - Pair stoneu2 = new Pair(new Stone( - -'u', StoneColor.GRAY), new Position(9.5f, 0)); - Pair stoneb = new Pair(new Stone( - -'b', StoneColor.BLACK), new Position(10.5f, 0)); + Pair stoneJ = new Pair(new Stone(-'J', + StoneColor.BLACK), new Position(2.5f, 0)); + Pair stoneR = new Pair(new Stone(-'R', + StoneColor.ORANGE), new Position(3.5f, 0)); + Pair stoneu1 = new Pair(new Stone(-'u', + StoneColor.BLUE), new Position(4.5f, 0)); + Pair stonem1 = new Pair(new Stone(-'m', + StoneColor.RED), new Position(5.5f, 0)); + Pair stonem2 = new Pair(new Stone(-'m', + StoneColor.GREEN), new Position(6.5f, 0)); + Pair stonei = new Pair(new Stone(-'i', + StoneColor.VIOLET), new Position(7.5f, 0)); + Pair stonek = new Pair(new Stone(-'k', + StoneColor.AQUA), new Position(8.5f, 0)); + Pair stoneu2 = new Pair(new Stone(-'u', + StoneColor.GRAY), new Position(9.5f, 0)); + Pair stoneb = new Pair(new Stone(-'b', + StoneColor.BLACK), new Position(10.5f, 0)); Pair stone1 = new Pair(new Stone( StoneColor.RED), new Position(2, 1)); @@ -542,9 +542,9 @@ public class View extends JFrame implements IView { Pair stone6 = new Pair(new Stone( StoneColor.BLACK), new Position(11, 1)); - return Arrays.asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei, - stonek, stoneu2, stoneb, stone1, stone2, stone3, stone4, - stone5, stone6); + return Arrays + .asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei, stonek, + stoneu2, stoneb, stone1, stone2, stone3, stone4, stone5, stone6); } @Override @@ -564,8 +564,7 @@ public class View extends JFrame implements IView { && type != BottomPanelType.WIN_PANEL && type != null); if (type == BottomPanelType.START_GAME_PANEL) { - table.setStoneSets(Collections - .> emptyList()); + table.setStoneSets(Collections.> emptyList()); playerPanel.getHandPanel().setStones(createDecorationStones()); } -- cgit v1.2.3