From 5397c0c59ee060a9cfb8906250a6537a63ee7262 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 9 May 2011 04:41:57 +0200 Subject: Fix table scale setting git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@182 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/TablePanel.java | 27 ++++++++++++++++++--------- 1 file 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) { -- cgit v1.2.3