Objets formes
vectorielles
sous Java 2D
FormesVectorielles.class
Fichier source
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Novembre 2001 */
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class FormesVectorielles extends Applet {
public void init() {
setBackground(Color.white);
}
public void paint(Graphics g) {
Graphics2D g2 =(Graphics2D) g;
g2.drawOval(25,40,40,70) ;
g2.fillOval(165,40,40,70) ;
g2.drawArc(80,40,40,70,45,170) ;
g2.fillArc(220,40,40,70,45,170) ;
g2.drawLine(30,10,260,30) ;
g2.drawRect(20,120,120,30) ;
g2.fillRect(160,120,120,30) ;
g2.drawRoundRect(20,165,120,30,25,15) ;
g2.fillRoundRect(160,165,120,30,25,15) ;
g2.setColor(new Color(0,0,0));
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.drawPolygon(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.fillPolygon(p2);
}
public String getAppletInfo() {
return "Objets formes vectorielles sous Java 2D.";
}
}