Anti-aliasing sous Java 2D

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!

AntiAliasing.class

Fichier source

AntiAliasing.java

/* 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 AntiAliasing extends Applet {

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

  public void paint(Graphics g) {
    Graphics2D g2 =(Graphics2D) g;
    g2.setColor(new Color(0,0,0));
    Polygon p1 = new Polygon();
    p1.addPoint(20,50); 
    p1.addPoint(70,100); 
    p1.addPoint(110,70); 
    p1.addPoint(150,80); 
    p1.addPoint(180,30); 
    g2.drawPolygon(p1);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
    Polygon p2 = new Polygon();
    p2.addPoint(120,120); 
    p2.addPoint(170,170); 
    p2.addPoint(210,140); 
    p2.addPoint(250,150); 
    p2.addPoint(280,100); 
    g2.drawPolygon(p2);
  }

  public String getAppletInfo() {
    return "Anti-Aliasing sous Java 2D.";
  }
}

RETOUR