summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/PlayerPanel.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-29 21:19:20 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-29 21:19:20 +0200
commitd6b8b23c6de5d9fbe65b49c784dd698e83b0ca79 (patch)
tree27acff80b4bff4b635ada20be0a608e149aaf0f5 /src/jrummikub/view/impl/PlayerPanel.java
parente4a1246f01c2a017042a2a80cc2e9a1e6b4bbd51 (diff)
downloadJRummikub-d6b8b23c6de5d9fbe65b49c784dd698e83b0ca79.tar
JRummikub-d6b8b23c6de5d9fbe65b49c784dd698e83b0ca79.zip
Disable player panel while settings panel is shown
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@313 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/PlayerPanel.java')
-rw-r--r--src/jrummikub/view/impl/PlayerPanel.java77
1 files changed, 42 insertions, 35 deletions
diff --git a/src/jrummikub/view/impl/PlayerPanel.java b/src/jrummikub/view/impl/PlayerPanel.java
index e3bf2b8..1db7f50 100644
--- a/src/jrummikub/view/impl/PlayerPanel.java
+++ b/src/jrummikub/view/impl/PlayerPanel.java
@@ -62,7 +62,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
* Sets the current player name
*
* @param playerName
- * the player name
+ * the player name
*/
void setCurrentPlayerName(String playerName) {
currentPlayerNameLabel.setText(playerName);
@@ -129,8 +129,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
leftPanel.add(hasLaidOutLabel);
sortByGroupsButton = createButton(leftPanel,
- "<html><center>Nach Sammlungen sortieren",
- new ActionListener() {
+ "<html><center>Nach Sammlungen sortieren", new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
sortByGroupsEvent.emit();
@@ -151,8 +150,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
private void createRightPanel() {
rightPanel = new JPanel();
rightPanel.setLayout(null);
- rightPanel.setBorder(new EmptyBorder(SIDE_PANEL_INSET,
- SIDE_PANEL_INSET, SIDE_PANEL_INSET, SIDE_PANEL_INSET));
+ rightPanel.setBorder(new EmptyBorder(SIDE_PANEL_INSET, SIDE_PANEL_INSET,
+ SIDE_PANEL_INSET, SIDE_PANEL_INSET));
handRowUpButton = createButton(rightPanel, "<html><center>\u25B2",
new ActionListener() {
@@ -213,8 +212,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
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;
int boardWidth = hand.getWidth();
int handButtonWidth = (int) (width * HAND_ROW_BUTTON_RATIO);
int meanPanelWidth = (width - boardWidth) / 2;
@@ -223,8 +221,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
leftPanel.setBounds(x, y, leftPanelWidth, height);
hand.setBounds(x + leftPanelWidth, y, boardWidth, height);
- rightPanel.setBounds(x + leftPanelWidth + boardWidth, y,
- rightPanelWidth, height);
+ rightPanel.setBounds(x + leftPanelWidth + boardWidth, y, rightPanelWidth,
+ height);
leftPanel.validate();
rightPanel.validate();
@@ -232,8 +230,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
void updateButtons() {
handRowUpButton.setEnabled(hand.canRowUp());
- handRowUpButton.setForeground(hand.canRowUp() ? Color.BLACK
- : Color.GRAY);
+ handRowUpButton.setForeground(hand.canRowUp() ? Color.BLACK : Color.GRAY);
handRowDownButton.setEnabled(hand.canRowDown());
handRowDownButton.setForeground(hand.canRowDown() ? Color.BLACK
: Color.GRAY);
@@ -272,8 +269,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
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;
+ - insets.left - insets.right, height = leftPanel.getHeight()
+ - insets.top - insets.bottom;
if (width > SIDE_PANEL_MAX_WIDTH) {
x += (width - SIDE_PANEL_MAX_WIDTH) / 4;
@@ -289,22 +286,18 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
fontSize = MAX_BUTTON_FONT_SIZE;
currentPlayerNameLabel.setBounds(x, y, width, oneLabelHeight);
- hasLaidOutLabel.setBounds(x, y + oneLabelHeight, width,
- oneLabelHeight);
- sortByGroupsButton.setBounds(x, y + labelHeight
- + SIDE_PANEL_SEPARATOR, buttonWidth, buttonHeight);
- sortByRunsButton.setBounds(x + buttonWidth + SIDE_PANEL_SEPARATOR,
- y + labelHeight + SIDE_PANEL_SEPARATOR, buttonWidth,
- buttonHeight);
+ hasLaidOutLabel.setBounds(x, y + oneLabelHeight, width, oneLabelHeight);
+ sortByGroupsButton.setBounds(x, y + labelHeight + SIDE_PANEL_SEPARATOR,
+ buttonWidth, buttonHeight);
+ sortByRunsButton.setBounds(x + buttonWidth + SIDE_PANEL_SEPARATOR, y
+ + labelHeight + SIDE_PANEL_SEPARATOR, buttonWidth, buttonHeight);
currentPlayerNameLabel.setFont(currentPlayerNameLabel.getFont()
.deriveFont(fontSize));
- hasLaidOutLabel.setFont(hasLaidOutLabel.getFont().deriveFont(
- fontSize));
+ hasLaidOutLabel.setFont(hasLaidOutLabel.getFont().deriveFont(fontSize));
sortByGroupsButton.setFont(sortByGroupsButton.getFont().deriveFont(
fontSize));
- sortByRunsButton.setFont(sortByRunsButton.getFont().deriveFont(
- fontSize));
+ sortByRunsButton.setFont(sortByRunsButton.getFont().deriveFont(fontSize));
}
}
@@ -328,8 +321,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
int smallButtonWidth = (width - SIDE_PANEL_SEPARATOR) / 2;
int buttonHeight = height - SIDE_PANEL_SEPARATOR - firstLineHeight;
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
- float smallFontSize = (float) Math.sqrt(smallButtonWidth
- * buttonHeight) / 5;
+ float smallFontSize = (float) Math.sqrt(smallButtonWidth * buttonHeight) / 5;
if (fontSize > MAX_BUTTON_FONT_SIZE)
fontSize = MAX_BUTTON_FONT_SIZE;
@@ -342,17 +334,16 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
fontSize * 1.5f));
timeBar.setBounds(x, y, width, firstLineHeight);
- endTurnButton.setBounds(x, y + firstLineHeight
- + SIDE_PANEL_SEPARATOR, buttonWidth, buttonHeight);
+ endTurnButton.setBounds(x, y + firstLineHeight + SIDE_PANEL_SEPARATOR,
+ buttonWidth, buttonHeight);
endTurnButton.setFont(endTurnButton.getFont().deriveFont(fontSize));
- redealButton.setBounds(x, y + firstLineHeight
- + SIDE_PANEL_SEPARATOR, smallButtonWidth, buttonHeight);
- redealButton.setFont(redealButton.getFont().deriveFont(
- smallFontSize));
- keepStonesButton.setBounds(x + smallButtonWidth
- + SIDE_PANEL_SEPARATOR, y + firstLineHeight
- + SIDE_PANEL_SEPARATOR, smallButtonWidth, buttonHeight);
+ redealButton.setBounds(x, y + firstLineHeight + SIDE_PANEL_SEPARATOR,
+ smallButtonWidth, buttonHeight);
+ redealButton.setFont(redealButton.getFont().deriveFont(smallFontSize));
+ keepStonesButton.setBounds(x + smallButtonWidth + SIDE_PANEL_SEPARATOR, y
+ + firstLineHeight + SIDE_PANEL_SEPARATOR, smallButtonWidth,
+ buttonHeight);
keepStonesButton.setFont(keepStonesButton.getFont().deriveFont(
smallFontSize));
@@ -371,4 +362,20 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
keepStonesButton.setVisible(smallButtons);
redealButton.setVisible(smallButtons);
}
+
+ void showButtons(boolean show) {
+ currentPlayerNameLabel.setVisible(show);
+ hasLaidOutLabel.setVisible(show);
+ sortByGroupsButton.setVisible(show);
+ sortByRunsButton.setVisible(show);
+ timeBar.setVisible(show);
+
+ if (!show) {
+ handRowDownButton.setEnabled(false);
+ handRowUpButton.setEnabled(false);
+ endTurnButton.setVisible(false);
+ redealButton.setVisible(false);
+ keepStonesButton.setVisible(false);
+ }
+ }
}