diff options
author | Adam NAILI | 2018-01-14 20:35:08 +0100 |
---|---|---|
committer | Adam NAILI | 2018-01-14 20:35:08 +0100 |
commit | d1c6b2f6a9fe6af75f1668e25d96ec4380f69f76 (patch) | |
tree | 72654a19214a8cbf8a47cb13dfa74b732fc23eef /src | |
parent | 7f7b25c81a81331f538b26b98b5e1e8f71bc1450 (diff) | |
download | wallj-d1c6b2f6a9fe6af75f1668e25d96ec4380f69f76.tar.gz |
Modifying implementation of paintCircle to center the cicle when it is smaller and implementing paintString to print text on screen
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/fr/umlv/java/wallj/context/GraphicsContext.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/context/GraphicsContext.java b/src/main/java/fr/umlv/java/wallj/context/GraphicsContext.java index 0475973..2c1c72a 100644 --- a/src/main/java/fr/umlv/java/wallj/context/GraphicsContext.java +++ b/src/main/java/fr/umlv/java/wallj/context/GraphicsContext.java | |||
@@ -1,5 +1,6 @@ | |||
1 | package fr.umlv.java.wallj.context; | 1 | package fr.umlv.java.wallj.context; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.board.TileVec2; | ||
3 | import fr.umlv.zen5.ScreenInfo; | 4 | import fr.umlv.zen5.ScreenInfo; |
4 | import org.jbox2d.common.Vec2; | 5 | import org.jbox2d.common.Vec2; |
5 | 6 | ||
@@ -47,7 +48,7 @@ public final class GraphicsContext { | |||
47 | */ | 48 | */ |
48 | public void paintCircle(Color color, Vec2 position, float size) { | 49 | public void paintCircle(Color color, Vec2 position, float size) { |
49 | graphics2D.setColor(color); | 50 | graphics2D.setColor(color); |
50 | graphics2D.fill(new Ellipse2D.Float(position.x, position.y, size, size)); | 51 | graphics2D.fillOval(Math.round(position.x + (TileVec2.TILE_DIM - size) / 2) - 1, Math.round(position.y + (TileVec2.TILE_DIM - size) / 2) - 1, Math.round(size), Math.round(size)); |
51 | } | 52 | } |
52 | 53 | ||
53 | /** | 54 | /** |
@@ -58,6 +59,11 @@ public final class GraphicsContext { | |||
58 | */ | 59 | */ |
59 | public void paintRectangle(Color color, Vec2 position, float width, float height) { | 60 | public void paintRectangle(Color color, Vec2 position, float width, float height) { |
60 | graphics2D.setColor(color); | 61 | graphics2D.setColor(color); |
61 | graphics2D.fill(new Rectangle2D.Float(position.x, position.y, width, height)); | 62 | graphics2D.fillRect(Math.round(position.x), Math.round(position.y), Math.round(width), Math.round(height)); |
63 | } | ||
64 | |||
65 | public void paintString(Color color, Vec2 position, String string){ | ||
66 | graphics2D.setColor(color); | ||
67 | graphics2D.drawString(string,position.x, position.y); | ||
62 | } | 68 | } |
63 | } | 69 | } |