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
This commit is contained in:
Matthias Schiffer 2011-05-31 03:11:29 +02:00
parent acc7d3f11f
commit eea3cb2188
2 changed files with 8 additions and 33 deletions

View file

@ -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

View file

@ -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));
}
}