Eval Class - Draw

Description:

The Draw class enables SteelBlue to draw lines, arcs, and text using the QuickImage application. The QuickImage application is a pair of programs developed by the Turner Consulting Group: a Java applet for client-side drawing, and a CGI program for server-side drawing. The choice for client or server-side drawing is determined by the value of the boolean member Draw::use_java.

In order to use the QuickImage Java Class, the configuration parameter QuickImageClassBase must be set to the QuickImage class base (the URL up to but not including the class name). For example, if the QuickImage class resides at "http://machine.com/scripts/QuickImage.class", QuickImageClassBase should be set to "http://machine.com/scripts/", or simply "/scripts/" if the server is on "machine.com".

In order to use the QuickImage CGI script, the configuration parameter QuickImageCGIPath must be set to the URL of the QuickImage executable (including executable name). In addition, the configuration parameter tmpdir must be set to a full path to a directory in which the web server has the ability to write temporary files.

Members:

commands -The command string sent to QuickImage
height -The height of the image
use_java -Flag whether to use QuickImage java class or CGI program
width -The width of the image

Methods:

Draw($w,$h) -Constructor setting the width and height
Draw() -Constructor
drawArc($x,$y,$w,$h,$s,$a) -Draws an arc
drawLine($xa,$ya,$xb,$yb) -Draws a line
drawPolygon($xa,$ya,...,$xn,$yn) -Draws a polygon
drawRect($x,$y,$w,$h) -Draws a rectangle
drawString($align,$x,$y,$str) -Draws text
fillArc($x,$y,$w,$h,$s,$a) -Draws a filled arc
fillPolygon($xa,$ya,...,$xn,$yn) -Draws a filled polygon
fillRect($x,$y,$w,$h) -Draws a filled rectangle
labelPolygon($xa,$ya,...,$xn,$yn,$label) -Adds a pop-up label for a polygonal region
labelRect($x,$y,$w,$h, $label) -Adds a pop-up label for a rectangle region
outputDrawing() -Writes IMG or APPLET tag to display the drawing
setColor($rgb) -Sets the current drawing color in hexadecimal as "RRGGBB"
setFont($face,$style,$pointsize) -Sets the current font face, style, and size

Example:

// The following prints a pretty button-like object with text

$a = new Draw(320,200); // 320 by 200 image
$a.setColor("A0A0A0");
$a.fillRect(45,5,230,40);
$a.setColor("000000");
$a.drawLine(50,40,270,40);
$a.drawLine(270,40,270,10);
$a.setColor("FFFFFF");
$a.drawLine(50,40,50,10);
$a.drawLine(50,10,270,10);
$a.setColor("000000");
$a.setFont("SansSerif","BoldItalic",20);
$a.drawString("Center",162,32,"This is a test");
$a.setColor("FFFF00");
$a.drawString("Center",160,30,"This is a test");
$a.use_java = 1;  // Uses QuickImage Java Class
$a.outputDrawing();

Member name: commandsClass Draw

Description:

The command string sent to QuickImage. This is not intended to be directly modified, but instead is created through calling the drawing methods.

Member name: heightClass Draw

Description:

The height of the image (defaults to 200).

Member name: use_javaClass Draw

Description:

Flag whether to use QuickImage Java class or CGI program (defaults to CGI program). If use_java is set to a non-zero integer, then the QuickImage Java class (client-side drawing) is used. If use_java is zero (the default), then the QuickImage CGI program (server-side drawing) is used.

Member name: widthClass Draw

Description:

The width of the image (defaults to 300).

Member name: Draw($w,$h)Class Draw

Description:

Creates a new drawing object, setting the width to $w and height to $h.

Usage:

$img = new Draw($w,$h);
$img-Resulting drawing object

Member name: Draw()Class Draw

Description:

Creates a new drawing object, setting the width to 300 and height to 200.

Usage:

$img = new Draw();
$img-Resulting drawing object

Member name: drawArc($x,$y,$w,$h,$s,$a)Class Draw

Description:

Draws an arc with the upper left coordinates ($x,$y), width $w, and height $h. The arc begins at $s degrees (0 being East), and continues counter-clockwise $a degrees.

Usage:

$img.drawArc($x,$y,$w,$h,$s,$a)
$x-Upper left x coordinate
$y-Upper left y coordinate
$w-Elipse width
$h-Elipse height
$s-Beginning angle in degrees
$a-length in degrees

Member name: drawLine($xa,$ya,$xb,$yb)Class Draw

Description:

Draws a line from point ($xa,$ya) to ($xb,$yb).

Usage:

