summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/View.java
diff options
context:
space:
mode:
authorBennet Gerlach <bennet_gerlach@web.de>2011-05-04 15:40:34 +0200
committerBennet Gerlach <bennet_gerlach@web.de>2011-05-04 15:40:34 +0200
commite39a539ee38a1413aac9f09a556a9ca4a181bc39 (patch)
tree7dfaf1623cf6e8f620790f150f14a9c124ad9938 /src/jrummikub/view/impl/View.java
parenta0a32b4f2df05b973c3f235508ef52b510873e19 (diff)
downloadJRummikub-e39a539ee38a1413aac9f09a556a9ca4a181bc39.tar
JRummikub-e39a539ee38a1413aac9f09a556a9ca4a181bc39.zip
Added StartTurnPanel
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@102 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/View.java')
-rw-r--r--src/jrummikub/view/impl/View.java158
1 files changed, 92 insertions, 66 deletions
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java
index 7ef0e18..e3d58ea 100644
--- a/src/jrummikub/view/impl/View.java
+++ b/src/jrummikub/view/impl/View.java
@@ -10,6 +10,7 @@ import javax.swing.JFrame;
import javax.swing.border.MatteBorder;
import jrummikub.model.Stone;
+import jrummikub.util.IEvent;
import jrummikub.view.IPlayerPanel;
import jrummikub.view.ITablePanel;
import jrummikub.view.IView;
@@ -19,70 +20,95 @@ import jrummikub.view.IView;
*/
@SuppressWarnings("serial")
public class View extends JFrame implements IView {
- private TablePanel table;
- private PlayerPanel playerPanel;
-
- private final static float PLAYER_PANEL_RATIO = 0.14f;
- private final static int PLAYER_PANEL_BORDER_WIDTH = 1;
- private final static int PLAYER_PANEL_MAX_HEIGHT = 180 + PLAYER_PANEL_BORDER_WIDTH;
-
- private static int even(double d) {
- return 2 * (int) (d / 2);
- }
-
- public ITablePanel getTablePanel() {
- return table;
- }
-
- public IPlayerPanel getPlayerPanel() {
- return playerPanel;
- }
-
- /**
- * Create a new instance of the view
- */
- public View() {
- super("JRummikub");
- setLayout(null);
-
- setSize(800, 600);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
-
- table = new TablePanel();
- add(table);
-
- playerPanel = new PlayerPanel();
- playerPanel.setBorder(new MatteBorder(PLAYER_PANEL_BORDER_WIDTH, 0, 0, 0,
- Color.BLACK));
- add(playerPanel);
-
- addComponentListener(new ComponentAdapter() {
- @Override
- public void componentResized(ComponentEvent e) {
- Insets insets = getInsets();
- int width = getWidth() - insets.left
- - insets.right, height = getHeight() - insets.top - insets.bottom;
-
- int playerPanelHeight = even(Math.pow((double) width * width * height,
- 1 / 3.0) * PLAYER_PANEL_RATIO)
- + PLAYER_PANEL_BORDER_WIDTH;
- if (playerPanelHeight > PLAYER_PANEL_MAX_HEIGHT)
- playerPanelHeight = PLAYER_PANEL_MAX_HEIGHT;
-
- int tableHeight = height - playerPanelHeight;
-
- table.setBounds(0, 0, width, tableHeight);
- table.validate();
- playerPanel.setBounds(0, tableHeight, width, playerPanelHeight);
- }
- });
-
- setVisible(true);
- }
-
- @Override
- public void setSelectedStones(Collection<Stone> stones) {
- table.setSelectedStones(stones);
- playerPanel.getHandPanel().setSelectedStones(stones);
- }
+ private TablePanel table;
+ private PlayerPanel playerPanel;
+ private StartTurnPanel startTurnPanel;
+
+ private final static float PLAYER_PANEL_RATIO = 0.14f;
+ private final static int PLAYER_PANEL_BORDER_WIDTH = 1;
+ private final static int PLAYER_PANEL_MAX_HEIGHT = 180 + PLAYER_PANEL_BORDER_WIDTH;
+
+ private static int even(double d) {
+ return 2 * (int) (d / 2);
+ }
+
+ @Override
+ public ITablePanel getTablePanel() {
+ return table;
+ }
+
+ @Override
+ public IPlayerPanel getPlayerPanel() {
+ return playerPanel;
+ }
+
+ /**
+ * Create a new instance of the view
+ */
+ public View() {
+ super("JRummikub");
+ setLayout(null);
+
+ setSize(800, 600);
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+
+ table = new TablePanel();
+ add(table);
+
+ playerPanel = new PlayerPanel();
+ playerPanel.setBorder(new MatteBorder(PLAYER_PANEL_BORDER_WIDTH, 0, 0, 0,
+ Color.BLACK));
+ add(playerPanel);
+
+ startTurnPanel = new StartTurnPanel();
+ startTurnPanel.setVisible(false);
+ add(startTurnPanel);
+
+ addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ Insets insets = getInsets();
+ int width = getWidth() - insets.left - insets.right, height = getHeight()
+ - insets.top - insets.bottom;
+
+ int playerPanelHeight = even(Math.pow((double) width * width * height,
+ 1 / 3.0) * PLAYER_PANEL_RATIO)
+ + PLAYER_PANEL_BORDER_WIDTH;
+ if (playerPanelHeight > PLAYER_PANEL_MAX_HEIGHT)
+ playerPanelHeight = PLAYER_PANEL_MAX_HEIGHT;
+
+ int tableHeight = height - playerPanelHeight;
+
+ table.setBounds(0, 0, width, tableHeight);
+ table.validate();
+ playerPanel.setBounds(0, tableHeight, width, playerPanelHeight);
+ startTurnPanel.setBounds(0, tableHeight, width, playerPanelHeight);
+ }
+ });
+
+ setVisible(true);
+ }
+
+ @Override
+ public void setSelectedStones(Collection<Stone> stones) {
+ table.setSelectedStones(stones);
+ playerPanel.getHandPanel().setSelectedStones(stones);
+ }
+
+ @Override
+ public void enableStartTurnPanel(boolean enable) {
+ playerPanel.setVisible(!enable);
+ startTurnPanel.setVisible(enable);
+ }
+
+ @Override
+ public void setCurrentPlayerName(String playerName) {
+ playerPanel.setCurrentPlayerName(playerName);
+ startTurnPanel.setCurrentPlayerName(playerName);
+ }
+
+ @Override
+ public IEvent getStartTurnEvent() {
+ return startTurnPanel.getStartTurnEvent();
+ }
}