summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/StonePainter.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-04-30 23:17:48 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-04-30 23:17:48 +0200
commitd262d91b076cbaa322d49818476b251c06cee42e (patch)
tree5289130de3d010483318e6559dd3ad59a6829e71 /src/jrummikub/view/impl/StonePainter.java
parent28f1ecd987dbe86a59ce474f3f58eb75838edc68 (diff)
downloadJRummikub-d262d91b076cbaa322d49818476b251c06cee42e.tar
JRummikub-d262d91b076cbaa322d49818476b251c06cee42e.zip
Add display for selected stones above board
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@41 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/StonePainter.java')
-rw-r--r--src/jrummikub/view/impl/StonePainter.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/jrummikub/view/impl/StonePainter.java b/src/jrummikub/view/impl/StonePainter.java
index 9bdca05..600a570 100644
--- a/src/jrummikub/view/impl/StonePainter.java
+++ b/src/jrummikub/view/impl/StonePainter.java
@@ -73,12 +73,20 @@ class StonePainter {
* @return position in grid coordinates
*/
public Position calculatePosition(int x, int y){
- float width = even(DEFAULT_WIDTH*scale);
- float height = (int)(DEFAULT_WIDTH*scale/ASPECT_RATIO);
+ float width = getStoneWidth();
+ float height = getStoneHeight();
return new Position(x/width, y/height);
}
+ public int getStoneWidth() {
+ return even(DEFAULT_WIDTH*scale);
+ }
+
+ public int getStoneHeight() {
+ return (int)(DEFAULT_WIDTH*scale/ASPECT_RATIO);
+ }
+
StonePainter(float scale) {
this.scale = scale;
}
@@ -199,8 +207,8 @@ class StonePainter {
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 width = getStoneWidth();
+ int height = getStoneHeight();
int x = (int)(p.getX()*width);
int y = (int)(p.getY()*height);