01: import java.applet.*;
02: import java.awt.*;
03: import JSci.maths.chaos.*;
04:
05: /**
06: * Plot of Cantor dust.
07: * @author Mark Hale
08: * @version 1.0
09: */
10: public final class CantorDustPlot extends Applet {
11: private final int N = 5;
12: private Image img;
13: private CantorDustGraphic dust;
14: private int width, height;
15:
16: public void init() {
17: width = getSize().width;
18: height = getSize().height;
19: img = createImage(width, height);
20: dust = new CantorDustGraphic(img.getGraphics());
21: dust.draw(0, width, N);
22: }
23:
24: public void paint(Graphics g) {
25: g.drawImage(img, 0, 0, this );
26: }
27:
28: class CantorDustGraphic extends CantorDust {
29: private final Graphics g;
30:
31: public CantorDustGraphic(Graphics grafixs) {
32: g = grafixs;
33: }
34:
35: public void draw(int start, int end, int n) {
36: g.setColor(Color.black);
37: g.drawLine(start, height / 2, end, height / 2);
38: g.setColor(getBackground());
39: recurse(start, end, n);
40: }
41:
42: protected void eraseLine(double start, double end) {
43: g.drawLine((int) Math.round(start), height / 2, (int) Math
44: .round(end), height / 2);
45: }
46: }
47: }
|