From 2a553fe6a56edcd3ccbb9b39a26a828034d80c5c Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Tue, 21 Jun 2011 18:51:21 +0200 Subject: Modified sidepanel layout git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@551 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/SidePanel.java | 79 ++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/jrummikub/view/impl/SidePanel.java b/src/jrummikub/view/impl/SidePanel.java index d17838f..38ff892 100644 --- a/src/jrummikub/view/impl/SidePanel.java +++ b/src/jrummikub/view/impl/SidePanel.java @@ -17,7 +17,6 @@ import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.image.BufferedImage; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import javax.swing.ImageIcon; @@ -35,7 +34,6 @@ import javax.swing.border.MatteBorder; import jrummikub.model.GameSettings; import jrummikub.model.IPlayer; -import jrummikub.model.Player; import jrummikub.model.PlayerSettings; import jrummikub.view.ISidePanel; @@ -162,7 +160,8 @@ class SidePanel extends JPanel implements ISidePanel { c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; JLabel nameLabel = new JLabel(name + ": "); - nameLabel.setPreferredSize(new Dimension(0,nameLabel.getPreferredSize().height)); + nameLabel.setPreferredSize(new Dimension(0, nameLabel + .getPreferredSize().height)); panel.add(nameLabel, c); JLabel label = new JLabel(""); label.setHorizontalAlignment(SwingConstants.RIGHT); @@ -173,7 +172,6 @@ class SidePanel extends JPanel implements ISidePanel { return label; } - @SuppressWarnings("serial") class BottomScrollPane extends JPanel { JComponent content; JViewport viewport; @@ -322,42 +320,43 @@ class SidePanel extends JPanel implements ISidePanel { } class PlayerListItem extends JPanel { - JLabel playerName; - JLabel playerStatus; - JLabel playerColor; - public PlayerListItem(IPlayer player) { setLayout(new GridBagLayout()); setBorder(new EmptyBorder(0, 4, 0, 4)); PlayerSettings settings = player.getPlayerSettings(); GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = 0; - c.gridheight = gameSettings.getSeeHandSize() ? 3 : 2; - c.weighty = 1; - c.insets = new Insets(4, 4, 4, 4); - playerColor = new JLabel(ImageUtil.createColorIcon( - settings.getColor(), 12, 1)); - add(playerColor, c); - c.gridx = 1; c.gridy = 0; c.gridheight = 1; c.gridwidth = 2; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; - c.insets = new Insets(2, 2, 2, 2); + c.insets = new Insets(4, 2, 0, 2); - playerName = new JLabel(settings.getName()); + JLabel playerName = new JLabel(settings.getName()); + playerName.setIcon(ImageUtil.createColorIcon(settings.getColor(), + 12, 1)); playerName.putClientProperty("html.disable", Boolean.TRUE); add(playerName, c); + addLastTurnInfo(player); + + if (gameSettings.getSeeHandSize()) { + addHandSizeInfo(player); + } + } + + private void addLastTurnInfo(IPlayer player) { + GridBagConstraints c = new GridBagConstraints(); + c.gridwidth = 2; + c.weightx = 1; + c.fill = GridBagConstraints.HORIZONTAL; + c.insets = new Insets(2, 2, 2, 2); c.gridx = 1; c.gridy = 1; - + c.anchor = GridBagConstraints.WEST; String status = "Stein gezogen"; - if (player.wasLastTurnInvalid()) { status = "ungültiger Zug"; if (!player.getLaidOut()) { @@ -369,26 +368,32 @@ class SidePanel extends JPanel implements ISidePanel { } else if (player.getLastTurnStoneCount() == 1) { status = "1 Stein abgelegt"; } else if (player.getLastTurnStoneCount() > 1) { - status = player.getLastTurnStoneCount() + " Steine abgelegt"; + status = player.getLastTurnStoneCount() + + " Steine abgelegt"; } } - playerStatus = new JLabel(status); + JLabel playerStatus = new JLabel(status); add(playerStatus, c); - - if (gameSettings.getSeeHandSize()) { - JLabel handSizeLabel = new JLabel("Handsteine: "); - JLabel handSizeInfo = new JLabel("" + player.getHand().getSize()); - c.gridy = 2; - c.gridwidth = 1; - add(handSizeLabel, c); - - c.gridx = 2; - c.weightx = 0; - c.insets = new Insets(2, 4, 2, 4); - c.anchor = GridBagConstraints.EAST; - add(handSizeInfo, c); - } + } + + private void addHandSizeInfo(IPlayer player) { + JLabel handSizeLabel = new JLabel("Handsteine: "); + JLabel handSizeInfo = new JLabel("" + player.getHand().getSize()); + GridBagConstraints c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 2; + c.weightx = 1; + c.gridwidth = 1; + c.insets = new Insets(2, 2, 2, 2); + c.anchor = GridBagConstraints.WEST; + add(handSizeLabel, c); + + c.gridx = 2; + c.weightx = 0; + c.insets = new Insets(2, 4, 2, 4); + c.anchor = GridBagConstraints.EAST; + add(handSizeInfo, c); } } -- cgit v1.2.3