Primitive Objects:
circle
[name] [x] [y] [width] [color] [bkgrd]
Creates a circle at (x, y) with the specified attributes.
line [name] [x1] [y1] [x2] [y2] [color]
Creates a line starting at (x1, y1) and going to (x2, y2).
text [name] [x] [y] ["text"] [color] [point]
Prints the string "text" at location (x, y). Point refers to the
size of the text.
rectangle [name] [x] [y] [width] [height] [color] [bkgrd]
Creates a rectangle at (x, y) with specified attributes.
oval [name] [x] [y] [width] [height] [color] [bkgrd]
Creates an oval at (x, y) with specified attributes.
polygon [name] [n] [x1] [y1] ... [xn] [yn] [color] [bkgrd]
Builds a polygon with n vertices and the specified attributes.
General Action Commands:
begin..end
Place a group of commands in a begin end block in order to make those
commands execute simultaneously.
changeParam [target] [parameter..] [new value]
This command is used to change the appearance and/or data of many of the
objects listed above. Available parameters: color, bkgrd (background),
textcolor, text, point, width, height, x, y. See the extended description of this command
below for further details on its usage.
moveRelative [target] [x-offset]
[y-offset]
This command animates the movement of the target object from its
original location to a new location. The new location is calculated by
adding the x and y offset to the target object's x and y-coordinate.
delay [milliseconds]
Causes the Jawaa animation to pause for the specified number of
milliseconds.
groupObject [name] [n] [objects names..]
This command is used to group objects under a single name.
The group name can be referenced in the moveRelative and the changeParam commands.
scale [target] [percentage]
This command can be used on primitive objects and nodes to either
increase or decrease the size of the object.
remove [target]
Causes the target object to be removed from the screen and the name
freed for use again.
Data Structures:
array [name] [x] [y] [n.m] [data..] [orientation]
[color] [bkgrd] [textcolor]
Creates an array with n cells and m data elements per cell with the
specified orientation and attributes.
queue [name] [x] [y] [n] [data..] [color] [textcolor]
Creates a LILO queue with the text data as contents. Data elements can be
added, using enqueue, and removed by using
dequeue .
stack [name] [x] [y] [n] [data..] [color] [textcolor]
Creates a LIFO stack containing n data items with the nth datum on the
bottom of the stack. Data elements can be added using push
and removed by using pop.
list [name] [x] [y] [width] [height] [header] [n]
[nodes..] [orientation] [color] [bkgrd] [textcolor] [type]
Generates a linked-list data structure from a list of nodes. The nodes are connected
in the order that they appear. The orientation can be VERT or HORZ. Type refers to the
graphic representation of the node, either CIRCLE or RECT.
listpointer [name] [target] [direction]
[color] [textcolor]
Creates a pointer pointing at target in the specified direction.
tree [name] [x] [y] [width] [root] [n]
[connections..] [color] [bkgrd] (does not work)
Command to generate a tree data structure. The x and y coordinate specify the root node position.
Connections are specified by the use of parentheses, eg. (node1, node2).
graph [name] [x] [y] [width] [n] [connections..]
[color] [bkgrd] (does not work)
Command to generate a graph data structure. Connections are specified by the use of parentheses,
eg. (node1, node2).
node [name] [x] [y] [width] [height] [n] [data..]
[color] [bkgrd] [textcolor] [type]
Creates a stand alone node with the specified attributes and data items. Type refers to the
graphic representation of the node, either CIRCLE or RECT.
marker [name] [node] [diameter] [color] [bkgrd]
Creates a marker that is located at the specified node with the defined attributes.
Data Structure Action Commands:
push [target] [data]
This command can only be used when the target object is a stack. The data object is pushed onto the stack.
pop [target]
This command can only be used when the target object is a stack. The top-most data entry in the stack is popped
off.
enqueue [target] [data]
This command can only be used when the target object is a queue. The data object is enqueued at the end of the
queue.
dequeue [target]
This command can only be used when the target object is a queue. The right-most data entry is dequeued from the
queue.
moveMarker [target] [node]
This command can only be used when the target object is a marker. The marker is moved to the new node.
connectNodes [name] [node1] [node2]
[color] [num]
This command creates an arrow connection from one node
to another. The arrow that is drawn can be referenced by the
specified name. The arrow has the specified color and
0, 1 or 2 arrowheads
as specified by the num parameter.
Descriptions:
Circle
Parameters:
name |
a name uniquely identifying this circle |
x |
x-coordinate |
y |
y-coordinate |
width |
diameter of the circle |
color |
color of the circle outline |
bkgrd |
color of the circle background |
The top edge of the circle will be at the y-coordinate and the left edge of the
circle will be at the x-coordinate of the specified location. The circle is first
drawn in the outline color and then filled in
with the background color.
Example:circle c1 25 25 80 green yellow
This will create a circle at the point (25,25) relative to the
upper left hand corner of the applet. The circle will have a 80
pixel diameter and have a green outline with a yellow backgorund. This
is shown below.
Line
Parameters:
name |
a name uniquely identifying this line |
x |
starting x-coordinate |
y |
starting y-coordinate |
x |
ending x-coordinate |
y |
ending y-coordinate |
color |
color of the line |
Example:line l1 30 30 90 90 blue
line l2 200 60 280 60 magenta
The first example will draw a green line starting at (30,30) and going to
(90,90) as shown below in the picture on the left.
The second example, shown below in the drawing on the right, will draw a magenta line starting
at (20,60) and going to (100,60).
Text
Parameters:
name |
a name uniquely identifying this text object |
x |
x-coordinate |
y |
y-coordinate |
text |
the text to be displayed encapsulated in quotes |
color |
color of the text |
point |
the point size of the text. If no size is
specified the point size is 12 by default. |
Example:text t1 60 60 "jawaa" blue
text t2 220 60 "can create multiple words" red 24
The first example will create a text object at (60,60). The object will display
"jawaa" and be blue. Since no point size is specified the size is 12.
This is shown in the figure below on the left.
The second example will create a text object at (160,60). The
object will display "can create multiple words" and be
red. Its point size will be 24. This is shown in the figure below on the right.
Rectangle
Parameters:
name |
a name uniquely identifying this rectangle |
x |
x-coordinate |
y |
y-coordinate |
width |
width of the rectangle |
height |
height of the rectangle |
color |
color of the rectangle outline |
bkgrd |
color of the rectangle's background |
Example:rectangle r1 10 20 100 120 black red
rectangle r2 150 20 180 60 cyan yellow
The first example will create a rectangle with its upper left corner at (10,20) and
with a width of 100 and a height of 120. The rectangle will be red
with a black outline, as shown in the figure below on the left.
The second example will create a rectangle with its upper corner at
(150,20) and with a width of 180 and a height of 60. The rectangle
will be yellow with a cyan outline. This is shown in the figure
below on the right.
Oval
Parameters:
name |
a name uniquely identifying this oval |
x |
x-coordinate |
y |
y-coordinate |
width |
width of the oval |
height |
height of the oval |
color |
color of the oval outline |
bkgrd |
color of the oval's background |
Example:oval o1 10 20 200 60 black orange
oval o2 250 20 30 120 red transparent
The first example will create a oval with its upper left corner at (10,20) and
with a width of 200 and a height of 60. The oval will be orange
with a black outline. The oval object is essentially identical to
the rectangle object except for the way that it is drawn. This
example is shown below on the left.
The second example will create a oval with its upper corner at
(250,20) and with a width of 30 and a height of 120. The oval will be
transparent with a red outline.
Polygon
Parameters:
name |
a name uniquely identifying this polygon |
n |
number of points in the polygon |
x1 y1 ... xn yn |
a list of the points |
color |
color of the polygon's outline |
bkgrd |
color of the polygon's background |
Example:polygon p1 3 10 120 80 60 150 150 blue green
polygon star 10 100 20 80 60 40 60 72 80
45 120 100 90 155 120 128 80 160 60 120 60 black yellow
The first example will create a triangle with vertices at (10,120), (80,60), and (150,150).
The edges will be blue with green on the interior. This is shown below
on the left.
The second example will create a star with ten vertices. The edges
will be black with yellow on the interior. This is shown below on
the right.

