Objets formes vectorielles
par dérivation
de l'interface Shape

WB01624_.gif (281 octets) RETOUR

</COMMENT> alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet, for some reason." Your browser is completely ignoring the &lt;APPLET&gt; tag!

Shapes.class

Fichier source

Shapes.java

/* Auteur: Nicolas JANEY         */
/* nicolas.janey@univ-fcomte.fr  */
/* Novembre 2001                 */

import java.awt.*;
import java.awt.geom.*;
import java.applet.*;

public class Shapes extends Applet {

  public void init() {
    setBackground(Color.white); 
  }

  public void paint(Graphics g) {
    Graphics2D g2 =(Graphics2D) g;
    g2.setColor(new Color(0,0,0));
    g2.draw(new Line2D.Double(30,10,260,30)) ;
    g2.draw(new Ellipse2D.Double(25,40,40,70)) ;
    g2.fill(new Ellipse2D.Double(165,40,40,70)) ;
    g2.draw(new Arc2D.Double(80,40,40,70,45,170,Arc2D.Double.OPEN)) ;
    g2.fill(new Arc2D.Double(220,40,40,70,45,170,Arc2D.Double.PIE)) ;
    g2.draw(new Rectangle(20,120,120,30)) ;
    g2.fill(new Rectangle(160,120,120,30)) ;
    g2.draw(new RoundRectangle2D.Double(20,165,120,30,25,15)) ;
    g2.fill(new RoundRectangle2D.Double(160,165,120,30,25,15)) ;
    Polygon p1 = new Polygon();
    p1.addPoint(20,230); 
    p1.addPoint(60,280); 
    p1.addPoint(90,250); 
    p1.addPoint(120,270); 
    p1.addPoint(140,210); 
    g2.draw(p1);
    Polygon p2 = new Polygon();
    p2.addPoint(160,230); 
    p2.addPoint(200,280); 
    p2.addPoint(230,250); 
    p2.addPoint(260,270); 
    p2.addPoint(280,210); 
    g2.fill(p2);
  }

  public String getAppletInfo() {
    return "Objets formes vectorielles par derivation de Shape sous Java 2D.";
  }
}

RETOUR