Sybernet / Supplied Packages Reference
Release 3.00
May 25, 2003
backwards forwards

HTTP.AWT

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.

Summary of Subprograms

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 Procedure

draw3DLayer is exactly the same as drawLayer except that a 3D effect is created by shading each border.


Syntax

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
)

Parameters

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.


Example

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 Procedure

draw3DRect is exactly the same as drawRect except that a 3D effect is created by shading each border


Syntax

procedure draw3DRect
(
    @top               int
,   @left              int
,   @height            int
,   @width             int
,   @color             varchar(30)
)

Parameters

Parameter Description
top
 
Absolute Y coordinate.
left
 
Absolute X coordinate.
height
 
Height of object.
width
 
Width of object.
color
 
Object color.


Example

The following example illustrates how to call draw3drect:

exec http.awt.draw3DRect

    @top            = 100
,   @left           = 100
,   @height         = 100
,   @width          = 100
,   @color          = 'red'

DRAWANGLE Procedure

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.


Syntax

procedure drawAngle
(
    @x              int
,   @y              int
,   @radius         int
,   @angle          int
,   @color          varchar(30)
)

Parameters

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.


Example

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

DRAWARC Procedure

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.


Syntax

procedure drawArc
(
    @x                 int
,   @y                 int
,   @radius            int
,   @startAngle        int
,   @arcAngle          int
,   @color             varchar(30)
)

Parameters

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.


Example

The following example illustrates how to call drawarc:

exec http.awt.drawArc

    0
,   0
,   100
,   22
,   45
,   'blue'

DRAWBARCHART Procedure

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.


Syntax

procedure drawBarChart
(
    @value             varchar(255)
,   @width             int
,   @height            int
,   @bgColor           varchar(30)
,   @cellspacing       int
,   @cellpadding       int
,   @title             varchar(255)
,   @force_label       varchar(6)
)

Parameters

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.


Example

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'

DRAWCHART Procedure

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.


Syntax

procedure drawChart
(
    @value             varchar(255)
,   @width             int
,   @height            int
,   @bgColor           varchar(30)
,   @cellspacing       int
,   @cellpadding       int
,   @title             varchar(255)
,   @force_label       varchar(6)
)

Parameters

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.


Example

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'

DRAWCIRCLE Procedure

Draws a circle whose center is at X and Y with a radius of radius using the specified color.


Syntax

procedure drawCircle
(
    @x                int
,   @y                int
,   @radius           int
,   @color            varchar(30)
)

Parameters

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.


Example

The following example illustrates how to call drawcircle:

exec http.awt.drawCircle

    0
,   0
,   100
,   'black'

DRAWLAYER Procedure

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.


Syntax

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)
)

Parameters

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.


Example

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

DRAWLINE Procedure

Draws a line between the coordinates (TOP,LEFT) and (BOTTOM,RIGHT).


Syntax

procedure drawLine
(
    @top               int
,   @left              int
,   @bottom            int
,   @right             int
,   @color             varchar(30)
)

Parameters

Parameter Description
top
 
Absolute Y coordinate.
left
 
Absolute X coordinate.
bottom
 
Absolute Y coordinate.
right
 
Absolute X coordinate.
color
 
Object color.


Example

The following example illustrates how to call drawline:

exec http.awt.drawLine

    0
,   0
,   150
,   150

DRAWOVAL Procedure

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.


Syntax

procedure drawOval
(
    @x                 int
,   @y                 int
,   @xradius           int
,   @yradius           int
,   @color             varchar(30)
)

Parameters

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.


Example

The following example illustrates how to call drawoval:

exec http.awt.drawOval

    0
,   0
,   50
,   100
,   'navy'

DRAWOVALARC Procedure

Draws an oval arc.


Syntax

procedure drawOvalArc
(
    @x                 int
,   @y                 int
,   @xradius           int
,   @yradius           int
,   @startAngle        int
,   @arcAngle          int
,   @color             varchar(30)
)

Parameters

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.


Example

The following example illustrates how to call drawovalarc:

exec http.awt.drawOvalArc

    100
,   100
,   98
,   200
,   22
,   45
,   'red'

DRAWPIE Procedure

Draws a piece of pie.


Syntax

procedure drawPieChart
(
    @value             varchar(255)
,   @radius            int
,   @width             int
,   @height            int
,   @bgColor           varchar(30)
,   @cellspacing       int
,   @cellpadding       int
,   @title             varchar(255)
,   @threshold         real
)

Parameters

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.


Example

The following example illustrates how to call drawpie:

exec http.awt.drawPie

    50
,   150
,   150
,   190
,   30
,   'black'

DRAWPIECHART Procedure

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.


Syntax

drawPieChart
(
    @value             varchar(255)
,   @radius            int
,   @width             int
,   @height            int
,   @bgColor           varchar(30)
,   @cellspacing       int
,   @cellpadding       int
,   @title             varchar(255)
,   @threshold         real
)

Parameters

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.


Example

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

DRAWPOINT Procedure

This procedure draws a single point or pixel with the specified color.


Syntax

procedure drawPoint
(
    @top               int
,   @left              int
,   @color             varchar(30)
)

Parameters

Parameter Description
top
 
