next up previous contents
Next: Postscript Up: Libraries Previous: The SolCanvas Graphics System

The SolCanvas Graphics System

The SolCanvas graphics system is implemented as a Sol category. The member-set of the category is the return-type of many member functions.

(define SolGraphics
(category
() ; No parent category

; Set of objects the
; SolGraphics functions will
; manipulate. Starts out
; empty. As new objects are
; created, they are added to
; the set.

(set "SolCanvas: Error")

() ; No set operators

; Define the list of member methods.

;; The newFrame method produces a new AWT frame with the specified
;; title, width, and height, and adds it to the member-set. This
;; method is primarily for creating Sol applications rather than
;; applets (which will inherit a frame from the SolApplet java class).

((newFrame
(function
member-set ((title sstring)
(width integer)
(height integer))
(let ((frame
((primitive-constructor
<java.awt.Frame> (<java.lang.String>)) title)))
(set-set! (union member-set (set frame)))
(setFrameSize frame width height)
(return frame))))

;; The setFrameSize method sets he size of a frame.

(setFrameSize
(function
sol ((frame member-set)
(width integer)
(height integer))
((primitive-virtual-method
<java.awt.Frame> "setSize" <void> (<int> <int>)) frame width height)))


;; The showFrame method displays a frame previously created by
;; newFrame.

(showFrame
(function
sol ((frame sol))
((primitive-virtual-method <java.awt.Frame> "show" <void> ()) frame)))

;; The getCanvas method gets a drawing canvas from a SolApplet
;; subclass instance. This is what Sol applets use to get a drawing
;; context.

(getCanvas
(function
member-set ()
(let ((canvas2
((primitive-get-static
<sol.java.SolApplet> "solCanvas" <sol.java.SolCanvas>))))
(set-set! (union member-set (set canvas2)))
(return canvas2))))

;; The newSolCanvas method creates a new SolCanvas with the specified
;; update delay time (in miliseconds), and adds it to the member-set.

(newSolCanvas
(function
member-set ((delay integer))
(let ((canvas
((primitive-constructor <sol.java.SolCanvas> (<long>)) delay)))
(set-set! (union member-set (set canvas)))
(return canvas))))

;; The updatePosition method changes the x,y location of a drawable
;; and updates the bounding box assuming the size has not changed.

(updatePosition
(function
sol ((drawable sol)
(x integer)
(y integer))
((primitive-virtual-method
<sol.java.Drawable> "updatePosition" <void> (<int> <int>))
drawable x y)))

;; The newCircleDrawable method creates a new CircleDrawable with the
;; specified center, radius, color, and fill-flag.

(newCircleDrawable
(function
sol ((x integer)
(y integer)
(radius integer)
(color sol)
(drawMe boolean))
((primitive-constructor
<sol.java.CircleDrawable>
(<int> <int> <int> <java.awt.Color> <boolean>))
x y radius color drawMe)))

;; The newLineDrawable method creates a new LineDrawable with the
;; specified coordinates and color.

(newLineDrawable
(function
sol ((x1 integer)
(y1 integer)
(x2 integer)
(y2 integer)
(color sol))
((primitive-constructor
<sol.java.LineDrawable>
(<int> <int> <int> <int> <java.awt.Color>)) x1 y1 x2 y2 color)))

;; The newPolyDrawable method creates a new PolyDrawable with the
;; specified coordinates and color.

(newPolyDrawable
(function
sol ((x integer)
(y integer)
(color sol)
(drawme boolean))
((primitive-constructor
<sol.java.PolyDrawable>
(<int> <int> <java.awt.Color> <boolean>)) x y color drawme)))

;; The addPolyPoint method adds a point to a PolyDrawable.

(addPolyPoint
(function
sol ((poly sol)
(x integer)
(y integer))
((primitive-virtual-method
<sol.java.PolyDrawable> "addPoint" <boolean> (<int> <int>))
poly x y)))

;; The addDrawable method adds a drawable to a SolCanvas.

(addDrawable
(function
sol ((canvas member-set)
(drawable sol))
((primitive-virtual-method
<sol.java.SolCanvas> "addDrawable" <void> (<sol.java.Drawable>))
canvas drawable)))

;; The removeAllDrawables method removes al drawables from a SolCanvas.

(removeAllDrawables
(function
sol ((canvas member-set))
((primitive-virtual-method
<sol.java.SolCanvas> "removeAllDrawables" <void> ()) canvas)))

;; The paint method paints a SolCanvas

(paint
(function
sol ((canvas member-set))
((primitive-virtual-method
<sol.java.SolCanvas> "paint" <void> ()) canvas)))

;; The add method adds a component (like a SolCanvas) to a container
;; (like a Frame)

(add
(function
sol ((container member-set)
(location sstring)
(component member-set))
((primitive-virtual-method
<java.awt.Container>
"add" <java.awt.Component> (<String>
<java.awt.Component>))
container location component)))

;; The nameColor method gets an AWT color by name

(nameColor
(function
sol ((name sstring))
((primitive-get-static <java.awt.Color> name <java.awt.Color>))))

;; The rgbColor method gets an AWT color by RGB values.

(rgbColor
(function
sol ((red real)
(green real)
(blue real))
((primitive-constructor
<java.awt.Color> (<float> <float> <float>)) red green blue)))

;; The setBackground method sets the background color of a component.

(setBackground
(function
sol ((component member-set)
(color sol))
((primitive-virtual-method
<java.awt.Component>
"setBackground" <void> (<java.awt.Color>)) component color)))

;; The setForeground method sets the foreground color of a component.

(setForeground
(function
sol ((component member-set)
(color sol))
((primitive-virtual-method
<java.awt.Component>
"setForeground" <void> (<java.awt.Color>)) component color)))

)))


next up previous contents
Next: Postscript Up: Libraries Previous: The SolCanvas Graphics System
Richard W. DeVaul
1998-12-07