Array
Parameters:
name |
a name uniquely identifying this array |
x |
x-coordinate |
y |
y-coordinate |
n.m |
n - number of cells, m - data items per cell |
data |
the text to fill the array cells with. If the array
is defined to have two cells with two data items per cell, then four data
items are required. The first two data items are put in the first cell and
the second two are put in the second cell. |
orientation |
vert-vertical or horz-horizontal alignment of cells |
color |
color of the cell outline |
bkgrd |
color of the cell background |
textcolor |
color of the text |
The x and y coordinate specify the top left corner of the first cell in the array.
All of the cells are adjusted so that they are all the same size and also accomodate the
largest data in the set. To make the cells bigger a long
transparent word can be put in then changed to another word. The
cells will remain the size it was before. Cells in the array can be accessed
individually and its parameters can be changed via changeParam.
Example:array a 25 25 4.1 A Ray of Hope horz
red yellow blue
changeParam a[0] bkgrd white
moveRelative a[2] 0 25
array array2 40 40 3.2 One 1 Two 2 Three 3 vert green black white
changeParam array2 index on
The first example will create an array starting at the point (25,25) relative to the upper
left hand corner of the applet. It will contain four cells with one item
in each cell. Its orientation will be horizontal. The cell
outline will be red, the background yellow and the text color will
be blue. This is shown
below on the left.
The second example will change the background of the first cell in
the above array to white. It will then move the third cell down 25.
This is shown below in the middle.
The third example will create an array starting at the point
(40,40). It will contain three cells with two elements in each
cell. Its orientation will be vertical. The cell outline
will be green, the background black, and the text color white. Using
changeParam the array index has been turned on. (By default the index
is off). This is shown below on the right.

