diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-29 21:19:20 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-29 21:19:20 +0200 |
commit | d6b8b23c6de5d9fbe65b49c784dd698e83b0ca79 (patch) | |
tree | 27acff80b4bff4b635ada20be0a608e149aaf0f5 /src/jrummikub/view/impl | |
parent | e4a1246f01c2a017042a2a80cc2e9a1e6b4bbd51 (diff) | |
download | JRummikub-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')
-rw-r--r-- | src/jrummikub/view/impl/PlayerPanel.java | 77 | ||||
-rw-r--r-- | src/jrummikub/view/impl/View.java | 40 |
2 files changed, 80 insertions, 37 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); + } + } } diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java index b2ae7fb..e374f8c 100644 --- a/src/jrummikub/view/impl/View.java +++ b/src/jrummikub/view/impl/View.java @@ -4,15 +4,22 @@ import java.awt.Color; import java.awt.Insets; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; +import java.util.List; import javax.swing.JFrame; import javax.swing.JLayeredPane; import javax.swing.JPanel; import javax.swing.border.MatteBorder; +import jrummikub.model.Position; import jrummikub.model.Stone; +import jrummikub.model.StoneColor; +import jrummikub.model.StoneSet; import jrummikub.util.IEvent; +import jrummikub.util.Pair; import jrummikub.view.IHandPanel; import jrummikub.view.IPlayerPanel; import jrummikub.view.IScorePanel; @@ -90,8 +97,8 @@ public class View extends JFrame implements IView { mainLayer.add(table); playerPanel = new PlayerPanel(); - playerPanel.setBorder(new MatteBorder(PLAYER_PANEL_BORDER_WIDTH, 0, 0, - 0, Color.BLACK)); + playerPanel.setBorder(new MatteBorder(PLAYER_PANEL_BORDER_WIDTH, 0, 0, 0, + Color.BLACK)); mainLayer.add(playerPanel); startTurnPanel = new StartTurnPanel(); @@ -214,4 +221,33 @@ public class View extends JFrame implements IView { return winPanel.getEndProgramEvent(); } + @SuppressWarnings("unchecked") + private List<Pair<Stone, Position>> createDecorationStones() { + Pair<Stone, Position> stone1 = new Pair<Stone, Position>(new Stone( + StoneColor.RED), new Position(3.5f, 0)); + Pair<Stone, Position> stone2 = new Pair<Stone, Position>(new Stone(13, + StoneColor.BLACK), new Position(5, 0)); + Pair<Stone, Position> stone3 = new Pair<Stone, Position>(new Stone(13, + StoneColor.ORANGE), new Position(6, 0)); + Pair<Stone, Position> stone4 = new Pair<Stone, Position>(new Stone(13, + StoneColor.BLUE), new Position(7, 0)); + Pair<Stone, Position> stone5 = new Pair<Stone, Position>(new Stone(13, + StoneColor.RED), new Position(8, 0)); + Pair<Stone, Position> stone6 = new Pair<Stone, Position>(new Stone( + StoneColor.BLACK), new Position(9.5f, 0)); + + return Arrays.asList(stone1, stone2, stone3, stone4, stone5, stone6); + } + + @Override + public void showInterface(boolean enable) { + if (enable) { + playerPanel.showButtons(true); + } else { + List<Pair<StoneSet, Position>> emptyTable = Collections.emptyList(); + table.setStoneSets(emptyTable); + playerPanel.getHandPanel().setStones(createDecorationStones()); + playerPanel.showButtons(false); + } + } } |