summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view/impl')
-rw-r--r--src/jrummikub/view/impl/TablePanel.java34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/jrummikub/view/impl/TablePanel.java b/src/jrummikub/view/impl/TablePanel.java
index 19489f2..c118613 100644
--- a/src/jrummikub/view/impl/TablePanel.java
+++ b/src/jrummikub/view/impl/TablePanel.java
@@ -4,9 +4,11 @@ import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
+import java.awt.Shape;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.geom.AffineTransform;
+import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Collection;
@@ -31,6 +33,8 @@ import jrummikub.view.ITablePanel;
class TablePanel extends AbstractStonePanel implements ITablePanel {
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"));
private final static float MIN_VISIBLE_WIDTH = 15;
private final static float MIN_VISIBLE_HEIGHT = 7.5f;
@@ -238,14 +242,16 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
* stoneHeight));
}
- private void paintStoneSet(Graphics2D g, StoneSet stoneSet, Position pos) {
+ private void paintStoneSet(Graphics2D g, StoneSet stoneSet, Position pos,
+ Area connectorArea) {
float x = pos.getX();
int width = getStonePainter().getStoneWidth(), height = getStonePainter()
.getStoneHeight();
- g.setColor(new Color(0, 0, 0, 0.25f));
- g.fillRect((int) (x * width - width * CONNECTOR_WIDTH),
- (int) (pos.getY() * height), (int) (width * CONNECTOR_WIDTH), height);
+ // Left connector
+ connectorArea.add(new Area(new Rectangle2D.Float((int) (x * width - width
+ * CONNECTOR_WIDTH), (int) (pos.getY() * height),
+ (int) (width * CONNECTOR_WIDTH), height)));
for (Stone stone : stoneSet) {
getStonePainter().paintStone(g, stone, new Position(x, pos.getY()),
@@ -253,9 +259,9 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
x++;
}
- g.setColor(new Color(0, 0, 0, 0.25f));
- g.fillRect((int) (x * width), (int) (pos.getY() * height),
- (int) (width * CONNECTOR_WIDTH), height);
+ // Right connector
+ connectorArea.add(new Area(new Rectangle2D.Float((int) (x * width),
+ (int) (pos.getY() * height), (int) (width * CONNECTOR_WIDTH), height)));
}
@Override
@@ -269,14 +275,26 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
}
AffineTransform oldTransform = g.getTransform();
+ Shape oldClip = g.getClip();
Pair<Integer, Integer> translation = getTranslation();
g.translate(translation.getFirst(), translation.getSecond());
+ Area connectorArea = new Area();
+
for (Pair<StoneSet, Position> entry : stoneSets) {
- paintStoneSet(g, entry.getFirst(), entry.getSecond());
+ paintStoneSet(g, entry.getFirst(), entry.getSecond(), connectorArea);
}
+ g.setClip(connectorArea);
g.setTransform(oldTransform);
+
+ for (int x = 0; x < getWidth(); x += DARK_BACKGROUND.getIconWidth()) {
+ for (int y = 0; y < getHeight(); y += DARK_BACKGROUND.getIconHeight()) {
+ DARK_BACKGROUND.paintIcon(this, g, x, y);
+ }
+ }
+
+ g.setClip(oldClip);
}
}