summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/StonePainter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view/impl/StonePainter.java')
-rw-r--r--src/jrummikub/view/impl/StonePainter.java33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/jrummikub/view/impl/StonePainter.java b/src/jrummikub/view/impl/StonePainter.java
index db3a477..e536e32 100644
--- a/src/jrummikub/view/impl/StonePainter.java
+++ b/src/jrummikub/view/impl/StonePainter.java
@@ -8,6 +8,7 @@ import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Rectangle2D;
+import jrummikub.model.Position;
import jrummikub.model.Stone;
import jrummikub.model.StoneColor;
@@ -36,7 +37,7 @@ class StonePainter {
return null;
}
- public static void paintStone(Graphics g, Stone stone, float x, float y, float scale) {
+ public static void paintStone(Graphics g, Stone stone, Position p, float scale) {
if (g instanceof Graphics2D) {
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
@@ -45,33 +46,33 @@ class StonePainter {
int width = (int)(DEFAULT_WIDTH*scale);
int height = (int)(DEFAULT_WIDTH*scale/ASPECT_RATIO);
- int xpos = (int)(x*width);
- int ypos = (int)(y*height);
+ int x = (int)(p.getX()*width);
+ int y = (int)(p.getY()*height);
// Paint background
g.setColor(BACKGROUND_COLOR);
- g.fillRect(xpos, ypos, width, height);
+ g.fillRect(x, y, width, height);
// Paint bevel border
g.setColor(BACKGROUND_COLOR.brighter().brighter());
- g.fillRect(xpos, ypos, 1, height);
+ g.fillRect(x, y, 1, height);
g.setColor(BACKGROUND_COLOR.brighter());
- g.fillRect(xpos+1, ypos+1, 1, height-2);
+ g.fillRect(x+1, y+1, 1, height-2);
g.setColor(BACKGROUND_COLOR.brighter().brighter());
- g.fillRect(xpos, ypos, width, 1);
+ g.fillRect(x, y, width, 1);
g.setColor(BACKGROUND_COLOR.brighter());
- g.fillRect(xpos+1, ypos+1, width-2, 1);
+ g.fillRect(x+1, y+1, width-2, 1);
g.setColor(BACKGROUND_COLOR.darker().darker());
- g.fillRect(xpos+width-1, ypos, 1, height);
+ g.fillRect(x+width-1, y, 1, height);
g.setColor(BACKGROUND_COLOR.darker());
- g.fillRect(xpos+width-2, ypos+1, 1, height-2);
+ g.fillRect(x+width-2, y+1, 1, height-2);
g.setColor(BACKGROUND_COLOR.darker().darker());
- g.fillRect(xpos, ypos+height-1, width, 1);
+ g.fillRect(x, y+height-1, width, 1);
g.setColor(BACKGROUND_COLOR.darker());
- g.fillRect(xpos+1, ypos+height-2, width-2, 1);
+ g.fillRect(x+1, y+height-2, width-2, 1);
// Paint number
g.setFont(new Font("SansSerif", Font.BOLD, height/4));
@@ -80,15 +81,15 @@ class StonePainter {
Rectangle2D stringRect = fm.getStringBounds(value, g);
g.setColor(getColor(stone.getColor()).darker());
- g.drawString(value, (int)(xpos+width/2-stringRect.getWidth()/2)+1, ypos+height/4+(fm.getAscent()-fm.getDescent())/2+1);
+ g.drawString(value, (int)(x+width/2-stringRect.getWidth()/2)+1, y+height/4+(fm.getAscent()-fm.getDescent())/2+1);
g.setColor(getColor(stone.getColor()));
- g.drawString(value, (int)(xpos+width/2-stringRect.getWidth()/2), ypos+height/4+(fm.getAscent()-fm.getDescent())/2);
+ g.drawString(value, (int)(x+width/2-stringRect.getWidth()/2), y+height/4+(fm.getAscent()-fm.getDescent())/2);
// Paint circle
g.setColor(BACKGROUND_COLOR.darker());
- g.drawArc((int)(xpos+width/2-width*CIRCLE_WIDTH/2), (int)(ypos+height*0.65f-width*CIRCLE_WIDTH/2), (int)(width*CIRCLE_WIDTH), (int)(width*CIRCLE_WIDTH), 50, 170);
+ g.drawArc((int)(x+width/2-width*CIRCLE_WIDTH/2), (int)(y+height*0.65f-width*CIRCLE_WIDTH/2), (int)(width*CIRCLE_WIDTH), (int)(width*CIRCLE_WIDTH), 50, 170);
g.setColor(BACKGROUND_COLOR.brighter());
- g.drawArc((int)(xpos+width/2-width*CIRCLE_WIDTH/2), (int)(ypos+height*0.65f-width*CIRCLE_WIDTH/2), (int)(width*CIRCLE_WIDTH), (int)(width*CIRCLE_WIDTH), -130, 170);
+ g.drawArc((int)(x+width/2-width*CIRCLE_WIDTH/2), (int)(y+height*0.65f-width*CIRCLE_WIDTH/2), (int)(width*CIRCLE_WIDTH), (int)(width*CIRCLE_WIDTH), -130, 170);
}
}