AColor went to IColor

svn: r7541
This commit is contained in:
Matthias Felleisen 2007-10-20 17:47:27 +00:00
parent 9a0ec1c0bf
commit 75b33996b1
14 changed files with 57 additions and 67 deletions

View File

@ -1,3 +0,0 @@
package colors;
public abstract class AColor { }

View File

@ -1,3 +1,3 @@
package colors; package colors;
public class Black extends AColor { } public class Black implements IColor { }

View File

@ -1,3 +1,3 @@
package colors; package colors;
public class Blue extends AColor { } public class Blue implements IColor { }

View File

@ -1,3 +1,3 @@
package colors; package colors;
public class Green extends AColor { } public class Green implements IColor { }

View File

@ -0,0 +1,3 @@
package colors;
public interface IColor { }

View File

@ -1,3 +1,3 @@
package colors; package colors;
public class Red extends AColor { } public class Red implements IColor { }

View File

@ -1,3 +1,3 @@
package colors; package colors;
public class White extends AColor { } public class White implements IColor { }

View File

@ -1,3 +1,3 @@
package colors; package colors;
public class Yellow extends AColor { } public class Yellow implements IColor { }

View File

@ -14,7 +14,7 @@
(compile-java 'file 'file 'full (compile-java 'file 'file 'full
(build-path draw-path file) (build-path draw-path file)
#f #f))))) #f #f)))))
(javac "AColor.java") (javac "IColor.java")
(javac "Red.java") (javac "Red.java")
(javac "White.java") (javac "White.java")
(javac "Blue.java") (javac "Blue.java")

View File

@ -60,7 +60,7 @@ public class Canvas {
*@param c its outline color *@param c its outline color
*@return true, if it can draw the circle into this canvas *@return true, if it can draw the circle into this canvas
*/ */
public native boolean drawCircle(Posn p, int r, AColor c); public native boolean drawCircle(Posn p, int r, IColor c);
/** /**
*@param p the center of the disk *@param p the center of the disk
@ -68,7 +68,7 @@ public class Canvas {
*@param c its fill and outline color *@param c its fill and outline color
*@return true, if it can draw the disk into this canvas *@return true, if it can draw the disk into this canvas
*/ */
public native boolean drawDisk(Posn p, int r, AColor c); public native boolean drawDisk(Posn p, int r, IColor c);
/** /**
*@param p the upper left of the rectangle *@param p the upper left of the rectangle
@ -77,7 +77,7 @@ public class Canvas {
*@param c its outline color *@param c its outline color
*@return true, if it can draw the rectangle into this canvas *@return true, if it can draw the rectangle into this canvas
*/ */
public native boolean drawRect(Posn p, int width, int height, AColor c); public native boolean drawRect(Posn p, int width, int height, IColor c);
/** /**
*@param p0 the first point on the line *@param p0 the first point on the line
@ -85,7 +85,7 @@ public class Canvas {
*@param c its color *@param c its color
*@return true, if it can draw the line into this canvas *@return true, if it can draw the line into this canvas
*/ */
public native boolean drawLine(Posn p0, Posn p1, AColor c); public native boolean drawLine(Posn p0, Posn p1, IColor c);
/** /**
*@param p the position of the baseline of the string *@param p the position of the baseline of the string

View File

@ -17,19 +17,19 @@ public class SillyCanvas extends Canvas {
throw new RuntimeException("SillyCanvas: bad size"); throw new RuntimeException("SillyCanvas: bad size");
} }
public boolean drawCircle(Posn p, int r, AColor c) { public boolean drawCircle(Posn p, int r, IColor c) {
return super.drawCircle(p,r,c) && warning(); return super.drawCircle(p,r,c) && warning();
} }
public boolean drawDisk(Posn p, int r, AColor c) { public boolean drawDisk(Posn p, int r, IColor c) {
return super.drawDisk(p,r,c) && warning(); return super.drawDisk(p,r,c) && warning();
} }
public boolean drawRect(Posn p, int width, int height, AColor c) { public boolean drawRect(Posn p, int width, int height, IColor c) {
return super.drawRect(p,width,height,c) && warning(); return super.drawRect(p,width,height,c) && warning();
} }
public boolean drawLine(Posn p0, Posn p1, AColor c) { public boolean drawLine(Posn p0, Posn p1, IColor c) {
return super.drawLine(p0,p1,c) && warning(); return super.drawLine(p0,p1,c) && warning();
} }

View File

@ -21,10 +21,10 @@
xclose-native xclose-native
stop-native stop-native
copy-native copy-native
drawCircle-geometry.Posn-int-colors.AColor-native drawCircle-geometry.Posn-int-colors.IColor-native
drawDisk-geometry.Posn-int-colors.AColor-native drawDisk-geometry.Posn-int-colors.IColor-native
drawRect-geometry.Posn-int-int-colors.AColor-native drawRect-geometry.Posn-int-int-colors.IColor-native
drawLine-geometry.Posn-geometry.Posn-colors.AColor-native drawLine-geometry.Posn-geometry.Posn-colors.IColor-native
drawString-geometry.Posn-java.lang.String-native drawString-geometry.Posn-java.lang.String-native
)) ))
@ -117,23 +117,23 @@
(define (copy-native this accs gets privates) (define (copy-native this accs gets privates)
(wrap-start-check ([hash-table-get privates 'copy]))) (wrap-start-check ([hash-table-get privates 'copy])))
(define (drawCircle-geometry.Posn-int-colors.AColor-native this accs gets privates posn r c) (define (drawCircle-geometry.Posn-int-colors.IColor-native this accs gets privates posn r c)
(wrap-start-check (wrap-start-check
(check-arg r "drawCircle(Posn, int, AColor)" "second") (check-arg r "drawCircle(Posn, int, IColor)" "second")
([hash-table-get privates '%draw-circle] (build-posn posn) r (color->symbol c)))) ([hash-table-get privates '%draw-circle] (build-posn posn) r (color->symbol c))))
(define (drawDisk-geometry.Posn-int-colors.AColor-native this accs gets privates posn r c) (define (drawDisk-geometry.Posn-int-colors.IColor-native this accs gets privates posn r c)
(wrap-start-check (wrap-start-check
(check-arg r "drawDisk(Posn, int, AColor)" "second") (check-arg r "drawDisk(Posn, int, IColor)" "second")
([hash-table-get privates '%draw-solid-disk] (build-posn posn) r (color->symbol c)))) ([hash-table-get privates '%draw-solid-disk] (build-posn posn) r (color->symbol c))))
(define (drawRect-geometry.Posn-int-int-colors.AColor-native this accs gets privates posn w h c) (define (drawRect-geometry.Posn-int-int-colors.IColor-native this accs gets privates posn w h c)
(wrap-start-check (wrap-start-check
(check-arg w "drawRect(Posn, int, int, AColor)" "second") (check-arg w "drawRect(Posn, int, int, IColor)" "second")
(check-arg h "drawRect(Posn, int, int, AColor)" "third") (check-arg h "drawRect(Posn, int, int, IColor)" "third")
([hash-table-get privates '%draw-solid-rect] (build-posn posn) w h (color->symbol c)))) ([hash-table-get privates '%draw-solid-rect] (build-posn posn) w h (color->symbol c))))
(define (drawLine-geometry.Posn-geometry.Posn-colors.AColor-native this accs gets privates p0 p1 c) (define (drawLine-geometry.Posn-geometry.Posn-colors.IColor-native this accs gets privates p0 p1 c)
(wrap-start-check (wrap-start-check
([hash-table-get privates '%draw-solid-line] (build-posn p0) (build-posn p1) (color->symbol c)))) ([hash-table-get privates '%draw-solid-line] (build-posn p0) (build-posn p1) (color->symbol c))))
@ -144,26 +144,26 @@
([hash-table-get privates '%draw-string] (build-posn p) s*))) ([hash-table-get privates '%draw-string] (build-posn p) s*)))
#; #;
(define (clearCircle-geometry.Posn-int-colors.AColor-native this accs gets privates p r c) (define (clearCircle-geometry.Posn-int-colors.IColor-native this accs gets privates p r c)
(wrap-start-check (wrap-start-check
(check-arg r "clearCircle(Posn, int, AColor)" "second") (check-arg r "clearCircle(Posn, int, IColor)" "second")
([hash-table-get privates '%clear-circle] (build-posn p) r (color->symbol c)))) ([hash-table-get privates '%clear-circle] (build-posn p) r (color->symbol c))))
#; #;
(define (clearDisk-geometry.Posn-int-colors.AColor-native this accs gets privates p r c) (define (clearDisk-geometry.Posn-int-colors.IColor-native this accs gets privates p r c)
(wrap-start-check (wrap-start-check
(check-arg r "clearDisk(Posn, int, AColor)" "second") (check-arg r "clearDisk(Posn, int, IColor)" "second")
([hash-table-get privates '%clear-solid-disk] (build-posn p) r (color->symbol c)))) ([hash-table-get privates '%clear-solid-disk] (build-posn p) r (color->symbol c))))
#; #;
(define (clearRect-geometry.Posn-int-int-colors.AColor-native this accs gets privates p w h c) (define (clearRect-geometry.Posn-int-int-colors.IColor-native this accs gets privates p w h c)
(wrap-start-check (wrap-start-check
(check-arg w "clearRect(Posn, int, int, AColor)" "second") (check-arg w "clearRect(Posn, int, int, IColor)" "second")
(check-arg h "clearRect(Posn, int, int, AColor)" "third") (check-arg h "clearRect(Posn, int, int, IColor)" "third")
([hash-table-get privates '%clear-solid-rect] (build-posn p) w h (color->symbol c)))) ([hash-table-get privates '%clear-solid-rect] (build-posn p) w h (color->symbol c))))
#; #;
(define (clearLine-geometry.Posn-geometry.Posn-colors.AColor-native this accs gets privates p0 p1 c) (define (clearLine-geometry.Posn-geometry.Posn-colors.IColor-native this accs gets privates p0 p1 c)
(wrap-start-check (wrap-start-check
([hash-table-get privates '%clear-solid-line] (build-posn p0) (build-posn p1) (color->symbol c)))) ([hash-table-get privates '%clear-solid-line] (build-posn p0) (build-posn p1) (color->symbol c))))
) )

View File

@ -4,22 +4,22 @@ import colors.*;
import geometry.*; import geometry.*;
public class Canvas { public class Canvas {
private int width = 0; private int width = 0;
private int height = 0; private int height = 0;
public Canvas(int width, int height) { public Canvas(int width, int height) {
this.width = width; this.width = width;
this.height = height; this.height = height;
} }
// these two are cheats: // these two are cheats:
protected native void copy(); protected native void copy();
protected native void stop(); protected native void stop();
// MF: I need to figure out how to accomplish these two things, especially // MF: I need to figure out how to accomplish these two things, especially
// stop, directly at the Scheme level w/o going thru the Java layer. // stop, directly at the Scheme level w/o going thru the Java layer.
private boolean showing = false; private boolean showing = false;
public void show() { public void show() {
if (!showing) { if (!showing) {
xshow(); xshow();
@ -27,17 +27,18 @@ public class Canvas {
} }
return ; return ;
} }
public void close() { public void close() {
xclose(); xclose();
showing = false; showing = false;
return ; return ;
} }
public native void xshow(); public native void xshow();
public native void xclose(); public native void xclose();
public native void drawCircle(Posn p, int r, AColor c); public native void drawCircle(Posn p, int r, IColor c);
public native void drawDisk(Posn p, int r, AColor c); public native void drawDisk(Posn p, int r, IColor c);
public native void drawRect(Posn p, int width, int height, AColor c); public native void drawRect(Posn p, int width, int height, IColor c);
public native void drawLine(Posn p0, Posn p1, AColor c); public native void drawLine(Posn p0, Posn p1, IColor c);
public native void drawString(Posn p, String s); public native void drawString(Posn p, String s);
} }

View File

@ -12,15 +12,4 @@
(build-path draw-path file) (build-path draw-path file)
#f #f))))) #f #f)))))
(javac "Canvas.java") (javac "Canvas.java")
(javac "World.java") (javac "World.java")))))
#|
(javac "Posn.java")
(javac "AColor.java")
(javac "Red.java")
(javac "White.java")
(javac "Blue.java")
(javac "Black.java")
(javac "Green.java")
(javac "Yellow.java")
|#
))))