Show heap size in side panel
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@497 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
9df5497276
commit
ec54bde90a
5 changed files with 107 additions and 36 deletions
|
@ -13,4 +13,16 @@ public class MockSidePanel implements ISidePanel {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeapCapacity(int capacity) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeapSize(int size) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -203,12 +203,15 @@ public class RoundControl {
|
|||
}
|
||||
|
||||
void deal() {
|
||||
view.getSidePanel().setHeapCapacity(roundState.getGameHeap().getSize());
|
||||
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
||||
IHand hand = roundState.getNthNextPlayer(i).getHand();
|
||||
for (int j = 0; j < roundState.getGameSettings().getNumberOfStonesDealt(); j++) {
|
||||
hand.drop(roundState.getGameHeap().drawStone(), new Position(0, 0));
|
||||
}
|
||||
}
|
||||
view.getSidePanel().setHeapSize(roundState.getGameHeap().getSize());
|
||||
|
||||
}
|
||||
|
||||
private boolean laidOutValidPoints() {
|
||||
|
@ -392,6 +395,8 @@ public class RoundControl {
|
|||
hand.drop(roundState.getGameHeap().drawStone(), new Position(
|
||||
Hand.WIDTH - 1, rowCount - 1));
|
||||
}
|
||||
|
||||
view.getSidePanel().setHeapSize(roundState.getGameHeap().getSize());
|
||||
}
|
||||
|
||||
private void dealStone() {
|
||||
|
|
|
@ -6,4 +6,8 @@ public interface ISidePanel {
|
|||
|
||||
public void setGameSettings(GameSettings settings);
|
||||
|
||||
void setHeapCapacity(int capacity);
|
||||
|
||||
void setHeapSize(int size);
|
||||
|
||||
}
|
|
@ -22,9 +22,11 @@ import javax.swing.JCheckBox;
|
|||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JScrollBar;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.border.MatteBorder;
|
||||
|
||||
|
@ -33,9 +35,9 @@ import jrummikub.view.ISidePanel;
|
|||
|
||||
@SuppressWarnings("serial")
|
||||
class SidePanel extends JPanel implements ISidePanel {
|
||||
InfoPanel infoPanel;
|
||||
PlayerListPanel playerListPanel;
|
||||
BottomScrollPane playerListScrollPane;
|
||||
//private InfoPanel infoPanel;
|
||||
private PlayerListPanel playerListPanel;
|
||||
private BottomScrollPane playerListScrollPane;
|
||||
private JLabel initialMeldLabel;
|
||||
private JLabel setNumberLabel;
|
||||
private JLabel highestValueLabel;
|
||||
|
@ -43,18 +45,19 @@ class SidePanel extends JPanel implements ISidePanel {
|
|||
private JLabel jokerLabel;
|
||||
private JLabel noLimitsLabel;
|
||||
private JLabel colorLabel;
|
||||
private JProgressBar heapBar;
|
||||
|
||||
public SidePanel() {
|
||||
setLayout(new GridBagLayout());
|
||||
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
|
||||
infoPanel = new InfoPanel(createRuleInfoPanel());
|
||||
InfoPanel infoPanel = new InfoPanel(createGameInfoPanel(), createRuleInfoPanel());
|
||||
c.gridx = 0;
|
||||
c.gridy = 0;
|
||||
c.weightx = 1;
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
infoPanel.setBorder(new MatteBorder(0, 0, 1, 1, Color.BLACK));
|
||||
infoPanel.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY));
|
||||
add(infoPanel, c);
|
||||
|
||||
playerListPanel = new PlayerListPanel();
|
||||
|
@ -65,8 +68,6 @@ class SidePanel extends JPanel implements ISidePanel {
|
|||
c.fill = GridBagConstraints.BOTH;
|
||||
|
||||
playerListScrollPane = new BottomScrollPane(playerListPanel);
|
||||
playerListScrollPane
|
||||
.setBorder(new MatteBorder(0, 0, 0, 1, Color.BLACK));
|
||||
|
||||
add(playerListScrollPane, c);
|
||||
|
||||
|
@ -82,6 +83,43 @@ class SidePanel extends JPanel implements ISidePanel {
|
|||
colorLabel.setText("" + settings.getStoneColors().size());
|
||||
noLimitsLabel.setVisible(settings.isNoLimits());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeapCapacity(int capacity) {
|
||||
heapBar.setMaximum(capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeapSize(int size) {
|
||||
heapBar.setValue(size);
|
||||
if (size > 0) {
|
||||
heapBar.setString("" + size);
|
||||
} else {
|
||||
heapBar.setIndeterminate(true);
|
||||
heapBar.setString("leer");
|
||||
}
|
||||
}
|
||||
|
||||
private JPanel createGameInfoPanel() {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new GridBagLayout());
|
||||
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.gridx = 0;
|
||||
c.gridy = 0;
|
||||
c.anchor = GridBagConstraints.WEST;
|
||||
panel.add(new JLabel("Stapel: "), c);
|
||||
c.gridx = 1;
|
||||
c.weightx = 1;
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
heapBar = new JProgressBar();
|
||||
heapBar.setPreferredSize(new Dimension(16,16));
|
||||
panel.add(heapBar, c);
|
||||
|
||||
heapBar.setStringPainted(true);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JPanel createRuleInfoPanel() {
|
||||
JPanel panel = new JPanel();
|
||||
|
@ -193,18 +231,25 @@ class SidePanel extends JPanel implements ISidePanel {
|
|||
|
||||
static class InfoPanel extends JPanel {
|
||||
JPanel ruleInfoPanel;
|
||||
JPanel gameInfoPanel;
|
||||
JCheckBox showRules;
|
||||
JProgressBar heapBar;
|
||||
|
||||
public InfoPanel(JPanel ruleInfo) {
|
||||
public InfoPanel(JPanel gameInfo, JPanel ruleInfo) {
|
||||
ruleInfoPanel = ruleInfo;
|
||||
gameInfoPanel = gameInfo;
|
||||
setLayout(new GridBagLayout());
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
showRules = new JCheckBox("Regeln");
|
||||
showRules.setSelected(true);
|
||||
c.gridx = 0;
|
||||
c.weightx = 1;
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
c.anchor = GridBagConstraints.WEST;
|
||||
|
||||
c.insets = new Insets(4, 8, 4, 8);
|
||||
add(gameInfoPanel, c);
|
||||
|
||||
showRules = new JCheckBox("Regeln");
|
||||
showRules.setSelected(true);
|
||||
setupTriangleIcons(showRules);
|
||||
c.insets = new Insets(0, 4, 0, 4);
|
||||
add(showRules, c);
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.swing.JMenuBar;
|
|||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.MatteBorder;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
|
||||
|
@ -186,7 +187,8 @@ public class View extends JFrame implements IView {
|
|||
showSettingsPanel(false);
|
||||
showLoginPanel(false);
|
||||
showGameListPanel(false);
|
||||
getHandPanel().setStones(Collections.<Pair<Stone, Position>> emptyList());
|
||||
getHandPanel().setStones(
|
||||
Collections.<Pair<Stone, Position>> emptyList());
|
||||
getTablePanel().setStoneSets(
|
||||
Collections.<Pair<StoneSet, Position>> emptyList());
|
||||
setSelectedStones(Collections.<Stone> emptyList());
|
||||
|
@ -366,7 +368,8 @@ public class View extends JFrame implements IView {
|
|||
|
||||
table = new TablePanel();
|
||||
mainLayer.add(table);
|
||||
table.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0, Color.BLACK));
|
||||
table.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0,
|
||||
Color.BLACK));
|
||||
|
||||
playerPanel = new PlayerPanel();
|
||||
mainLayer.add(playerPanel);
|
||||
|
@ -390,8 +393,9 @@ public class View extends JFrame implements IView {
|
|||
sidePanel = new SidePanel();
|
||||
sidePanel.setVisible(false);
|
||||
mainLayer.add(sidePanel);
|
||||
sidePanel.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0,
|
||||
Color.BLACK));
|
||||
sidePanel.setBorder(new CompoundBorder(new MatteBorder(0, 0, 0, 1,
|
||||
Color.BLACK), new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0,
|
||||
Color.GRAY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -556,24 +560,24 @@ public class View extends JFrame implements IView {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Pair<Stone, Position>> createDecorationStones() {
|
||||
Pair<Stone, Position> stoneJ = new Pair<Stone, Position>(new Stone(-'J',
|
||||
StoneColor.BLACK), new Position(2.5f, 0));
|
||||
Pair<Stone, Position> stoneR = new Pair<Stone, Position>(new Stone(-'R',
|
||||
StoneColor.ORANGE), new Position(3.5f, 0));
|
||||
Pair<Stone, Position> stoneu1 = new Pair<Stone, Position>(new Stone(-'u',
|
||||
StoneColor.BLUE), new Position(4.5f, 0));
|
||||
Pair<Stone, Position> stonem1 = new Pair<Stone, Position>(new Stone(-'m',
|
||||
StoneColor.RED), new Position(5.5f, 0));
|
||||
Pair<Stone, Position> stonem2 = new Pair<Stone, Position>(new Stone(-'m',
|
||||
StoneColor.GREEN), new Position(6.5f, 0));
|
||||
Pair<Stone, Position> stonei = new Pair<Stone, Position>(new Stone(-'i',
|
||||
StoneColor.VIOLET), new Position(7.5f, 0));
|
||||
Pair<Stone, Position> stonek = new Pair<Stone, Position>(new Stone(-'k',
|
||||
StoneColor.AQUA), new Position(8.5f, 0));
|
||||
Pair<Stone, Position> stoneu2 = new Pair<Stone, Position>(new Stone(-'u',
|
||||
StoneColor.GRAY), new Position(9.5f, 0));
|
||||
Pair<Stone, Position> stoneb = new Pair<Stone, Position>(new Stone(-'b',
|
||||
StoneColor.BLACK), new Position(10.5f, 0));
|
||||
Pair<Stone, Position> stoneJ = new Pair<Stone, Position>(new Stone(
|
||||
-'J', StoneColor.BLACK), new Position(2.5f, 0));
|
||||
Pair<Stone, Position> stoneR = new Pair<Stone, Position>(new Stone(
|
||||
-'R', StoneColor.ORANGE), new Position(3.5f, 0));
|
||||
Pair<Stone, Position> stoneu1 = new Pair<Stone, Position>(new Stone(
|
||||
-'u', StoneColor.BLUE), new Position(4.5f, 0));
|
||||
Pair<Stone, Position> stonem1 = new Pair<Stone, Position>(new Stone(
|
||||
-'m', StoneColor.RED), new Position(5.5f, 0));
|
||||
Pair<Stone, Position> stonem2 = new Pair<Stone, Position>(new Stone(
|
||||
-'m', StoneColor.GREEN), new Position(6.5f, 0));
|
||||
Pair<Stone, Position> stonei = new Pair<Stone, Position>(new Stone(
|
||||
-'i', StoneColor.VIOLET), new Position(7.5f, 0));
|
||||
Pair<Stone, Position> stonek = new Pair<Stone, Position>(new Stone(
|
||||
-'k', StoneColor.AQUA), new Position(8.5f, 0));
|
||||
Pair<Stone, Position> stoneu2 = new Pair<Stone, Position>(new Stone(
|
||||
-'u', StoneColor.GRAY), new Position(9.5f, 0));
|
||||
Pair<Stone, Position> stoneb = new Pair<Stone, Position>(new Stone(
|
||||
-'b', StoneColor.BLACK), new Position(10.5f, 0));
|
||||
|
||||
Pair<Stone, Position> stone1 = new Pair<Stone, Position>(new Stone(
|
||||
StoneColor.RED), new Position(2, 1));
|
||||
|
@ -588,9 +592,9 @@ public class View extends JFrame implements IView {
|
|||
Pair<Stone, Position> stone6 = new Pair<Stone, Position>(new Stone(
|
||||
StoneColor.BLACK), new Position(11, 1));
|
||||
|
||||
return Arrays
|
||||
.asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei, stonek,
|
||||
stoneu2, stoneb, stone1, stone2, stone3, stone4, stone5, stone6);
|
||||
return Arrays.asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei,
|
||||
stonek, stoneu2, stoneb, stone1, stone2, stone3, stone4,
|
||||
stone5, stone6);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -610,7 +614,8 @@ public class View extends JFrame implements IView {
|
|||
&& type != BottomPanelType.WIN_PANEL && type != null);
|
||||
|
||||
if (type == BottomPanelType.START_GAME_PANEL) {
|
||||
table.setStoneSets(Collections.<Pair<StoneSet, Position>> emptyList());
|
||||
table.setStoneSets(Collections
|
||||
.<Pair<StoneSet, Position>> emptyList());
|
||||
playerPanel.getHandPanel().setStones(createDecorationStones());
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue