att.grappa
Class Edge

java.lang.Object
  extended by att.grappa.Element
      extended by att.grappa.Edge
All Implemented Interfaces:
GrappaConstants

public class Edge
extends Element

This class describes an edge.

Version:
1.2, ; Copyright 1996 - 2010 by AT&T Corp.
Author:
John Mocenigo, Research @ AT&T Labs

Field Summary
static java.lang.String defaultNamePrefix
          Default edge name prefix used by setName().
 
Fields inherited from class att.grappa.Element
counter, highlight, linewidth, object, printAllAttributes, printDefaultAttributes, selectable, usePrintList, visible
 
Fields inherited from interface att.grappa.GrappaConstants
_NO_TYPE, ANONYMOUS_PREFIX, BBOX_ATTR, BBOX_HASH, BOX_SHAPE, BOX_TYPE, CLUSTERRANK_ATTR, COLOR_ATTR, COLOR_HASH, COLOR_TYPE, CUSTOM_ATTR, CUSTOM_HASH, CUSTOM_SHAPE, DELETION_MASK, DIAMOND_SHAPE, DIR_ATTR, DIR_HASH, DIR_TYPE, DISTORTION_ATTR, DISTORTION_HASH, DOUBLE_TYPE, DOUBLECIRCLE_SHAPE, DOUBLEOCTAGON_SHAPE, EDGE, EGG_SHAPE, FILLCOLOR_ATTR, FILLCOLOR_HASH, FONTCOLOR_ATTR, FONTCOLOR_HASH, FONTNAME_ATTR, FONTNAME_HASH, FONTSIZE_ATTR, FONTSIZE_HASH, FONTSTYLE_ATTR, FONTSTYLE_HASH, FONTSTYLE_TYPE, GRAPPA_BACKGROUND_COLOR_ATTR, GRAPPA_BACKGROUND_COLOR_HASH, GRAPPA_DELETION_STYLE_ATTR, GRAPPA_DELETION_STYLE_HASH, GRAPPA_FONTSIZE_ADJUSTMENT_ATTR, GRAPPA_FONTSIZE_ADJUSTMENT_HASH, GRAPPA_SELECTION_STYLE_ATTR, GRAPPA_SELECTION_STYLE_HASH, GRAPPA_SHAPE, HASHMAP_TYPE, HEADLABEL_ATTR, HEADLABEL_HASH, HEADLP_ATTR, HEADLP_HASH, HEIGHT_ATTR, HEIGHT_HASH, HEXAGON_SHAPE, HIGHLIGHT_MASK, HIGHLIGHT_OFF, HIGHLIGHT_ON, HIGHLIGHT_TOGGLE, HOUSE_SHAPE, IDENTXFRM, IMAGE_ATTR, IMAGE_HASH, INTEGER_TYPE, INVERTEDHOUSE_SHAPE, INVERTEDTRAPEZIUM_SHAPE, INVERTEDTRIANGLE_SHAPE, LABEL_ATTR, LABEL_HASH, LINE_SHAPE, LINE_TYPE, LOG10, LP_ATTR, LP_HASH, MARGIN_ATTR, MARGIN_HASH, MCIRCLE_SHAPE, MCLIMIT_ATTR, MCLIMIT_HASH, MDIAMOND_SHAPE, MINBOX_ATTR, MINBOX_HASH, MINLEN_ATTR, MINLEN_HASH, MINSIZE_ATTR, MINSIZE_HASH, MRECORD_SHAPE, MSQUARE_SHAPE, NBSP, NEW_LINE, NO_SHAPE, NODE, NODESEP_ATTR, NODESEP_HASH, OCTAGON_SHAPE, ORIENTATION_ATTR, ORIENTATION_HASH, OVAL_SHAPE, PACKAGE_PREFIX, PARALLELOGRAM_SHAPE, PATCH_ATTR, PATCH_HASH, PENTAGON_SHAPE, PERIPHERIES_ATTR, PERIPHERIES_HASH, PERIPHERY_GAP, PKG_LOWER, PKG_UPLOW, PKG_UPPER, PLAINTEXT_SHAPE, POINT_SHAPE, POINT_TYPE, PointsPerInch, POLYGON_SHAPE, POS_ATTR, POS_HASH, PRINTLIST_ATTR, PRINTLIST_HASH, RANKDIR_ATTR, RANKDIR_HASH, RANKSEP_ATTR, RANKSEP_HASH, RECORD_SHAPE, RECTS_ATTR, RECTS_HASH, ROTATION_ATTR, ROTATION_HASH, ROUNDEDBOX_SHAPE, SELECTION_MASK, SHAPE_ATTR, SHAPE_HASH, SHAPE_MASK, SHAPE_TYPE, SIDES_ATTR, SIDES_HASH, SIZE_ATTR, SIZE_HASH, SIZE_TYPE, SKEW_ATTR, SKEW_HASH, STRING_TYPE, STYLE_ATTR, STYLE_HASH, STYLE_TYPE, SUBGRAPH, SYSTEM, TAG_ATTR, TAG_HASH, TAILLABEL_ATTR, TAILLABEL_HASH, TAILLP_ATTR, TAILLP_HASH, TIP_ATTR, TIP_HASH, TRAPEZIUM_SHAPE, TRIANGLE_SHAPE, TRIPLEOCTAGON_SHAPE, TYPES_SHIFT, WEIGHT_ATTR, WEIGHT_HASH, WIDTH_ATTR, WIDTH_HASH
 
