diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-06 03:14:05 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-06 03:14:05 +0200 |
commit | 093e1560188f5c84416c4d8e46bbc0259ece362e (patch) | |
tree | 9076fc9a8a236fa145e8d0cd333a50f852c9738e /src/jrummikub/view/impl | |
parent | d6fc29d32619f3a0e5db09bf4739f49e78a60fa1 (diff) | |
download | JRummikub-093e1560188f5c84416c4d8e46bbc0259ece362e.tar JRummikub-093e1560188f5c84416c4d8e46bbc0259ece362e.zip |
Got rid of alpha blending in TablePanel
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@165 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl')
-rw-r--r-- | src/jrummikub/view/impl/TablePanel.java | 34 |
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); } } |