Absolute Y coordinate.
left
 
Absolute X coordinate.
color
 
Object color.


Example

The following example illustrates how to call drawpoint:

exec http.awt.drawPoint

    0
,   0
,   'magenta'

DRAWQUAD Procedure

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.


Syntax

procedure drawQuad
(
    @top               int
,   @left              int
,   @south             int
,   @west              int
,   @north             int
,   @east              int
,   @bottom            int
,   @right             int
,   @color             varchar(30)
)

Parameters

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.


Example

The following example illustrates how to call drawquad:

exec http.awt.drawQuad

      0 ,   0
,   100 ,   0
,     0 ,   0
,   100 , 200

DRAWRECT Procedure

Draws the outline of the specified rectangle using the specified color.


Syntax

procedure drawRect
(
    @top               int
,   @left              int
,   @height            int
,   @width             int
,   @color             varchar(30)
)

Parameters

Parameter Description
top
 
Absolute Y coordinate.
left
 
Absolute X coordinate.
height
 
Height of object.
width
 
Width of object.
color
 
Object color.


Example

The following example illustrates how to call drawrect:

exec http.awt.drawRect

    0
,   0
,   20
,   40
,   'red'

DRAWTEXT Procedure

This procedure writes some text at the specified location.


Syntax

procedure drawText
(
    @top               int
,   @left              int
,   @height            int
,   @width             int
,   @text              varchar(255)
)

Parameters

Parameter Description
top
 
Absolute Y coordinate.
left
 
Absolute X coordinate.
height
 
Height of object.
width
 
Width of object.
text
 
The text to be written.


Example

The following example illustrates how to call drawtext:

exec http.awt.drawText

    0
,   0
,   10
,   10
,   'Hello, World'

FILL3DRECT Procedure

fill3DRect is exactly the same as fillRect except that a 3D effect is created by shading each border.


Syntax

procedure fill3DRect
(
    @top               int
,   @left              int
,   @height            int
,   @width             int
,   @color             varchar(30)
)

Parameters

Parameter Description
top
 
Absolute Y coordinate.
left
 
Absolute X coordinate.
height
 
Height of object.
width
 
Width of object.
color
 
Object color.


Example

The following example illustrates how to call fill3drect:

exec http.awt.fill3DRect

    0
,   0
,   20
,   40
,   'red'

FILLCIRCLE Procedure

Fills a circle whose center is at X and Y with a radius of radius using the specified color.


Syntax

procedure fillCircle
(
    @x                 int
,   @y                 int
,   @radius            int
,   @color             varchar(30)
)

Parameters

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.


Example

The following example illustrates how to call fillcircle:

exec http.awt.fillCircle

    0
,   0
,   40
,   'yellow'

FILLOVAL Procedure

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.


Syntax

procedure fillOval
(
    @x                 int
,   @y                 int
,   @xradius           int
,   @yradius           int
,   @color             varchar(30)
)

Parameters

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.


Example

The following example illustrates how to call filloval:

exec http.awt.fillOval

    0
,   0
,   50
,   100
,   'navy'

FILLPIE Procedure

Fills a piece of pie.


Syntax

procedure fillPie
(
    @x                 int
,   @y                 int
,   @radius            int
,   @startAngle        int
,   @arcAngle          int
,   @color             varchar(30)
)

Parameters

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.


Example

The following example illustrates how to call fillpie:

exec http.awt.fillPie

    50
,   150
,   150
,   190
,   30
,   'black'

FILLQUAD Procedure

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.


Syntax

procedure fillQuad
(
    @top               int
,   @left              int
,   @south             int
,   @west              int
,   @north             int
,   @east              int
,   @bottom            int
,   @right             int
,   @color             varchar(30)
)

Parameters

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.


Example

The following example illustrates how to call fillquad:

exec http.awt.fillQuad

      0 ,   0
,   100 ,   0
,     0 ,   0
,   100 , 200

FILLRECT Procedure

Fills the specified rectangle with the specified color.


Syntax

procedure fillRect
(
    @top               int
,   @left              int
,   @height            int
,   @width             int
,   @color             varchar(30)
)

Parameters

Parameter Description
top
 
Absolute Y coordinate.
left
 
Absolute X coordinate.
height
 
Height of object.
width
 
Width of object.
color
 
Object color.


Example

The following example illustrates how to call fillrect:

exec http.awt.fillRect
    0
,   0
,   20
,   40
,   'red'



X_ORIGIN Procedure

Sets the X origin.


Syntax

procedure X_ORIGIN
(
    @X_ORIGIN          int
)

Parameters

Parameter Description
X
 
X origin in pixels.


Example

The following example illustrates how to call X_ORIGIN:

exec http.awt.X_ORIGIN 100



Y_ORIGIN Procedure

Sets the Y origin.


Syntax

procedure Y_ORIGIN
(
    @Y_ORIGIN          int
)

Parameters

Parameter Description
Y
 
Y origin in pixels.


Example

The following example illustrates how to call Y_ORIGIN:

exec http.awt.Y_ORIGIN 100



Sybernet is a trademark of SRI International.
Copyright © 1996-2008 SRI International. All Rights Reserved.
Denis D. Workman / http://Sybernet.sri.com/