Queue
Parameters:
name |
a name uniquely identifying this queue |
x |
x-coordinate |
y |
y-coordinate |
n |
total number of data items |
data |
the text to fill the queue with. The
data elements are added to the queue in the order that they
appear. |
color |
color of the queue outline |
textcolor |
color of the text |
The x and y coordinate specify the top left corner of the queue outline.
The queue will grow itself to accomodate all of the data items
as they are enqueued or dequeued.
The individual data elements cannot be accessed as they are in an array. Thus, the changeParam can't be used to change the data of
the queue. However, the color values can be altered with changeParam.
Altering the position of the queue causes the outline and the data to
move together as if they were in a group.
Example:queue q1 25 25 4 Out First In First red
blue
queue q2 220 25 6 Four 4 "Three 3" Two 2 "One 1" magenta black
The first example will create a queue at (25,25) with blue text and a red
outline. The queue from left to right will contain "First In First
Out".
The words appear backwards because the data is inserted into the
queue in the order that they appear in the Jawaa command.
This example is shown below on the left.
The second example will create a queue at (220,25) with black text and
a magenta outline. The queue from left to right will contain "'One 1' 2
Two 'Three 3' 4 Four ", as shown below on the right.
Stack
Parameters:
name |
a name uniquely identifying this stack |
x |
x-coordinate |
y |
y-coordinate |
n |
total number of data items |
data |
the text to fill the stack with. The
data elements are added to the stack in the order that they
appear. |
color |
color of the outline |
textcolor |
color of the text |
The x and y coordinate specify the top left corner of the stack outline.
The stack will grow itself to accomodate all of the data items
as they are popped or pushed. The
stack centers all text and grows to fit the widest data item anytime the
data set is altered. The individual data elements cannot be
accessed as they are in an array. Thus, the changeParam can't be used to change the data of
the stack. However, the color values can be altered with changeParam.
Altering the position of the stack causes the outline and the data to
move together as if they were in a group.
Example:stack s1 25 25 4 Last In First Out blue
red
stack s2 50 50 5 words 2 numbers 4 stack black magenta
The first example will create a stack at (25,25) with red text and a blue
outline. The stack will be 3 data elements deep and wide enough to
accomodate the widest word. This is shown in the figure below on the left.
The second example will create a stack with numbers and words as
shown below on the right.
Node
Parameters:
name |
a name uniquely identifying this node |
x |
x-coordinate of node |
y |
y-coordinate of node |
width |
width of node |
height |
height of node |
n |
number of data in the node |
data |
the text to put in the node |
color |
color of text and outline |
bkgrd |
background color of node |
textcolor |
the color of the text |
type |
shape of node, either CIRCLE or RECT |
Example:
node n1 20 40 100 100 3 Nodes "are for" Lists black red white CIRCLE
node n2 200 40 90 90 2 123 Rectangular magenta transparent green RECT
The first example will create a circular node at position (20,40)
with width 100 and height 100.
The node will contain three data elements, "Nodes", "are for",
and "Lists". Its outline color is black. Its background is red and the
textcolor is white.
The second example will create a rectangular node with width 90 and height
90. The node will contain "123" and "Rectangular". Its outline will be in
magenta. Its text will be green and the background white.
List
Parameters:
name |
a name uniquely identifying this group
of nodes |
x |
x-coordinate of first node |
y |
y-coordinate of first node |
width |
Note: only used if new node created.
width of new nodes |
height |
Note: only used if new node
created. height of new nodes |
header |
name of header pointer |
n |
total number nodes in the list |
nodes |
the names of the nodes that are to be
in the list, followed by the data for the node if the node has not already
been created. The nodes used in the list may already exist and if not are
created automatically. If it has already been created no data is required.
When a node already exists (created with the node
command) it's previous edge connections are removed and the edge
connections required by the list are added. When a node does not exist it
is created with the parameters width, height, color,
and background. |
orientation |
VERT-vertical or HORZ-horizontal |
color |
Note: used only if a new node is
created. The color of the node outline. |
bkgrd |
Note: used only if a new node is
created. The color of the background of a node. |
textcolor |
Note: used only if a new node is
created. The color of the text of a
node.
|
type |
shape of newly craeted nodes in the
list. either RECT or CIRCLE |
This command serves as both an action command and a object
creation command. The major function of this command is to form a list
structure out of a group of nodes. The node names listed in the nodes
parameter may reference nodes that already exist or nodes that do not
exist. Nodes that do not exist are created and contain the data specified
after the name of the node. New nodes are all created with the width, height,
color, background and textcolor parameter specifications. If a node name
references a node that already exists it is incorporated into the list
and all of its previous edge connections are removed. The edges that are created by this command are also given
names that can be referenced individually. The edges have the name in
the format node1_arrow, node2_arrow, etc. So a connection from node "red" to node
"blue" can be referenced in Jawaa as "red_arrow".
Finally, the
list command will create a groupObject that
contains all of the nodes in the list. This way the entire list can be
referenced together by using the name of the list.
Example:
list myList 50 50 30 30 head 5 node1 "n1" node2 "n2" node3 "n3" node4 "n4"
node5 "n5" HORZ blue yellow red CIRCLE
We assume that the nodes node1, node2, node3, node4, and node5 do not
already exist. Thus, the execution of this command results in the
creation of five new nodes all with width 40, height 40, blue outline, red
text, and yellow background. A pointer at the head of the list with the
name "head" is also created. The list has all circle nodes. Four new edges
are also created, node1_arrow, node2_arrow, node3_arrow, and node4_arrow.
The entire list can be moved with a command similar to "moveRelative myList 50 0". The list is shown
below.
Example:
node node1 20 20 40 40 1"add" blue red
blue CIRCLE
node node2 50 50 40 40 1 "to list" black
green black CIRCLE
list myList2 120 120 40 40 top 4 newnode "new" node1 newnode2 "nodes" node2
HORZ black cyan magenta RECT
The two node commands will create to nodes, node1 and node2 with the
specified attributes.
The list command now only creates two new nodes, newnode and newnode2 with the
specified attributes. The other two nodes, node1 and node2 already
exist and are merely incorporated into the list. The first node, newnode, is
moved to the location (120, 120). The rest of the nodes are moved to line
up with the first node in a horizontal line. Three new edge connections
are created by the list command, "newnode_arrow", "node1_arrow", and
"newnode2_arrow". The entire list can be moved with a command similar to "moveRelative myList2 50 0". Or a single node
can be deleted with the command "delete node1". A single edge connection can be
deleted with the command "delete newnode_arrow". The list is shown below.
Example:
list myList3 80 80 25 25 numbers 3 one 3 two 2 three 1 VERT magenta white blue RECT
A List can also be vertical. This example will create a vertical list with
3 rectangular nodes with text, "3", "2", and "1". All three nodes will have width and height of
25, magneta outline, blue text, and a white background, as shown below.
List Pointer
Parameters:
name |
a name uniquely identifying this list pointer
|
target |
node that the list pointer will point to |
direction |
the direction in which the list pointer
points. Can be one of eight directions: N (north), S (south), E
(east). W (west), NW (northwest), NE (northeast), SW (southwest),
and SE (southeast). |
color |
Color of arrow. Arrow color can be
changed using changeParam . |
textcolor |
Text color for name of list pointer.
Text color can be changed using changeParam
|
This command will create a list pointer with the specified name that points
at a node. The pointer can point at the node from one of eight
directions.
Example:
list myList 100 100 50 30 header 4 n1 nodeA n2 nodeB n3 nodeC n4 nodeD HORZ magenta
yellow blue RECT
listpointer pointer n2 N cyan red
The first snippet of code will create a list with four nodes in it. Then
the last line will create a listpointer called "pointer" pointing at
n2. The arrow color will be cyan and the text red. This is shown
below.
Begin..End
A group of Jawaa commands can be put in a Begin-End block in order to
force all of the commands to be executed simultaneously.
Example:
begin
moveRelative myCircle 100 50
changeParam myCircle bkgrd blue
end
This will cause the two commands moveRelative and changeParam to be
executed simlutaneously. The circle referred to by myCircle will move
while also changing colors at the same time.
changeParam
Parameters:
name |
name referencing the target object |
parameter |
color, bkgrd,
textcolor,text, width, height, point, x, y, target, direction,
arrowcolor, swap |
new value |
a new value for the specified parameter |
Usage:
Parameter |
Used with.. |
Effect |
color |
all objects |
Changes foreground color of target
object. Special cases exist - see individual objects for specific effects |
bkgrd |
all object except line, text, queue, stack. |
Changes background color of target
object. Special cases exist - see individual objects for specific effects |
textcolor |
text, array elements, node |
Changes the text color of the target. Nodes and arrays contain multiple
text elements that must be addressed properly. |
text |
text, array elements, node |
Changes the text of the target. Nodes and arrays contain multiple
text elements that must be addressed properly. |
width |
circle, rectangle, oval, node, marker |
sets the width of the target object to
the new value |
height |
rectangle, oval, node |
sets the height of the target object
to the new value |
point |
text, node and array data elements |
sets the new font size of the target text |
target |
listpointers |
sets the listpointer to now point at the
new node specified |
direction |
listpointers |
sets the direction of the listpointer to
the direction sepcified. Can be either N, S, E, W, NW, NE, SW, or
SE
|
arrowcolor |
listpointers |
changes the arrow color of the listpointer
|
swap |
arrays |
swaps the contents of one array cell with
the contents of another array cell |
index |
arrays |
turns the array index on or off |
x |
all objects |
sets the x-coordinate of the target object |
y |
all objects |
sets the y-coordinate of the target object |
xn |
polygon, line |
sets the nth x-coordinate of the target object |
yn |
polygon, line |
sets the nth y-coordinate of the target object |
The changeParam command is very versatile in its ability to change the
attributes of an object that has already been created. With this command
the location, size, color, or data of an object can be changed. The
following examples illustrate its many uses.
Example:
circle myCircle 25 25 80 black yellow
changeParam myCircle color green
changeParam myCircle bkgrd pink
This snip of Jawaa code will create a circle with a black outline
and a yellow background (as shown below on the left). Then the first
changeParam command will change the outline of the circle to green (shown
below in the middle). The second changeParam command will change the
background to pink, as shown below on the right.
Note: There are three separate snapshots to illustrate how the circle
changes.
Example:
rectangle myRect 100 120 40 60 black red
begin
changeParam myRect width 70
changeParam myRect x 50
changeParam myRect y 50
end
This code will create a rectangle with the following attributes:
width 40, height 60, outline black, background red. This is shown
below on the left. The begin/end block
executes and simultaneously changes the rectangle to have width 70
and to now be located at (50,50) instead of (100,120). This is shown
on the right.
Example:
polygon myPoly 3 100 100 140 140 60 140 black red
changeParam myPoly y0 50
changeParam myPoly x2 60
changeparam myPoly x1 120
This code creates a polygon with 3 vertices (100,100), (140,140),
and (60, 140), as shown below on the left. The changeParams that follow change the location of the
polygon's vertices to (100,50), (120,140), (60,140). The new polygon
is shown below on the right.
Example:
text myText 50 100 "!--writing text in jawaa--!" magenta
changeParam myText point 32
The first line in this code will draw a text string on the screen (shown
below on the left) and the changeParam command
then changes the point size of the font to 32, as shown below on the right. The default point size is 12.
Example:
list l1 100 100 25 25 head 4 n1 n1 n2 n2 n3 n3 n4 n4 VERT black white
cyan CIRCLE
listpointer temp n2 E green blue
changeParam temp target n4
changeParam temp direction SW
changeParam temp arrowcolor red
The first two lines of code will create a list and a listpointer called
temp that points at the second node in the list, as shown below on the
furthermost left. The third line will change the listpointer to now point
at the fourth node. This is shown below in the second figure from the left.
The fourth line of code will change the direction of the listpointer from east
to southwest. This is shown in the figure third from the left. The fifth
line of code will change the arrow color of the listpointer from green to
red, as shown below on the furthermost right.
Example:
array arr 100 100 4.2 swap abc two xyz array 123 cells 789 VERT black
yellow blue
changeParam arr[0] swap arr[3]
changeParam arr[2].1 text alpha
The first line will create an array with four data elements, as shown below on
the left. The second line will then do a swap of arr[0] with
arr[3] as shown below in the middle. The third line will change the text
of the second element of the third cell. This is shown below on the right
moveRelative
Parameters:
target |
the name of the target object |
x-offset |
the pixel amount to offset the x-coordinate |
y-offset |
the pixel amount to offset the y-coordinate |
This command is used to animate movement of an object from one point to
another. The x and y offsets are used to calculate the ending point. The
object is then moved through a progression to its new location. The
final effect is a smooth moving animation.
Example:
line l1 30 30 60 60 orange
moveRelative l1 100 100
This will draw an orange line starting at (30,30) and going to
(60,60). The line will then be animated as both of its starting and
ending coordinates are offset by +100 in the x (100 pixels to the right)
and +100 in the y (100 pixels down).
delay
Parameters:
milliseconds |
the number of milliseconds the delay |
This command simply delays execution of the next line of code by the
specified number of milliseconds.
groupObject
Parameters:
name |
the name of this groupObject |
n |
the number of objects in this group |
object names.. |
the names of all of the objects in the
group (all of these objects must already exist on the screen) |
This command is used to create a groupObject which can be conveniently
used to address a number of objects through a single name. When the changeParam command is used on a groupObject,
only the objects in the group that have the specified parameter are
affected by the command (an example below illustrates this point).
Example:
line l1 30 30 60 60 orange
circle c1 50 50 30 white red
text t1 100 120 "groupObject
demo" blue
rectangle r1 20 80 40 20 green
magenta
groupObject group 4 l1 c1 t1 r1
moveRelative group 100 100
This code will draw a line, a circle, a rectangle, and a text object on the screen
with the specified attributes. These four objects will then be grouped
and the moveRelative command will result in all of the objects moving
simultaneously.
Example:
line l1 40 30 90 60 orange
circle c1 125 80 30 red white
text t1 30 150 "groupObject
demo" blue 20
rectangle r1 20 80 40 20 green
magenta
groupObject group 4 l1 c1 t1 r1
changeParam group bkgrd black
This code draws the same four objects on the screen, shown below on the left. Now however a
changeParam is applied to them. The changeparam command calls for a
change in the background parameter of the objects. Since only the
circle and rectangle have a background property, thier background property will be
changed to black and the other two objects in the group will remain
unchanged. This is shown below on the right.
scale
Parameters:
target |
the target object |
precentage |
the percentage amount to scale the
size of the object |
This command can be used to change the size of a Jawaa object. The
change in size of the object is shown as a gradual progression so as to
look animated. The range for the percentage variable is the set of
positive integers.
Example:
circle myCircle 100 200 40 red blue
scale myCircle 200
scale myCircle 75
This code will first draw a circle with radius 40 on the screen, as shown
below on the left. The circle will then grow to 200% of its size
(radius of 80), as shown below in the middle. The second
scale command changes the circle to 80% of its previous size (radius
down to 64). This is shown below on the right.
Example:
node myNode 50 50 100 100 2 ABC 123
red yellow red RECT
scale myNode 60
This code will first draw a node with width and height of 100, as
shown below on the left. The scale command will then reduce the node
to 60% of its original size. This is shown below on the right.
remove
Parameters:
Causes the target object to be removed from the screen and the name to
be freed for use again.
push
Parameters:
target |
the target object (must be a stack) |
data |
the string to push onto the stack |
The push command is the only way to add data to a stack. The data string
must be encapsulated in quotes if it contains spaces. The data string is
added to the top of the stack and the stack grows to accomodate the new
data.
Example:
stack s1 200 200 3 Stacks on Top
black red
push s1 "new top"
push s1 now_on_top
This code will first create a stack with three data items (shown below on
the left). The string "new top" will be pushed onto the top of the stack
(shown below in the middle)
and the string "now_on_top" will be pushed on top of that (shown below on
the right).
pop
Parameters:
target |
the target object (must be a stack) |
This command causes the target stack to have its top data element
removed. Upon removing that data element the stack will resize itself.
Example:
stack s1 200 200 4 Pop The Top Off
black red
pop s1
pop s1
This will first create a stack with four data items, as shown below on the
left. The first pop command removes the "Pop" data element. This is shown
below in the middle. The second pop command removes the "The" data element
from the top of the stack, as shown below on the right.
enqueue
Parameters:
target |
the target object (must be a queue) |
data |
the string to enqueue |
The enqueue command is the only way to add data to a queue. The data string
must be encapsulated in quotes if it contains spaces. The data string is
added to left end of the queue and the queue grows to accomodate the new
data.
Example:
queue q1 200 200 2 backwards
insert green black
enqueue q1 1
enqueue q1 "2 3"
This code will first create a queue with the two data items (shown below
on the left). Then the data string "1" will be added to the lefthand side of
the queue. This is shown below in the middle. The data string "2 3" will
then be added to the left of "1", as shown below on the right.
dequeue
Parameters:
target |
the target object (must be a queue) |
This command causes the target queue to have its rightmost data element
removed. Upon removing that data element the queue will resize itself.
Example:
queue q1 200 200 6 A 1 B 2 C 3 red blue
dequeue q1
dequeue q1
This code will first generate a queue with "A", "1", "B", "2",
"C", and "3" in it. This is shown below on the left. The first dequeue
command will remove the rightmost element, "A". This is shown below
in the middle. The second dequeue command will remove "1", as shown below
on the right.
connectNodes
Parameters:
name |
the name to refer to this edge
connection by |
node1 |
the start node |
node2 |
the end node |
color |
the color of the line |
num |
the number of arrowheads on edge (0,1,or 2) |
This command will create an edge between the two specified nodes. The
edge can later be referenced by the specified name. Edges are elastic
and remain connected to their nodes as the nodes are moved on the screen.
Example:
node node1 50 50 50 50 1 "connect" green
black green
CIRCLE
node node2 50 50 35 35 1 "nodes" black
green black CIRCLE
connectNodes node1_to_node2 node1 node2 magenta 1
The first two lines of the code will create two nodes. This is shown below
on the left. The third line creates a magenta connection between them, as
shown below on the right. The edge has one arrow that is located at the end
node, node2. The edge can be referenced in other commands through the name
node1_to_node2.
moveMarker
Parameters:
target |
the target object (must be a marker) |
node |
the new node to move to |
This command causes the marker to move from the node it is currently on
to the new specified node. A node connection must exist from the node it
is currently on to the new specified node.
Trick: Markers will only move in the
direction the connection was made. To have a two way connection a
transparent connection should be made in the opposite way.
Example:
node node1 50 50 50 50 2 "First" "Node"
cyan black cyan RECT
node node2 100 100 50 50 2 "Second" "Node"
black cyan black RECT
connectNodes node1_to_node2
node1 node2 red 2
marker mark node1 10 black yellow
moveMarker mark node2
Two nodes are created with a two-arrow connection between them, as shown
below on the left. A yellow marker is created on node1. This is shown below
in the middle. The marker then moves across the node1_to_node2 edge and
centers itself on node2, as shown below on the right.
Colors
There are two ways to specify a color in Jawaa. The color may be in
the form of a string representing the name of the color. The color may
also be a RGB triplet (three integers that specify the amount of red,
green, and blue to mix together).
Recognized Colors:
Example:
circle myCircle 20 10 10 black red
This command will create a circle with a black outline and red
background.
circle myrCicle 20 10 10 black
(255,0,0)
This command will do the exact same thing. The RGB triplet specifies
the color red. The parentheses around the triplet are
required. See here
for more RGB colors.
Example:
circle c1 40 40 40 black
(193,255,193)
circle c2 100 40 40 black
(155,205,155)
circle c3 160 40 40 black
(105,139,105)
circle c4 220 40 40 black
(110,139,61)
circle c5 280 40 40 black (85,107,47)
This code will create five circles all having different shades of green.
The five circles are shown below.
|