import java.awt.Graphics2D; import java.awt.geom.Line2D; /** D'après Jean Brondeau */ public abstract class Courbe extends Thread { private static final long serialVersionUID = 1L; protected double position; protected int vitesse; protected Graphics2D graphics; protected int largeur; public Courbe(int vitesse, Graphics2D g, int largeur) { this.vitesse = vitesse; this.graphics = g; this.largeur = largeur; position = 0.; } public void run() { int periode = 100 / vitesse; double yp = fonction(position); Line2D line = new Line2D.Double(); while (position < largeur) { try { sleep(periode); position++; double y = fonction(position); line.setLine(position - 1, yp, position, y); graphics.draw(line); yp = y; } catch (InterruptedException e) { } } } public abstract double fonction(double x); }