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() {
|
void deal() {
|
||||||
|
view.getSidePanel().setHeapCapacity(roundState.getGameHeap().getSize());
|
||||||
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
||||||
IHand hand = roundState.getNthNextPlayer(i).getHand();
|
IHand hand = roundState.getNthNextPlayer(i).getHand();
|
||||||
for (int j = 0; j < roundState.getGameSettings().getNumberOfStonesDealt(); j++) {
|
for (int j = 0; j < roundState.getGameSettings().getNumberOfStonesDealt(); j++) {
|
||||||
hand.drop(roundState.getGameHeap().drawStone(), new Position(0, 0));
|
hand.drop(roundState.getGameHeap().drawStone(), new Position(0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
view.getSidePanel().setHeapSize(roundState.getGameHeap().getSize());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean laidOutValidPoints() {
|
private boolean laidOutValidPoints() {
|
||||||
|
@ -392,6 +395,8 @@ public class RoundControl {
|
||||||
hand.drop(roundState.getGameHeap().drawStone(), new Position(
|
hand.drop(roundState.getGameHeap().drawStone(), new Position(
|
||||||
Hand.WIDTH - 1, rowCount - 1));
|
Hand.WIDTH - 1, rowCount - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view.getSidePanel().setHeapSize(roundState.getGameHeap().getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dealStone() {
|
private void dealStone() {
|
||||||
|
|
|
@ -6,4 +6,8 @@ public interface ISidePanel {
|
||||||
|
|
||||||
public void setGameSettings(GameSettings settings);
|
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.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.JScrollBar;
|
import javax.swing.JScrollBar;
|
||||||
import javax.swing.JViewport;
|
import javax.swing.JViewport;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.border.CompoundBorder;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
import javax.swing.border.MatteBorder;
|
import javax.swing.border.MatteBorder;
|
||||||
|
|
||||||
|
@ -33,9 +35,9 @@ import jrummikub.view.ISidePanel;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
class SidePanel extends JPanel implements ISidePanel {
|
class SidePanel extends JPanel implements ISidePanel {
|
||||||
InfoPanel infoPanel;
|
//private InfoPanel infoPanel;
|
||||||
PlayerListPanel playerListPanel;
|
private PlayerListPanel playerListPanel;
|
||||||
BottomScrollPane playerListScrollPane;
|
private BottomScrollPane playerListScrollPane;
|
||||||
private JLabel initialMeldLabel;
|
private JLabel initialMeldLabel;
|
||||||
private JLabel setNumberLabel;
|
private JLabel setNumberLabel;
|
||||||
private JLabel highestValueLabel;
|
private JLabel highestValueLabel;
|
||||||
|
@ -43,18 +45,19 @@ class SidePanel extends JPanel implements ISidePanel {
|
||||||
private JLabel jokerLabel;
|
private JLabel jokerLabel;
|
||||||
private JLabel noLimitsLabel;
|
private JLabel noLimitsLabel;
|
||||||
private JLabel colorLabel;
|
private JLabel colorLabel;
|
||||||
|
private JProgressBar heapBar;
|
||||||
|
|
||||||
public SidePanel() {
|
public SidePanel() {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
|
||||||
infoPanel = new InfoPanel(createRuleInfoPanel());
|
InfoPanel infoPanel = new InfoPanel(createGameInfoPanel(), createRuleInfoPanel());
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
c.gridy = 0;
|
c.gridy = 0;
|
||||||
c.weightx = 1;
|
c.weightx = 1;
|
||||||
c.fill = GridBagConstraints.BOTH;
|
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);
|
add(infoPanel, c);
|
||||||
|
|
||||||
playerListPanel = new PlayerListPanel();
|
playerListPanel = new PlayerListPanel();
|
||||||
|
@ -65,8 +68,6 @@ class SidePanel extends JPanel implements ISidePanel {
|
||||||
c.fill = GridBagConstraints.BOTH;
|
c.fill = GridBagConstraints.BOTH;
|
||||||
|
|
||||||
playerListScrollPane = new BottomScrollPane(playerListPanel);
|
playerListScrollPane = new BottomScrollPane(playerListPanel);
|
||||||
playerListScrollPane
|
|
||||||
.setBorder(new MatteBorder(0, 0, 0, 1, Color.BLACK));
|
|
||||||
|
|
||||||
add(playerListScrollPane, c);
|
add(playerListScrollPane, c);
|
||||||
|
|
||||||
|
@ -82,6 +83,43 @@ class SidePanel extends JPanel implements ISidePanel {
|
||||||
colorLabel.setText("" + settings.getStoneColors().size());
|
colorLabel.setText("" + settings.getStoneColors().size());
|
||||||
noLimitsLabel.setVisible(settings.isNoLimits());
|
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() {
|
private JPanel createRuleInfoPanel() {
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
|
@ -193,18 +231,25 @@ class SidePanel extends JPanel implements ISidePanel {
|
||||||
|
|
||||||
static class InfoPanel extends JPanel {
|
static class InfoPanel extends JPanel {
|
||||||
JPanel ruleInfoPanel;
|
JPanel ruleInfoPanel;
|
||||||
|
JPanel gameInfoPanel;
|
||||||
JCheckBox showRules;
|
JCheckBox showRules;
|
||||||
|
JProgressBar heapBar;
|
||||||
|
|
||||||
public InfoPanel(JPanel ruleInfo) {
|
public InfoPanel(JPanel gameInfo, JPanel ruleInfo) {
|
||||||
ruleInfoPanel = ruleInfo;
|
ruleInfoPanel = ruleInfo;
|
||||||
|
gameInfoPanel = gameInfo;
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
showRules = new JCheckBox("Regeln");
|
|
||||||
showRules.setSelected(true);
|
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
c.weightx = 1;
|
c.weightx = 1;
|
||||||
c.fill = GridBagConstraints.HORIZONTAL;
|
c.fill = GridBagConstraints.HORIZONTAL;
|
||||||
c.anchor = GridBagConstraints.WEST;
|
c.anchor = GridBagConstraints.WEST;
|
||||||
|
|
||||||
|
c.insets = new Insets(4, 8, 4, 8);
|
||||||
|
add(gameInfoPanel, c);
|
||||||
|
|
||||||
|
showRules = new JCheckBox("Regeln");
|
||||||
|
showRules.setSelected(true);
|
||||||
setupTriangleIcons(showRules);
|
setupTriangleIcons(showRules);
|
||||||
c.insets = new Insets(0, 4, 0, 4);
|
c.insets = new Insets(0, 4, 0, 4);
|
||||||
add(showRules, c);
|
add(showRules, c);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import javax.swing.JMenuBar;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.CompoundBorder;
|
||||||
import javax.swing.border.MatteBorder;
|
import javax.swing.border.MatteBorder;
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
|
|
||||||
|
@ -186,7 +187,8 @@ public class View extends JFrame implements IView {
|
||||||
showSettingsPanel(false);
|
showSettingsPanel(false);
|
||||||
showLoginPanel(false);
|
showLoginPanel(false);
|
||||||
showGameListPanel(false);
|
showGameListPanel(false);
|
||||||
getHandPanel().setStones(Collections.<Pair<Stone, Position>> emptyList());
|
getHandPanel().setStones(
|
||||||
|
Collections.<Pair<Stone, Position>> emptyList());
|
||||||
getTablePanel().setStoneSets(
|
getTablePanel().setStoneSets(
|
||||||
Collections.<Pair<StoneSet, Position>> emptyList());
|
Collections.<Pair<StoneSet, Position>> emptyList());
|
||||||
setSelectedStones(Collections.<Stone> emptyList());
|
setSelectedStones(Collections.<Stone> emptyList());
|
||||||
|
@ -366,7 +368,8 @@ public class View extends JFrame implements IView {
|
||||||
|
|
||||||
table = new TablePanel();
|
table = new TablePanel();
|
||||||
mainLayer.add(table);
|
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();
|
playerPanel = new PlayerPanel();
|
||||||
mainLayer.add(playerPanel);
|
mainLayer.add(playerPanel);
|
||||||
|
@ -390,8 +393,9 @@ public class View extends JFrame implements IView {
|
||||||
sidePanel = new SidePanel();
|
sidePanel = new SidePanel();
|
||||||
sidePanel.setVisible(false);
|
sidePanel.setVisible(false);
|
||||||
mainLayer.add(sidePanel);
|
mainLayer.add(sidePanel);
|
||||||
sidePanel.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0,
|
sidePanel.setBorder(new CompoundBorder(new MatteBorder(0, 0, 0, 1,
|
||||||
Color.BLACK));
|
Color.BLACK), new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0,
|
||||||
|
Color.GRAY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -556,24 +560,24 @@ public class View extends JFrame implements IView {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private List<Pair<Stone, Position>> createDecorationStones() {
|
private List<Pair<Stone, Position>> createDecorationStones() {
|
||||||
Pair<Stone, Position> stoneJ = new Pair<Stone, Position>(new Stone(-'J',
|
Pair<Stone, Position> stoneJ = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.BLACK), new Position(2.5f, 0));
|
-'J', StoneColor.BLACK), new Position(2.5f, 0));
|
||||||
Pair<Stone, Position> stoneR = new Pair<Stone, Position>(new Stone(-'R',
|
Pair<Stone, Position> stoneR = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.ORANGE), new Position(3.5f, 0));
|
-'R', StoneColor.ORANGE), new Position(3.5f, 0));
|
||||||
Pair<Stone, Position> stoneu1 = new Pair<Stone, Position>(new Stone(-'u',
|
Pair<Stone, Position> stoneu1 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.BLUE), new Position(4.5f, 0));
|
-'u', StoneColor.BLUE), new Position(4.5f, 0));
|
||||||
Pair<Stone, Position> stonem1 = new Pair<Stone, Position>(new Stone(-'m',
|
Pair<Stone, Position> stonem1 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.RED), new Position(5.5f, 0));
|
-'m', StoneColor.RED), new Position(5.5f, 0));
|
||||||
Pair<Stone, Position> stonem2 = new Pair<Stone, Position>(new Stone(-'m',
|
Pair<Stone, Position> stonem2 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.GREEN), new Position(6.5f, 0));
|
-'m', StoneColor.GREEN), new Position(6.5f, 0));
|
||||||
Pair<Stone, Position> stonei = new Pair<Stone, Position>(new Stone(-'i',
|
Pair<Stone, Position> stonei = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.VIOLET), new Position(7.5f, 0));
|
-'i', StoneColor.VIOLET), new Position(7.5f, 0));
|
||||||
Pair<Stone, Position> stonek = new Pair<Stone, Position>(new Stone(-'k',
|
Pair<Stone, Position> stonek = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.AQUA), new Position(8.5f, 0));
|
-'k', StoneColor.AQUA), new Position(8.5f, 0));
|
||||||
Pair<Stone, Position> stoneu2 = new Pair<Stone, Position>(new Stone(-'u',
|
Pair<Stone, Position> stoneu2 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.GRAY), new Position(9.5f, 0));
|
-'u', StoneColor.GRAY), new Position(9.5f, 0));
|
||||||
Pair<Stone, Position> stoneb = new Pair<Stone, Position>(new Stone(-'b',
|
Pair<Stone, Position> stoneb = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.BLACK), new Position(10.5f, 0));
|
-'b', StoneColor.BLACK), new Position(10.5f, 0));
|
||||||
|
|
||||||
Pair<Stone, Position> stone1 = new Pair<Stone, Position>(new Stone(
|
Pair<Stone, Position> stone1 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.RED), new Position(2, 1));
|
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(
|
Pair<Stone, Position> stone6 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.BLACK), new Position(11, 1));
|
StoneColor.BLACK), new Position(11, 1));
|
||||||
|
|
||||||
return Arrays
|
return Arrays.asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei,
|
||||||
.asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei, stonek,
|
stonek, stoneu2, stoneb, stone1, stone2, stone3, stone4,
|
||||||
stoneu2, stoneb, stone1, stone2, stone3, stone4, stone5, stone6);
|
stone5, stone6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -610,7 +614,8 @@ public class View extends JFrame implements IView {
|
||||||
&& type != BottomPanelType.WIN_PANEL && type != null);
|
&& type != BottomPanelType.WIN_PANEL && type != null);
|
||||||
|
|
||||||
if (type == BottomPanelType.START_GAME_PANEL) {
|
if (type == BottomPanelType.START_GAME_PANEL) {
|
||||||
table.setStoneSets(Collections.<Pair<StoneSet, Position>> emptyList());
|
table.setStoneSets(Collections
|
||||||
|
.<Pair<StoneSet, Position>> emptyList());
|
||||||
playerPanel.getHandPanel().setStones(createDecorationStones());
|
playerPanel.getHandPanel().setStones(createDecorationStones());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue