Module: objectdrawGraceDocs

Types

Type name
Application
A standalone window which contains other components.
Audio
Type of audio file that can be played
Button
type of button component in window
Choice
Type for pop-up menus
ChoiceFactory
Type of factory to generate choice boxes (pop-up menus)
Color
Color composed of r, g, and b components
Component
The super-type of all components in a GUI.
ComponentFactory<T>
where T <: Component
Container
The type of components that contain other components.
DrawableImageFactory
type of factory for creating images on canvas at(location: Point) size(width: Number, height: Number) file(fileName: String) on (canvas: DrawingCanvas) -> Graphic2D
DrawingCanvas
DrawingCanvas holding graphic objects
Event
Generic event containing source of the event.
FieldFactory
Type of object that generates text fields Text fields can respond to user actions
Foreign
Function<T, R>
Types of blocks representing functions taking an argument of type T and returning a value of type R
Function2<T, U, R>
Types of blocks representing functions taking two arguments of type T and U and returning a value of type R
Graphic
Objects that can be drawn on a canvas and moved around.
Graphic2D
Two-dimensional objects that can also be resized
GraphicApplication
Type of object that runs a graphical application that draws objects on a canvas included in the window and responds to mouse actions
Input
Component that can take input and respond to an event
KeyEvent
Type of an event associated with a key press
KeyResponse
type of an action taking a KeyEvent as a parameter
Labeled
Component of window that holds text
Line
One-dimensional objects
LineFactory
Type of factory for creating line segments
MouseEvent
Mouse event containing mouse location when event generated
MouseResponse
type of an action taking a MouseEvent as a parameter
NumberField
Component in window taking user numeric input
Procedure<T>
Type of block taking argument of type T and returning Done
Response
type of an action taking an Event as a paramter
Text
Text that can be drawn on a canvas.
TextBox
Component of window that holds text
TextField
Component in window taking user text input

Classes

Class name & constructor
application.title(initialTitle:String)size(initialWidth:Number, initialHeight:Number) -> Application
Create Application with window w/title initialTitle and size initialWidth x initialHeight
audio.url(source':String) -> Audio
Create an audio file from source', which is a web URL
button.labeled(label':String) -> Button
Create a button with label given by label'
color.r(r':Number)g(g':Number)b(b':Number) -> Color
Simple color class
drawable.at(location':Point)on(canvas':DrawingCanvas) -> Graphic
abstract superclass for drawable objects (of type Graphic)
drawable2D.at(location':Point)size(width':Number, height':Number)on(canvas':DrawingCanvas) -> Graphic2D
abstract class for two-dimensional objects
drawingCanvas.size(width':Number, height':Number) -> DrawingCanvas
class representing a window panel that manages graphics on screen The window containing the canvas has dimensions width' x height'
event.source(source':Component) -> Event
class to create an event generated by source'
eventLog.kind(kind':String)response(response':Procedure)
Log entry to keep take of response to an event
field.ofType(inputType:String)labeled(label':String) -> Input
Create input field of type inputType showing label'
filledArc.at(location':Point)size(width':Number, height':Number)from(startAngle:Number)to(endAngle:Number)on(canvas':DrawingCanvas) -> Graphic2D
class to generate filled arc at (x',y') with size width' x height' from startAngle degrees to endAngle degrees created on canvas' Note that angle 0 is in direction of positive x axis and increases in angles go clockwise.
filledOval.at(location':Point)size(width':Number, height':Number)on(canvas':DrawingCanvas) -> Graphic2D
class to generate filled oval at (x',y') with size width' x height' created on canvas'
filledRect.at(location':Point)size(width':Number, height':Number)on(canvas':DrawingCanvas) -> Graphic2D
class to generate filled rectangle at (x', y') with size width' x height' created on canvas'
framedArc.at(location':Point)size(width':Number, height':Number)from(startAngle:Number)to(endAngle:Number)on(canvas':DrawingCanvas) -> Graphic2D
class to generate framed arc at (x',y') with size width' x height' from startAngle radians to endAngle radians created on canvas' Note that angle 0 is in direction of positive x axis and increases in angles go clockwise.
framedOval.at(location':Point)size(width':Number, height':Number)on(canvas':DrawingCanvas) -> Graphic2D
class to generate framed oval at (x',y') with size width' x height' created on canvas'
framedRect.at(location':Point)size(width':Number, height':Number)on(canvas':DrawingCanvas) -> Graphic2D
class to generate framed rectangle at (x',y') with size width' x height' created on canvas'
graphicApplication.size(theWidth':Number, theHeight':Number) -> GraphicApplication
Create window with dimensions theWidth' x theHeight's with canvas installed and that responds to mouse actions
keyEvent.source(source':Component)event(event':Foreign) -> KeyEvent
class to create an event with the key code from event'
mouseEvent.source(source':Component)event(event':Foreign) -> MouseEvent
class to create an event with the mouse location from event'
resizable2D.at(location':Point)size(width':Number, height':Number)on(canvas':DrawingCanvas) -> Graphic2D
abstract class to be extended for 2 dimensional objects that can be resized.
text.at(location':Point)with(contents':String)on(canvas':DrawingCanvas) -> Text
class to generate text at location' on canvas' initially showing contents'
textBox.with(contents':String) -> TextBox
Create a component in window that holds the string contents' It cannot respond to user actions

Methods

Method signature Return type
ColorOutOfRange
Exception that may be thrown if the r, b, or g components are not between 0 and 255 (inclusive)
black Color
blue Color
container ComponentFactory<Container>
a factory to create new containers
cyan Color
gray Color
green Color
magenta Color
neutral Color
numberField FieldFactory
Factory to generate fields holding only numbers
passwordField FieldFactory
Factory to generate fields to hold passwords
pi Number
A rough approximation of the value of pi.
randomColor Color
Produce a random color.
randomIntFrom(m:Number)to(n:Number) Number
A random integer from m to n, inclusive.
randomNumberFrom(m:Number)to(n:Number) Number
A random number from m to n, inclusive.
red Color
selectBox ChoiceFactory
Factory to generate choice boxes (pop-up menus)
textField FieldFactory
Factory to generate text fields Generate a text field with initial contents given by label' It can respond to user input
white Color
yellow Color