Fix table scale setting
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@182 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
ad3b8ecb48
commit
5397c0c59e
1 changed files with 18 additions and 9 deletions
|
@ -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) {
|
||||
|
|
Reference in a new issue