In this section, you will learn about defining graph rules inside
an xml configuration file. Such a file is included with this tutorial
and is aptly called “rules.xml”.
Below is a sample GraphRule defined in an
attribute-based xml format. This type of rule is applied to a visual
graph as a whole and is much simpler than the rules created for its embedded
visual elements.
Example 6.1. Graph Rule XML Fragment
... <list name="Rule"> <attribute name="Name" type="String" value="graphrule"/> <attribute name="Type" type="String" value="GraphRule"/> <list name="Properties"> <attribute name="EdgeInsertSinglePosition" type="Boolean" value="false"/> <attribute name="AutoSpaceMode" type="String" value="no autospace"/> <attribute name="AcceptLooseObjects" type="Boolean" value="true"/> </list> </list> ...
There are various visual graph attributes which together form the basis of a rule. For visual graph objects, the relevant attributes are listed below.
EdgeInsertSinglePosition
Also known as an “Edge Split,” this flag deals with edges that have been configured to accept nodes dropped on them. In other words, when a user drags and drops a node on an edge which has this attribute value set to true, the nodes previously connected by that edge will lose that connection and subsequently connect to the dropped node.
Multiply-selected nodes that are simultaneously dropped over distinct edges will also split the affected edges.
AutoSpaceMode
The given value for the attribute AutoSpaceMode must
be one of the following enumerations. The AutoSpaceMode
attribute specifies how nodes are moved when they are dropped onto each other.
horizontal autospace
vertical autospace
no autospace
AcceptLooseObjects
This flag allows or disallows “loose” elements (isolated nodes or edges) at the top-level of a visual graph. Isolated elements are not allowed in a real graph but may be permitted here for designers who perform intermediate steps towards completion of their models. If you wish to enforce a "Do it now or never" policy you would set this flag to “false”.
© 2004, 2005 Tensegrity Software GmbH