$img.drawLine($xa,$ya,$xb,$yb);
$xa-Starting x coordinate
$ya-Starting y coordinate
$xb-Ending x coordinate
$yb-Ending y coordinate

Member name: drawPolygon($xa,$ya,...,$xn,$yn)Class Draw

Description:

Draws a polygon defined by the multiple pairs of points.

Usage:

$img.drawPolygon($xa,$ya,...,$xn,$yn);
$xa-Starting x coordinate
$ya-Starting y coordinate
$xn-Ending x coordinate
$yn-Ending y coordinate

Member name: drawRect($x,$y,$w,$h)Class Draw

Description:

Draws a rectangle with upper left coordinate ($x,$y) with width $w and height $h.

Usage:

$img.drawLine($xa,$ya,$xb,$yb);
$x-Starting x coordinate
$y-Starting y coordinate
$w-Width
$h-Height

Member name: drawString($align,$x,$y,$str)Class Draw

Description:

Draws the text $str at the specified coordinate ($x,$y) using the alignment given in $align. $align is one of "center", "left" or "right". $str must not contain single or double quotes.

Usage:

$img.drawString($align,$x,$y,$str)
$align-Alignment of text ("center", "left", or "right")
$x-x coordinate of text
$y-y coordinate of text
$str-Text to draw

Member name: fillArc($x,$y,$w,$h,$s,$a)Class Draw

Description:

Draws a filled arc with the upper left coordinates ($x,$y), width $w, and height $h. The arc begins at $s degrees (0 being East), and continues counter-clockwise $a degrees.

Usage:

$img.fillArc($x,$y,$w,$h,$s,$a)
$x-Upper left x coordinate
$y-Upper left y coordinate
$w-Elipse width
$h-Elipse height
$s-Beginning angle in degrees
$a-Arc length in degrees

Member name: fillPolygon($xa,$ya,...,$xn,$yn)Class Draw

Description:

Draws a filled polygon defined by the multiple pairs of points.

Usage:

$img.fillPolygon($xa,$ya,...,$xn,$yn);
$xa-Starting x coordinate
$ya-Starting y coordinate
$xn-Ending x coordinate
$yn-Ending y coordinate

Member name: fillRect($x,$y,$w,$h)Class Draw

Description:

Draws a filled rectangle with upper left coordinate ($x,$y) with width $w and height $h.

Usage:

$img.drawLine($xa,$ya,$xb,$yb);
$x-Starting x coordinate
$y-Starting y coordinate
$w-Width
$h-Height

Member name: labelPolygon($xa,$ya,...,$xn,$yn,$label)Class Draw

Description:

Adds a pop-up label for a polygonal region

Usage:

$img.labelPolygon($xa,$ya,...,$xn,$yn,$label);
$xa-Starting x coordinate
$ya-Starting y coordinate
$xn-Ending x coordinate
$yn-Ending y coordinate
$label-Pop-up label for the polygonal region

Member name: labelRect($x,$y,$w,$h, $label)Class Draw

Description:

Adds a pop-up label for a rectangle region.

Usage:

$img.drawLine($xa,$ya,$xb,$yb);
$x-Starting x coordinate
$y-Starting y coordinate
$w-Width
$h-Height
$label-Pop-up label for the rectangle region

Member name: outputDrawing()Class Draw

Description:

Writes the IMG or APPLET tag to display the drawing. If the method Draw::use_java is non-zero, then the APPLET tag is written to call the QuickImage Java applet. If the method Draw::use_java is zero, then the IMG tag is written to call the QuickImage CGI applet (in which case the Quick Image commands are written to a temporary file).

Usage:

$img.outputDrawing()

Member name: setColor($rgb)Class Draw

Description:

Sets the current drawing color to the color specified in $rgb as a hexadecimal "RRGGBB" number (red, green, and blue).

Usage:

$img.setColor($rgb)
$rgb-Color specified in hexadecimal as "RRGGBB"

Member name: setFont($face,$style,$pointsize)Class Draw

Description:

Sets the current font face, style and size. The font face is one of "Serif", "SanSerif", or "Monospaced". The style is one of "plain", "bold" "italic" or "bolditalic". The QuickImage Java applet can accept any point size, while the QuickImage CGI script will only draw point sizes of 8, 10, 12, and 20 (other point sizes will be rounded to those).

Usage:

$img.setFont($face,$style,$pointsize)
$face-Font face (one of "Serif", "SanSerif", or "Monospaced")
$style-Font style (one of "plain", "bold", "italic", or "bolditalic")
$pointsize-Point size (one of 8, 10, 12, 20 for CGI script)

Back to the Class Reference Index