diff options
-rw-r--r-- | src/jrummikub/view/impl/TablePanel.java | 27 |
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) { |