From 367aa6a65cd7b593e4f3628db246e1460e25326b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 6 May 2011 01:46:10 +0200 Subject: Make StoneCollectionPanel opaque git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@163 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/StoneCollectionPanel.java | 33 ++++++++--------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'src/jrummikub/view/impl') diff --git a/src/jrummikub/view/impl/StoneCollectionPanel.java b/src/jrummikub/view/impl/StoneCollectionPanel.java index 493b299..a3453d1 100644 --- a/src/jrummikub/view/impl/StoneCollectionPanel.java +++ b/src/jrummikub/view/impl/StoneCollectionPanel.java @@ -25,6 +25,8 @@ import jrummikub.view.IStoneCollectionPanel; class StoneCollectionPanel extends AbstractStonePanel implements IStoneCollectionPanel { private final static ImageIcon BACKGROUND = new ImageIcon( + HandPanel.class.getResource("/jrummikub/resource/felt.png")); + private final static ImageIcon DARK_BACKGROUND = new ImageIcon( HandPanel.class.getResource("/jrummikub/resource/dark_felt.png")); /** * The width of the border of the collection panel @@ -37,7 +39,6 @@ class StoneCollectionPanel extends AbstractStonePanel implements * Creates a new StoneCollection instance */ StoneCollectionPanel() { - setOpaque(false); setBorder(new EmptyBorder(INSET, INSET, INSET, INSET)); addComponentListener(new ComponentAdapter() { @@ -54,26 +55,8 @@ class StoneCollectionPanel extends AbstractStonePanel implements getStonePainter().setScale(height * StonePainter.HEIGHT_SCALE); repaint(); - - /* - * setSize(getStonePainter().getStoneWidth() * selectedStones.size() + 2 - * INSET, getStonePainter().getStoneHeight() + 2 * INSET); - */ } - /** - * Sets the height to paint the collected stones in - * - * @param height - * the height in pixels - */ - /* - * void setStoneHeight(int height) { getStonePainter().setScale(height * - * StonePainter.HEIGHT_SCALE); - * - * rescale(); repaint(); //} - */ - /** * Sets the stones to be shown in the collection * @@ -106,16 +89,22 @@ class StoneCollectionPanel extends AbstractStonePanel implements @Override public void paintComponent(Graphics g1) { + for (int xpos = 0; xpos < getWidth(); xpos += BACKGROUND.getIconWidth()) { + for (int ypos = 0; ypos < getHeight(); ypos += BACKGROUND.getIconHeight()) { + BACKGROUND.paintIcon(this, g1, xpos, ypos); + } + } + int width = getStonePainter().getStoneWidth() * selectedStones.size() + 2 * INSET, height = getHeight(); int x = (getWidth() - width) / 2; Graphics2D g = (Graphics2D) g1.create(x, 0, width, height); if (!selectedStones.isEmpty()) { - for (int xpos = 0; xpos < getWidth(); xpos += BACKGROUND.getIconWidth()) { - for (int ypos = 0; ypos < getHeight(); ypos += BACKGROUND + for (int xpos = 0; xpos < width; xpos += DARK_BACKGROUND.getIconWidth()) { + for (int ypos = 0; ypos < height; ypos += DARK_BACKGROUND .getIconHeight()) { - BACKGROUND.paintIcon(this, g, xpos, ypos); + DARK_BACKGROUND.paintIcon(this, g, xpos, ypos); } } -- cgit v1.2.3