From 538e9601332b75bcd9b501796681a7f3fcbe9267 Mon Sep 17 00:00:00 2001 From: Matthias Felleisen Date: Thu, 24 Apr 2008 02:16:40 +0000 Subject: [PATCH] svn: r9447 --- collects/teachpack/htdc/Docs/draw.scrbl | 128 ++++++++++-------- .../htdc/Docs/{idraw.thtml => idraw.scrbl} | 0 collects/teachpack/htdc/Docs/index.thtml | 11 -- 3 files changed, 70 insertions(+), 69 deletions(-) rename collects/teachpack/htdc/Docs/{idraw.thtml => idraw.scrbl} (100%) delete mode 100644 collects/teachpack/htdc/Docs/index.thtml diff --git a/collects/teachpack/htdc/Docs/draw.scrbl b/collects/teachpack/htdc/Docs/draw.scrbl index 880cc1b066..a0f361958b 100644 --- a/collects/teachpack/htdc/Docs/draw.scrbl +++ b/collects/teachpack/htdc/Docs/draw.scrbl @@ -2,7 +2,7 @@ @(require scribble/manual) -@title[#:tag "draw"]{Draw: draw.*} +@title[#:tag "Jdraw"]{Draw: draw.*} Add @verbatim[#:indent 3]{ @@ -18,61 +18,74 @@ import geometry.*; +-----------------------------------+ | abstract World | - +-----------------------------------+ +---------------------------------------+ - | Canvas theCanvas |------>| Canvas | - +-----------------------------------+ +---------------------------------------+ - | boolean bigBang(int,int,double) | +---------------------------------------+ - | boolean endOfTime(String) | | boolean show() | - | World endOfWorld(String) | | boolean close() | - | | | boolean drawCircle(Posn,int,IColor) | - | | | boolean drawDisk(Posn,int,IColor) | - | abstract World onTick() | | boolean drawRect(Posn,int,int,IColor) | - | abstract World onKeyEvent(String) | | boolean drawLine(Posn,Posn,IColor) | - | abstract boolean draw() | | boolean drawString(Posn,String) | - +-----------------------------------+ +---------------------------------------+ -} + +-----------------------------------+ + | Canvas theCanvas |----+ + +-----------------------------------+ | + | boolean bigBang(int,int,double) | | + | boolean endOfTime(String) | | + | World endOfWorld(String) | | + | | | + | | | + | abstract World onTick() | | + | abstract World onKeyEvent(String) | | + | abstract boolean draw() | | + +-----------------------------------+ | + | + v + +---------------------------------------+ + | Canvas | + +---------------------------------------+ + +---------------------------------------+ + | boolean show() | + | boolean close() | + | boolean drawCircle(Posn,int,IColor) | + | boolean drawDisk(Posn,int,IColor) | + | boolean drawRect(Posn,int,int,IColor) | + | boolean drawLine(Posn,Posn,IColor) | + | boolean drawString(Posn,String) | + +---------------------------------------+} Methods in these classes may fail due to the unavailability of the physical devices, inappropriate uses, etc. In those cases, they fail with an exception. -@section[#:tag "world"]{World} +@section[#:tag "Jworld"]{World} -The abstract @scheme[World] class exports the following methods. +The abstract @tt{World} class exports the following methods. @; ----------------------------------------------------------------------------- bigBang(int width,int height,double speed) -Initializes the world, associates it with a @scheme[width] x -@scheme[height] @scheme[Canvas], displays +Initializes the world, associates it with a @tt{width} x +@tt{height} @tt{Canvas}, displays this canvas, enables keyevents, and finally starts the clock at a rate of -one tick per @scheme[speed] seconds. If it succeeds with all of its -actions, the method produces @scheme[true]. +one tick per @tt{speed} seconds. If it succeeds with all of its +actions, the method produces @tt{true}. -@bold{Note}: @scheme[width], @scheme[height] and -@scheme[speed] must be a positive. +@bold{Note}: @tt{width}, @tt{height} and +@tt{speed} must be a positive. @; ----------------------------------------------------------------------------- -The canvas in @scheme[World] is called +The canvas in @tt{World} is called - @scheme[theCanvas]. + @tt{theCanvas}. -References to a "canvas" in conjunction with the @scheme[World] class +References to a "canvas" in conjunction with the @tt{World} class denote this default canvas. @; ----------------------------------------------------------------------------- endOfTime() Displays the given message, stops the clock and, if it succeeds, produces -@scheme[true]. After the end of time, events no longer trigger calls -to @scheme[onTick] or @scheme[onKeyEvent]. The canvas remains visible. +@tt{true}. After the end of time, events no longer trigger calls +to @tt{onTick} or @tt{onKeyEvent}. The canvas remains visible. @; ----------------------------------------------------------------------------- endOfWorld(String msg) Displays the given message, stops the clock and, if it succeeds, produces the -last @scheme[World]. After the end of the world, events no longer trigger calls -to @scheme[onTick] or @scheme[onKeyEvent] (see below). The canvas +last @tt{World}. After the end of the world, events no longer trigger calls +to @tt{onTick} or @tt{onKeyEvent} (see below). The canvas remains visible. @; ----------------------------------------------------------------------------- @@ -82,79 +95,78 @@ A derived concrete class must supply definitions for the following methods: onTick() Invoked for every tick of the clock. Its purpose is to create a -@scheme[World] whose differences with @scheme[this] one represent +@tt{World} whose differences with @tt{this} one represent what happened during the amount of time it takes the clock to tick. @; ----------------------------------------------------------------------------- onKeyEvent(String key) Invoked for every keyboard event associated with the canvas. Its purposes - is to create a @scheme[World] whose differences with - @scheme[this] one represent what happens due to the user's use of the + is to create a @tt{World} whose differences with + @tt{this} one represent what happens due to the user's use of the keyboard. The latter is represented with the string-valued argument - @scheme[key]. + @tt{key}. @; ----------------------------------------------------------------------------- draw() Invoked after one of the two event handlers has been called. Its -purpose is to present @scheme[this World ] graphically on its -canvas. If it succeeds, its result is @scheme[true.] +purpose is to present @tt{this World} graphically on its +canvas. If it succeeds, its result is @tt{true}. A program may, in principle, start several instances of (subclasses of) -@scheme[World]. If it does, the event handlers are called in a unpredictable +@tt{World}. If it does, the event handlers are called in a unpredictable order. @section[#:tag "canvas"]{Canvas} -To create an instance of the @scheme[Canvas] class, a program must supply -two @scheme[int] values: one for the width of the canvas and one for its +To create an instance of the @tt{Canvas} class, a program must supply +two @tt{int} values: one for the width of the canvas and one for its height. The canvas is a rectangle, whose borders are parallel to the computer screen's borders. A program can use the following methods on instances of -@scheme[Canvas:] +@tt{Canvas}] show() Initializes the canvas to a white area, enables the drawing methods, and finally displays the canvas. If it succeeds, it produces - @scheme[true]. Invoking the method a second time without calling - @scheme[close] before has no effect. + @tt{true}. Invoking the method a second time without calling + @tt{close} before has no effect. close() Hides the canvas and erases the current content. If it succeeds, it -produces @scheme[true]. +produces @tt{true}. Closing the Canvas using the display controls does not fully hide the -canvas; it is still necessary to invoke @scheme[close] before -@scheme[show] is re-enabled. +canvas; it is still necessary to invoke @tt{close} before +@tt{show} is re-enabled. drawCircle(Posn p,int r,IColor c)> -Draws a circle on @scheme[this Canvas] at @scheme[p] with radius -@scheme[r] and color @scheme[c]. If it succeeds, it produces -@scheme[true]. +Draws a circle on @tt{this}Canvas] at @tt{p} with radius +@tt{r} and color @tt{c}. If it succeeds, it produces +@tt{true}. drawDisk(Posn p,int r,IColor c) -Draws a disk on @scheme[this Canvas] at @scheme[p] with radius -@scheme[r] and color @scheme[c]. If it succeeds, it produces -@scheme[true]. +Draws a disk on @tt{this}Canvas] at @tt{p} with radius +@tt{r} and color @tt{c}. If it succeeds, it produces +@tt{true}. drawRect(Posn p,int w,int h,IColor c) -Draws a solid rectangle on @scheme[this Canvas] at @scheme[p] with -width @scheme[w], height @scheme[h], and color @scheme[c]. The +Draws a solid rectangle on @tt{this}Canvas] at @tt{p} with +width @tt{w}, height @tt{h}, and color @tt{c}. The rectangle's lines are parallel to the canvas's borders. If it succeeds, it -produces @scheme[true]. +produces @tt{true}. drawLine(Posn p0,Posn p1,IColor c) -Draws a line on @scheme[this Canvas] from @scheme[p0] to -@scheme[p1] using color @scheme[c]. If it succeeds, it produces -@scheme[true]. +Draws a line on @tt{this}Canvas] from @tt{p0} to +@tt{p1} using color @tt{c}. If it succeeds, it produces +@tt{true}. drawString(Posn p,String s) -Draws the string @scheme[s] at @scheme[p] on @scheme[this -Canvas]. If it succeeds, it produces @scheme[true]. +Draws the string @tt{s} at @tt{p} on @tt{this}Canvas]. If it succeeds, it produces @tt{true}. diff --git a/collects/teachpack/htdc/Docs/idraw.thtml b/collects/teachpack/htdc/Docs/idraw.scrbl similarity index 100% rename from collects/teachpack/htdc/Docs/idraw.thtml rename to collects/teachpack/htdc/Docs/idraw.scrbl diff --git a/collects/teachpack/htdc/Docs/index.thtml b/collects/teachpack/htdc/Docs/index.thtml deleted file mode 100644 index acafc6acad..0000000000 --- a/collects/teachpack/htdc/Docs/index.thtml +++ /dev/null @@ -1,11 +0,0 @@ - - -Teachpacks for How to Design Classes - - -

Teachpacks for "How to Design Classes"

- - - -{(include "foot.tinc")}