diff options
Diffstat (limited to 'src/jrummikub/view/impl/TablePanel.java')
-rw-r--r-- | src/jrummikub/view/impl/TablePanel.java | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/jrummikub/view/impl/TablePanel.java b/src/jrummikub/view/impl/TablePanel.java index 080d476..2c7d899 100644 --- a/src/jrummikub/view/impl/TablePanel.java +++ b/src/jrummikub/view/impl/TablePanel.java @@ -4,10 +4,8 @@ import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; -import java.awt.RenderingHints; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.util.ArrayList; @@ -31,7 +29,7 @@ import jrummikub.view.ITablePanel; */ @SuppressWarnings("serial") class TablePanel extends AbstractStonePanel implements ITablePanel { - private final static ImageIcon background = new ImageIcon( + private final static ImageIcon BACKGROUND = new ImageIcon( HandPanel.class.getResource("/jrummikub/resource/felt.png")); private final static float MIN_VISIBLE_WIDTH = 15; @@ -141,15 +139,12 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { stoneCollection = new StoneCollectionPanel(); add(stoneCollection); - ComponentListener rescaleListener = new ComponentAdapter() { + addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { rescale(); } - }; - - addComponentListener(rescaleListener); - stoneCollection.addComponentListener(rescaleListener); + }); } private Rectangle2D calculateTableExtent() { @@ -187,9 +182,6 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { topPlayerLabel.setBounds(x, y, width, height); rightPlayerLabel.setBounds(x, y, width, height); - stoneCollection.setLocation(x + width / 2 - stoneCollection.getWidth() / 2, - y + height - stoneCollection.getHeight() - COLLECTION_GAP); - Rectangle2D extent = calculateTableExtent(); float widthScale = width / (float) extent.getWidth() @@ -199,7 +191,11 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { getStonePainter().setScale(Math.min(widthScale, heightScale)); - stoneCollection.setStoneHeight((int) (height * COLLECTION_RATIO)); + int collectionHeight = (int) (height * COLLECTION_RATIO) + 2 + * StoneCollectionPanel.INSET; + stoneCollection + .setBounds(x, y + height - collectionHeight - COLLECTION_GAP, width, + collectionHeight); repaint(); } @@ -267,9 +263,9 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { protected void paintComponent(Graphics g1) { Graphics2D g = (Graphics2D) g1; - for (int x = 0; x < getWidth(); x += background.getIconWidth()) { - for (int y = 0; y < getHeight(); y += background.getIconHeight()) { - background.paintIcon(this, g, x, y); + for (int x = 0; x < getWidth(); x += BACKGROUND.getIconWidth()) { + for (int y = 0; y < getHeight(); y += BACKGROUND.getIconHeight()) { + BACKGROUND.paintIcon(this, g, x, y); } } @@ -278,9 +274,6 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { Pair<Integer, Integer> translation = getTranslation(); g.translate(translation.getFirst(), translation.getSecond()); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - for (Pair<StoneSet, Position> entry : stoneSets) { paintStoneSet(g, entry.getFirst(), entry.getSecond()); } |