summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-04-30 21:50:28 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-04-30 21:50:28 +0200
commit9ea9b1150121738a5d5260d380aab654ef218079 (patch)
tree83f60e9c5c0ed61800928aa5777f10a4deee0669 /src
parente45610ece685de5bcb35b9f49d03f1de2719370a (diff)
downloadJRummikub-9ea9b1150121738a5d5260d380aab654ef218079.tar
JRummikub-9ea9b1150121738a5d5260d380aab654ef218079.zip
Added highlighting to StonePainter
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@36 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src')
-rw-r--r--src/jrummikub/view/impl/Board.java2
-rw-r--r--src/jrummikub/view/impl/StonePainter.java35
-rw-r--r--src/jrummikub/view/impl/Table.java2
3 files changed, 20 insertions, 19 deletions
diff --git a/src/jrummikub/view/impl/Board.java b/src/jrummikub/view/impl/Board.java
index b8bd206..82794b3 100644
--- a/src/jrummikub/view/impl/Board.java
+++ b/src/jrummikub/view/impl/Board.java
@@ -66,7 +66,7 @@ public class Board extends JPanel implements IBoard {
RenderingHints.VALUE_ANTIALIAS_ON);
for (Map.Entry<Stone, Position> stone : stones.entrySet()) {
- stonePainter.paintStone(g, stone.getKey(), stone.getValue());
+ stonePainter.paintStone(g, stone.getKey(), stone.getValue(), false);
}
}
diff --git a/src/jrummikub/view/impl/StonePainter.java b/src/jrummikub/view/impl/StonePainter.java
index fa039f7..f795eea 100644
--- a/src/jrummikub/view/impl/StonePainter.java
+++ b/src/jrummikub/view/impl/StonePainter.java
@@ -12,7 +12,6 @@ import java.awt.geom.Rectangle2D;
import jrummikub.model.Position;
import jrummikub.model.Stone;
import jrummikub.model.StoneColor;
-import jrummikub.model.StoneSet;
class StonePainter {
private static final float ASPECT_RATIO = 0.75f;
@@ -24,6 +23,7 @@ class StonePainter {
private static final Color BACKGROUND_COLOR = new Color(0.9f, 0.9f, 0.6f);
+ private static final Color HIGHLIGHTED_COLOR = BACKGROUND_COLOR.darker();
public static final float BOARD_SCALE = 75.0f*ASPECT_RATIO/DEFAULT_WIDTH;
@@ -75,30 +75,30 @@ class StonePainter {
}
private void paintStoneBackground(Graphics2D g, int x, int y,
- int width, int height) {
+ int width, int height, Color background) {
// Paint background
- g.setColor(BACKGROUND_COLOR);
+ g.setColor(background);
g.fillRect(x, y, width, height);
// Paint bevel border
- g.setColor(BACKGROUND_COLOR.brighter().brighter());
+ g.setColor(background.brighter().brighter());
g.fillRect(x, y, 1, height);
- g.setColor(BACKGROUND_COLOR.brighter());
+ g.setColor(background.brighter());
g.fillRect(x+1, y+1, 1, height-2);
- g.setColor(BACKGROUND_COLOR.brighter().brighter());
+ g.setColor(background.brighter().brighter());
g.fillRect(x, y, width, 1);
- g.setColor(BACKGROUND_COLOR.brighter());
+ g.setColor(background.brighter());
g.fillRect(x+1, y+1, width-2, 1);
- g.setColor(BACKGROUND_COLOR.darker().darker());
+ g.setColor(background.darker().darker());
g.fillRect(x+width-1, y, 1, height);
- g.setColor(BACKGROUND_COLOR.darker());
+ g.setColor(background.darker());
g.fillRect(x+width-2, y+1, 1, height-2);
- g.setColor(BACKGROUND_COLOR.darker().darker());
+ g.setColor(background.darker().darker());
g.fillRect(x, y+height-1, width, 1);
- g.setColor(BACKGROUND_COLOR.darker());
+ g.setColor(background.darker());
g.fillRect(x+1, y+height-2, width-2, 1);
}
@@ -176,26 +176,27 @@ class StonePainter {
g.drawString(value, (int)(x+width/2-stringRect.getWidth()/2), pos+(fm.getAscent()-fm.getDescent())/2);
}
- private void paintCircle(Graphics2D g, int x, int y, int width, int height) {
+ private void paintCircle(Graphics2D g, int x, int y, int width, int height, Color background) {
int size = even(width*CIRCLE_WIDTH);
int pos = y + (int)(CIRCLE_POS*height);
// Paint circle
- g.setColor(BACKGROUND_COLOR.darker());
+ g.setColor(background.darker());
g.drawArc(x+width/2-size/2, pos-size/2, size, size, 50, 170);
- g.setColor(BACKGROUND_COLOR.brighter());
+ g.setColor(background.brighter());
g.drawArc((int)(x+width/2-size/2), pos-size/2, size, size, -130, 170);
}
- public void paintStone(Graphics2D g, Stone stone, Position p) {
+ public void paintStone(Graphics2D g, Stone stone, Position p, boolean highlighted) {
+ Color background = highlighted ? HIGHLIGHTED_COLOR : BACKGROUND_COLOR;
int width = even(DEFAULT_WIDTH*scale);
int height = (int)(DEFAULT_WIDTH*scale/ASPECT_RATIO);
int x = (int)(p.getX()*width);
int y = (int)(p.getY()*height);
- paintStoneBackground(g, x, y, width, height);
+ paintStoneBackground(g, x, y, width, height, background);
if (stone.isJoker()) {
paintJoker(g, x, y, width, height, stone);
@@ -203,6 +204,6 @@ class StonePainter {
paintStoneNumber(g, x, y, width, height, stone);
}
- paintCircle(g, x, y, width, height);
+ paintCircle(g, x, y, width, height, background);
}
}
diff --git a/src/jrummikub/view/impl/Table.java b/src/jrummikub/view/impl/Table.java
index a8c513e..e4601c5 100644
--- a/src/jrummikub/view/impl/Table.java
+++ b/src/jrummikub/view/impl/Table.java
@@ -99,7 +99,7 @@ public class Table extends JPanel implements ITable {
float x = pos.getX();
for(Stone stone : stoneSet){
- stonePainter.paintStone(g, stone, new Position(x, pos.getY()));
+ stonePainter.paintStone(g, stone, new Position(x, pos.getY()), false);
x++;
}
}