Back to index

plt-scheme  4.2.1
Canvas.java
Go to the documentation of this file.
00001 package idraw;
00002 
00003 import colors.*;
00004 import geometry.*;
00005         
00006 public class Canvas {
00007     private int width = 0; 
00008     private int height = 0; 
00009 
00010     public Canvas(int width, int height) { 
00011        this.width = width; 
00012        this.height = height; 
00013     }
00014     
00015     // these two are cheats: 
00016     protected native void copy();
00017     protected native void stop();
00018     // MF: I need to figure out how to accomplish these two things, especially
00019     //     stop, directly at the Scheme level w/o going thru the Java layer.
00020      
00021     private boolean showing = false; 
00022 
00023     public void show() { 
00024        if (!showing) {
00025            xshow();
00026            showing = true; 
00027        }
00028        return ; 
00029     }
00030 
00031     public void close() { 
00032        xclose(); 
00033        showing = false; 
00034        return ; 
00035     }
00036            
00037     public native void xshow();
00038     public native void xclose();
00039     public native void drawCircle(Posn p, int r, IColor c);
00040     public native void drawDisk(Posn p, int r, IColor c);
00041     public native void drawRect(Posn p, int width, int height, IColor c);
00042     public native void drawLine(Posn p0, Posn p1, IColor c);
00043     public native void drawString(Posn p, String s);
00044 }