summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/View.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-01 19:14:55 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-01 19:14:55 +0200
commitb2dbfcc317d7cdec57cc4081801e75a9d25b1d07 (patch)
tree1b45352d56a4eeb3543ca1257eb322a691150607 /src/jrummikub/view/impl/View.java
parent5436407515a14ed6a53276c26f0b8403ec27020f (diff)
downloadJRummikub-b2dbfcc317d7cdec57cc4081801e75a9d25b1d07.tar
JRummikub-b2dbfcc317d7cdec57cc4081801e75a9d25b1d07.zip
Fix formatting
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@52 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/View.java')
-rw-r--r--src/jrummikub/view/impl/View.java37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java
index 4cbad44..3508877 100644
--- a/src/jrummikub/view/impl/View.java
+++ b/src/jrummikub/view/impl/View.java
@@ -1,7 +1,6 @@
package jrummikub.view.impl;
import java.awt.Color;
-import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
@@ -18,16 +17,15 @@ import jrummikub.view.IView;
public class View extends JFrame implements IView {
private Table table;
private PlayerPanel playerPanel;
-
+
private final static float PLAYER_PANEL_RATIO = 0.125f;
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);
+ return 2 * (int) (d / 2);
}
-
+
public ITable getTable() {
return table;
}
@@ -36,39 +34,42 @@ public class View extends JFrame implements IView {
return playerPanel;
}
-
public View() {
super("JRummikub");
setLayout(null);
-
+
setSize(1000, 700);
setDefaultCloseOperation(EXIT_ON_CLOSE);
-
+
table = new Table();
add(table);
playerPanel = new PlayerPanel();
- playerPanel.setBorder(new CustomBorder(Color.BLACK, PLAYER_PANEL_BORDER_WIDTH, 0, 0, 0));
+ playerPanel.setBorder(new CustomBorder(Color.BLACK,
+ PLAYER_PANEL_BORDER_WIDTH, 0, 0, 0));
add(playerPanel);
-
+
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
Insets insets = getInsets();
- int x = insets.left, y = insets.top, 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;
+ int x = insets.left, y = insets.top, 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(x, y, width, tableHeight);
table.validate();
- playerPanel.setBounds(x, y+tableHeight, width, playerPanelHeight);
+ playerPanel.setBounds(x, y + tableHeight, width, playerPanelHeight);
}
});
-
+
setVisible(true);
}