summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/View.java
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-06-19 18:31:03 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-06-19 18:31:03 +0200
commit2db77addd9082e33dda6c4ba5e957a6d7c6fa877 (patch)
treef47c079c8e1ac14c52048d882a46ab6bc6f5bbbf /src/jrummikub/view/impl/View.java
parentd0d349e5a8cd1d48bfe50fc93e762b26ee17a39a (diff)
downloadJRummikub-2db77addd9082e33dda6c4ba5e957a6d7c6fa877.tar
JRummikub-2db77addd9082e33dda6c4ba5e957a6d7c6fa877.zip
Added minimal sizes and some more side panel code
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@485 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/View.java')
-rw-r--r--src/jrummikub/view/impl/View.java38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java
index cb9bd93..2bfee8e 100644
--- a/src/jrummikub/view/impl/View.java
+++ b/src/jrummikub/view/impl/View.java
@@ -1,6 +1,7 @@
package jrummikub.view.impl;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
@@ -47,8 +48,8 @@ import jrummikub.view.IView;
@SuppressWarnings("serial")
public class View extends JFrame implements IView {
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 final static int PLAYER_PANEL_MAX_HEIGHT = 180;
+ private final static int TABLE_BORDER_WIDTH = 1;
private JLayeredPane layeredPane;
private JPanel mainLayer;
@@ -254,6 +255,7 @@ public class View extends JFrame implements IView {
setLayout(null);
setSize(1000, 700);
+ setMinimumSize(new Dimension(750, 550));
setDefaultCloseOperation(EXIT_ON_CLOSE);
createFileChooser();
@@ -322,10 +324,10 @@ 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));
playerPanel = new PlayerPanel();
- playerPanel.setBorder(new MatteBorder(PLAYER_PANEL_BORDER_WIDTH, 0, 0,
- 0, Color.BLACK));
mainLayer.add(playerPanel);
startTurnPanel = new StartTurnPanel();
@@ -342,6 +344,8 @@ public class View extends JFrame implements IView {
sidePanel = new SidePanel();
mainLayer.add(sidePanel);
+ sidePanel.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0,
+ Color.BLACK));
}
@Override
@@ -360,8 +364,7 @@ public class View extends JFrame implements IView {
mainLayer.setBounds(0, 0, width, height);
int playerPanelHeight = even(Math.pow((double) width * width * height,
- 1 / 3.0) * PLAYER_PANEL_RATIO)
- + PLAYER_PANEL_BORDER_WIDTH;
+ 1 / 3.0) * PLAYER_PANEL_RATIO);
if (playerPanelHeight > PLAYER_PANEL_MAX_HEIGHT)
playerPanelHeight = PLAYER_PANEL_MAX_HEIGHT;
@@ -378,10 +381,25 @@ public class View extends JFrame implements IView {
startTurnPanel.setBounds(0, tableHeight, width, playerPanelHeight);
pausePanel.setBounds(0, tableHeight, width, playerPanelHeight);
winPanel.setBounds(0, tableHeight, width, playerPanelHeight);
- settingsPanel.setBounds(width / 4, height / 4, width / 2, height / 2);
- scorePanel.setBounds(width / 8, height / 4, width * 3 / 4, height / 2);
- loginPanel.setBounds(width / 3, height / 3, width / 3, height / 3);
- gameListPanel.setBounds(width / 4, height / 4, width / 2, height / 2);
+
+
+ rescaleSubpanel(settingsPanel, 1 / 2.0, 1/ 2.0, 475, 300);
+ rescaleSubpanel(scorePanel, 3 / 4.0, 1/ 2.0, 450, 300);
+ rescaleSubpanel(loginPanel, 1 / 3.0, 1/ 3.0, 200, 200);
+ rescaleSubpanel(gameListPanel, 1 / 2.0, 1/ 2.0, 475, 300);
+ }
+
+ private void rescaleSubpanel(JPanel sub, double widthFactor,
+ double heightFactor, int minWidth, int minHeight) {
+ int width = getContentPane().getWidth(), height = getContentPane()
+ .getHeight();
+
+ int panelWidth = Math.max(minWidth, (int) (width * widthFactor));
+ int panelHeight = Math.max(minHeight, (int) (height * heightFactor));
+
+ int x = (width - panelWidth) / 2;
+ int y = (height - panelHeight) / 2;
+ sub.setBounds(x, y, panelWidth, panelHeight);
}
@Override