|
Sybernet / Supplied Packages Reference
Release 3.00 May 25, 2003 |
|
The AWT package provides subprograms for creating graphics. With it you can draw points, lines, circles, arcs, squares, pies, and quadrilaterals. There are also three subprograms that draw a pie chart, bar chart, and line graph simply by passing a select statement.
Although loosely patterned after the Java awt package, Java is not required to use this package. Graphic "images" created by this package are rendered in real-time. Depending on your broswer, you may actually see the image being drawn.
All images are created relative to the origin (0,0). By default this is the upper-left and upper-right area of your browser's window. You may change the origin with two procedures in this package: X_ORIGIN and Y_ORIGIN. It's always a good idea to reset them to zero when you are done.
| Subprogram | Description |
|---|---|
drawPoint |
Draws a point. |
drawLine |
Draws a line between two points. |
drawRect |
Draws a rectangle. |
fillRect |
Fills a rectangle. |
draw3DRect |
Draws a 3D rectangle. |
fill3DRect |
Fills a 3D rectangle. |
drawCircle |
Draws a circle. |
fillCircle |
Fills a circle. |
drawText |
Writes your text at a particular coordinate. |
drawOval |
Draws an Oval. |
fillOval |
Fills an Oval. |
drawArc |
Draws an arc. |
drawOvalArc |
Draws an oval arc. |
drawAngle |
Draws a line for a given angle. |
drawPie |
Draws a pie. |
fillPie |
Fills a pie. |
drawOvalArc |
Draws an oval arc. |
drawQuad |
Draws a quadrilateral. |
fillQuad |
Fills a quadrilateral. |
drawLayer |
Creates a layer or div element. |
draw3DLayer |
Creates a 3D layer or div element. |
drawChart |
Creates a line graph. |
drawBarChart |
Creates a bar chart. |
drawPieChart |
Creates a pie chart. |
X_ORIGIN |
Sets the X origin. |
Y_ORIGIN |
Sets the Y origin. |
draw3DLayer is exactly the same as drawLayer except that a 3D effect is created by shading each border.
procedure draw3DLayer
(
@name varchar(255) = null
, @top int = null
, @left int = null
, @height int = null
, @width int = null
, @bgcolor varchar(255) = null
, @visibility varchar(255) = null
, @onMouseOver varchar(255) = null
, @onMouseOut varchar(255) = null
, @onMouseDown varchar(255) = null
, @onMouseMove varchar(255) = null
, @filler varchar(255) = null
)
| Parameter | Description |
|---|---|
name |
Name of layer. |
top |
Absolute Y coordinate. |
left |
Absolute X coordinate. | height |
Height of object. |
width |
Width of object. |
bgcolor |
Background color of layer. |
visibility |
Determines is layer is visible (show) or invisbile (hide). |
onmouseover |
JavaScript onMouseOver event. |
onmouseout |
JavaScript onMouseOut event. |
onmousedown |
JavaScript onMouseDown event. |
onmousemove |
JavaScript onMouseMove event. |
filler |
Optional text. |
The following example illustrates how to call draw3dlayer:
exec http.awt.draw3DLayer
@name = NULL
, @top = 100
, @left = 100
, @height = 100
, @width = 100
, @bgcolor = 'black'
, @visibility = NULL
, @onMouseOver = 'window.status=''Hello'';return true;'
, @onMouseOut = NULL
, @onMouseDown = NULL
, @onMouseMove = NULL
, @filler = NULL
draw3DRect is exactly the same as drawRect except that a 3D effect is created by shading each border
procedure draw3DRect
(
@top int
, @left int
, @height int
, @width int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
top |
Absolute Y coordinate. |
left |
Absolute X coordinate. | height |
Height of object. |
width |
Width of object. |
color |
Object color. |
The following example illustrates how to call draw3drect:
exec http.awt.draw3DRect
@top = 100
, @left = 100
, @height = 100
, @width = 100
, @color = 'red'
This procedure draws a line (not an angle) of length radius. The line is drawn from the X and Y coordinate with a length of radius with an angle offset of angle from the X coordinate.
procedure drawAngle
(
@x int
, @y int
, @radius int
, @angle int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
x |
The X coordinate of the center of the circle. |
y |
The Y coordinate of the center of the circle. |
radius |
Radius of circle. |
angle |
Angle of line from the X coordindate. |
color |
Object color. |
The following example illustrates how to call drawangle:
declare
@i int
, @angle int
begin
select @i = 0
while (@i <= 3)
begin
select @angle = @i * 90
exec http.awt.drawAngle 0,0,100,@angle,'green'
select @angle = @i * 90 + 45
exec http.awt.drawAngle 0,0,100,@angle,'blue'
select @i = @i + 1
end
end
Draws an arc bounded by the specified rectangle from startAngle to endAngle. 0 degrees is at the 3-o'clock position. Positive arc angles indicate counter-clockwise rotations, negative arc angles are drawn clockwise.
procedure drawArc
(
@x int
, @y int
, @radius int
, @startAngle int
, @arcAngle int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
x |
The X coordinate of the center of the circle. |
y |
The Y coordinate of the center of the circle. |
radius |
Radius of circle. |
startangle |
Beginning angle in degrees. |
arcangle |
Length of angle in degrees. |
color |
Object color. |
The following example illustrates how to call drawarc:
exec http.awt.drawArc
0
, 0
, 100
, 22
, 45
, 'blue'
This subprogram creates a bar chart from your select (value) statement. Your select statement should return two columns that correspond to the Y axis (its label) and the X axis (its value). It is up to you to specify the appropriate ORDER BY and GROUP BY clause.
If all labels can be centered at the bottom of the screen, they will be centered at the bottom of the screen. If this is not possible, your labels are displayed vertically if their length is less than four characters or you specified force_label to be true. In any case, a mouseOver on each bar will display its label and value.
procedure drawBarChart
(
@value varchar(255)
, @width int
, @height int
, @bgColor varchar(30)
, @cellspacing int
, @cellpadding int
, @title varchar(255)
, @force_label varchar(6)
)
| Parameter | Description |
|---|---|
value |
The select statement used to create this graph. |
width |
Width of chart. |
height |
Height of chart. |
bgcolor |
Background color of chart. |
cellspacing |
Number of pixels between each bar. |
cellpadding |
Number of pixels between each bar and the X axis. |
title |
Optional title. |
force_label |
Forces the label to be drawn for each bar even if it would look stupid doing so. |
The following example illustrates how to call drawbarchart:
execute http.awt.drawBarChart
@value = 'SELECT LEIBNITZ_TYPES.value, COUNT(*) FROM sysobjects, LEIBNITZ_TYPES where sysobjects.type = LEIBNITZ_TYPES.type GROUP BY LEIBNITZ_TYPES.value'
, @width = 500
, @height = 200
, @cellspacing = 6
, @cellpadding = 3
, @title = '<h1 align=center>Objects in Database</h1>'
, @threshold = 3.00
, @force_label = 'TRUE'
This subprogram creates a graph or line chart from your select (value) statement. Your select statement should return two columns that correspond to the Y axis (its label) and the X axis (its value).
If all labels can be centered at the bottom of the screen, they will be centered at the bottom of the screen. If this is not possible, your labels are displayed vertically if their length is less than four characters or you specified force_label to be true. This procedure will not display the same label twice in succession. If you are graphing activity for each day and your label is the current month, then only the 1st of the month is labeled.
procedure drawChart
(
@value varchar(255)
, @width int
, @height int
, @bgColor varchar(30)
, @cellspacing int
, @cellpadding int
, @title varchar(255)
, @force_label varchar(6)
)
| Parameter | Description |
|---|---|
value |
The select statement used to create this graph. |
width |
Width of chart. |
height |
Height of chart. |
bgcolor |
Background color of chart. |
cellspacing |
Number of pixesl between each point. |
cellpadding |
Number of pixels between lowest point and Y axis. |
title |
Optional title. |
force_label |
Forces the label to be drawn for each line even if it would look stupid doing so. |
The following example illustrates how to call drawchart:
exec http.awt.drawChart
@value = 'select datename(day,TIMESTAMP), count(*) from HTTP_AUDITFILE group by datename(day,TIMESTAMP)'
, @width = 400
, @height = 280
, @bgcolor = 'e7e7ce'
, @cellspacing = 0
, @cellpadding = 0
, @title = '<h1 align=center>Sybernet Application Usage 2005</h1>'
, @force_label = 'FALSE'
Draws a circle whose center is at X and Y with a radius of radius using the specified color.
procedure drawCircle
(
@x int
, @y int
, @radius int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
x |
The X coordinate of the center of the circle. |
y |
The Y coordinate of the center of the circle. |
radius |
Radius of circle. |
color |
Object color. |
The following example illustrates how to call drawcircle:
exec http.awt.drawCircle
0
, 0
, 100
, 'black'
drawLayer creates a layer or div object (depending upon the browser that invoked it) and is thus compatible with Netscape 4.X browers and Netscape 7.X browsers. Most of the subprograms in this package actually call drawLayer.
onMouseOver, onMouseOut, onMouseDown, and onMouseMove are JavaScript events that may have to be supplied by JavaScript functions that you write; for example, onMouseOver may change the backGround color of a layer while onMouseOut restores the background color of that layer. It is beyond the scope of this manual to actually explain how you do that. HTTP.SP_HTML_CALENDAR is just one example that you might want to reference since it handles all of these events.
procedure drawLayer
(
@name varchar(255)
, @top int
, @left int
, @height int
, @width int
, @bgcolor varchar(255)
, @visibility varchar(255)
, @onMouseOver varchar(255)
, @onMouseOut varchar(255)
, @onMouseDown varchar(255)
, @onMouseMove varchar(255)
, @filler varchar(255)
)
| Parameter | Description |
|---|---|
name |
The name of this layer. |
top |
Absolute Y coordinate. |
left |
Absolute X coordinate. | height |
Height of object. |
width |
Width of object. |
bgcolor |
Background color of layer. |
visibility |
Determines is layer is visible (show) or invisbile (hide). |
onmouseover |
JavaScript onMouseOver event. |
onmouseout |
JavaScript onMouseOut event. |
onmousedown |
JavaScript onMouseDown event. |
onmousemove |
JavaScript onMouseMove event. |
filler |
Optional text. |
The following example illustrates how to call drawlayer:
exec http.awt.drawLayer
@name = NULL
, @top = 100
, @left = 100
, @height = 100
, @width = 100
, @bgcolor = 'black'
, @visibility = NULL
, @onMouseOver = 'window.status=''Hello'';return true;'
, @onMouseOut = NULL
, @onMouseDown = NULL
, @onMouseMove = NULL
, @filler = NULL
Draws a line between the coordinates (TOP,LEFT) and (BOTTOM,RIGHT).
procedure drawLine
(
@top int
, @left int
, @bottom int
, @right int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
top |
Absolute Y coordinate. |
left |
Absolute X coordinate. | bottom |
Absolute Y coordinate. |
right |
Absolute X coordinate. |
color |
Object color. |
The following example illustrates how to call drawline:
exec http.awt.drawLine
0
, 0
, 150
, 150
Draws an oval whose center is at X and Y with a X radius of xradius and Y radius of yradius using the specified color.
procedure drawOval
(
@x int
, @y int
, @xradius int
, @yradius int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
x |
The X coordinate of the center of the circle. |
y |
The Y coordinate of the center of the circle. |
xradius |
Radius of circle along the X axis. |
yradius |
Radius of circle along the Y axis. |
color |
Object color. |
The following example illustrates how to call drawoval:
exec http.awt.drawOval
0
, 0
, 50
, 100
, 'navy'
Draws an oval arc.
procedure drawOvalArc
(
@x int
, @y int
, @xradius int
, @yradius int
, @startAngle int
, @arcAngle int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
x |
The X coordinate of the center of the circle. |
y |
The Y coordinate of the center of the circle. |
xradius |
Radius of circle along the X axis. |
yradius |
Radius of circle along the Y axis. |
startangle |
Beginning angle in degrees. |
arcangle |
Length of angle in degrees. |
color |
Object color. |
The following example illustrates how to call drawovalarc:
exec http.awt.drawOvalArc
100
, 100
, 98
, 200
, 22
, 45
, 'red'
Draws a piece of pie.
procedure drawPieChart
(
@value varchar(255)
, @radius int
, @width int
, @height int
, @bgColor varchar(30)
, @cellspacing int
, @cellpadding int
, @title varchar(255)
, @threshold real
)
| Parameter | Description |
|---|---|
x |
The X coordinate of the center of the circle. |
y |
The Y coordinate of the center of the circle. |
radius |
Radius of circle. |
startangle |
Beginning angle in degrees. |
arcangle |
Length of angle in degrees. |
color |
Object color. |
The following example illustrates how to call drawpie:
exec http.awt.drawPie
50
, 150
, 150
, 190
, 30
, 'black'
This subprogram creates a pie chart from your select (value) statement. Your select statement should return two columns that correspond to the Y axis (its label) and the X axis (its value). It is up to you to specify the appropriate ORDER BY and GROUP BY clause.
Since it is difficult (or unpleasant) to display more than a few pieces of pie, you may specify a threshold for those values that should be grouped in the other category. Normally, pie charts display their values in descending order. Without the appropriate ORDER BY clause, your pie chart may group the wrong information under other.
drawPieChart
(
@value varchar(255)
, @radius int
, @width int
, @height int
, @bgColor varchar(30)
, @cellspacing int
, @cellpadding int
, @title varchar(255)
, @threshold real
)
| Parameter | Description |
|---|---|
value |
The select statement used to create this graph. |
radius |
Radius of circle. |
width |
Width of object. |
height |
Height of object. |
bgcolor |
Background color of chart. |
cellspacing |
unused. |
cellpadding |
unused. |
title |
Optional title. |
threshold |
Determines the percentage at which any value is displayed as other. |
The following example illustrates how to call drawpiechart:
exec http.awt.drawPieChart
@value = 'SELECT SUBSTRING(COLOR,1,1), COUNT(*) FROM http..HTTP_COLORS GROUP BY SUBSTRING(COLOR,1,1) order by COUNT(*) DESC'
, @radius = 140
, @width = 500
, @height = 260
, @bgColor = 'white'
, @cellspacing = 1
, @cellpadding = 1
, @title = 'Colors by Color Name'
, @threshold = 3.00
This procedure draws a single point or pixel with the specified color.
procedure drawPoint
(
@top int
, @left int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
top |
Absolute Y coordinate. |
left |
Absolute X coordinate. | color |
Object color. |
The following example illustrates how to call drawpoint:
exec http.awt.drawPoint
0
, 0
, 'magenta'
This procedure draws a quadrilateral. It is different from drawRect because each of the four corners may be anywhere on the screen. If you don't specify the corners correctly, you might end up with an hour-glass affect (which you might want) and if two of the corners share the same point, you'll end up with a triangle.
procedure drawQuad
(
@top int
, @left int
, @south int
, @west int
, @north int
, @east int
, @bottom int
, @right int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
top |
Absolute Y coordinate. |
left |
Absolute X coordinate. | south |
Absolute Y coordinate. |
west |
Absolute X coordinate. |
north |
Absolute Y coordinate. |
east |
Absolute X coordinate. |
bottom |
Absolute Y coordinate. |
right |
Absolute X coordinate. |
color |
Object color. |
The following example illustrates how to call drawquad:
exec http.awt.drawQuad
0 , 0
, 100 , 0
, 0 , 0
, 100 , 200
Draws the outline of the specified rectangle using the specified color.
procedure drawRect
(
@top int
, @left int
, @height int
, @width int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
top |
Absolute Y coordinate. |
left |
Absolute X coordinate. | height |
Height of object. |
width |
Width of object. |
color |
Object color. |
The following example illustrates how to call drawrect:
exec http.awt.drawRect
0
, 0
, 20
, 40
, 'red'
This procedure writes some text at the specified location.
procedure drawText
(
@top int
, @left int
, @height int
, @width int
, @text varchar(255)
)
| Parameter | Description |
|---|---|
top |
Absolute Y coordinate. |
left |
Absolute X coordinate. | height |
Height of object. |
width |
Width of object. |
text |
The text to be written. |
The following example illustrates how to call drawtext:
exec http.awt.drawText
0
, 0
, 10
, 10
, 'Hello, World'
fill3DRect is exactly the same as fillRect except that a 3D effect is created by shading each border.
procedure fill3DRect
(
@top int
, @left int
, @height int
, @width int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
top |
Absolute Y coordinate. |
left |
Absolute X coordinate. | height |
Height of object. |
width |
Width of object. |
color |
Object color. |
The following example illustrates how to call fill3drect:
exec http.awt.fill3DRect
0
, 0
, 20
, 40
, 'red'
Fills a circle whose center is at X and Y with a radius of radius using the specified color.
procedure fillCircle
(
@x int
, @y int
, @radius int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
x |
The X coordinate of the center of the circle. |
y |
The Y coordinate of the center of the circle. |
radius |
Radius of circle. |
color |
Object color. |
The following example illustrates how to call fillcircle:
exec http.awt.fillCircle
0
, 0
, 40
, 'yellow'
Fills an oval whose center is at X and Y with a X radius of xradius and Y radius of yradius using the specified color.
procedure fillOval
(
@x int
, @y int
, @xradius int
, @yradius int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
x |
The X coordinate of the center of the circle. |
y |
The Y coordinate of the center of the circle. |
xradius |
Radius of circle along the X axis. |
yradius |
Radius of circle along the Y axis. |
color |
Object color. |
The following example illustrates how to call filloval:
exec http.awt.fillOval
0
, 0
, 50
, 100
, 'navy'
Fills a piece of pie.
procedure fillPie
(
@x int
, @y int
, @radius int
, @startAngle int
, @arcAngle int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
x |
The X coordinate of the center of the circle. |
y |
The Y coordinate of the center of the circle. |
radius |
Radius of circle. |
startangle |
Beginning angle in degrees. |
arcangle |
Length of angle in degrees. |
color |
Object color. |
The following example illustrates how to call fillpie:
exec http.awt.fillPie
50
, 150
, 150
, 190
, 30
, 'black'
This procedure fills a quadrilateral. It is different from fillRect because each of the four corners may be anywhere on the screen. If you don't specify the corners correctly, you might end up with an hour-glass affect (which you might want) and if two of the corners share the same point, you'll end up with a triangle.
procedure fillQuad
(
@top int
, @left int
, @south int
, @west int
, @north int
, @east int
, @bottom int
, @right int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
top |
Absolute Y coordinate. |
left |
Absolute X coordinate. | south |
Absolute Y coordinate. |
west |
Absolute X coordinate. |
north |
Absolute Y coordinate. |
east |
Absolute X coordinate. |
bottom |
Absolute Y coordinate. |
right |
Absolute X coordinate. |
color |
Object color. |
The following example illustrates how to call fillquad:
exec http.awt.fillQuad
0 , 0
, 100 , 0
, 0 , 0
, 100 , 200
Fills the specified rectangle with the specified color.
procedure fillRect
(
@top int
, @left int
, @height int
, @width int
, @color varchar(30)
)
| Parameter | Description |
|---|---|
top |
Absolute Y coordinate. |
left |
Absolute X coordinate. |
height |
Height of object. |
width |
Width of object. |
color |
Object color. |
The following example illustrates how to call fillrect:
exec http.awt.fillRect
0
, 0
, 20
, 40
, 'red'
Sets the X origin.
procedure X_ORIGIN
(
@X_ORIGIN int
)
| Parameter | Description |
|---|---|
X |
X origin in pixels. |
The following example illustrates how to call X_ORIGIN:
exec http.awt.X_ORIGIN 100
Sets the Y origin.
procedure Y_ORIGIN
(
@Y_ORIGIN int
)
| Parameter | Description |
|---|---|
Y |
Y origin in pixels. |
The following example illustrates how to call Y_ORIGIN:
exec http.awt.Y_ORIGIN 100