summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/StonePainter.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-08 21:58:16 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-08 21:58:16 +0200
commit45d5b3ae10ed8cfbecb5489636093c6fb0576970 (patch)
tree1aa1c012f46fe204d997e8c6896940800f5461bb /src/jrummikub/view/impl/StonePainter.java
parent2e376414b941da3c6fa3c20ddad085c695175542 (diff)
downloadJRummikub-45d5b3ae10ed8cfbecb5489636093c6fb0576970.tar
JRummikub-45d5b3ae10ed8cfbecb5489636093c6fb0576970.zip
Implement pause function
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@390 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/StonePainter.java')
-rw-r--r--src/jrummikub/view/impl/StonePainter.java86
1 files changed, 40 insertions, 46 deletions
diff --git a/src/jrummikub/view/impl/StonePainter.java b/src/jrummikub/view/impl/StonePainter.java
index ea52387..298f9ac 100644
--- a/src/jrummikub/view/impl/StonePainter.java
+++ b/src/jrummikub/view/impl/StonePainter.java
@@ -60,8 +60,7 @@ class StonePainter {
int g = (int) (color.getGreen() * BRIGHTER_SCALE);
int b = (int) (color.getBlue() * BRIGHTER_SCALE);
- return new Color(r > 255 ? 255 : r, g > 255 ? 255 : g, b > 255 ? 255
- : b);
+ return new Color(r > 255 ? 255 : r, g > 255 ? 255 : g, b > 255 ? 255 : b);
}
private static Color hover(Color color) {
@@ -69,28 +68,27 @@ class StonePainter {
int g = (int) (color.getGreen() * HOVER_RATIO + 255 * (1 - HOVER_RATIO));
int b = (int) (color.getBlue() * HOVER_RATIO + 255 * (1 - HOVER_RATIO));
- return new Color(r > 255 ? 255 : r, g > 255 ? 255 : g, b > 255 ? 255
- : b);
+ return new Color(r > 255 ? 255 : r, g > 255 ? 255 : g, b > 255 ? 255 : b);
}
public static Color getColor(StoneColor color) {
switch (color) {
- case BLACK:
- return new Color(0.0f, 0.0f, 0.0f);
- case BLUE:
- return new Color(0.0f, 0.0f, 1.0f);
- case ORANGE:
- return new Color(1.0f, 0.4f, 0.0f);
- case RED:
- return new Color(0.9f, 0.0f, 0.25f);
- case AQUA:
- return new Color(0.0f, 0.85f, 0.75f);
- case GREEN:
- return new Color(0.0f, 0.65f, 0.0f);
- case VIOLET:
- return new Color(0.75f, 0.325f, 0.75f);
- case GRAY:
- return new Color(0.5f, 0.5f, 0.5f);
+ case BLACK:
+ return new Color(0.0f, 0.0f, 0.0f);
+ case BLUE:
+ return new Color(0.0f, 0.0f, 1.0f);
+ case ORANGE:
+ return new Color(1.0f, 0.4f, 0.0f);
+ case RED:
+ return new Color(0.9f, 0.0f, 0.25f);
+ case AQUA:
+ return new Color(0.0f, 0.85f, 0.75f);
+ case GREEN:
+ return new Color(0.0f, 0.65f, 0.0f);
+ case VIOLET:
+ return new Color(0.75f, 0.325f, 0.75f);
+ case GRAY:
+ return new Color(0.5f, 0.5f, 0.5f);
}
return null;
@@ -100,7 +98,7 @@ class StonePainter {
* Sets the new grid scale
*
* @param scale
- * the new scale
+ * the new scale
*/
public void setScale(double scale) {
this.scale = scale;
@@ -114,9 +112,9 @@ class StonePainter {
/**
* @param x
- * x position in screen coordinates
+ * x position in screen coordinates
* @param y
- * y position in screen coordinates
+ * y position in screen coordinates
* @return position in grid coordinates
*/
public Position calculatePosition(int x, int y) {
@@ -211,21 +209,19 @@ class StonePainter {
defaultStones.put(color, new HashMap<Integer, BufferedImage>());
selectedStones.put(color, new HashMap<Integer, BufferedImage>());
hoveredStones.put(color, new HashMap<Integer, BufferedImage>());
- hoveredSelectedStones.put(color,
- new HashMap<Integer, BufferedImage>());
+ hoveredSelectedStones.put(color, new HashMap<Integer, BufferedImage>());
}
}
/**
* @param scale
- * the scaling factor for the grid coordinates
+ * the scaling factor for the grid coordinates
*/
StonePainter(double scale) {
setScale(scale);
}
- private void paintStoneBackground(Graphics2D g, Rectangle r,
- Color background) {
+ private void paintStoneBackground(Graphics2D g, Rectangle r, Color background) {
// Paint background
g.setColor(background);
g.fillRect(r.x, r.y, r.width, r.height);
@@ -326,9 +322,8 @@ class StonePainter {
pos + (fm.getAscent() - fm.getDescent()) / 2 + 1);
}
g.setColor(color);
- g.drawString(value,
- (int) (r.x + r.width / 2 - stringRect.getWidth() / 2), pos
- + (fm.getAscent() - fm.getDescent()) / 2);
+ g.drawString(value, (int) (r.x + r.width / 2 - stringRect.getWidth() / 2),
+ pos + (fm.getAscent() - fm.getDescent()) / 2);
}
private void paintCircle(Graphics2D g, Rectangle r, Color background) {
@@ -337,42 +332,41 @@ class StonePainter {
// Paint circle
g.setColor(background.darker());
- g.drawArc(r.x + r.width / 2 - size / 2, pos - size / 2, size, size, 50,
- 170);
+ g.drawArc(r.x + r.width / 2 - size / 2, pos - size / 2, size, size, 50, 170);
g.setColor(brighter(background));
- g.drawArc((int) (r.x + r.width / 2 - size / 2), pos - size / 2, size,
- size, -130, 170);
+ g.drawArc((int) (r.x + r.width / 2 - size / 2), pos - size / 2, size, size,
+ -130, 170);
}
/**
* Paints a stone
*
* @param g
- * the graphics context to paint the stone on
+ * the graphics context to paint the stone on
* @param stone
- * the stone to paint
+ * the stone to paint
* @param p
- * the position of the stone
+ * the position of the stone
* @param selected
- * if selected is true the stone will be painted darker
+ * if selected is true the stone will be painted darker
* @param hovered
- * if hovered is true the stone will be painted brighter
+ * if hovered is true the stone will be painted brighter
*/
public void paintStone(Graphics2D g, Stone stone, Position p,
boolean selected, boolean hovered) {
int width = getStoneWidth();
int height = getStoneHeight();
- int x = (int) Math.round(p.getX() * width), y = (int) Math.round(p
- .getY() * height);
+ int x = (int) Math.round(p.getX() * width), y = (int) Math.round(p.getY()
+ * height);
if (stone.isJoker()) {
- g.drawImage(getStoneImage(stone.getColor(), 0, selected, hovered),
- x, y, null);
+ g.drawImage(getStoneImage(stone.getColor(), 0, selected, hovered), x, y,
+ null);
} else {
g.drawImage(
- getStoneImage(stone.getColor(), stone.getValue(), selected,
- hovered), x, y, null);
+ getStoneImage(stone.getColor(), stone.getValue(), selected, hovered),
+ x, y, null);
}
}
}