summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/PlayerPanel.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-02 03:40:24 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-02 03:40:24 +0200
commit6d406adc6d04589e757a68d158d005e4bf949215 (patch)
tree761120442cad6cb64937febf56d434fcc405106a /src/jrummikub/view/impl/PlayerPanel.java
parent15a41ec38eaf5baca7c4266de52d1ae86ee9488b (diff)
downloadJRummikub-6d406adc6d04589e757a68d158d005e4bf949215.tar
JRummikub-6d406adc6d04589e757a68d158d005e4bf949215.zip
Fixed some metrics in the view
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@61 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/PlayerPanel.java')
-rw-r--r--src/jrummikub/view/impl/PlayerPanel.java123
1 files changed, 62 insertions, 61 deletions
diff --git a/src/jrummikub/view/impl/PlayerPanel.java b/src/jrummikub/view/impl/PlayerPanel.java
index 6bc3d09..1d62aab 100644
--- a/src/jrummikub/view/impl/PlayerPanel.java
+++ b/src/jrummikub/view/impl/PlayerPanel.java
@@ -107,40 +107,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
});
leftPanel.add(sortByColorButton);
- leftPanel.addComponentListener(new ComponentAdapter() {
- @Override
- public void componentResized(ComponentEvent e) {
- Insets insets = leftPanel.getInsets();
- int x = insets.left, y = insets.top, width = leftPanel.getWidth()
- - insets.left - insets.right, height = leftPanel.getHeight()
- - insets.top - insets.bottom;
-
- if (width > SIDE_PANEL_MAX_WIDTH) {
- x += (width - SIDE_PANEL_MAX_WIDTH) / 4;
- width = width / 2 + SIDE_PANEL_MAX_WIDTH / 2;
- }
-
- int firstLineHeight = (int) ((height - SIDE_PANEL_SEPARATOR) * SIDE_PANEL_FIRST_LINE_HEIGHT);
- int buttonWidth = (width - SIDE_PANEL_SEPARATOR) / 2;
- int buttonHeight = height - SIDE_PANEL_SEPARATOR - firstLineHeight;
- float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
- if (fontSize > MAX_BUTTON_FONT_SIZE)
- fontSize = MAX_BUTTON_FONT_SIZE;
-
- currentPlayerNameLabel.setBounds(x, y, width, firstLineHeight);
- sortByNumberButton.setBounds(x, y + firstLineHeight
- + SIDE_PANEL_SEPARATOR, buttonWidth, buttonHeight);
- sortByColorButton
- .setBounds(x + buttonWidth + SIDE_PANEL_SEPARATOR, y
- + firstLineHeight + SIDE_PANEL_SEPARATOR, buttonWidth,
- buttonHeight);
-
- sortByNumberButton.setFont(sortByNumberButton.getFont().deriveFont(
- fontSize));
- sortByColorButton.setFont(sortByColorButton.getFont().deriveFont(
- fontSize));
- }
- });
+ leftPanel.addComponentListener(new LeftPanelResizeListener());
}
private void createRightPanel() {
@@ -164,33 +131,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
rightPanel.add(endTurnButton);
- rightPanel.addComponentListener(new ComponentAdapter() {
- @Override
- public void componentResized(ComponentEvent e) {
- Insets insets = rightPanel.getInsets();
- int x = insets.left, y = insets.top, width = rightPanel.getWidth()
- - insets.left - insets.right, height = rightPanel.getHeight()
- - insets.top - insets.bottom;
-
- if (width > SIDE_PANEL_MAX_WIDTH) {
- x += (width - SIDE_PANEL_MAX_WIDTH) / 4;
- width = width / 2 + SIDE_PANEL_MAX_WIDTH / 2;
- }
-
- int firstLineHeight = (int) ((height - SIDE_PANEL_SEPARATOR) * SIDE_PANEL_FIRST_LINE_HEIGHT);
- int buttonWidth = width;
- int buttonHeight = height - SIDE_PANEL_SEPARATOR - firstLineHeight;
- float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
- if (fontSize > MAX_BUTTON_FONT_SIZE)
- fontSize = MAX_BUTTON_FONT_SIZE;
-
- timeBar.setBounds(x, y, width, firstLineHeight);
- endTurnButton.setBounds(x, y + firstLineHeight + SIDE_PANEL_SEPARATOR,
- buttonWidth, buttonHeight);
- endTurnButton.setFont(endTurnButton.getFont().deriveFont(
- fontSize));
- }
- });
+ rightPanel.addComponentListener(new RightPanelResizeListener());
}
private void rescale() {
@@ -232,4 +173,64 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
addComponentListener(rescaleListener);
board.addComponentListener(rescaleListener);
}
+
+ private class LeftPanelResizeListener extends ComponentAdapter {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ Insets insets = leftPanel.getInsets();
+ int x = insets.left, y = insets.top, width = leftPanel.getWidth()
+ - insets.left - insets.right, height = leftPanel.getHeight()
+ - insets.top - insets.bottom;
+
+ if (width > SIDE_PANEL_MAX_WIDTH) {
+ x += (width - SIDE_PANEL_MAX_WIDTH) / 4;
+ width = width / 2 + SIDE_PANEL_MAX_WIDTH / 2;
+ }
+
+ int firstLineHeight = (int) ((height - SIDE_PANEL_SEPARATOR) * SIDE_PANEL_FIRST_LINE_HEIGHT);
+ int buttonWidth = (width - SIDE_PANEL_SEPARATOR) / 2;
+ int buttonHeight = height - SIDE_PANEL_SEPARATOR - firstLineHeight;
+ float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
+ if (fontSize > MAX_BUTTON_FONT_SIZE)
+ fontSize = MAX_BUTTON_FONT_SIZE;
+
+ currentPlayerNameLabel.setBounds(x, y, width, firstLineHeight);
+ sortByNumberButton.setBounds(x, y + firstLineHeight
+ + SIDE_PANEL_SEPARATOR, buttonWidth, buttonHeight);
+ sortByColorButton.setBounds(x + buttonWidth + SIDE_PANEL_SEPARATOR, y
+ + firstLineHeight + SIDE_PANEL_SEPARATOR, buttonWidth, buttonHeight);
+
+ sortByNumberButton.setFont(sortByNumberButton.getFont().deriveFont(
+ fontSize));
+ sortByColorButton.setFont(sortByColorButton.getFont()
+ .deriveFont(fontSize));
+ }
+ }
+
+ private class RightPanelResizeListener extends ComponentAdapter {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ Insets insets = rightPanel.getInsets();
+ int x = insets.left, y = insets.top, width = rightPanel.getWidth()
+ - insets.left - insets.right, height = rightPanel.getHeight()
+ - insets.top - insets.bottom;
+
+ if (width > SIDE_PANEL_MAX_WIDTH) {
+ x += (width - SIDE_PANEL_MAX_WIDTH) / 4;
+ width = width / 2 + SIDE_PANEL_MAX_WIDTH / 2;
+ }
+
+ int firstLineHeight = (int) ((height - SIDE_PANEL_SEPARATOR) * SIDE_PANEL_FIRST_LINE_HEIGHT);
+ int buttonWidth = width;
+ int buttonHeight = height - SIDE_PANEL_SEPARATOR - firstLineHeight;
+ float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
+ if (fontSize > MAX_BUTTON_FONT_SIZE)
+ fontSize = MAX_BUTTON_FONT_SIZE;
+
+ timeBar.setBounds(x, y, width, firstLineHeight);
+ endTurnButton.setBounds(x, y + firstLineHeight + SIDE_PANEL_SEPARATOR,
+ buttonWidth, buttonHeight);
+ endTurnButton.setFont(endTurnButton.getFont().deriveFont(fontSize));
+ }
+ }
}