Got rid of alpha blending in TablePanel
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@165 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
d6fc29d326
commit
093e156018
1 changed files with 26 additions and 8 deletions
|
@ -4,9 +4,11 @@ import java.awt.Color;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.Shape;
|
||||||
import java.awt.event.ComponentAdapter;
|
import java.awt.event.ComponentAdapter;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -31,6 +33,8 @@ import jrummikub.view.ITablePanel;
|
||||||
class TablePanel extends AbstractStonePanel implements ITablePanel {
|
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"));
|
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_WIDTH = 15;
|
||||||
private final static float MIN_VISIBLE_HEIGHT = 7.5f;
|
private final static float MIN_VISIBLE_HEIGHT = 7.5f;
|
||||||
|
@ -238,14 +242,16 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
* stoneHeight));
|
* 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();
|
float x = pos.getX();
|
||||||
int width = getStonePainter().getStoneWidth(), height = getStonePainter()
|
int width = getStonePainter().getStoneWidth(), height = getStonePainter()
|
||||||
.getStoneHeight();
|
.getStoneHeight();
|
||||||
|
|
||||||
g.setColor(new Color(0, 0, 0, 0.25f));
|
// Left connector
|
||||||
g.fillRect((int) (x * width - width * CONNECTOR_WIDTH),
|
connectorArea.add(new Area(new Rectangle2D.Float((int) (x * width - width
|
||||||
(int) (pos.getY() * height), (int) (width * CONNECTOR_WIDTH), height);
|
* CONNECTOR_WIDTH), (int) (pos.getY() * height),
|
||||||
|
(int) (width * CONNECTOR_WIDTH), height)));
|
||||||
|
|
||||||
for (Stone stone : stoneSet) {
|
for (Stone stone : stoneSet) {
|
||||||
getStonePainter().paintStone(g, stone, new Position(x, pos.getY()),
|
getStonePainter().paintStone(g, stone, new Position(x, pos.getY()),
|
||||||
|
@ -253,9 +259,9 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setColor(new Color(0, 0, 0, 0.25f));
|
// Right connector
|
||||||
g.fillRect((int) (x * width), (int) (pos.getY() * height),
|
connectorArea.add(new Area(new Rectangle2D.Float((int) (x * width),
|
||||||
(int) (width * CONNECTOR_WIDTH), height);
|
(int) (pos.getY() * height), (int) (width * CONNECTOR_WIDTH), height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -269,14 +275,26 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
AffineTransform oldTransform = g.getTransform();
|
AffineTransform oldTransform = g.getTransform();
|
||||||
|
Shape oldClip = g.getClip();
|
||||||
|
|
||||||
Pair<Integer, Integer> translation = getTranslation();
|
Pair<Integer, Integer> translation = getTranslation();
|
||||||
g.translate(translation.getFirst(), translation.getSecond());
|
g.translate(translation.getFirst(), translation.getSecond());
|
||||||
|
|
||||||
|
Area connectorArea = new Area();
|
||||||
|
|
||||||
for (Pair<StoneSet, Position> entry : stoneSets) {
|
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);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue