1 import java.applet.*; 2 import java.awt.*; 3 import JSci.maths.chaos.*; 4 5 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 public void init() { 16 width=getSize().width; 17 height=getSize().height; 18 img=createImage(width, height); 19 dust=new CantorDustGraphic(img.getGraphics()); 20 dust.draw(0, width, N); 21 } 22 public void paint(Graphics g) { 23 g.drawImage(img, 0, 0, this); 24 } 25 class CantorDustGraphic extends CantorDust { 26 private final Graphics g; 27 public CantorDustGraphic(Graphics grafixs) { 28 g=grafixs; 29 } 30 public void draw(int start, int end, int n) { 31 g.setColor(Color.black); 32 g.drawLine(start, height/2, end, height/2); 33 g.setColor(getBackground()); 34 recurse(start, end, n); 35 } 36 protected void eraseLine(double start, double end) { 37 g.drawLine((int)Math.round(start), height/2, (int)Math.round(end), height/2); 38 } 39 } 40 } 41 42 | Popular Tags |