Vispatch Tutorial (using Java 1.02) > TOC > The Vispatch Visual Language > Bodies of Rules > Equiv Lines

Equiv Lines

The equiv line figure tells the Vispatch system to reuse a point that was matched to a point in the rule's head. An equiv line figure shares a characteristic point with figure(s) in the rule's head and a characteristic point with figure(s) in the rule's body. During the rewriting process, the shared point in the head and the one in the body are made equivalent.

To make the explanation clearer, call the characteristic point of the equiv line figure in the head the head point and the other characteristic point the body point. When a rule with an equiv line figure executes, its head point is matched to some point in the document. Call this point the document point. When copies of the figures from the body are placed in the document, any that share a characteristic point with the body point are placed at the same location as the document point. All this is more simple than it sounds, as the examples below show.

The first rule in the applet below matches any mouse drag and in response creates a red arrow figure. The equiv line figures in this rule indicate that the tail of the arrow should be placed at the beginning of the mouse drag and the head of the arrow should be placed at the end of the mouse drag.

The second rule will reverse the direction of a red arrow. This rule matches a mouse drag that ends at the head of an existing arrow. As indicated by the equiv line figures, it places a new arrow in the document whose head is at the tail of the existing arrow, and whose tail is at the head of the existing arrow. The existing arrow is removed, leaving only the reversed arrow.

The third rule matches a mouse drag extending from the head of an existing arrow. It places a line figure in the same location as the existing arrow and places a new arrow where the mouse drag was performed. The existing arrow is then removed.

The fourth rule matches a mouse drag that extends from the end of a line figure. It places a new line that extends from the end of the mouse drag to the other end of the existing line figure (i.e. not the end touching the mouse drag). Then the existing line figure is removed. The effect is as if the end point of the line is moved.

The last two rules match a mouse click on the primary and secondary characteristic points of figures of any type. They remove the matching figure and replace it with nothing, thus deleting it.

 
Notice that it does not matter where the location of the figures are located inside the head or body of the rule. All placements of new figures are based on the locations of the figures connected to the mouse drag. In all the examples above, the only information used from the rule is how body figures are connected to each other and to points in the head by way of equiv line figures.