org.graffiti.graph
Class AbstractEdge

java.lang.Object
  extended by org.graffiti.attributes.AbstractAttributable
      extended by org.graffiti.graph.AbstractGraphElement
          extended by org.graffiti.graph.AbstractEdge
All Implemented Interfaces:
Attributable, Edge, GraphElement
Direct Known Subclasses:
AdjListEdge, FastEdge

public abstract class AbstractEdge
extends AbstractGraphElement
implements Edge

Provides default implementations of methods on edges.

Version:
$Revision: 5779 $

Field Summary
 
Fields inherited from class org.graffiti.graph.AbstractGraphElement
graph
 
Fields inherited from class org.graffiti.attributes.AbstractAttributable
attributes
 
Fields inherited from interface org.graffiti.graph.Edge
DIRECTED, UNDIRECTED
 
Constructor Summary
AbstractEdge(Graph graph)
          Constructs a new AbstractEdge.
AbstractEdge(Graph graph, CollectionAttribute coll)
          Constructs a new AbstractEdge.
 
Method Summary
protected abstract  void doReverse()
          Swaps source and target of the edge.
protected abstract  void doSetDirected(boolean directed)
          Determines if an Edge is directed (true) or not.
protected abstract  void doSetSource(Node source)
          Sets the source of the current Edge to source.
protected abstract  void doSetTarget(Node target)
          Sets the target of the current Edge to target.
 void reverse()
          Swaps source and target of the edge.
 void setDirected(boolean directed)
          Determines if an Edge is directed (true) or not.
 void setSource(Node source)
          Sets the source of the current Edge to source.
 void setTarget(Node target)
          Sets the target of the current Edge to target.
 
Methods inherited from class org.graffiti.graph.AbstractGraphElement
getGraph, getListenerManager, remove, toString
 
Methods inherited from class org.graffiti.attributes.AbstractAttributable
addAttribute, addBoolean, addByte, addDouble, addFloat, addInteger, addLong, addShort, addString, changeBoolean, changeByte, changeDouble, changeFloat, changeInteger, changeLong, changeShort, changeString, containsAttribute, getAttribute, getAttributes, getBoolean, getByte, getDouble, getFloat, getInteger, getLong, getShort, getString, removeAttribute, setBoolean, setByte, setDouble, setFloat, setInteger, setLong, setShort, setString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.graffiti.graph.Edge
getSource, getTarget, isDirected
 
Methods inherited from interface org.graffiti.graph.GraphElement
getGraph, remove
 
Methods inherited from interface org.graffiti.attributes.Attributable
addAttribute, addBoolean, addByte, addDouble, addFloat, addInteger, addLong, addShort, addString, changeBoolean, changeByte, changeDouble, changeFloat, changeInteger, changeLong, changeShort, changeString, containsAttribute, getAttribute, getAttributes, getBoolean, getByte, getDouble, getFloat, getInteger, getListenerManager, getLong, getShort, getString, removeAttribute, setBoolean, setByte, setDouble, setFloat, setInteger, setLong, setShort, setString
 

Constructor Detail

AbstractEdge

public AbstractEdge(Graph graph)
Constructs a new AbstractEdge. Also sets the graph.

Parameters:
graph - the Graph the AbstractGraphElement belongs to.

AbstractEdge

public AbstractEdge(Graph graph,
                    CollectionAttribute coll)
Constructs a new AbstractEdge. Sets the graph of the new AbstractEdge.

Parameters:
graph - the Graph the new AbstractEdge instance shall belong to.
coll - the CollectionAttribute of the newly created AbstractEdge instance.
Method Detail

setDirected

public void setDirected(boolean directed)
Determines if an Edge is directed (true) or not. Informs the ListenerManager that the direction has been modified.

Specified by:
setDirected in interface Edge
Parameters:
directed - true, if the Edge is destined to be directed, false otherwise.

setSource

public void setSource(Node source)
               throws GraphElementNotFoundException
Sets the source of the current Edge to source. source must be contained in the same Graph as the current Edge. Informs the ListenerManager about the change.

Specified by:
setSource in interface Edge
Parameters:
source - the source to be set.
Throws:
GraphElementNotFoundException - if source cannot be found in the Graph.

setTarget

public void setTarget(Node target)
               throws GraphElementNotFoundException
Sets the target of the current Edge to target. Target must be contained in the same Graph as the Edge. Informs the ListenerManager about the change.

Specified by:
setTarget in interface Edge
Parameters:
target - the target to be set.
Throws:
GraphElementNotFoundException - if the target cannot be found in the Graph.

reverse

public void reverse()
Swaps source and target of the edge. Informs the listtenerManager about the change.

Specified by:
reverse in interface Edge

doReverse

protected abstract void doReverse()
Swaps source and target of the edge.


doSetDirected

protected abstract void doSetDirected(boolean directed)
Determines if an Edge is directed (true) or not.

Parameters:
directed - true, if the Edge is destined to be directed, false otherwise.

doSetSource

protected abstract void doSetSource(Node source)
                             throws GraphElementNotFoundException
Sets the source of the current Edge to source. source must be contained in the same Graph as the current Edge.

Parameters:
source - the source to be set.
Throws:
GraphElementNotFoundException - if source cannot be found in the Graph.

doSetTarget

protected abstract void doSetTarget(Node target)
                             throws GraphElementNotFoundException
Sets the target of the current Edge to target. Target must be contained in the same Graph as the Edge.

Parameters:
target - the target to be set.
Throws:
GraphElementNotFoundException - if the target cannot be found in the Graph.


Generated at 2012-05-30 11:00:36 PM CEST