GDHU, the Graphic DTD for HUmans |
|
Jan Christian Herlitz |
| Excosoft AB Electrum 420 Kista Sweden S-164 40 Phone: +46 8 703 91 90 Fax: +46 8 703 94 90 Email: herlitz@excosoft.se Web: www.excosoft.se |
Biographical notice: |
Jan Christian Herlitz, M.Sc. |
ABSTRACT: |
Introduction |
|
GDHU focuses on the process of maintaining and refining a drawing. A drawing should be as easy to update as the document it resides in. |
GDHU is based on the following requirements: |
The Concept |
|
Embedding |
|
There are several advantages accruing from a tight integration of a document and the drawings it contains. |
Automatic Sizing |
|
We expect a table cell to adjust to its content and a paragraph to adjust to the frame width and we should expect similar functionality in a drawing. |
<rectangle></rectangle> <rectangle> This is <emph>my</emph> text! </rectangle> |
![]() |
Note the emphasized "my"; SGML is doing its job inside the drawing! |
The expansion direction can also be set to the right. |
<rectangle expand-right> This is <emph>my</emph> text! </rectangle> |
![]() |
Expansion can also be inhibited. |
<rectangle expand-not> This is <emph>my</emph> text! </rectangle> |
![]() |
Automatic Positions |
|
<rectangle> <rectangle>Hello</rectangle> <oval></oval> <oval></oval> <rectangle>World</rectangle> </rectangle> |
![]() |
Wrapping can be turned off and the build direction can be changed. |
<rectangle child-direction=270> <rectangle></rectangle> <oval></oval> <oval></oval> <rectangle></rectangle> </rectangle> |
![]() |
Creating a drawing in GDHU will be working with structures rather than coordinate positions. |
<rectangle> <rectangle>Hello</rectangle> <rectangle>World</rectangle> </rectangle> |
![]() |
When the user adds a new shape to the row the application will make room for the new shape automatically. |
<rectangle> <rectangle>Hello</rectangle> <rectangle>new</rectangle> <rectangle>World</rectangle> </rectangle> |
![]() |
Shape positions can also be defined indirectly by another shape position. When the "master shape" is moved all attached shapes are moved with it. |
<rectangle shape-id=d1> I'm the master </rectangle> <oval attach-to=d1 delta-x=-25 delta-y=100> I follow the master </oval> |
Lastly a position can be explicitly defined using a coordinate. This coordinate is relative to its parent shape so when a parent is moved, its child is moved with it. |
Each shape defines a coordinate system for its children. The (0, 0) position is at the upper left corner of a surrounding rectangle. For a rectangle this is the rectangle itself. |
![]() |
Automatic Connections |
|
<oval shape-id=d1>Hello</oval> <oval x=50 y=50 shape-id=d2>World</oval> <polyline> <node attach-to=d1> <node attach-to=d2> </polyline> |
![]() |
<rectangle shape-id=d1>Hello</rectangle> <rectangle x=50 y=50 shape-id=d2>World</rectangle> <polyline> <node attach-to=d1> <node attach-to=d2> </polyline> |
![]() |
Sometimes we may want to connect to the nearest point on a shape or a to specific connection point. If there are several points to choose between, the point nearest (0,0) is selected. |
<rectangle shape-id=d1>Hello</rectangle> <rectangle x=100 y=100 shape-id=d2>World</rectangle> <polyline> <node attach-to="d1.$nearest"> <node attach-to="d2.w"> </polyline> |
![]() |
(The attach-to
value is an expression with a special syntax. Please refer to www.excosoft.se/dev/ for details.) |
Automatic Style |
|
Bits and Pieces |
|
The Elements |
|
GDHU defines only seven elements. |
DRAWING
element.
NODE
, POLYLINE
, RECTANGLE
and OVAL
.
NEWSHAPE
element.
SHAPE
, is a generic element obtaining its properties from elsewhere.
Element |
|
A drawing element defines a drawing area. It has a default size and is invisible. The drawing element represents a name space; shape identities need only be unique inside the current drawing. |
<drawing> </drawing> |
Element |
|
A node is an element primarily used to define polylines. A node is the only empty element in GDHU. |
Element |
|
<polyline> <node x=0 y=0> <node x=100 y=0> </polyline> |
![]() |
Other shapes can be "inside" a polyline; a polyline is a containing element! |
<polyline> <node x=0 y=0> <node x=100 y=50> <node x=0 y=100> Angle </polyline> |
![]() |
A polyline can be "closed" which will make it a "polygon". In a polygon the first node represents both the start and stop points. |
<polyline closed> <node x=0 y=0> <node x=50 y=50> <node x=0 y=100> </polyline> |
![]() |
Element |
|
The rectangle is probably the most used shape in technical drawings. It has a default size. |
<rectangle> </rectangle> |
![]() |
Element |
|
The oval represents an ellipse or a circle. It has a default size. |
<oval> </oval> |
![]() |
Element |
|
A new shape is created with the NEWSHAPE
element, please see "Creating New Shapes" below. |
Element |
|
The SHAPE
element is a generic element. The actual shape is specified with the BASED-ON
attribute. |
<shape based-on=MyNewShape> </shape> |
The Attributes |
|
The shape properties can be controlled by attributes. Almost all attributes are relevant for all shapes. |
Units |
|
Coordinates and Dimensions |
|
The unit for coordinates and dimensions is the point
. Examples of valid values: |
0 -4 64.75 99999 |
Color |
|
A color is specified with three integers. The three integers must range from 0 to 65535, and they denote the R, G and B values of the color, respectively. |
Degrees |
|
The degree unit ranges from 0 to 359. |
General Attributes |
|
Attribute |
|
The SHAPE-ID
attribute assigns an id to the shape. It must be unique inside the current drawing. |
<oval shape-id=d1></oval> |
Attribute |
|
The MAIN
attribute declares a shape to be the main shape when a new shape is created (see Creating New Shapes below). |
Attribute |
|
The LIKE
attribute forces a shape to inherit the properties of another shape with the specified SHAPE-ID
. |
The following attributers are inherited: MIN-W
, MAX-W
, MIN-H
, MAX-H
, PERFECT
, SMOOTHED
and all stroke, fill and shadow attributes. If the shape has its own attributes, they will take precedence. |
NB! The shape also inherits the shape type, i.e. the element name! A set of "rectangles" can be changed to "ovals" using this technique. |
Position attributes |
|
Attributes |
|
The X
and Y
attributes specify the shape position relative its parent. If these attributes are not specified the shape is positioned according to automatic positioning rules. |
<rectangle> <rectangle x=20 y=40> </rectangle> </rectangle> |
![]() |
Attribute |
|
The Z
attribute defines the order in which shapes are drawn inside a shape
. Shapes with lesser Z values are overlaid by shapes with greater Z values. |
<oval z=3></oval> |
If Z is not specified or shapes have the same Z value, the shapes are drawn in the order they are specified. |
Attributes |
|
The DELTA-X
and DELTA-Y
attributes define a delta displacement from the current position. |
<rectangle> <rectangle deltay=40> </rectangle> </rectangle> |
![]() |
Attribute |
|
The CHILD-DIRECTION
attribute forces the children to be positioned in a specified direction without any wrapping. |
Attribute |
|
The CHILD-SEPARATION
attribute defines the spacing of positioned child shapes. The default is 5 points. |
![]() |
Attribute |
|
The CHILD-ALIGN
attribute defines how child shapes are aligned. |
<rectangle child-align=top> <rectangle height=10></rectangle> <rectangle height=30></rectangle> <oval></oval> </rectangle> |
![]() |
<rectangle child-align=bottom> <rectangle height=10></rectangle> <rectangle height=30></rectangle> <oval></oval> </rectangle> |
![]() |
Size attributes |
|
Attributes |
|
The WIDTH
and HEIGHT
attributes specify the explicit size of a shape, automatic resizing will be inhibited. |
Attribute |
|
The EXPAND
attribute defines the direction in which the shape will be expanded when there isn't room for its children. |
expand (expand-down | expand-right | expand-not) expand-down |
The value expand-not
means that the shape is a fixed size shape. |
Attributes |
|
The attributes MIN-W
, MAX-W
, MIN-H
and MAX-H
define the extent to which a shape is allowed to shrink or expand. |
Attributes |
|
The RESIZE-X
and RESIZE-Y
attributes make the shape and its content uniformly bigger or smaller. |
Attribute |
|
![]() |
![]() |
In a perfect polyline all sub-lines are slanted 0, 45 or 90 degrees. The process starts with the start node and moves towards the stop node, changing the slant but keeping the sub-line length. |
![]() |
Attribute |
|
The SMOOTHED
attribute specifies how much the corners in the shape shall be smoothed. |
![]() |
![]() |
Stroke Attributes |
|
Attribute |
|
Attribute |
|
The LINE-COLOR
attribute determines the outline color of a shape. The default value is black. |
Attribute |
|
The LINE-DASH
attribute specifies the way in which lines in a shape are stroked. |
Fill Attributes |
|
Attribute |
|
The FILLED
attribute defines whether the shape is filled or not. |
Attribute |
|
The FILL-COLOR
attribute determines the fill color of a shape. The default value is white. |
Shadow attributes |
|
Attribute |
|
The SHADOWED
attribute defines whether a shape is shadowed or not. |
Attribute |
|
The SHADOW-COLOR
attribute determines the shadow color of a shape. |
Attributes |
|
The SHADOW-X
and SHADOW-Y
attributes specifies the offset of the shadow. Negative values are possible. Default offset is 10 points. |
Arrow Attributes |
|
Attribute |
|
The ARROWED
attribute defines whether or not to draw an arrowhead at a node. |
Attribute |
|
The ARROW-TYPE
attribute defines the type of arrowhead to be drawn at a node. |
Creation Attributes |
|
Attribute |
|
The NAME
attribute defines a name for a new shape. This name is used by generic shapes that are based on the new shape. |
Attribute |
|
The BASED-ON
attribute forces a shape to conform to a new shape. |
The DTD |
|
Here follows the Graphic DTD for HUmans. |
<!ENTITY % blocks "#PCDATA|para|table|list|equation"> <!ENTITY % expression "CDATA"> <!ENTITY % color "NUMBERS"> <!ENTITY % degrees "NUMBER"> <!ENTITY % yesorno "NUMBER"> <!ENTITY % shapes "rectangle|oval|polyline|shape|newshape"> <!ENTITY % directions "(expand-down|expand-right|expand-not)"> <!ENTITY % alignments "(align-top|align-left|align-right| align-bottom|align-centre)"> <!ELEMENT (drawing|%shapes;) - - (%shapes;|node|%blocks;)* > <!ELEMENT node - - EMPTY > <!ATTLIST drawing id ID #IMPLIED > <!ATTLIST (%shapes;|node) id ID #IMPLIED shape-id NAME #IMPLIED name NAME #IMPLIED based-on NAME #IMPLIED like NAME #IMPLIED main %yesorno; "0" x %expression; #IMPLIED y %expression; #IMPLIED z %expression; #IMPLIED delta-x %expression; "0" delta-y %expression; "0" attach-to NAME #IMPLIED width %expression; #IMPLIED height %expression; #IMPLIED expand %directions; expand-down min-w %expression; 100 max-w %expression; #IMPLIED min-h %expression; 50 max-h %expression; #IMPLIED resize-x NUMBER 100 resize-y NUMBER 100 perfect %yesorno; 0 smoothed NUMBER 0 line-width %expression; 1 line-color %color; "0 0 0" line-dash NAME #IMPLIED filled %yesorno; "0" fill-color %color; "65535 65535 65535" shadowed %yesorno; "0" shadow-color %color; "153 153 153" shadow-x %expression; "5" shadow-y %expression; "5" arrowed %yesorno; "0" arrow-name NAME #IMPLIED child-direction %degrees; #IMPLIED child-separation %expression; 5 child-align %alignments; align-top > |
Creating New Shapes |
|
A new shape is defined using primitive shapes or other created shapes. |
The following example defines a rectangle with a double border. |
<newshape name=double-rect> <rectangle> <rectangle x=2 y=2 main=1></rectangle> </rectangle> </newshape> |
![]() |
One of the shapes inside the new shape must be declared as the MAIN
shape. Any child element will be positioned inside the main shape. |
<shape based-on=double-rect line-width=3> Here I use a new shape! </shape> |
![]() |
An Example |
|
The following example demonstrates several GDHU features. |
<drawing> <newshape name=vg> <!-- Vertical Group --> <rectangle main=1 child-direction=270 line-width="-1"> </rectangle> </newshape> <newshape name=hg> <!-- Horizontal Group --> <rectangle main=1 child-direction=0 line-width="-1"> </rectangle> </newshape> <shape based-on=vg> <rectangle shape-id=d1> <title>System X</title> </rectangle> <shape based-on=hg> <shape like=d1 shape-id=d2> <subtitle>Subsystem A</subtitle> <para>This is text. This is text.</para> </shape> <shape like=d1 shape-id=d3> <subtitle>Subsystem B</subtitle> <list> <list-item>This is text.</list-item> <list-item>This is also text.</list-item> </list> </shape> </shape> </shape> <polyline> <node attach-to=d1><node attach-to=d2 arrowed=1> (mandatory) </polyline> <polyline> <node attach-to=d1><node attach-to=d3 arrowed=1> (optionsl) </polyline> </drawing> |
![]() |
The drawing is easy to maintain and to refine. If a new box is added or if more text is added in any rectangle, an application will still be capable of formatting the drawing nicely. |