summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/StonePainter.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-02 05:12:53 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-02 05:12:53 +0200
commitfcef81715bff95ac04176dd3d93bb44e1b625087 (patch)
treee02dcb3d31185afe5943680e1e4549f4ce66775c /src/jrummikub/view/impl/StonePainter.java
parenta9cf0d8c8fb5b489f07e4cc408cc5edf413ce26e (diff)
downloadJRummikub-fcef81715bff95ac04176dd3d93bb44e1b625087.tar
JRummikub-fcef81715bff95ac04176dd3d93bb44e1b625087.zip
Add JavaDoc to view implementation
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@66 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/StonePainter.java')
-rw-r--r--src/jrummikub/view/impl/StonePainter.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/jrummikub/view/impl/StonePainter.java b/src/jrummikub/view/impl/StonePainter.java
index ab523a7..47c0e9b 100644
--- a/src/jrummikub/view/impl/StonePainter.java
+++ b/src/jrummikub/view/impl/StonePainter.java
@@ -14,6 +14,10 @@ import jrummikub.model.Position;
import jrummikub.model.Stone;
import jrummikub.model.StoneColor;
+/**
+ * The StonePainter paints stones and converts between pixel and grid
+ * coordinates
+ */
class StonePainter {
private static final float ASPECT_RATIO = 0.75f;
private static final float DEFAULT_WIDTH = 40;
@@ -27,7 +31,13 @@ class StonePainter {
private static final float BRIGHTER_SCALE = 1.15f;
+ /**
+ * The width of one pixel in the scale of 1.0
+ */
public static final float WIDTH_SCALE = 1 / DEFAULT_WIDTH;
+ /**
+ * The height of one pixel in the scale of 1.0
+ */
public static final float HEIGHT_SCALE = ASPECT_RATIO / DEFAULT_WIDTH;
private float scale;
@@ -59,10 +69,19 @@ class StonePainter {
return null;
}
+ /**
+ * Sets the new grid scale
+ *
+ * @param scale
+ * the new scale
+ */
public void setScale(float scale) {
this.scale = scale;
}
+ /**
+ * @return the current grid scale
+ */
public float getScale() {
return scale;
}
@@ -81,14 +100,24 @@ class StonePainter {
return new Position(x / width, y / height);
}
+ /**
+ * @return the width of a stone in the current scale in pixels
+ */
public int getStoneWidth() {
return even(DEFAULT_WIDTH * scale);
}
+ /**
+ * @return the height of a stone in the current scale in pixels
+ */
public int getStoneHeight() {
return (int) (DEFAULT_WIDTH * scale / ASPECT_RATIO);
}
+ /**
+ * @param scale
+ * the scaling factor for the grid coordinates
+ */
StonePainter(float scale) {
this.scale = scale;
}
@@ -208,6 +237,18 @@ class StonePainter {
-130, 170);
}
+ /**
+ * Paints a stone
+ *
+ * @param g
+ * the graphics context to paint the stone on
+ * @param stone
+ * the stone to paint
+ * @param p
+ * the position of the stone
+ * @param selected
+ * if selected is true the stone will be painted darker
+ */
public void paintStone(Graphics2D g, Stone stone, Position p, boolean selected) {
Color background = selected ? SELECTED_COLOR : BACKGROUND_COLOR;
int width = getStoneWidth();