39 lines
936 B
Java
39 lines
936 B
Java
|
import java.awt.*;
|
||
|
import javax.swing.*;
|
||
|
|
||
|
public class Polyligne extends JComponent {
|
||
|
Point p1;
|
||
|
Point p2;
|
||
|
|
||
|
ProducteurDePoints pp;
|
||
|
|
||
|
public Polyligne(ProducteurDePoints arg) {
|
||
|
super();
|
||
|
pp = arg;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void paintComponent(Graphics brush) {
|
||
|
Graphics newBrush = brush.create();
|
||
|
|
||
|
if (this.isOpaque()) {
|
||
|
newBrush.setColor(this.getBackground());
|
||
|
newBrush.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||
|
}
|
||
|
|
||
|
newBrush.setColor(Color.BLACK);
|
||
|
System.out.println("Test");
|
||
|
|
||
|
while (true) {
|
||
|
if (p1 != null) {
|
||
|
newBrush.drawLine(p1.x, p1.y, p2.x, p2.y);
|
||
|
p1 = p2;
|
||
|
p2 = pp.suivant();
|
||
|
if (p2 == null) break;
|
||
|
} else {
|
||
|
p1 = pp.suivant();
|
||
|
p2 = pp.suivant();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|