| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 13)

Using Connections

You form a connection by dragging a stub to another object. Click on the destination object to end the connection.

Drawing Orthogonal Connections

When you drag an orthogonal connection, it forms a right angle between the object and your pointer. To reach a destination, you may want to create additional bends along the connection:


To create such angles, drag the connection with your pointer and click once at the location where you want to create an angle. (For the first angle, indicated in the previous diagram, you can just drag your pointer without clicking to form a bend.) Resume dragging (and optionally clicking to create angles) until you reach the end of the connection. Click close to the destination object or close to the last bend to end the connection.


Hint: If the connection seems to be stuck to the pointer and you cannot end it, double click or press Ctrl a to release the connection.

To lengthen or shorten a connection between two objects, click on one of the objects and move it further away from or closer to the other object. The connection stretches or shrinks depending on which way you drag the object. If there are multiple bends in a connection, only the last two links shorten or stretch as you drag the connected object. To shorten an unattached connection, click on the free end and retrace the connection route towards the object. The connection shrinks as you drag the pointer.

Drawing Diagonal Connections

When you drag a diagonal connection, G2 draws it as a solid line (one pixel wide) in the color first mentioned in the cross-section specification for the connection class.

Drawing diagonal connections is slightly different than drawing orthogonal connections.

To draw a diagonal connection:

  1. Click near the end of a diagonal connection, the last line segment becomes elastic.

  2. Move your pointer to extend the connection between the last bend and the pointer position.

  3. When the connection reaches a destination object, click to end the connection.


For diagonal connections, you cannot use the junction block that G2 creates automatically. You have to create a junction block subclass by using an object definition as described in Using Junction Blocks.


Note: Junction blocks work exactly the same way for diagonal connections as for orthogonal connections, except that the junction blocks are not created automatically.

Connecting to Objects Without Stubs

You can lengthen a stub by dragging it with the pointer and then connecting it to another item. While at least one object must have a stub to begin a connection, other items that you connect to may or may not have stubs.

For example, the first of these two diagrams shows several objects. Though only the object on the left has stubs, you can connect it to any one of the other objects, as the second diagram illustrates.


After you connect a stub to an item that did not previously have a connection, deleting the connection leaves the stub intact.

Defining Connectedness

Objects are considered connected to one another only when a direct path exists between them, consisting of connections or junction blocks. Other objects cannot exist between two objects in a connection. Two objects are:

Thus connectedness is not transitive: A connect B and B connect C does not imply A connect C. Note that two items could be both directly and indirectly connected if more than one route exists between them.

Disallowing Connections

G2 does not allow connections to items for which connections do not make sense, such as logbook pages or a readout tables.

All G2 items that permit connections can restrict other items from connecting to them by using this configuration statement: declare properties as follows: not manual connections.

Determining the Item Count for Connections

When you create objects with stubs, each stub counts as a single item in your KB. The item count changes as you connect and delete connections as follows:


Note: If you create a transient item with stubs but do not transfer the item to a workspace, looping over every connection with a statement such as for each connection connected to my-object do, will not locate connections of any items that are not on workspaces.

Deleting Stubs and Connections Interactively

To delete a stub:

  1. Click on the end of the stub and drag it inside of the object icon.

  2. Click to release. The stub is deleted.

To delete a connection:

  1. Click on the connection between two objects to display the connection menu.

  2. Choose delete. The connection is deleted without confirmation.


Deleting Stubs and Connections Programmatically

To delete stubs programmatically, use the delete action, described in delete.

Connection Layering

As Layering Items Upon the Same Workspace describes, each item upon a workspace has an associated item-layer-position. Connections are no exception. The item-layer-position of a connection is always above the object to which it is drawn to. G2 displays connections is this manner regardless of whether the connections are drawn interactively or programmatically.

Connections are layered above the object at their input end. For non-directional connections drawn interactively, this is the end from which you drag the stub, or the from object for connections drawn programmatically.

Connections with the same object at their input end are layered in the order you create them.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 13)

Copyright © 1997 Gensym Corporation, Inc.