summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-09 04:41:57 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-09 04:41:57 +0200
commit5397c0c59ee060a9cfb8906250a6537a63ee7262 (patch)
treeb2becd7e9aca2710868a07d452c86d4ffeb74bf3 /src/jrummikub/view
parentad3b8ecb48d4d18a79691e111e2875725b3b94e9 (diff)
downloadJRummikub-5397c0c59ee060a9cfb8906250a6537a63ee7262.tar
JRummikub-5397c0c59ee060a9cfb8906250a6537a63ee7262.zip
Fix table scale setting
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@182 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view')
-rw-r--r--src/jrummikub/view/impl/TablePanel.java27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/jrummikub/view/impl/TablePanel.java b/src/jrummikub/view/impl/TablePanel.java
index 7e2dfdb..dfca389 100644
--- a/src/jrummikub/view/impl/TablePanel.java
+++ b/src/jrummikub/view/impl/TablePanel.java
@@ -41,8 +41,8 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
private final static float MIN_VISIBLE_WIDTH = 15;
private final static float MIN_VISIBLE_HEIGHT = 7.5f;
- private final static float HORIZONTAL_MARGIN = 1.5f;
- private final static float VERTICAL_MARGIN = 1;
+ private final static float HORIZONTAL_MARGIN = 1;
+ private final static float VERTICAL_MARGIN = 0.7f;
private final static float CONNECTOR_WIDTH = 0.25f;
private final float COLLECTION_RATIO = 0.12f;
private final int COLLECTION_GAP = 5;
@@ -97,6 +97,8 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
setStones(stones);
this.stoneSets = stoneSets;
+ setScale();
+
repaint();
}
@@ -202,6 +204,20 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
topPlayerLabel.setBounds(x, y, width, height);
rightPlayerLabel.setBounds(x, y, width, height);
+ int collectionHeight = (int) (height * COLLECTION_RATIO);
+ stoneCollection
+ .setBounds(x, y + height - collectionHeight - COLLECTION_GAP, width,
+ collectionHeight);
+
+ setScale();
+
+ repaint();
+ }
+
+ private void setScale() {
+ Insets insets = getInsets();
+ int width = getWidth() - insets.left - insets.right, height = getHeight()
+ - insets.top - insets.bottom;
Rectangle2D extent = calculateTableExtent();
float widthScale = width / (float) extent.getWidth()
@@ -210,13 +226,6 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
/ (float) extent.getHeight() * StonePainter.HEIGHT_SCALE;
getStonePainter().setScale(Math.min(widthScale, heightScale));
-
- int collectionHeight = (int) (height * COLLECTION_RATIO);
- stoneCollection
- .setBounds(x, y + height - collectionHeight - COLLECTION_GAP, width,
- collectionHeight);
-
- repaint();
}
protected boolean handleOtherClickEvent(Position pos) {