Constructor Summary
Edge(Subgraph subg, Node tail, Node head)
          Use this constructor when creating an edge.
Edge(Subgraph subg, Node tail, Node head, java.lang.String name)
          Use this constructor when creating an edge with a supplied unique name for easy look-up (the name is also used as the key).
Edge(Subgraph subg, Node tail, java.lang.String tailPort, Node head, java.lang.String headPort)
          Use this constructor when creating an edge with ports.
Edge(Subgraph subg, Node tail, java.lang.String tailPort, Node head, java.lang.String headPort, java.lang.String key)
          Use this constructor when creating an edge requiring a key to distinguish it.
Edge(Subgraph subg, Node tail, java.lang.String tailPort, Node head, java.lang.String headPort, java.lang.String key, java.lang.String name)
          Use this constructor when creating an edge requiring a key to distinguish it and a supplied lookup name.
 
Method Summary
static int attributeType(java.lang.String attrname)
          Returns the attribute conversion type for the supplied attribute name.
static Edge findEdgeByKey(Node tail, Node head, java.lang.String key)
          Returns the edge with the given tail node, head node and key.
static java.util.Iterator<Edge> findEdgesByEnds(Node node1, Node node2)
          Returns an Iterator of edges that have one end fixed at node1 and the other end at node2.
 Node getHead()
          Get the node at the head end of the edge.
 java.lang.String getHeadPortId()
          Get the head port id of the edge.
 java.lang.String getKey()
          Get the key for this edge.
 Node getTail()
          Get the node at the tail end of the edge.
 java.lang.String getTailPortId()
          Get the tail port id of the edge.
 int getType()
          Get the type of this element.
 boolean goesForward()
          Check if the edge connects in the forward direction.
 boolean goesReverse()
          Check if the edge connects in the reverse direction.
 boolean isEdge()
          Check if this element is an edge.
 void printEdge(java.io.PrintWriter out)
          Print the edge description to the provided stream.
 java.lang.String toString()
          Get the String rendition of the edge.
 
Methods inherited from class att.grappa.Element
addTag, attrOfInterest, bdfs, buildShape, canonString, canonValue, clearBBox, delete, getAttribute, getAttributePairs, getAttributeValue, getDefaultAttribute, getDefaultAttribute, getGraph, getGrappaNexus, getId, getIdKey, getLocalAttribute, getLocalAttributeKeys, getLocalAttributePairs, getName, getSubgraph, getThisAttribute, getThisAttributeValue, hasAttributeForKey, hasDefaultTag, hasDefaultTags, hasLocalTag, hasLocalTags, hasTag, hasTags, isNode, isOfInterest, isSubgraph, listAttrsOfInterest, printElement, removeTag, removeTags, setAttribute, setAttribute, setDefaultAttribute, setDefaultAttribute, setDefaultAttribute, setDefaultAttribute, setIdKey, setSubgraph, setUserAttributeType, typeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultNamePrefix

public static final java.lang.String defaultNamePrefix
Default edge name prefix used by setName().

See Also:
setName(), Constant Field Values
Constructor Detail

Edge

public Edge(Subgraph subg,
            Node tail,
            Node head)
Use this constructor when creating an edge.

Parameters:
subg - the parent subgraph.
tail - node anchoring the tail of the edge.
head - node anchoring the head of the edge.

Edge

public Edge(Subgraph subg,
            Node tail,
            java.lang.String tailPort,
            Node head,
            java.lang.String headPort)
Use this constructor when creating an edge with ports.

Parameters:
subg - the parent subgraph.
tail - node anchoring the tail of the edge.
tailPort - the port to use within the tail node.
head - node anchoring the head of the edge.
headPort - the port to use within the head node.

Edge

