Back to index

plt-scheme  4.2.1
Canvas.java
Go to the documentation of this file.
00001 package draw;
00002 
00003 import geometry.*;
00004 import colors.*;
00005         
00006 public class Canvas {
00007     private int width = 0; 
00008     private int height = 0; 
00009 
00015     public Canvas(int width, int height) { 
00016        this.width = width; 
00017        this.height = height; 
00018     }
00019     
00020     // these two are cheats: 
00021     protected native boolean copy();
00022     protected native boolean stop();
00023     // I need to figure out how to accomplish these two things, especially stop,
00024     // directly at the Scheme level w/o going thru the Java layer.
00025      
00026     private boolean showing = false; 
00027 
00035     public boolean show() { 
00036        if (!showing) {
00037            xshow();
00038            showing = true; 
00039        }
00040        return true; 
00041     }
00042 
00043     
00048     public boolean close() { 
00049        xclose(); 
00050        showing = false; 
00051        return true; 
00052     }
00053            
00054     public native boolean xshow();
00055     public native boolean xclose();
00056 
00063     public native boolean drawCircle(Posn p, int r, IColor c);
00064 
00071     public native boolean drawDisk(Posn p, int r, IColor c);
00072 
00080     public native boolean drawRect(Posn p, int width, int height, IColor c);
00081 
00088     public native boolean drawLine(Posn p0, Posn p1, IColor c);
00089 
00095     public native boolean drawString(Posn p, String s);
00096 
00097 }