summaryrefslogtreecommitdiffstats
path: root/src/jrummikub
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub')
-rw-r--r--src/jrummikub/view/impl/Board.java10
-rw-r--r--src/jrummikub/view/impl/StonePainter.java31
2 files changed, 17 insertions, 24 deletions
diff --git a/src/jrummikub/view/impl/Board.java b/src/jrummikub/view/impl/Board.java
index a566312..0e41984 100644
--- a/src/jrummikub/view/impl/Board.java
+++ b/src/jrummikub/view/impl/Board.java
@@ -27,16 +27,6 @@ public class Board extends StonePanel implements IBoard {
super(DEFAULT_SCALE);
setBorder(new CustomBorder(Color.DARK_GRAY, 0, 1, 0, 1));
-
- /*addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- Insets insets = getInsets();
-
- clickEvent.fire(stonePainter.calculatePosition(e.getX() - insets.left,
- e.getY() - insets.top));
- }
- });*/
}
@Override
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);