public Edge(Subgraph subg,
            Node tail,
            java.lang.String tailPort,
            Node head,
            java.lang.String headPort,
            java.lang.String key)
     throws java.lang.RuntimeException
Use this constructor when creating an edge requiring a key to distinguish it.

Parameters:
subg - the parent subgraph.
tail - node anchoring the tail of the edge.
tailPort - the port to use within the tail node.
head - node anchoring the head of the edge.
headPort - the port to use within the head node.
key - identifier (used in conjection with tail/head, but not ports) to uniquely define edge (and prevent unwanted duplicate from being created)
Throws:
java.lang.RuntimeException

Edge

public Edge(Subgraph subg,
            Node tail,
            Node head,
            java.lang.String name)
     throws java.lang.RuntimeException
Use this constructor when creating an edge with a supplied unique name for easy look-up (the name is also used as the key).

Parameters:
subg - the parent subgraph.
tail - node anchoring the tail of the edge.
head - node anchoring the head of the edge.
name - identifier to uniquely define edge within the entire graph (reather than just between head/tail pairs)
Throws:
java.lang.RuntimeException

Edge

public Edge(Subgraph subg,
            Node tail,
            java.lang.String tailPort,
            Node head,
            java.lang.String headPort,
            java.lang.String key,
            java.lang.String name)
     throws java.lang.RuntimeException
Use this constructor when creating an edge requiring a key to distinguish it and a supplied lookup name. When name is null, it is automatically generated. When key is null, it is automatically generated or set to name, if it was supplied.

Parameters:
subg - the parent subgraph.
tail - node anchoring the tail of the edge.
tailPort - the port to use within the tail node.
head - node anchoring the head of the edge.
headPort - the port to use within the head node.
key - identifier (used in conjection with tail/head, but not ports) to uniquely define edge (and prevent unwanted duplicate from being created)
name - a unique name that can be used for lookup (if null, automatically generated)
Throws:
java.lang.RuntimeException
Method Detail

findEdgeByKey

public static Edge findEdgeByKey(Node tail,
                                 Node head,
                                 java.lang.String key)
Returns the edge with the given tail node, head node and key.

Parameters:
tail - the tail node of the desired edge.
head - the head node of the desired edge.
key - the key specifying the desired edge.
Returns:
the Edge matching the arguments or null, if there is no match.
See Also:
findEdgesByEnds(att.grappa.Node, att.grappa.Node)

isEdge

public boolean isEdge()
Check if this element is an edge. Useful for testing the subclass type of a Element object.

Overrides:
isEdge in class Element
Returns:
true if this object is a Edge.
See Also:
isEdge()

getType

public int getType()
Get the type of this element. Useful for distinguishing Element objects.

Specified by:
getType in class Element
Returns:
the class variable constant Grappa.EDGE.
See Also:
Grappa

getKey

public java.lang.String getKey()
Get the key for this edge.

Returns:
the key of the edge

getHead

public Node getHead()
Get the node at the head end of the edge.

Returns:
the head node of the edge

getHeadPortId

public java.lang.String getHeadPortId()
Get the head port id of the edge.

Returns:
the head port id of the edge

getTail

public Node getTail()
Get the node at the tail end of the edge.

Returns:
the tail node of the edge

getTailPortId

public java.lang.String getTailPortId()
Get the tail port id of the edge.

Returns:
the tail port id of the edge

toString

public java.lang.String toString()
Get the String rendition of the edge.

Overrides:
toString in class Element
Returns:
the string rendition of the edge, quoted as needed.

printEdge

public void printEdge(java.io.PrintWriter out)
Print the edge description to the provided stream.

Parameters:
out - the output stream for writing the description.

goesForward

public boolean goesForward()
Check if the edge connects in the forward direction.

Returns:
true when edge connects in the forward direction (tail to head)

goesReverse

public boolean goesReverse()
Check if the edge connects in the reverse direction.

Returns:
true when edge connects in the reverse direction (head to tail)

attributeType

public static int attributeType(java.lang.String attrname)
Returns the attribute conversion type for the supplied attribute name. After edge specific attribute name/type mappings are checked, mappings at the element level are checked.

Parameters:
attrname - the attribute name
Returns:
the currently associated attribute type

findEdgesByEnds

public static java.util.Iterator<Edge> findEdgesByEnds(Node node1,
                                                       Node node2)
Returns an Iterator of edges that have one end fixed at node1 and the other end at node2. If node2 is empty, an Iterator of all edges attached to node1 is returned.

Parameters:
node1 - one vertex of the set of edges to be returned
node2 - the other vertex of the set of edges to be returned, or null for no constraint on the other vertex
Returns:
an Iterator of Edge objects.


Grappa 1.2