Color to AColor

svn: r6892
This commit is contained in:
Matthias Felleisen 2007-07-11 15:39:43 +00:00
parent e4f5dfa8ce
commit aa18a7498a
15 changed files with 60 additions and 59 deletions

View File

@ -6,16 +6,16 @@ class SW extends World {
int x = 50; int x = 50;
int y; int y;
int low; int low;
Color c; AColor c;
Color white = new White(); AColor white = new White();
SW(int y, int low, Color c) { this.y = y; this.low = low; this.c = c; } SW(int y, int low, AColor c) { this.y = y; this.low = low; this.c = c; }
boolean go() { return this.bigBang(100,100,.1); } boolean go() { return this.bigBang(100,100,.1); }
World onTick() { World onTick() {
if (y >= low) if (y >= low)
return endOfWorld(); return endOfWorld("the end");
else else
return new SW(this.y+1,this.low,this.c); return new SW(this.y+1,this.low,this.c);
} }

View File

@ -10,8 +10,8 @@ import geometry.*;
class SW extends World { class SW extends World {
int x = 50; int x = 50;
int y; int y;
Color red = new Red(); AColor red = new Red();
Color white = new White(); AColor white = new White();
SW(int v) { y = v; } SW(int v) { y = v; }
@ -21,7 +21,7 @@ class SW extends World {
World onKeyEvent(String ke) { World onKeyEvent(String ke) {
if (ke.equals("s")) if (ke.equals("s"))
return this.endOfWorld(); return this.endOfWorld("the end");
else if (ke.equals("*")) else if (ke.equals("*"))
return new SW(99); return new SW(99);
else else

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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 "Color.java") (javac "AColor.java")
(javac "Red.java") (javac "Red.java")
(javac "White.java") (javac "White.java")
(javac "Blue.java") (javac "Blue.java")

View File

@ -34,13 +34,13 @@ public class Canvas {
public native boolean xshow(); public native boolean xshow();
public native boolean xclose(); public native boolean xclose();
public native boolean drawCircle(Posn p, int r, Color c); public native boolean drawCircle(Posn p, int r, AColor c);
public native boolean drawDisk(Posn p, int r, Color c); public native boolean drawDisk(Posn p, int r, AColor c);
public native boolean drawRect(Posn p, int width, int height, Color c); public native boolean drawRect(Posn p, int width, int height, AColor c);
public native boolean drawLine(Posn p0, Posn p1, Color c); public native boolean drawLine(Posn p0, Posn p1, AColor c);
public native boolean drawString(Posn p, String s); public native boolean drawString(Posn p, String s);
public native boolean clearCircle(Posn p, int r, Color c); public native boolean clearCircle(Posn p, int r, AColor c);
public native boolean clearDisk(Posn p, int r, Color c); public native boolean clearDisk(Posn p, int r, AColor c);
public native boolean clearRect(Posn p, int width, int height, Color c); public native boolean clearRect(Posn p, int width, int height, AColor c);
public native boolean clearLine(Posn p0, Posn p1, Color c); public native boolean clearLine(Posn p0, Posn p1, AColor c);
} }

View File

@ -21,15 +21,15 @@
xclose-native xclose-native
stop-native stop-native
copy-native copy-native
drawCircle-geometry.Posn-int-colors.Color-native drawCircle-geometry.Posn-int-colors.AColor-native
drawDisk-geometry.Posn-int-colors.Color-native drawDisk-geometry.Posn-int-colors.AColor-native
drawRect-geometry.Posn-int-int-colors.Color-native drawRect-geometry.Posn-int-int-colors.AColor-native
drawLine-geometry.Posn-geometry.Posn-colors.Color-native drawLine-geometry.Posn-geometry.Posn-colors.AColor-native
drawString-geometry.Posn-java.lang.String-native drawString-geometry.Posn-java.lang.String-native
clearCircle-geometry.Posn-int-colors.Color-native clearCircle-geometry.Posn-int-colors.AColor-native
clearDisk-geometry.Posn-int-colors.Color-native clearDisk-geometry.Posn-int-colors.AColor-native
clearRect-geometry.Posn-int-int-colors.Color-native clearRect-geometry.Posn-int-int-colors.AColor-native
clearLine-geometry.Posn-geometry.Posn-colors.Color-native)) clearLine-geometry.Posn-geometry.Posn-colors.AColor-native))
(define-signature support^ (void-or-true imperative)) (define-signature support^ (void-or-true imperative))
@ -120,23 +120,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.Color-native this accs gets privates posn r c) (define (drawCircle-geometry.Posn-int-colors.AColor-native this accs gets privates posn r c)
(wrap-start-check (wrap-start-check
(check-arg r "drawCircle(Posn, int, Color)" "second") (check-arg r "drawCircle(Posn, int, AColor)" "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.Color-native this accs gets privates posn r c) (define (drawDisk-geometry.Posn-int-colors.AColor-native this accs gets privates posn r c)
(wrap-start-check (wrap-start-check
(check-arg r "drawDisk(Posn, int, Color)" "second") (check-arg r "drawDisk(Posn, int, AColor)" "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.Color-native this accs gets privates posn w h c) (define (drawRect-geometry.Posn-int-int-colors.AColor-native this accs gets privates posn w h c)
(wrap-start-check (wrap-start-check
(check-arg w "drawRect(Posn, int, int, Color)" "second") (check-arg w "drawRect(Posn, int, int, AColor)" "second")
(check-arg h "drawRect(Posn, int, int, Color)" "third") (check-arg h "drawRect(Posn, int, int, AColor)" "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.Color-native this accs gets privates p0 p1 c) (define (drawLine-geometry.Posn-geometry.Posn-colors.AColor-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))))
@ -146,23 +146,23 @@
(wrap-start-check (wrap-start-check
([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.Color-native this accs gets privates p r c) (define (clearCircle-geometry.Posn-int-colors.AColor-native this accs gets privates p r c)
(wrap-start-check (wrap-start-check
(check-arg r "clearCircle(Posn, int, Color)" "second") (check-arg r "clearCircle(Posn, int, AColor)" "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.Color-native this accs gets privates p r c) (define (clearDisk-geometry.Posn-int-colors.AColor-native this accs gets privates p r c)
(wrap-start-check (wrap-start-check
(check-arg r "clearDisk(Posn, int, Color)" "second") (check-arg r "clearDisk(Posn, int, AColor)" "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.Color-native this accs gets privates p w h c) (define (clearRect-geometry.Posn-int-int-colors.AColor-native this accs gets privates p w h c)
(wrap-start-check (wrap-start-check
(check-arg w "clearRect(Posn, int, int, Color)" "second") (check-arg w "clearRect(Posn, int, int, AColor)" "second")
(check-arg h "clearRect(Posn, int, int, Color)" "third") (check-arg h "clearRect(Posn, int, int, AColor)" "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.Color-native this accs gets privates p0 p1 c) (define (clearLine-geometry.Posn-geometry.Posn-colors.AColor-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))))
) )
@ -209,7 +209,8 @@
(define (endOfWorld-java.lang.String-native this accs gets privates s) (define (endOfWorld-java.lang.String-native this accs gets privates s)
(define theCanvas ((hash-table-get accs 'theCanvas) this)) (define theCanvas ((hash-table-get accs 'theCanvas) this))
(define _ (check-string s "endOfWorld(String)" "first")) (define _ (check-string s "endOfWorld(String)" "first"))
(message-box "end of world" (send s get-mzscheme-string)) (parameterize ([current-eventspace (make-eventspace)])
(message-box "end of world" (send s get-mzscheme-string)))
(send theCanvas stop) (send theCanvas stop)
this)) this))
) )

View File

@ -35,13 +35,13 @@ public class Canvas {
public native void xshow(); public native void xshow();
public native void xclose(); public native void xclose();
public native void drawCircle(Posn p, int r, Color c); public native void drawCircle(Posn p, int r, AColor c);
public native void drawDisk(Posn p, int r, Color c); public native void drawDisk(Posn p, int r, AColor c);
public native void drawRect(Posn p, int width, int height, Color c); public native void drawRect(Posn p, int width, int height, AColor c);
public native void drawLine(Posn p0, Posn p1, Color c); public native void drawLine(Posn p0, Posn p1, AColor c);
public native void drawString(Posn p, String s); public native void drawString(Posn p, String s);
public native void clearCircle(Posn p, int r, Color c); public native void clearCircle(Posn p, int r, AColor c);
public native void clearDisk(Posn p, int r, Color c); public native void clearDisk(Posn p, int r, AColor c);
public native void clearRect(Posn p, int width, int height, Color c); public native void clearRect(Posn p, int width, int height, AColor c);
public native void clearLine(Posn p0, Posn p1, Color c); public native void clearLine(Posn p0, Posn p1, AColor c);
} }

View File

@ -15,7 +15,7 @@
(javac "World.java") (javac "World.java")
#| #|
(javac "Posn.java") (javac "Posn.java")
(javac "Color.java") (javac "AColor.java")
(javac "Red.java") (javac "Red.java")
(javac "White.java") (javac "White.java")
(javac "Blue.java") (javac "Blue.java")