From eea3cb2188e26db9680bec29316fc21d14f7118c Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 31 May 2011 03:11:29 +0200 Subject: Don't show last player when a round has ended git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@340 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/View.java | 1 - src/jrummikub/view/impl/WinPanel.java | 40 +++++++---------------------------- 2 files changed, 8 insertions(+), 33 deletions(-) (limited to 'src/jrummikub/view') diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java index fceaeeb..8c9bc9f 100644 --- a/src/jrummikub/view/impl/View.java +++ b/src/jrummikub/view/impl/View.java @@ -188,7 +188,6 @@ public class View extends JFrame implements IView { public void setCurrentPlayerName(String playerName) { playerPanel.setCurrentPlayerName(playerName); startTurnPanel.setCurrentPlayerName(playerName); - winPanel.setCurrentPlayerName(playerName); } @Override diff --git a/src/jrummikub/view/impl/WinPanel.java b/src/jrummikub/view/impl/WinPanel.java index 61f6e05..ff52d0e 100644 --- a/src/jrummikub/view/impl/WinPanel.java +++ b/src/jrummikub/view/impl/WinPanel.java @@ -7,7 +7,6 @@ import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import javax.swing.JButton; -import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; @@ -25,7 +24,6 @@ class WinPanel extends JPanel { private final static int PANEL_MAX_WIDTH = 180; private final static float MAX_BUTTON_FONT_SIZE = 12; - private JLabel winLabel; private JButton newRoundButton; private JButton newGameButton; private JButton endProgramButton; @@ -42,13 +40,6 @@ class WinPanel extends JPanel { setBorder(new EmptyBorder(PANEL_INSET, PANEL_INSET, PANEL_INSET, PANEL_INSET)); - winLabel = new JLabel(); - winLabel.setHorizontalAlignment(JLabel.CENTER); - winLabel.setHorizontalTextPosition(JLabel.CENTER); - winLabel.setVerticalAlignment(JLabel.CENTER); - winLabel.setVerticalTextPosition(JLabel.CENTER); - add(winLabel); - newRoundButton = new JButton("Neue Runde"); newRoundButton.addActionListener(new ActionListener() { @Override @@ -84,16 +75,6 @@ class WinPanel extends JPanel { }); } - /** - * Sets the name of the current player - * - * @param name - * the player name - */ - void setCurrentPlayerName(String name) { - winLabel.setText("Du hast gewonnen, " + name + "!"); - } - /** * The new round event is emitted when the player wants to start a new round * @@ -119,34 +100,29 @@ class WinPanel extends JPanel { private void rescale() { Insets insets = getInsets(); int x = insets.left, y = insets.top, width = getWidth() - insets.left - - insets.right, height = getHeight() - insets.top - - insets.bottom; + - insets.right, height = getHeight() - insets.top - insets.bottom; if (width > PANEL_MAX_WIDTH) { x += (width - PANEL_MAX_WIDTH) / 4; width = width / 2 + PANEL_MAX_WIDTH / 2; } - int firstLineHeight = (int) ((height - PANEL_SEPARATOR) * PANEL_FIRST_LINE_HEIGHT); int buttonWidth = (width - 2 * PANEL_SEPARATOR) / 3; - int buttonHeight = height - PANEL_SEPARATOR - firstLineHeight; + int buttonHeight = height; float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5; if (fontSize > MAX_BUTTON_FONT_SIZE) fontSize = MAX_BUTTON_FONT_SIZE; - winLabel.setBounds(x, y, width, firstLineHeight); - newRoundButton.setBounds(x, y + firstLineHeight + PANEL_SEPARATOR, - buttonWidth, buttonHeight); + newRoundButton.setBounds(x, y, buttonWidth, buttonHeight); newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize)); - newGameButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y - + firstLineHeight + PANEL_SEPARATOR, buttonWidth, buttonHeight); + newGameButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y, buttonWidth, + buttonHeight); newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize)); - endProgramButton.setBounds(x + 2 * (buttonWidth + PANEL_SEPARATOR), y - + firstLineHeight + PANEL_SEPARATOR, buttonWidth, buttonHeight); - endProgramButton.setFont(endProgramButton.getFont() - .deriveFont(fontSize)); + endProgramButton.setBounds(x + 2 * (buttonWidth + PANEL_SEPARATOR), y, + buttonWidth, buttonHeight); + endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize)); } } -- cgit v1.2.3