Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add comments to examples.
[graphlib_java.git] / DrawingWindow.java
index 2ecc740..9ab4da6 100644 (file)
@@ -28,7 +28,8 @@ import java.lang.reflect.*;
  * <a href="Exemple3.java">Exemple3.java</a>
  *
  * @author Arnaud Giersch &lt;arnaud.giersch@univ-fcomte.fr&gt;
- * @version 20141008
+ * @version Wed, 08 Oct 2014 21:29:23 +0200
+
  */
 public class DrawingWindow {
 
@@ -50,7 +51,7 @@ public class DrawingWindow {
      */
     public DrawingWindow(String title, int width, int height) {
 
-        this.title = new String(title);        
+        this.title = new String(title);
         this.width = width;
         this.height = height;
 
@@ -239,7 +240,7 @@ public class DrawingWindow {
         synchronized (image) {
             graphics.drawRect(x, y, w, h);
         }
-        panel.repaint(x, y, w, h);
+        panel.repaint(x, y, w + 1, h + 1);
     }
 
     /** Dessine un rectangle plein.
@@ -254,8 +255,8 @@ public class DrawingWindow {
     public void fillRect(int x1, int y1, int x2, int y2) {
         int x = Math.min(x1, x2);
         int y = Math.min(y1, y2);
-        int w = Math.abs(x1 - x2);
-        int h = Math.abs(y1 - y2);
+        int w = Math.abs(x1 - x2) + 1;
+        int h = Math.abs(y1 - y2) + 1;
         synchronized (image) {
             graphics.fillRect(x, y, w, h);
         }
@@ -275,7 +276,7 @@ public class DrawingWindow {
         synchronized (image) {
             graphics.drawOval(x - r, y - r, 2 * r, 2 * r);
         }
-        panel.repaint(x - r, y - r, 2 * r, 2 * r);
+        panel.repaint(x - r, y - r, 2 * r + 1, 2 * r + 1);
     }
 
     /**
@@ -289,9 +290,10 @@ public class DrawingWindow {
      */
     public void fillCircle(int x, int y, int r) {
         synchronized (image) {
+            graphics.drawOval(x - r, y - r, 2 * r, 2 * r);
             graphics.fillOval(x - r, y - r, 2 * r, 2 * r);
         }
-        panel.repaint(x - r, y - r, 2 * r, 2 * r);
+        panel.repaint(x - r, y - r, 2 * r + 1, 2 * r + 1);
     }
 
     /**