summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/HandPanel.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view/impl/HandPanel.java')
-rw-r--r--src/jrummikub/view/impl/HandPanel.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/jrummikub/view/impl/HandPanel.java b/src/jrummikub/view/impl/HandPanel.java
index bede319..1851ed9 100644
--- a/src/jrummikub/view/impl/HandPanel.java
+++ b/src/jrummikub/view/impl/HandPanel.java
@@ -29,16 +29,23 @@ class HandPanel extends AbstractStonePanel implements IHandPanel {
private final static int HEIGHT = 2;
private final static BufferedImage BACKGROUND;
+ private final static BufferedImage DARK_BACKGROUND;
static {
ImageIcon image = new ImageIcon(
HandPanel.class.getResource("/jrummikub/resource/wood.png"));
+ ImageIcon darkImage = new ImageIcon(
+ HandPanel.class.getResource("/jrummikub/resource/dark_wood.png"));
BACKGROUND = new BufferedImage(image.getIconWidth(), image.getIconHeight(),
BufferedImage.TYPE_INT_RGB);
+ DARK_BACKGROUND = new BufferedImage(darkImage.getIconWidth(), darkImage.getIconHeight(),
+ BufferedImage.TYPE_INT_RGB);
image.paintIcon(null, BACKGROUND.createGraphics(), 0, 0);
+ darkImage.paintIcon(null, DARK_BACKGROUND.createGraphics(), 0, 0);
}
private BufferedImage scaledBackground = BACKGROUND;
+ private BufferedImage scaledDarkBackground = BACKGROUND;
private PlayerPanel playerPanel;
@@ -47,7 +54,6 @@ class HandPanel extends AbstractStonePanel implements IHandPanel {
private boolean repaintAll = true;
private Collection<Stone> selectedStones = Collections.emptyList();
-
/**
* Creates a new Board instance
*/
@@ -65,14 +71,14 @@ class HandPanel extends AbstractStonePanel implements IHandPanel {
});
}
- private BufferedImage getScaledBackground(int size) {
+ private BufferedImage getScaledBackground(int size, BufferedImage background) {
BufferedImage scaled = new BufferedImage(size, size,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = scaled.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g.drawImage(BACKGROUND, 0, 0, size, size, null);
+ g.drawImage(background, 0, 0, size, size, null);
return scaled;
}
@@ -86,13 +92,22 @@ class HandPanel extends AbstractStonePanel implements IHandPanel {
int size = height / HEIGHT;
+
+ BufferedImage background = isEnabled() ? scaledBackground : scaledDarkBackground ;
+
if (repaintAll) {
- if (scaledBackground.getHeight() != size)
- scaledBackground = getScaledBackground(size);
-
+ if (background.getHeight() != size) {
+ if (!isEnabled()) {
+ scaledDarkBackground = getScaledBackground(size, DARK_BACKGROUND);
+ } else {
+ scaledBackground = getScaledBackground(size, BACKGROUND);
+ }
+ background = isEnabled() ? scaledBackground : scaledDarkBackground;
+ }
+
for (int i = 0; i < HEIGHT; ++i) {
for (int xpos = -size * i / 3; xpos < width; xpos += size) {
- g.drawImage(scaledBackground, xpos, size * i, null);
+ g.drawImage(background, xpos, size * i, null);
}
}
}