import java.applet.*; import java.awt.*; import java.lang.Math; import java.lang.Object; public class Blob extends Applet { public class point implements Cloneable{ public int x; public int y; public Object clone(){ //begin clone try{ //begin try return super.clone(); } //end try catch(CloneNotSupportedException e){ // begin catch return null; //if there is a catch } //end catch } //end cloning structure for point } //end point def public class rpoint implements Cloneable{ public double x; public double y; public double z; public Object clone(){ //begin clone try{ //begin try return super.clone(); } //end try catch(CloneNotSupportedException e){ // begin catch return null; //if there is a catch } //end catch } //end cloning structure for point } //end rpoint def public class Gsphere implements Cloneable{ public rpoint[][] sphere=new rpoint[mesh][mesh]; public point[][] osphere=new point[mesh][mesh]; public Object clone(){ //begin clone try{ //begin try Gsphere s=(Gsphere)super.clone(); s.sphere=(rpoint[][])sphere.clone(); s.osphere=(point[][])osphere.clone(); return s; } //end try catch(CloneNotSupportedException e){ return null; }//end catch } //end cloning structure for gsphere } // end Sphere def public int mesh=30; private int i; private int j; private int xxpix; private int xypix; private int yypix; private int yxpix; private int zypix; private double pie=3.14159265359; private double dirx=15*Math.cos(pie/3); private double diry=15*Math.sin(pie/3); private int last_x=0; private int last_y=0; private Color current_color=Color.black; private Button clear_button; private Button draw_button; private Choice ang_choices; public Gsphere er =new Gsphere(); public Gsphere cs = new Gsphere(); public Gsphere grid =new Gsphere(); private double radius; private double xmult=0.5; private double mult=0.01; private double phi=0.0; private double psi=0.0; private int delX; private int delY; //init applet public void init(){ //set backgd color this.setBackground(Color.white); //create a button clear_button=new Button("Clear"); clear_button.setForeground(Color.black); clear_button.setBackground(Color.lightGray); this.add(clear_button); //create a button draw_button=new Button("Draw Cube"); draw_button.setForeground(Color.black); draw_button.setBackground(Color.lightGray); this.add(draw_button); } //end init applet //called when mouse click public boolean mouseDown(Event e, int x, int y){ last_x=x; last_y=y; return true; } //called when mouse moves public boolean mouseDrag(Event e, int x, int y){ Graphics g=this.getGraphics(); er=(Gsphere)cs.clone(); // figure phi and psi delX=x - last_x; delY=y - last_y; phi=phi+ mult*delX; psi=psi- mult*delY; //figure vertices g.setColor(Color.white); //draw g.setColor(Color.black); last_x=x; last_y=y; return true; } //user clicks button or chooses a color public boolean action(Event event, Object arg){ if(event.target==clear_button){ Graphics g=this.getGraphics(); Rectangle r=this.bounds(); g.setColor(this.getBackground()); g.fillRect(r.x,r.y,r.width,r.height); return true; } //end clear // in case of click else if(event.target==draw_button){ // draw Graphics g=this.getGraphics(); g.setColor(Color.black); for(j=1;j<20;j++){ radius=3.0; cs.sphere[1][1].x=0.0; // cs.osphere[0][j].y=220; } //end for j init for(i=1;i