Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move sample tests in a separate file.
[graphlib_java.git] / DrawingWindow.java
index 9ab4da6..ba3d3ed 100644 (file)
@@ -28,8 +28,7 @@ import java.lang.reflect.*;
  * <a href="Exemple3.java">Exemple3.java</a>
  *
  * @author Arnaud Giersch &lt;arnaud.giersch@univ-fcomte.fr&gt;
- * @version Wed, 08 Oct 2014 21:29:23 +0200
-
+ * @version Thu Oct 9 16:03:46 2014 +0200
  */
 public class DrawingWindow {
 
@@ -296,6 +295,50 @@ public class DrawingWindow {
         panel.repaint(x - r, y - r, 2 * r + 1, 2 * r + 1);
     }
 
+    /**
+     * Dessine un triangle.
+     *
+     * Dessine un triangle défini par les coordonnées de ses sommets:
+     * (x1, y1), (x2, y2) et (x3, y3).  Utilise la couleur de dessin
+     * courante.
+     *
+     * @see #fillTriangle
+     * @see #setColor
+     */
+
+    public void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3) {
+        Polygon poly = new Polygon();
+        poly.addPoint(x1, y1);
+        poly.addPoint(x2, y2);
+        poly.addPoint(x3, y3);
+        synchronized (image) {
+            graphics.drawPolygon(poly);
+        }
+        panel.repaint(poly.getBounds());
+    }
+
+    /**
+     * Dessine un triangle plein.
+     *
+     * Dessine un triangle plein défini par les coordonnées de ses
+     * sommets: (x1, y1), (x2, y2) et (x3, y3).  Utilise la couleur de
+     * dessin courante.
+     *
+     * @see #drawTriangle
+     * @see #setColor
+     */
+    public void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3) {
+        Polygon poly = new Polygon();
+        poly.addPoint(x1, y1);
+        poly.addPoint(x2, y2);
+        poly.addPoint(x3, y3);
+        synchronized (image) {
+            graphics.drawPolygon(poly);
+            graphics.fillPolygon(poly);
+        }
+        panel.repaint(poly.getBounds());
+    }
+
     /**
      * Écrit du texte.
      *