summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/StonePainter.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-01 01:04:00 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-01 01:04:00 +0200
commitd028cb8a0c538c45f7bf1494d51e31528d5aa9f0 (patch)
tree7d7795a191d611061a7f7abc42d57d8cf3573a1b /src/jrummikub/view/impl/StonePainter.java
parent54271eb86d67d1c12f38e1b63cb6c455612f252b (diff)
downloadJRummikub-d028cb8a0c538c45f7bf1494d51e31528d5aa9f0.tar
JRummikub-d028cb8a0c538c45f7bf1494d51e31528d5aa9f0.zip
Paint value on selected stones darker
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@45 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/StonePainter.java')
-rw-r--r--src/jrummikub/view/impl/StonePainter.java31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/jrummikub/view/impl/StonePainter.java b/src/jrummikub/view/impl/StonePainter.java
index 600a570..d5bc752 100644
--- a/src/jrummikub/view/impl/StonePainter.java
+++ b/src/jrummikub/view/impl/StonePainter.java
@@ -22,7 +22,7 @@ class StonePainter {
private static final float CIRCLE_WIDTH = 0.45f;
private static final Color BACKGROUND_COLOR = new Color(0.9f, 0.9f, 0.6f);
- private static final Color HIGHLIGHTED_COLOR = BACKGROUND_COLOR.darker();
+ private static final Color SELECTED_COLOR = BACKGROUND_COLOR.darker();
private static final float BRIGHTER_SCALE = 1.15f;
@@ -119,8 +119,7 @@ class StonePainter {
g.fillRect(x+1, y+height-2, width-2, 1);
}
- private void paintJokerFace(Graphics2D g, int x, int y, int width, int height,
- Stone stone) {
+ private void paintJokerFace(Graphics2D g, int x, int y, int width, int height) {
Stroke oldStroke = g.getStroke();
g.setStroke(new BasicStroke(2));
@@ -170,26 +169,26 @@ class StonePainter {
}
private void paintJoker(Graphics2D g, int x, int y, int width, int height,
- Stone stone) {
+ Color color) {
int faceSize = even(FACE_WIDTH*width);
int pos = y + (int)(TEXT_POS*height);
- g.setColor(getColor(stone.getColor()));
- paintJokerFace(g, x+width/2-faceSize/2, pos-faceSize/2, faceSize, faceSize, stone);
+ g.setColor(color);
+ paintJokerFace(g, x+width/2-faceSize/2, pos-faceSize/2, faceSize, faceSize);
}
private void paintStoneNumber(Graphics2D g, int x, int y, int width,
- int height, Stone stone) {
+ int height, Color color, int v) {
int pos = y + (int)(TEXT_POS*height);
g.setFont(new Font("SansSerif", Font.BOLD, height/4));
FontMetrics fm = g.getFontMetrics();
- String value = Integer.toString(stone.getValue());
+ String value = Integer.toString(v);
Rectangle2D stringRect = fm.getStringBounds(value, g);
- g.setColor(getColor(stone.getColor()).darker());
+ g.setColor(color.darker());
g.drawString(value, (int)(x+width/2-stringRect.getWidth()/2)+1, pos+(fm.getAscent()-fm.getDescent())/2+1);
- g.setColor(getColor(stone.getColor()));
+ g.setColor(color);
g.drawString(value, (int)(x+width/2-stringRect.getWidth()/2), pos+(fm.getAscent()-fm.getDescent())/2);
}
@@ -205,8 +204,8 @@ class StonePainter {
g.drawArc((int)(x+width/2-size/2), pos-size/2, size, size, -130, 170);
}
- public void paintStone(Graphics2D g, Stone stone, Position p, boolean highlighted) {
- Color background = highlighted ? HIGHLIGHTED_COLOR : BACKGROUND_COLOR;
+ public void paintStone(Graphics2D g, Stone stone, Position p, boolean selected) {
+ Color background = selected ? SELECTED_COLOR : BACKGROUND_COLOR;
int width = getStoneWidth();
int height = getStoneHeight();
@@ -215,10 +214,14 @@ class StonePainter {
paintStoneBackground(g, x, y, width, height, background);
+ Color color = getColor(stone.getColor());
+ if (selected)
+ color = color.darker();
+
if (stone.isJoker()) {
- paintJoker(g, x, y, width, height, stone);
+ paintJoker(g, x, y, width, height, color);
} else {
- paintStoneNumber(g, x, y, width, height, stone);
+ paintStoneNumber(g, x, y, width, height, color, stone.getValue());
}
paintCircle(g, x, y, width, height, background);