summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/WinPanel.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view/impl/WinPanel.java')
-rw-r--r--src/jrummikub/view/impl/WinPanel.java99
1 files changed, 69 insertions, 30 deletions
diff --git a/src/jrummikub/view/impl/WinPanel.java b/src/jrummikub/view/impl/WinPanel.java
index 4d9aacc..888cf75 100644
--- a/src/jrummikub/view/impl/WinPanel.java
+++ b/src/jrummikub/view/impl/WinPanel.java
@@ -28,6 +28,8 @@ class WinPanel extends JPanel {
private final static float MAX_BUTTON_FONT_SIZE = 12;
private JLabel waitingLabel;
+ private JLabel connectionLostLabel;
+
private JButton newRoundButton;
private JButton newGameButton;
private JButton endProgramButton;
@@ -50,6 +52,12 @@ class WinPanel extends JPanel {
waitingLabel.setVerticalAlignment(JLabel.CENTER);
add(waitingLabel);
+ connectionLostLabel = new JLabel(
+ "Die Verbindung zu einem Spieler ist abgebrochen.");
+ connectionLostLabel.setHorizontalAlignment(JLabel.CENTER);
+ connectionLostLabel.setVerticalAlignment(JLabel.CENTER);
+ add(connectionLostLabel);
+
newRoundButton = new JButton("Neue Runde");
newRoundButton.addActionListener(new ActionListener() {
@Override
@@ -117,44 +125,26 @@ class WinPanel extends JPanel {
width = width / 2 + PANEL_MAX_WIDTH / 2;
}
- int buttonWidth;
- int buttonHeight;
- int buttonY;
if (type == BottomPanelType.WIN_PANEL) {
- buttonWidth = (width - 2 * PANEL_SEPARATOR) / 3;
- buttonHeight = height;
- buttonY = y;
- } else {
- buttonWidth = (width - PANEL_SEPARATOR) / 2;
- buttonHeight = height * 2 / 3 - PANEL_SEPARATOR;
- buttonY = y + height - buttonHeight;
+ rescaleWinPanel(x, y, width, height);
+ } else if (type == BottomPanelType.NETWORK_WIN_PANEL) {
+ rescaleNetworkWinPanel(x, y, width, height);
+ } else if (type == BottomPanelType.NETWORK_CONNECTION_LOST_PANEL) {
+ rescaleNetworkConnectionLostPanel(x, y, width, height);
}
- int labelHeight = height - buttonHeight - PANEL_SEPARATOR;
+ }
+
+ private void rescaleWinPanel(int x, int y, int width, int height) {
+ int buttonWidth = (width - 2 * PANEL_SEPARATOR) / 3;
+ int buttonHeight = height;
+ int buttonY = y;
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
if (fontSize > MAX_BUTTON_FONT_SIZE)
fontSize = MAX_BUTTON_FONT_SIZE;
- if (type == BottomPanelType.WIN_PANEL) {
- rescaleWinPanel(x, buttonWidth, buttonHeight, buttonY, fontSize);
- } else if (type == BottomPanelType.NETWORK_WIN_PANEL) {
- waitingLabel.setBounds(x, y, width, labelHeight);
- waitingLabel.setVisible(true);
-
- newRoundButton.setVisible(false);
-
- newGameButton.setBounds(x, buttonY, buttonWidth, buttonHeight);
- newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
-
- endProgramButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, buttonY,
- buttonWidth, buttonHeight);
- endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
- }
- }
-
- private void rescaleWinPanel(int x, int buttonWidth, int buttonHeight,
- int buttonY, float fontSize) {
waitingLabel.setVisible(false);
+ connectionLostLabel.setVisible(false);
newRoundButton.setBounds(x, buttonY, buttonWidth, buttonHeight);
newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize));
newRoundButton.setVisible(true);
@@ -168,6 +158,55 @@ class WinPanel extends JPanel {
endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
}
+ private void rescaleNetworkWinPanel(int x, int y, int width, int height) {
+ int buttonWidth = (width - PANEL_SEPARATOR) / 2;
+ int buttonHeight = height * 2 / 3 - PANEL_SEPARATOR;
+ int buttonY = y + height - buttonHeight;
+ int labelHeight = height - buttonHeight - PANEL_SEPARATOR;
+
+ float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
+ if (fontSize > MAX_BUTTON_FONT_SIZE)
+ fontSize = MAX_BUTTON_FONT_SIZE;
+
+ waitingLabel.setBounds(x, y, width, labelHeight);
+ waitingLabel.setVisible(true);
+ connectionLostLabel.setVisible(false);
+
+ newRoundButton.setVisible(false);
+
+ newGameButton.setBounds(x, buttonY, buttonWidth, buttonHeight);
+ newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
+
+ endProgramButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, buttonY,
+ buttonWidth, buttonHeight);
+ endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
+ }
+
+ private void rescaleNetworkConnectionLostPanel(int x, int y, int width,
+ int height) {
+ int buttonWidth = (width - PANEL_SEPARATOR) / 2;
+ int buttonHeight = height * 2 / 3 - PANEL_SEPARATOR;
+ int buttonY = y + height - buttonHeight;
+ int labelHeight = height - buttonHeight - PANEL_SEPARATOR;
+
+ float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
+ if (fontSize > MAX_BUTTON_FONT_SIZE)
+ fontSize = MAX_BUTTON_FONT_SIZE;
+
+ waitingLabel.setVisible(false);
+ connectionLostLabel.setBounds(x, y, width, labelHeight);
+ connectionLostLabel.setVisible(true);
+
+ newRoundButton.setVisible(false);
+
+ newGameButton.setBounds(x, buttonY, buttonWidth, buttonHeight);
+ newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
+
+ endProgramButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, buttonY,
+ buttonWidth, buttonHeight);
+ endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
+ }
+
void setType(BottomPanelType type) {
this.type = type;
rescale();