Diagrams - User documentation of the Diagrams package
The Diagrams package is meant to help drawing diagrams, like flowcharts. The philosophy is that you should be concentrating on the contents of the diagram, rather than the exact positioning and sizing of all items within it. The Diagrams package uses a few simple rules to layout the items:
Each item (or object) in the diagram has a number of "anchors" - places where arrows and lines can be connected to.
You can draw an arrow or a line from an object in a preset direction
Sizing and positioning should be done as automatic as possible: this is achieved for instance by drawing boxes and circles with text, rather than first drawing a rectangle and then drawing the text inside it or vice versa.
The commands within this package can be split up in several categories. Each category is described in a separate section.
Set the canvas widget in which to draw
Widget to draw in
Save the drawing in a PostScript file
Name of the file to save the drawing in
Set the direction for moving the current position. The direction is one of: north northeast east southeast south southwest west northwest N NE E SE S SW W NW up up-right left down-right down down-left left up-left centre center C
New direction
Set the current position explicitly (argument must be a position "object")
New position (retrieve via getpos for instance)
Get the position of a particular "anchor" point of an object anchor should be one of the direction strings
Name of the anchor (one of the directions - see the direction command
The object in question
Create a position "object"
X-coordinate of the position
Y-coordinate of the position
Draw a box from the current position (width and height are both optional; if not given, the text determines the width and height)
Text to be shown inside the box
Width (if any) of the box in pixels
Height (if any) of the box in pixels
Draw plain text from the current position (width and height are both optional; if not given, the text determines the width and height)
Text to be shown
Width (if any) of the (invisible) box in which to position the text
Height (if any) of the box
Draw a circle from the current position (the radius is optional)
Text to be shown inside the circle
Radius (if any) of the circle in pixels
Draw a slanted box from the current position (width, height and angle are optional)
Text to be shown inside the box
Width (if any) of the box in pixels
Height (if any) of the box in pixels
Angle of the slanted box
Draw a diamond-shaped box from the current position (width and height are both optional; if not given, the text determines the width and height)
Text to be shown inside the diamond
Width (if any) of the diamond in pixels
Height (if any) of the diamond in pixels
Draw a drumshaped item from th ecurrent position (width and height are both optional; if not given, the text determines the width and height)
Text to be shown inside the drum
Width (if any) of the drum in pixels
Height (if any) of the drum in pixels
Draw an arrow from the current position to the next. The text is drawn next to the arrow, the length (in pixels) is optional. If not given the gap parameters are used.
Text to be shown along the arrow
Length of the arrow in pixels
Which arrow heads to draw (first, last or both - defaults to last)
Draw a line specified via positions or via line segments The arguments are either position or length-angle pairs
List of positions or of length-angle pairs
Draw an arrow consisting of three lines from one item to another. The first argument gives the direction in which the arrow "bulges" away from the items, the second argument gives the distance over which it bulges.
Direction of "bulging" - one of north, south, east or west.
Length of the two end pieces of the arrow
Description of the item where the arrow begins as (returned by one of the item creation procedures, box, circle ...)
Ditto for the item where the arrow points to
(Note: attributes are persistent)
Set the anchor point for attaching arrows to
Any one of the valid anchor (e.g. N or North)
Set the color for the outline of a box etc.
Name of the colour to be used
Set the color to fill the objects
Name of the colour to be used
Set the color to draw the text in
Name of the colour to be used
Turn the gap on (1) or off (0). Note: usually a small gap is used when positioning objects.
Use the gap to compute the position of the next object or not
Size of the gap in horizontal direction (in pixels)
Gap width in pixels
Size of the gap in vertical direction (in pixels)
Gap height in pixels
Set the name of the font to use
Name of a text font
Set the width of the lines (in line objects and arrows and the outline of boxes and other objects)
Number of pixels the lines are wide
Set the style of the lines and arrows and of the outline of boxes and other objects. The predefined line styles are: solid, dot, dash, dash-dot, dash-dot-dot (these are the distinguishable line styles on Windows). You can also use the style patterns from the canvas directly.
Name of a valid line style
Note: it is best to study how for instance box objects are implemented first.
Save the current global settings Used when defining an object that is composed of other objects
Restore the previously saved global settings
Compute the current position
Compute the anchor coordinates for a box-like object (this is merely a convenience routine. In general, you will have to compute the list of coordinates yourself - see for instance the diamond object)
X coordinate of upper-left corner
Y coordinate of upper-left corner
X coordinate of lower-right corner
Y coordinate of lower-right corner
Move the object to the right position and return the new information
List of data representing the object