summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view/impl')
-rw-r--r--src/jrummikub/view/impl/PlayerPanel.java35
-rw-r--r--src/jrummikub/view/impl/TablePanel.java8
-rw-r--r--src/jrummikub/view/impl/View.java86
3 files changed, 69 insertions, 60 deletions
diff --git a/src/jrummikub/view/impl/PlayerPanel.java b/src/jrummikub/view/impl/PlayerPanel.java
index e557842..0e5639a 100644
--- a/src/jrummikub/view/impl/PlayerPanel.java
+++ b/src/jrummikub/view/impl/PlayerPanel.java
@@ -6,6 +6,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
import java.text.DecimalFormat;
import java.util.Collections;
@@ -60,6 +61,10 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
private Event redealEvent = new Event();
private Event pauseEvent = new Event();
private int leftPanelWidth;
+ private boolean mayPause = true;
+
+ private ComponentListener leftPanelResizeListener = new LeftPanelResizeListener();
+ private ComponentListener rightPanelResizeListener = new RightPanelResizeListener();
HandPanel getHandPanel() {
return hand;
@@ -157,7 +162,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
}
});
- leftPanel.addComponentListener(new LeftPanelResizeListener());
+ leftPanel.addComponentListener(leftPanelResizeListener);
}
private void createRightPanel() {
@@ -188,7 +193,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
createRightPanelButtons();
- rightPanel.addComponentListener(new RightPanelResizeListener());
+ rightPanel.addComponentListener(rightPanelResizeListener);
}
private void createRightPanelButtons() {
@@ -237,7 +242,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
Insets insets = getInsets();
int x = insets.left, y = insets.top, width = getWidth() - insets.left
- insets.right, height = getHeight() - insets.top - insets.bottom;
-
+
int boardWidth = hand.rescale(height);
int handButtonWidth = (int) (width * HAND_ROW_BUTTON_RATIO);
int meanPanelWidth = (width - boardWidth) / 2;
@@ -252,7 +257,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
leftPanel.validate();
rightPanel.validate();
}
-
+
int getLeftPanelWidth() {
return leftPanelWidth;
}
@@ -342,6 +347,11 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
hand.setEnabled(enable);
}
+ void setMayPause(boolean mayPause) {
+ this.mayPause = mayPause;
+ rightPanelResizeListener.componentResized(null);
+ }
+
private class LeftPanelResizeListener extends ComponentAdapter {
@Override
public void componentResized(ComponentEvent e) {
@@ -427,12 +437,17 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
}
private void rescaleTimeBar(int x, int y, int width, int firstLineHeight) {
- timeBar.setBounds(x, y, width - firstLineHeight - SIDE_PANEL_SEPARATOR,
- firstLineHeight);
- pauseButton.setBounds(x + width - firstLineHeight, y, firstLineHeight,
- firstLineHeight);
- pauseButton.setIcon(ImageUtil
- .createPauseIcon((int) (firstLineHeight * 0.5f)));
+ if (mayPause) {
+ timeBar.setBounds(x, y, width - firstLineHeight - SIDE_PANEL_SEPARATOR,
+ firstLineHeight);
+ pauseButton.setBounds(x + width - firstLineHeight, y, firstLineHeight,
+ firstLineHeight);
+ pauseButton.setIcon(ImageUtil
+ .createPauseIcon((int) (firstLineHeight * 0.5f)));
+ } else {
+ timeBar.setBounds(x, y, width, firstLineHeight);
+ pauseButton.setBounds(0, 0, 0, 0);
+ }
}
private void rescaleUpDownButtons(int handButtonWidth, float fontSize) {
diff --git a/src/jrummikub/view/impl/TablePanel.java b/src/jrummikub/view/impl/TablePanel.java
index 563ad3b..4db1a52 100644
--- a/src/jrummikub/view/impl/TablePanel.java
+++ b/src/jrummikub/view/impl/TablePanel.java
@@ -123,22 +123,14 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
void createPauseStoneSets() {
pauseStoneSets = new ArrayList<Pair<StoneSet, Position>>();
- Stone stoneCoffee1 = new Stone(-'\u2615', StoneColor.BLACK);
-
Stone stoneP = new Stone(-'P', StoneColor.BLACK);
Stone stonea = new Stone(-'a', StoneColor.ORANGE);
Stone stoneu = new Stone(-'u', StoneColor.BLUE);
Stone stones = new Stone(-'s', StoneColor.RED);
Stone stonee = new Stone(-'e', StoneColor.BLACK);
- Stone stoneCoffee2 = new Stone(-'\u2615', StoneColor.RED);
-
- pauseStoneSets.add(new Pair<StoneSet, Position>(new StoneSet(stoneCoffee1),
- new Position(-4, 0)));
pauseStoneSets.add(new Pair<StoneSet, Position>(new StoneSet(Arrays.asList(
stoneP, stonea, stoneu, stones, stonee)), new Position(-2.5, 0)));
- pauseStoneSets.add(new Pair<StoneSet, Position>(new StoneSet(stoneCoffee2),
- new Position(3, 0)));
}
/**
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java
index a9dc46f..69d0d25 100644
--- a/src/jrummikub/view/impl/View.java
+++ b/src/jrummikub/view/impl/View.java
@@ -193,8 +193,7 @@ 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());
@@ -321,6 +320,7 @@ public class View extends JFrame implements IView {
public void componentResized(ComponentEvent e) {
rescale();
}
+
@Override
public void componentMoved(ComponentEvent e) {
quitWarningFrame.setLocationRelativeTo(View.this);
@@ -355,10 +355,10 @@ public class View extends JFrame implements IView {
quitWarningFrame.add(quitWarningPanel);
quitWarningFrame.setAlwaysOnTop(true);
quitWarningFrame.setUndecorated(true);
-
- //layeredPane.setLayer(quitWarningPanel, JLayeredPane.POPUP_LAYER);
- //layeredPane.add(quitWarningPanel);
- //quitWarningPanel.setVisible(true);
+
+ // layeredPane.setLayer(quitWarningPanel, JLayeredPane.POPUP_LAYER);
+ // layeredPane.add(quitWarningPanel);
+ // quitWarningPanel.setVisible(true);
scorePanel = new ScorePanel();
scorePanel.setVisible(false);
layeredPane.setLayer(scorePanel, JLayeredPane.POPUP_LAYER);
@@ -390,8 +390,7 @@ 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);
@@ -411,9 +410,14 @@ public class View extends JFrame implements IView {
sidePanel = new SidePanel();
sidePanel.setVisible(false);
mainLayer.add(sidePanel);
- sidePanel.setBorder(new CompoundBorder(new MatteBorder(0, 0, 0, 1,
- Color.BLACK), new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0,
- Color.GRAY)));
+ sidePanel
+ .setBorder(new CompoundBorder(new MatteBorder(0, 0, 0, 1, Color.BLACK),
+ new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0, Color.GRAY)));
+ }
+
+ @Override
+ public void setMayPause(boolean mayPause) {
+ playerPanel.setMayPause(mayPause);
}
@Override
@@ -525,15 +529,14 @@ public class View extends JFrame implements IView {
public void showQuitWarningPanel(boolean show) {
quitWarningFrame.setLocationRelativeTo(this);
quitWarningFrame.setVisible(show);
-
+
setEnabled(!show);
- /*mainLayer.setEnabled(!show);
- menuBar.setEnabled(!show);
- settingsPanel.setEnabled(!show);
- loginPanel.setEnabled(!show);
- scorePanel.setEnabled(!show);
- gameListPanel.setEnabled(!show);
- connectPanel.setEnabled(!show);*/
+ /*
+ * mainLayer.setEnabled(!show); menuBar.setEnabled(!show);
+ * settingsPanel.setEnabled(!show); loginPanel.setEnabled(!show);
+ * scorePanel.setEnabled(!show); gameListPanel.setEnabled(!show);
+ * connectPanel.setEnabled(!show);
+ */
}
@Override
@@ -597,24 +600,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));
@@ -629,9 +632,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
@@ -650,8 +653,7 @@ 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());
}