htdch collection reorganized, docs too
svn: r3631
This commit is contained in:
parent
463f71e53d
commit
c8e7482511
|
@ -1,3 +0,0 @@
|
|||
package draw;
|
||||
|
||||
public class Black extends Color { }
|
|
@ -1,3 +0,0 @@
|
|||
package draw;
|
||||
|
||||
public class Blue extends Color { }
|
|
@ -1,4 +1,7 @@
|
|||
package draw;
|
||||
|
||||
import geometry.*;
|
||||
import colors.*;
|
||||
|
||||
public class Canvas {
|
||||
private int width = 0;
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
package draw;
|
||||
|
||||
public abstract class Color { }
|
|
@ -1,3 +0,0 @@
|
|||
package draw;
|
||||
|
||||
public class Green extends Color { }
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
package draw;
|
||||
|
||||
public class Red extends Color { }
|
|
@ -1,3 +0,0 @@
|
|||
package draw;
|
||||
|
||||
public class White extends Color { }
|
|
@ -1,3 +0,0 @@
|
|||
package draw;
|
||||
|
||||
public class Yellow extends Color { }
|
|
@ -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")))))
|
||||
|
||||
|
|
|
@ -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))))
|
||||
))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package idraw;
|
||||
|
||||
import draw.Color;
|
||||
import draw.Posn;
|
||||
import colors.*;
|
||||
import geometry.*;
|
||||
|
||||
public class Canvas {
|
||||
private int width = 0;
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
package idraw;
|
||||
|
||||
public abstract class Color { }
|
|
@ -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"))))
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
26
collects/teachpack/htdc/Docs/colors.thtml
Normal file
26
collects/teachpack/htdc/Docs/colors.thtml
Normal file
|
@ -0,0 +1,26 @@
|
|||
{ (define LIBNAME "A Colors Library (HtDC)")
|
||||
(include "head.tinc") }
|
||||
|
||||
This <code>draw</code> package provides classes for representing colors:
|
||||
<pre>
|
||||
<code>
|
||||
+-------+
|
||||
| Color |
|
||||
+-------+
|
||||
|
|
||||
/ \
|
||||
---
|
||||
|
|
||||
------------------------------------------
|
||||
| | | | |
|
||||
+-------+ +-------+ +-------+ +-------+ +-------+
|
||||
| Blue | | Green | | Red | | White | | Yellow|
|
||||
+-------+ +-------+ +-------+ +-------+ +-------+
|
||||
</code>
|
||||
</pre>
|
||||
|
||||
<p>The <code>Color</code> class is abstract. Its variants (subclasses) are
|
||||
created with no arguments.
|
||||
</p>
|
||||
|
||||
{(include "foot.tinc")}
|
|
@ -5,6 +5,9 @@ This <code>draw</code> package provides classes and methods for a visual
|
|||
world. Here is its class diagram of public fields and methods:
|
||||
<pre>
|
||||
<code>
|
||||
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|
|
||||
+-------+ +-------+ +-------+ +-------+ +-------+
|
||||
</code>
|
||||
</pre>
|
||||
|
||||
|
@ -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.</p>
|
||||
</p>
|
||||
|
||||
<p>To create an instance of the <code>Posn</code> class, a program must supply
|
||||
two <code>int</code> values: one for its x coordinate of the canvas and the
|
||||
second for its y coordinate. </p>
|
||||
|
||||
<p>The <code>Color</code> class is abstract. Its variants (subclasses) are
|
||||
created with no arguments.
|
||||
</p>
|
||||
|
||||
{(include "foot.tinc")}
|
||||
|
|
21
collects/teachpack/htdc/Docs/geometry.thtml
Normal file
21
collects/teachpack/htdc/Docs/geometry.thtml
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ (define LIBNAME "A Geometry Library (HtDC)")
|
||||
(include "head.tinc") }
|
||||
|
||||
This <code>geometry</code> package provides a class for representing
|
||||
positions in a Cartesian world:
|
||||
<pre>
|
||||
<code>
|
||||
+----------+
|
||||
| Posn |
|
||||
+----------+
|
||||
| int x |
|
||||
| int y |
|
||||
+----------+
|
||||
</code>
|
||||
</pre>
|
||||
|
||||
<p>To create an instance of the <code>Posn</code> class, a program must supply
|
||||
two <code>int</code> values: one for its x coordinate of the canvas and the
|
||||
second for its y coordinate. </p>
|
||||
|
||||
{(include "foot.tinc")}
|
|
@ -7,8 +7,8 @@ for a visual world. Here is its class diagram of public fields and methods:
|
|||
|
||||
<pre>
|
||||
<code>
|
||||
import draw.Color;
|
||||
import draw.Posn;
|
||||
import colors.*;
|
||||
import geometry.*;
|
||||
|
||||
+---------------------------------+
|
||||
| abstract World |
|
||||
|
|
|
@ -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"))
|
||||
|
|
1
collects/teachpack/htdc/colors.ss
Normal file
1
collects/teachpack/htdc/colors.ss
Normal file
|
@ -0,0 +1 @@
|
|||
(printf "this is just a stand-in for the plt/collects/htdch/colors/ library\n")
|
1
collects/teachpack/htdc/geometry.ss
Normal file
1
collects/teachpack/htdc/geometry.ss
Normal file
|
@ -0,0 +1 @@
|
|||
(printf "this is just a stand-in for the plt/collects/htdch/geometry/ library\n")
|
Loading…
Reference in New Issue
Block a user