diff --git a/collects/htdch/draw/Black.java b/collects/htdch/draw/Black.java deleted file mode 100644 index 1cf5043d13..0000000000 --- a/collects/htdch/draw/Black.java +++ /dev/null @@ -1,3 +0,0 @@ -package draw; - -public class Black extends Color { } diff --git a/collects/htdch/draw/Blue.java b/collects/htdch/draw/Blue.java deleted file mode 100644 index 5887478e76..0000000000 --- a/collects/htdch/draw/Blue.java +++ /dev/null @@ -1,3 +0,0 @@ -package draw; - -public class Blue extends Color { } diff --git a/collects/htdch/draw/Canvas.java b/collects/htdch/draw/Canvas.java index e4876d0f7d..35bfefeed6 100644 --- a/collects/htdch/draw/Canvas.java +++ b/collects/htdch/draw/Canvas.java @@ -1,4 +1,7 @@ package draw; + +import geometry.*; +import colors.*; public class Canvas { private int width = 0; diff --git a/collects/htdch/draw/Color.java b/collects/htdch/draw/Color.java deleted file mode 100644 index d3116457e4..0000000000 --- a/collects/htdch/draw/Color.java +++ /dev/null @@ -1,3 +0,0 @@ -package draw; - -public abstract class Color { } \ No newline at end of file diff --git a/collects/htdch/draw/Green.java b/collects/htdch/draw/Green.java deleted file mode 100644 index b58f1b8e18..0000000000 --- a/collects/htdch/draw/Green.java +++ /dev/null @@ -1,3 +0,0 @@ -package draw; - -public class Green extends Color { } diff --git a/collects/htdch/draw/Posn.java b/collects/htdch/draw/Posn.java deleted file mode 100644 index 1328dffa94..0000000000 --- a/collects/htdch/draw/Posn.java +++ /dev/null @@ -1,10 +0,0 @@ -package draw; - -public class Posn { - public int x, y; - - public Posn( int x, int y ) { - this.x = x; - this.y = y; - } -} \ No newline at end of file diff --git a/collects/htdch/draw/Red.java b/collects/htdch/draw/Red.java deleted file mode 100644 index db44213b34..0000000000 --- a/collects/htdch/draw/Red.java +++ /dev/null @@ -1,3 +0,0 @@ -package draw; - -public class Red extends Color { } \ No newline at end of file diff --git a/collects/htdch/draw/White.java b/collects/htdch/draw/White.java deleted file mode 100644 index a583bec9d7..0000000000 --- a/collects/htdch/draw/White.java +++ /dev/null @@ -1,3 +0,0 @@ -package draw; - -public class White extends Color { } diff --git a/collects/htdch/draw/Yellow.java b/collects/htdch/draw/Yellow.java deleted file mode 100644 index b14bcd80db..0000000000 --- a/collects/htdch/draw/Yellow.java +++ /dev/null @@ -1,3 +0,0 @@ -package draw; - -public class Yellow extends Color { } diff --git a/collects/htdch/draw/installer.ss b/collects/htdch/draw/installer.ss index 5bd2c7f43d..c61f192dac 100644 --- a/collects/htdch/draw/installer.ss +++ b/collects/htdch/draw/installer.ss @@ -14,15 +14,6 @@ (compile-java 'file 'file 'full (build-path draw-path file) #f #f))))) - (javac "Posn.java") - (javac "Color.java") (javac "Canvas.java") - (javac "World.java") - (javac "Red.java") - (javac "White.java") - (javac "Blue.java") - (javac "Black.java") - (javac "Green.java") - (javac "Yellow.java") - )))) + (javac "World.java"))))) diff --git a/collects/htdch/draw/support.scm b/collects/htdch/draw/support.scm index 98a914acdb..59d0cc8121 100644 --- a/collects/htdch/draw/support.scm +++ b/collects/htdch/draw/support.scm @@ -20,15 +20,15 @@ close-native stop-native copy-native - drawCircle-draw.Posn-int-draw.Color-native - drawDisk-draw.Posn-int-draw.Color-native - drawRect-draw.Posn-int-int-draw.Color-native - drawLine-draw.Posn-draw.Posn-draw.Color-native - drawString-draw.Posn-java.lang.String-native - clearCircle-draw.Posn-int-draw.Color-native - clearDisk-draw.Posn-int-draw.Color-native - clearRect-draw.Posn-int-int-draw.Color-native - clearLine-draw.Posn-draw.Posn-draw.Color-native)) + drawCircle-geometry.Posn-int-colors.Color-native + drawDisk-geometry.Posn-int-colors.Color-native + drawRect-geometry.Posn-int-int-colors.Color-native + drawLine-geometry.Posn-geometry.Posn-colors.Color-native + drawString-geometry.Posn-java.lang.String-native + clearCircle-geometry.Posn-int-colors.Color-native + clearDisk-geometry.Posn-int-colors.Color-native + clearRect-geometry.Posn-int-int-colors.Color-native + clearLine-geometry.Posn-geometry.Posn-colors.Color-native)) (define-signature support^ (void-or-true imperative)) @@ -59,8 +59,8 @@ (exn-message e)))))) (begin (begin body ...) void-or-true))])) - (define Posn-x-get (dynamic-require '(lib "Posn.ss" "htdch" "draw") 'Posn-x-get)) - (define Posn-y-get (dynamic-require '(lib "Posn.ss" "htdch" "draw") 'Posn-y-get)) + (define Posn-x-get (dynamic-require '(lib "Posn.ss" "htdch" "geometry") 'Posn-x-get)) + (define Posn-y-get (dynamic-require '(lib "Posn.ss" "htdch" "geometry") 'Posn-y-get)) (define (build-posn posnO) (make-posn (Posn-x-get posnO) (Posn-y-get posnO))) (define (color->symbol colorO) (string->symbol (to-lower-case (send colorO my-name)))) @@ -118,49 +118,49 @@ (define (copy-native this accs gets privates) (wrap-start-check ([hash-table-get privates 'copy]))) - (define (drawCircle-draw.Posn-int-draw.Color-native this accs gets privates posn r c) + (define (drawCircle-geometry.Posn-int-colors.Color-native this accs gets privates posn r c) (wrap-start-check (check-arg r "drawCircle(Posn, int, Color)" "second") ([hash-table-get privates '%draw-circle] (build-posn posn) r (color->symbol c)))) - (define (drawDisk-draw.Posn-int-draw.Color-native this accs gets privates posn r c) + (define (drawDisk-geometry.Posn-int-colors.Color-native this accs gets privates posn r c) (wrap-start-check (check-arg r "drawDisk(Posn, int, Color)" "second") ([hash-table-get privates '%draw-solid-disk] (build-posn posn) r (color->symbol c)))) - (define (drawRect-draw.Posn-int-int-draw.Color-native this accs gets privates posn w h c) + (define (drawRect-geometry.Posn-int-int-colors.Color-native this accs gets privates posn w h c) (wrap-start-check (check-arg w "drawRect(Posn, int, int, Color)" "second") (check-arg h "drawRect(Posn, int, int, Color)" "third") ([hash-table-get privates '%draw-solid-rect] (build-posn posn) w h (color->symbol c)))) - (define (drawLine-draw.Posn-draw.Posn-draw.Color-native this accs gets privates p0 p1 c) + (define (drawLine-geometry.Posn-geometry.Posn-colors.Color-native this accs gets privates p0 p1 c) (wrap-start-check ([hash-table-get privates '%draw-solid-line] (build-posn p0) (build-posn p1) (color->symbol c)))) - (define (drawString-draw.Posn-java.lang.String-native this accs gets privates p s) + (define (drawString-geometry.Posn-java.lang.String-native this accs gets privates p s) (define _ (check-string s "drawString(Posn, String)" "second")) (define s* (send s get-mzscheme-string)) (wrap-start-check ([hash-table-get privates '%draw-string] (build-posn p) s*))) - (define (clearCircle-draw.Posn-int-draw.Color-native this accs gets privates p r c) + (define (clearCircle-geometry.Posn-int-colors.Color-native this accs gets privates p r c) (wrap-start-check (check-arg r "clearCircle(Posn, int, Color)" "second") ([hash-table-get privates '%clear-circle] (build-posn p) r (color->symbol c)))) - (define (clearDisk-draw.Posn-int-draw.Color-native this accs gets privates p r c) + (define (clearDisk-geometry.Posn-int-colors.Color-native this accs gets privates p r c) (wrap-start-check (check-arg r "clearDisk(Posn, int, Color)" "second") ([hash-table-get privates '%clear-solid-disk] (build-posn p) r (color->symbol c)))) - (define (clearRect-draw.Posn-int-int-draw.Color-native this accs gets privates p w h c) + (define (clearRect-geometry.Posn-int-int-colors.Color-native this accs gets privates p w h c) (wrap-start-check (check-arg w "clearRect(Posn, int, int, Color)" "second") (check-arg h "clearRect(Posn, int, int, Color)" "third") ([hash-table-get privates '%clear-solid-rect] (build-posn p) w h (color->symbol c)))) - (define (clearLine-draw.Posn-draw.Posn-draw.Color-native this accs gets privates p0 p1 c) + (define (clearLine-geometry.Posn-geometry.Posn-colors.Color-native this accs gets privates p0 p1 c) (wrap-start-check ([hash-table-get privates '%clear-solid-line] (build-posn p0) (build-posn p1) (color->symbol c)))) )) diff --git a/collects/htdch/idraw/Canvas.java b/collects/htdch/idraw/Canvas.java index 7bcd454296..62763b389b 100644 --- a/collects/htdch/idraw/Canvas.java +++ b/collects/htdch/idraw/Canvas.java @@ -1,7 +1,7 @@ package idraw; -import draw.Color; -import draw.Posn; +import colors.*; +import geometry.*; public class Canvas { private int width = 0; diff --git a/collects/htdch/idraw/Color.java b/collects/htdch/idraw/Color.java deleted file mode 100644 index 22f65bdc77..0000000000 --- a/collects/htdch/idraw/Color.java +++ /dev/null @@ -1,3 +0,0 @@ -package idraw; - -public abstract class Color { } diff --git a/collects/htdch/info.ss b/collects/htdch/info.ss index 813bc7c0f9..c36a7a369c 100644 --- a/collects/htdch/info.ss +++ b/collects/htdch/info.ss @@ -1,5 +1,9 @@ (module info (lib "infotab.ss" "setup") (define name "htdch") - (define compile-subcollections (list (list "htdch" "draw") - (list "htdch" "graphics") - (list "htdch" "idraw")))) + (define compile-subcollections + (list + (list "htdch" "draw") + (list "htdch" "geometry") + (list "htdch" "colors") + (list "htdch" "graphics") + (list "htdch" "idraw")))) diff --git a/collects/profjWizard/todo b/collects/profjWizard/todo index 09b87069ae..1f5e43f910 100644 --- a/collects/profjWizard/todo +++ b/collects/profjWizard/todo @@ -5,12 +5,15 @@ The Java Wizard helps programmers create The class wizard requests class name, superclass, and field specifications. From these, it generates a class, its constructor, and optionally a partial -template for methods and a toString method. +template for methods, a toString method, and a diagram. The union wizard requests a union name and specifications for the variants. From these, it generates an abstract class (for the union name) and one variant class that extends the abstract class per variant specification. -Again, it optionally adds templates and toString methods. +Again, it optionally adds templates, a toString method, and a diagram. + +Both wizards generate their text in a language-sensitive manner. For +Beginner and Intermediate, they omit privacy specifications. The wizards are added to the Special menu and insert text at the current point. @@ -23,29 +26,31 @@ The two major files are: class.scm, which is the model and provides the functions for turning a spec into a string that represents a class or a union. -At the moment, class.scm does not use the Java implementation to perform -basic checks on the information. It just leaves this to the programmer. -So, for example, if a programmer says a field has type "moo" and "moo" -doesn't exist as a class, then the wizard inserts a buggy program. - +Also, class.scm does not use the Java implementation to perform basic +checks on the information. It just leaves this to the programmer. So, for +example, if a programmer says a field has type "moo" and "moo" doesn't +exist as a class, then the wizard inserts a buggy class. |# -bugs: +BUGS: -drawing: +* union: -* finish drawing unions, recursion +** when a programmer changes the name of the Union after the variants have + been specified, the wizard fails to change the type name in the + variants. -model +* drawing: -* figure out how to add toString and template flags to the macro version +** the Union wizard draws the method specs into the boxes for the + classes. The book "thinks" of them as inherited. view -both +FEATURES: -* allow common fields in abstract classes -* parameterize over language level? -* privacy modifiers +** allow the introduction of an abstract class for common features in + Unions (common fields, common methods) +** specification of mutually recursive features diff --git a/collects/teachpack/htdc/Docs/colors.thtml b/collects/teachpack/htdc/Docs/colors.thtml new file mode 100644 index 0000000000..9a41372c3a --- /dev/null +++ b/collects/teachpack/htdc/Docs/colors.thtml @@ -0,0 +1,26 @@ +{ (define LIBNAME "A Colors Library (HtDC)") + (include "head.tinc") } + +This draw package provides classes for representing colors: +
+
+                              +-------+
+                              | Color |
+                              +-------+
+                                  |
+                                 / \
+                                 ---
+                                  |
+             ------------------------------------------
+             |          |         |         |         |     
+         +-------+  +-------+ +-------+ +-------+ +-------+  
+         | Blue  |  | Green | | Red   | | White | | Yellow| 
+         +-------+  +-------+ +-------+ +-------+ +-------+ 
+
+
+ +

The Color class is abstract. Its variants (subclasses) are +created with no arguments. +

+ +{(include "foot.tinc")} diff --git a/collects/teachpack/htdc/Docs/draw.thtml b/collects/teachpack/htdc/Docs/draw.thtml index 9da6301966..20148b4d19 100644 --- a/collects/teachpack/htdc/Docs/draw.thtml +++ b/collects/teachpack/htdc/Docs/draw.thtml @@ -5,6 +5,9 @@ This draw package provides classes and methods for a visual world. Here is its class diagram of public fields and methods:
 
+import colors.*;
+import geometry.*;
+
  +-----------------------------------+
  | abstract World                    |
  +-----------------------------------+       +---------------------------------------+
@@ -23,26 +26,6 @@ world. Here is its class diagram of public fields and methods:
                                              | boolean clearRect(Posn,int,int,Color) |
                                              | boolean clearLine(Posn,Posn,Color)    |
                                              +---------------------------------------+
-
-                      +----------+
-                      | Posn     |
-                      +----------+
-                      | int x    |
-                      | int y    |
-                      +----------+
-
-                              +-------+
-                              | Color |
-                              +-------+
-                                  |
-                                 / \
-                                 ---
-                                  |
-             ------------------------------------------
-             |          |         |         |         |     
-         +-------+  +-------+ +-------+ +-------+ +-------+  
-         | Blue  |  | Green | | Red   | | White | | Yellow| 
-         +-------+  +-------+ +-------+ +-------+ +-------+ 
 
 
@@ -159,12 +142,4 @@ The methods may fail due to the unavailability of the physical devices, inappropriate uses, etc. In those cases, they fail with an exception.

-

To create an instance of the Posn class, a program must supply -two int values: one for its x coordinate of the canvas and the -second for its y coordinate.

- -

The Color class is abstract. Its variants (subclasses) are -created with no arguments. -

- {(include "foot.tinc")} diff --git a/collects/teachpack/htdc/Docs/geometry.thtml b/collects/teachpack/htdc/Docs/geometry.thtml new file mode 100644 index 0000000000..45782b9259 --- /dev/null +++ b/collects/teachpack/htdc/Docs/geometry.thtml @@ -0,0 +1,21 @@ +{ (define LIBNAME "A Geometry Library (HtDC)") + (include "head.tinc") } + +This geometry package provides a class for representing +positions in a Cartesian world: +
+
+                      +----------+
+                      | Posn     |
+                      +----------+
+                      | int x    |
+                      | int y    |
+                      +----------+
+
+
+ +

To create an instance of the Posn class, a program must supply +two int values: one for its x coordinate of the canvas and the +second for its y coordinate.

+ +{(include "foot.tinc")} diff --git a/collects/teachpack/htdc/Docs/idraw.thtml b/collects/teachpack/htdc/Docs/idraw.thtml index cf04d0bee0..689fb899d1 100644 --- a/collects/teachpack/htdc/Docs/idraw.thtml +++ b/collects/teachpack/htdc/Docs/idraw.thtml @@ -7,8 +7,8 @@ for a visual world. Here is its class diagram of public fields and methods:
 
-import draw.Color; 
-import draw.Posn; 
+import colors.*; 
+import geometry.*; 
 
   +---------------------------------+     
   | abstract World                  |
diff --git a/collects/teachpack/htdc/Docs/mkdocs b/collects/teachpack/htdc/Docs/mkdocs
index d715425eea..e7ea2a01d7 100755
--- a/collects/teachpack/htdc/Docs/mkdocs
+++ b/collects/teachpack/htdc/Docs/mkdocs
@@ -16,6 +16,8 @@ fi
 (define libraries*
   '(#"A Functional Drawing Library (HtDC)"
     #"An Imperative Drawing Library (HtDC)"
+    #"A Geometry Library (HtDC)"
+    #"A Colors Library (HtDC)"
     ))
 
 (define dest-dir (build-path (find-doc-dir) "teachpack-htdc"))
diff --git a/collects/teachpack/htdc/colors.ss b/collects/teachpack/htdc/colors.ss
new file mode 100644
index 0000000000..1b7fab4da2
--- /dev/null
+++ b/collects/teachpack/htdc/colors.ss
@@ -0,0 +1 @@
+(printf "this is just a stand-in for the plt/collects/htdch/colors/ library\n")
diff --git a/collects/teachpack/htdc/geometry.ss b/collects/teachpack/htdc/geometry.ss
new file mode 100644
index 0000000000..9ee5040749
--- /dev/null
+++ b/collects/teachpack/htdc/geometry.ss
@@ -0,0 +1 @@
+(printf "this is just a stand-in for the plt/collects/htdch/geometry/ library\n")