summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/GameListPanel.java
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-21 15:23:29 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-21 15:23:29 +0200
commit7899a38fe63a819d405a18e0139cea6ff95aac33 (patch)
tree559c4f4f80f0fad9548bb31673be9e89c70b72c5 /src/jrummikub/view/impl/GameListPanel.java
parente4e66240bf864354715f3812f70444d7f7511dd2 (diff)
downloadJRummikub-7899a38fe63a819d405a18e0139cea6ff95aac33.tar
JRummikub-7899a38fe63a819d405a18e0139cea6ff95aac33.zip
Noch mehr Kommentare, z.B. alle Methoden im Model und in der IView
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@547 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/GameListPanel.java')
-rw-r--r--src/jrummikub/view/impl/GameListPanel.java35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/jrummikub/view/impl/GameListPanel.java b/src/jrummikub/view/impl/GameListPanel.java
index d5328af..eebe3f5 100644
--- a/src/jrummikub/view/impl/GameListPanel.java
+++ b/src/jrummikub/view/impl/GameListPanel.java
@@ -49,6 +49,9 @@ class GameListPanel extends JPanel implements IGameListPanel {
private List<GameData> games = Collections.emptyList();
+ /**
+ * Creates new game list panel
+ */
GameListPanel() {
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
@@ -70,10 +73,13 @@ class GameListPanel extends JPanel implements IGameListPanel {
addButtons(c);
- setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(
- 10, 10, 10, 10)));
+ setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
+ new EmptyBorder(10, 10, 10, 10)));
}
+ /**
+ * Creates the game list to be displayed in the panel
+ */
private void createGameList() {
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
@@ -113,6 +119,12 @@ class GameListPanel extends JPanel implements IGameListPanel {
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), c);
}
+ /**
+ * Adds all three buttons to the panel
+ *
+ * @param c
+ * constraints for button positioning
+ */
private void addButtons(GridBagConstraints c) {
joinButton = new JButton("Beitreten");
c.gridwidth = 1;
@@ -154,6 +166,9 @@ class GameListPanel extends JPanel implements IGameListPanel {
});
}
+ /**
+ * Resets panel if all games have been removed from list
+ */
void reset() {
games.clear();
}
@@ -193,6 +208,9 @@ class GameListPanel extends JPanel implements IGameListPanel {
return cancelEvent;
}
+ /**
+ * Emits a join event if a user selects a game and dedides to join it
+ */
private void join() {
Object data = gameList.getSelectedValue();
@@ -201,6 +219,13 @@ class GameListPanel extends JPanel implements IGameListPanel {
}
}
+ /**
+ * Counts the empty slots for network players in a game
+ *
+ * @param gameData
+ * of the game
+ * @return Pair of occupied spaces and vacant spaces
+ */
private static Pair<Integer, Integer> getPlayerSlotCount(GameData gameData) {
int total = gameData.getGameSettings().getPlayerList().size();
int occupied = total;
@@ -214,11 +239,17 @@ class GameListPanel extends JPanel implements IGameListPanel {
return new Pair<Integer, Integer>(occupied, total);
}
+ /**
+ * Class presenting the game data in a readable way
+ */
private static class GameDataCellRenderer extends JPanel implements
ListCellRenderer {
private static final long serialVersionUID = -892701906163443927L;
JLabel hostLabel, playerCountLabel;
+ /**
+ * Create new game data cell renderer
+ */
GameDataCellRenderer() {
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();