summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-05-29 18:42:36 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-05-29 18:42:36 +0200
commit05107f6035e93d8fe37de0b6beb627b11a05b87b (patch)
tree4cc4218db5457c3b7f8f95755c9a96ab833787de /src
parent9cf3dc09ae319b6e627a4c52923bbc325137ef34 (diff)
downloadJRummikub-05107f6035e93d8fe37de0b6beb627b11a05b87b.tar
JRummikub-05107f6035e93d8fe37de0b6beb627b11a05b87b.zip
Rauskommen ist in der View zu sehen, genauso wie Farben
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@299 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src')
-rw-r--r--src/jrummikub/control/RoundControl.java3
-rw-r--r--src/jrummikub/view/IScorePanel.java15
-rw-r--r--src/jrummikub/view/IView.java25
-rw-r--r--src/jrummikub/view/impl/PlayerPanel.java193
-rw-r--r--src/jrummikub/view/impl/View.java16
5 files changed, 156 insertions, 96 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index 413211a..3bb1a3b 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -79,6 +79,9 @@ public class RoundControl {
view.getTablePanel().setStoneSets(clonedTable);
view.setCurrentPlayerName(roundState.getActivePlayer()
.getPlayerSettings().getName());
+ view.setCurrentPlayerColor(roundState.getActivePlayer()
+ .getPlayerSettings().getColor());
+ view.setHasLaidOut(roundState.getActivePlayer().getLaidOut());
}
diff --git a/src/jrummikub/view/IScorePanel.java b/src/jrummikub/view/IScorePanel.java
index be0b912..22e27fe 100644
--- a/src/jrummikub/view/IScorePanel.java
+++ b/src/jrummikub/view/IScorePanel.java
@@ -10,24 +10,27 @@ public interface IScorePanel {
/**
* Sets the scores of the played rounds
*
- * @param scores the round scores
+ * @param scores
+ * the round scores
*/
public void setScores(Iterable<Score> scores);
-
+
/**
* Sets the accumulated scores to display
*
- * @param accumulatedScore the accumulated score
+ * @param accumulatedScore
+ * the accumulated score
*/
public void setAccumulatedScore(Score accumulatedScore);
-
+
/**
* Sets the player list to display
*
- * @param players the player list
+ * @param players
+ * the player list
*/
void setPlayers(Iterable<PlayerSettings> players);
-
+
/**
* Updates the score display
*/
diff --git a/src/jrummikub/view/IView.java b/src/jrummikub/view/IView.java
index 3e33e44..21aa173 100644
--- a/src/jrummikub/view/IView.java
+++ b/src/jrummikub/view/IView.java
@@ -1,5 +1,6 @@
package jrummikub.view;
+import java.awt.Color;
import java.util.Collection;
import jrummikub.model.Stone;
@@ -46,7 +47,7 @@ public interface IView {
* Sets the current player's name
*
* @param playerName
- * the player name
+ * the player name
*/
public void setCurrentPlayerName(String playerName);
@@ -54,7 +55,7 @@ public interface IView {
* Sets the stones that are to be painted selected
*
* @param stones
- * the stones to be painted selected
+ * the stones to be painted selected
*/
public void setSelectedStones(Collection<Stone> stones);
@@ -62,7 +63,7 @@ public interface IView {
* Enables or disables the player's StartTurnPanel
*
* @param enable
- * enable/disable
+ * enable/disable
*/
public void enableStartTurnPanel(boolean enable);
@@ -77,9 +78,9 @@ public interface IView {
* Enables or disables the panel shown when a player has won
*
* @param enable
- * enable/disable
+ * enable/disable
*/
- void enableWinPanel(boolean enable);
+ public void enableWinPanel(boolean enable);
/**
* The quit event is emitted when the player wants to quit the game
@@ -93,21 +94,25 @@ public interface IView {
*
* @return the event
*/
- IEvent getNewRoundEvent();
+ public IEvent getNewRoundEvent();
/**
* Shows or hides the game settings panel
*
* @param show
- * specifies if the panel shall be shown or hidden
+ * specifies if the panel shall be shown or hidden
*/
- void showSettingsPanel(boolean show);
+ public void showSettingsPanel(boolean show);
/**
* Shows or hides the score panel
*
* @param show
- * specifies if the panel shall be shown or hidden
+ * specifies if the panel shall be shown or hidden
*/
- void showScorePanel(boolean show);
+ public void showScorePanel(boolean show);
+
+ public void setCurrentPlayerColor(Color color);
+
+ public void setHasLaidOut(boolean hasLaidOut);
}
diff --git a/src/jrummikub/view/impl/PlayerPanel.java b/src/jrummikub/view/impl/PlayerPanel.java
index 4dd38d6..e3bf2b8 100644
--- a/src/jrummikub/view/impl/PlayerPanel.java
+++ b/src/jrummikub/view/impl/PlayerPanel.java
@@ -25,8 +25,8 @@ import jrummikub.view.IPlayerPanel;
*/
@SuppressWarnings("serial")
class PlayerPanel extends JPanel implements IPlayerPanel {
- private final static int SIDE_PANEL_INSET = 15;
- private final static int SIDE_PANEL_SEPARATOR = 10;
+ private final static int SIDE_PANEL_INSET = 10;
+ private final static int SIDE_PANEL_SEPARATOR = 5;
private final static float SIDE_PANEL_FIRST_LINE_HEIGHT = 0.375f;
private final static int SIDE_PANEL_MAX_WIDTH = 180;
private final static float HAND_ROW_BUTTON_RATIO = 0.03f;
@@ -39,6 +39,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
private JPanel leftPanel, rightPanel;
private JLabel currentPlayerNameLabel;
+ private JLabel hasLaidOutLabel;
private JButton sortByGroupsButton;
private JButton sortByRunsButton;
private JButton handRowUpButton;
@@ -47,7 +48,6 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
private JButton endTurnButton;
private JButton keepStonesButton;
private JButton redealButton;
-
private Event sortByGroupsEvent = new Event();
private Event sortByRunsEvent = new Event();
@@ -62,12 +62,24 @@ 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);
}
+ void setCurrentPlayerColor(Color color) {
+ currentPlayerNameLabel.setIcon(ImageUtil.createColorIcon(color, 12, 1));
+ }
+
+ void setHasLaidOut(boolean hasLaidOut) {
+ if (hasLaidOut) {
+ hasLaidOutLabel.setText("ist rausgekommen");
+ } else {
+ hasLaidOutLabel.setText("ist nicht rausgekommen");
+ }
+ }
+
@Override
public void setTimeLeft(int time) {
timeBar.setValue(time);
@@ -94,7 +106,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
public IEvent getEndTurnEvent() {
return endTurnEvent;
}
-
+
@Override
public IEvent getRedealEvent() {
return redealEvent;
@@ -108,24 +120,30 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
currentPlayerNameLabel = new JLabel();
currentPlayerNameLabel.setHorizontalAlignment(JLabel.CENTER);
- currentPlayerNameLabel.setHorizontalTextPosition(JLabel.CENTER);
currentPlayerNameLabel.setVerticalAlignment(JLabel.CENTER);
- currentPlayerNameLabel.setVerticalTextPosition(JLabel.CENTER);
leftPanel.add(currentPlayerNameLabel);
- sortByGroupsButton = createButton(leftPanel, "<html><center>Nach Sammlungen sortieren", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- sortByGroupsEvent.emit();
- }
- });
-
- sortByRunsButton = createButton(leftPanel, "<html><center>Nach Reihen sortieren", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- sortByRunsEvent.emit();
- }
- });
+ hasLaidOutLabel = new JLabel();
+ hasLaidOutLabel.setHorizontalAlignment(JLabel.CENTER);
+ hasLaidOutLabel.setVerticalAlignment(JLabel.CENTER);
+ leftPanel.add(hasLaidOutLabel);
+
+ sortByGroupsButton = createButton(leftPanel,
+ "<html><center>Nach Sammlungen sortieren",
+ new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ sortByGroupsEvent.emit();
+ }
+ });
+
+ sortByRunsButton = createButton(leftPanel,
+ "<html><center>Nach Reihen sortieren", new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ sortByRunsEvent.emit();
+ }
+ });
leftPanel.addComponentListener(new LeftPanelResizeListener());
}
@@ -133,22 +151,24 @@ 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));
-
- handRowUpButton = createButton(rightPanel, "<html><center>\u25B2", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- hand.rowUp();
- }
- });
-
- handRowDownButton = createButton(rightPanel, "<html><center>\u25BC", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- hand.rowDown();
- }
- });
+ rightPanel.setBorder(new EmptyBorder(SIDE_PANEL_INSET,
+ SIDE_PANEL_INSET, SIDE_PANEL_INSET, SIDE_PANEL_INSET));
+
+ handRowUpButton = createButton(rightPanel, "<html><center>\u25B2",
+ new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ hand.rowUp();
+ }
+ });
+
+ handRowDownButton = createButton(rightPanel, "<html><center>\u25BC",
+ new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ hand.rowDown();
+ }
+ });
timeBar = new JProgressBar(0, 60);
timeBar.setStringPainted(true);
@@ -160,25 +180,28 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
endTurnEvent.emit();
}
});
-
- keepStonesButton = createButton(rightPanel, "<html><center>Steine<br>behalten", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- endTurnEvent.emit();
- }
- });
- redealButton = createButton(rightPanel, "<html><center>Neu<br>geben", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- redealEvent.emit();
- }
- });
-
+ keepStonesButton = createButton(rightPanel,
+ "<html><center>Steine<br>behalten", new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ endTurnEvent.emit();
+ }
+ });
+
+ redealButton = createButton(rightPanel, "<html><center>Neu<br>geben",
+ new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ redealEvent.emit();
+ }
+ });
+
rightPanel.addComponentListener(new RightPanelResizeListener());
}
-
- private JButton createButton(JPanel panel, String caption, ActionListener listener) {
+
+ private JButton createButton(JPanel panel, String caption,
+ ActionListener listener) {
JButton button = new JButton(caption);
button.setFont(button.getFont().deriveFont(0));
button.setMargin(new Insets(0, 0, 0, 0));
@@ -190,7 +213,8 @@ 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;
@@ -199,8 +223,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();
@@ -208,7 +232,8 @@ 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);
@@ -238,7 +263,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
addComponentListener(rescaleListener);
hand.addComponentListener(rescaleListener);
-
+
setEndTurnMode(true, true);
}
@@ -247,30 +272,39 @@ 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;
width = width / 2 + SIDE_PANEL_MAX_WIDTH / 2;
}
- int firstLineHeight = (int) ((height - SIDE_PANEL_SEPARATOR) * SIDE_PANEL_FIRST_LINE_HEIGHT);
+ int labelHeight = (int) ((height - SIDE_PANEL_SEPARATOR) * SIDE_PANEL_FIRST_LINE_HEIGHT);
+ int oneLabelHeight = labelHeight / 2;
int buttonWidth = (width - SIDE_PANEL_SEPARATOR) / 2;
- int buttonHeight = height - SIDE_PANEL_SEPARATOR - firstLineHeight;
+ int buttonHeight = height - SIDE_PANEL_SEPARATOR - labelHeight;
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 6;
if (fontSize > MAX_BUTTON_FONT_SIZE)
fontSize = MAX_BUTTON_FONT_SIZE;
- currentPlayerNameLabel.setBounds(x, y, width, firstLineHeight);
- sortByGroupsButton.setBounds(x, y + firstLineHeight
+ 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
- + firstLineHeight + 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));
sortByGroupsButton.setFont(sortByGroupsButton.getFont().deriveFont(
fontSize));
- sortByRunsButton.setFont(sortByRunsButton.getFont().deriveFont(fontSize));
+ sortByRunsButton.setFont(sortByRunsButton.getFont().deriveFont(
+ fontSize));
}
}
@@ -294,7 +328,8 @@ 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;
@@ -307,19 +342,23 @@ 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);
- keepStonesButton.setFont(keepStonesButton.getFont().deriveFont(smallFontSize));
-
+
+ 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));
+
}
}
-
+
@Override
public void setEndTurnMode(boolean inspectOnly, boolean mayRedeal) {
if (!inspectOnly) {
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java
index 7381175..184155f 100644
--- a/src/jrummikub/view/impl/View.java
+++ b/src/jrummikub/view/impl/View.java
@@ -90,12 +90,12 @@ 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.setVisible(false);
+ playerPanel.setBorder(new MatteBorder(PLAYER_PANEL_BORDER_WIDTH, 0, 0,
+ 0, Color.BLACK));
mainLayer.add(playerPanel);
startTurnPanel = new StartTurnPanel();
+ startTurnPanel.setVisible(false);
mainLayer.add(startTurnPanel);
winPanel = new WinPanel();
@@ -185,6 +185,16 @@ public class View extends JFrame implements IView {
}
@Override
+ public void setCurrentPlayerColor(Color color) {
+ playerPanel.setCurrentPlayerColor(color);
+ }
+
+ @Override
+ public void setHasLaidOut(boolean hasLaidOut) {
+ playerPanel.setHasLaidOut(hasLaidOut);
+ }
+
+ @Override
public IEvent getStartTurnEvent() {
return startTurnPanel.getStartTurnEvent();
}