de.fhstralsund.vinets.structure
Class GraphAdapter

java.lang.Object
  extended by de.fhstralsund.vinets.structure.GraphAdapter
All Implemented Interfaces:
Graph, NetElement, java.io.Serializable, java.lang.Cloneable

public class GraphAdapter
extends java.lang.Object
implements Graph

A convenience class for Graph-Decorators. All methods are delegated to the encapsulated Graph, so that a special decorator subclass must override only some of these methods. Any instance of the GraphAdapter class is a transparent object, what means that it has no own ID and all its contained NetElements remain hosted by the encapsulated graph.

See Also:
Serialized Form

Field Summary
protected  Graph G
           
 
Constructor Summary
GraphAdapter(Graph theGraph)
           
 
Method Summary
 void clearLabels()
          Clears all labels of this NetElement.
 java.lang.Object clone()
          Delivers a deep copy of this Graph.
 boolean containsLabel(java.lang.Object key)
          Returns true if the label contains a mapping for the specified key.
 int countEdges()
          Returns the number of Links in this Graph.
 int countNodes()
          Returns the number of Nodes in this Graph.
 Link createEdge(Node start, Node end)
          Constructs and returns a new Edge of the appropriate type.
 Link createEdge(Node start, Node end, boolean directed)
          Constructs and returns a new directed or undirected Edge.
 Link createEdge(Node start, Node end, boolean directed, java.lang.Object data)
          Constructs and returns a new directed or undirected Edge with two end vertices.
 Node createNode()
          Constructs and returns a new Node.
 Node createNode(java.lang.String name)
          Constructs and returns a new Node.
 Node createNode(java.lang.String name, java.lang.Object data)
          Constructs and returns a new Node.
 java.util.Iterator edges()
          Delivers an Iterator over all Links in this Graph.
 java.util.Set edgeSet()
          Delivers the Set of Links in this Graph.
 boolean getBooleanLabel(java.lang.Object key)
          Returns the label value associated with the passed key as boolean value.
 java.lang.Object getData()
          Delivers application specific data stored by this NetElement which have no relation to the network algorithms.
 double getDoubleLabel(java.lang.Object key)
          Returns the label value associated with the passed key as double value.
 NetElementGeometry getGeometry()
          Delivers the NetElementGeometry instance containing the position and the size of this NetElement in the relative coordinate system of its host.
 GraphType getGraphType()
          Returns the Type of this Graph.
 NetElement getHost()
          Delivers the parent of this NetElement in the inclusion hierarchy.
 java.lang.Object getID()
          Delivers the identifier of this NetElement.
 int getIntLabel(java.lang.Object key)
          Returns the label value associated with the passed key as int value.
 java.lang.Object getLabel(java.lang.Object key)
          Returns the label value associated with the passed key, or null if the label Map does not contain a mapping for this key.
 java.util.Set getLabelKeySet()
          Returns a Set which contains the Keys inside the LabelMap.
 java.lang.String getName()
          Delivers a human readable name of this NetElement.
 NetElement getOriginal()
          Delivers the NetElement from which this one was copied.
 de.fhstralsund.vinets.graphics.NetElementRepresentation getRepresentation()
          Delivers the NetElementRepresentation instance containing information for rendering this NetElement.
 boolean isDirected()
          All Links of a directed Graph are directed Edges between two Nodes.
 boolean isHyperGraph()
          A HyperGraph may contain HyperEdges that have more than two end vertices.
 boolean isMixed()
          A mixed Graph may contain some undirected and some directed Edges, but all Links have exactly two end Nodes.
 boolean isUndirected()
          All Links of an undirected Graph are undirected Edges between two Nodes.
 java.util.Iterator nodes()
          Delivers an Iterator over all Nodes in this Graph.
 java.util.Set nodeSet()
          Delivers the Set of Nodes in this Graph.
 boolean remove(NetElement elem)
          Removes a NetElement from this Graph.
 java.lang.Object removeLabel(java.lang.Object key)
          Removes a property stored as label from this NetElement.
 void setBooleanLabel(java.lang.Object key, boolean i)
          Adds to this NetElement a boolean value label or changes it.
 void setData(java.lang.Object data)
          Assigns new application specific data to this NetElement which have no relation to the network algorithms.
 void setDoubleLabel(java.lang.Object key, double i)
          Adds to this NetElement a double value label or changes it.
 void setGeometry(NetElementGeometry geo)
          Assigns a new NetElementGeometry instance containing the position and the size of this NetElement in the relative coordinate system of its host.
 void setIntLabel(java.lang.Object key, int i)
          Adds to this NetElement an integer value label or changes it.
 void setLabel(java.lang.Object key, java.lang.Object value)
          Adds a new property to be stored as a label of this NetElement or changes the value of an existing property.
 void setName(java.lang.String name)
          Sets a human readable name for this NetElement.
 void setRepresentation(de.fhstralsund.vinets.graphics.NetElementRepresentation repres)
          Assigns a new NetElementRepresentation instance containing information for rendering this NetElement.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

G

protected Graph G
Constructor Detail

GraphAdapter

public GraphAdapter(Graph theGraph)
Method Detail

isDirected

public boolean isDirected()
Description copied from interface: Graph
All Links of a directed Graph are directed Edges between two Nodes.

Specified by:
isDirected in interface Graph
Returns:
true if the Graph is directed.

isUndirected

public boolean isUndirected()
Description copied from interface: Graph
All Links of an undirected Graph are undirected Edges between two Nodes.

Specified by:
isUndirected in interface Graph
Returns:
true if the Graph is undirected.

isMixed

public boolean isMixed()
Description copied from interface: Graph
A mixed Graph may contain some undirected and some directed Edges, but all Links have exactly two end Nodes.

Specified by:
isMixed in interface Graph
Returns:
true if the Graph is a mixed Graph.

isHyperGraph

public boolean isHyperGraph()
Description copied from interface: Graph
A HyperGraph may contain HyperEdges that have more than two end vertices. A HyperGraph is neither directed nor undirected.

Specified by:
isHyperGraph in interface Graph
Returns:
true if the Graph is a HyperGraph.

countNodes

public int countNodes()
Description copied from interface: Graph
Returns the number of Nodes in this Graph.

Specified by:
countNodes in interface Graph
Returns:
the number of Nodes.

countEdges

public int countEdges()
Description copied from interface: Graph
Returns the number of Links in this Graph.

Specified by:
countEdges in interface Graph
Returns:
the number of all Links (directed/undirected/hyperedges).

nodes

public java.util.Iterator nodes()
Description copied from interface: Graph
Delivers an Iterator over all Nodes in this Graph.

Specified by:
nodes in interface Graph
Returns:
an Iterator to traverse all Nodes of this Graph.

nodeSet

public java.util.Set nodeSet()
Description copied from interface: Graph
Delivers the Set of Nodes in this Graph.

Specified by:
nodeSet in interface Graph
Returns:
a Set which contains all Nodes of this Graph.

edges

public java.util.Iterator edges()
Description copied from interface: Graph
Delivers an Iterator over all Links in this Graph.

Specified by:
edges in interface Graph
Returns:
an Iterator to traverse all Links of this Graph.

edgeSet

public java.util.Set edgeSet()
Description copied from interface: Graph
Delivers the Set of Links in this Graph.

Specified by:
edgeSet in interface Graph
Returns:
a Set which contains all Links of this Graph.

createNode

public Node createNode(java.lang.String name,
                       java.lang.Object data)
Description copied from interface: Graph
Constructs and returns a new Node.

Specified by:
createNode in interface Graph
Parameters:
name - a name used to identify this Node for the user.
data - external data of any kind that an application may need.
Returns:
a new Node instance.

createNode

public Node createNode(java.lang.String name)
Description copied from interface: Graph
Constructs and returns a new Node.

Specified by:
createNode in interface Graph
Parameters:
name - a name used to identify this Node for the user.
Returns:
a new Node instance.

createNode

public Node createNode()
Description copied from interface: Graph
Constructs and returns a new Node.

Specified by:
createNode in interface Graph
Returns:
a new Node instance.

createEdge

public Link createEdge(Node start,
                       Node end,
                       boolean directed,
                       java.lang.Object data)
Description copied from interface: Graph
Constructs and returns a new directed or undirected Edge with two end vertices.

Specified by:
createEdge in interface Graph
Parameters:
start - the source Node.
end - the target Node.
directed - true if the Edge is directed.
data - external data of any kind that an application may need
Returns:
a new Edge instance

createEdge

public Link createEdge(Node start,
                       Node end,
                       boolean directed)
Description copied from interface: Graph
Constructs and returns a new directed or undirected Edge. The source and target Nodes should have the same host.

Specified by:
createEdge in interface Graph
Parameters:
start - source Node
end - target Node
directed - true if the Edge is directed, false otherwise.
Returns:
a new Edge instance

createEdge

public Link createEdge(Node start,
                       Node end)
Description copied from interface: Graph
Constructs and returns a new Edge of the appropriate type. The source and target Nodes should have the same host.

Specified by:
createEdge in interface Graph
Parameters:
start - source Node
end - target Node
Returns:
a new Edge instance

remove

public boolean remove(NetElement elem)
Description copied from interface: Graph
Removes a NetElement from this Graph. The method should be implemented for all types of Nodes and Links of the concrete Graph class.

Specified by:
remove in interface Graph
Parameters:
elem - the NetElement to be removed.
Returns:
true if n was removed succesfully, false if it was not contained in this Graph.

getID

public java.lang.Object getID()
Description copied from interface: NetElement
Delivers the identifier of this NetElement. It is intended that the ID should be unique and given to this NetElement automatically during creation. There should be no public possibility to change the ID.

Specified by:
getID in interface NetElement
Returns:
the identifier.

getName

public java.lang.String getName()
Description copied from interface: NetElement
Delivers a human readable name of this NetElement.

Specified by:
getName in interface NetElement
Returns:
a human readable name of this NetElement.

setName

public void setName(java.lang.String name)
Description copied from interface: NetElement
Sets a human readable name for this NetElement.

Specified by:
setName in interface NetElement
Parameters:
name - the name.

getHost

public NetElement getHost()
Description copied from interface: NetElement
Delivers the parent of this NetElement in the inclusion hierarchy. Usually, the host is a container containing this NetElement. Moreover, the host was responsible for creating this NetElement, i.e. the host provides factory methods. The corresponding host attribute of this NetElement should not be changed.

Specified by:
getHost in interface NetElement
Returns:
the NetElement containing this NetElement.

getOriginal

public NetElement getOriginal()
Description copied from interface: NetElement
Delivers the NetElement from which this one was copied. It can be used for maintaining the isomorphism between two instances of one Graph. The corresponding attribute of this NetElement should be set by the clone method and should not be changed afterwards.

Specified by:
getOriginal in interface NetElement
Returns:
the NetElement from which this one had been copied.

getGeometry

public NetElementGeometry getGeometry()
Description copied from interface: NetElement
Delivers the NetElementGeometry instance containing the position and the size of this NetElement in the relative coordinate system of its host.

Specified by:
getGeometry in interface NetElement
Returns:
a reference to the NetElementGeometry.

setGeometry

public void setGeometry(NetElementGeometry geo)
Description copied from interface: NetElement
Assigns a new NetElementGeometry instance containing the position and the size of this NetElement in the relative coordinate system of its host.

Specified by:
setGeometry in interface NetElement
Parameters:
geo - a reference to the new NetElementGeometry.

getRepresentation

public de.fhstralsund.vinets.graphics.NetElementRepresentation getRepresentation()
Description copied from interface: NetElement
Delivers the NetElementRepresentation instance containing information for rendering this NetElement.

Specified by:
getRepresentation in interface NetElement
Returns:
a reference to the graphic representation of this NetElement.

setRepresentation

public void setRepresentation(de.fhstralsund.vinets.graphics.NetElementRepresentation repres)
Description copied from interface: NetElement
Assigns a new NetElementRepresentation instance containing information for rendering this NetElement.

Specified by:
setRepresentation in interface NetElement
Parameters:
repres - a reference to the graphic representation of this NetElement.

getData

public java.lang.Object getData()
Description copied from interface: NetElement
Delivers application specific data stored by this NetElement which have no relation to the network algorithms.

Specified by:
getData in interface NetElement
Returns:
a reference to the external data.

setData

public void setData(java.lang.Object data)
Description copied from interface: NetElement
Assigns new application specific data to this NetElement which have no relation to the network algorithms.

Specified by:
setData in interface NetElement
Parameters:
data - a reference to the external information to be stored.

setLabel

public void setLabel(java.lang.Object key,
                     java.lang.Object value)
Description copied from interface: NetElement
Adds a new property to be stored as a label of this NetElement or changes the value of an existing property. The idea is that any network algorithm should be able to store the information obtained during its execution locally for further use in a Map on each NetElement. The Object used as key should not change in a manner that affects equals comparisons while used for a label. The key should not be null, but for the value this restriction does not hold.

Specified by:
setLabel in interface NetElement
Parameters:
key - an Object with which the specified value is to be associated.
value - an Object to be associated with the specified key.

getLabel

public java.lang.Object getLabel(java.lang.Object key)
Description copied from interface: NetElement
Returns the label value associated with the passed key, or null if the label Map does not contain a mapping for this key. A return value of null does not necessarily indicate that the label contains no mapping for the key; it is also possible that the label explicitly maps the key to null. The containsLabel method may be used to distinguish these two cases.

Specified by:
getLabel in interface NetElement
Parameters:
key - the key whose associated value is to be returned.
Returns:
the value to which the label maps the specified key or null if there is no mapping for this key.
See Also:
NetElement.setLabel(Object, Object)

getLabelKeySet

public java.util.Set getLabelKeySet()
Description copied from interface: NetElement
Returns a Set which contains the Keys inside the LabelMap.

Specified by:
getLabelKeySet in interface NetElement
Returns:
a Set of Keys

containsLabel

public boolean containsLabel(java.lang.Object key)
Description copied from interface: NetElement
Returns true if the label contains a mapping for the specified key.

Specified by:
containsLabel in interface NetElement
Parameters:
key - the key whose presence as label is to be tested.
Returns:
true if the label contains a mapping for the specified key.
See Also:
NetElement.setLabel(Object, Object)

setIntLabel

public void setIntLabel(java.lang.Object key,
                        int i)
Description copied from interface: NetElement
Adds to this NetElement an integer value label or changes it. Convenience method - equivalent to setLabel(key, new Integer(i))}.

Specified by:
setIntLabel in interface NetElement
Parameters:
key - an Object with which the integer value is to be associated.
i - an int value to be associated with the specified key.
See Also:
NetElement.setLabel(Object, Object)

getIntLabel

public int getIntLabel(java.lang.Object key)
Description copied from interface: NetElement
Returns the label value associated with the passed key as int value. Convenience method - equivalent to containsLabel(key) ? ((Integer)getLabel(key)).intValue()) : Integer.MAX_VALUE.

Specified by:
getIntLabel in interface NetElement
Parameters:
key - the key whose associated integer value is to be returned.
Returns:
an int to which the label maps the specified key or Integer.MAX_VALUE if there is no mapping for the key.
See Also:
NetElement.getLabel(Object)

setDoubleLabel

public void setDoubleLabel(java.lang.Object key,
                           double i)
Description copied from interface: NetElement
Adds to this NetElement a double value label or changes it. Convenience method - equivalent to setLabel(key, new Double(x)).

Specified by:
setDoubleLabel in interface NetElement
Parameters:
key - an Object with which the double value is to be associated.
i - a double value to be associated with the specified key.
See Also:
NetElement.setLabel(Object, Object)

getDoubleLabel

public double getDoubleLabel(java.lang.Object key)
Description copied from interface: NetElement
Returns the label value associated with the passed key as double value. Convenience method - equivalent to containsLabel(key) ? ((Double)getLabel(key)).doubleValue() : Double.NaN.

Specified by:
getDoubleLabel in interface NetElement
Parameters:
key - the key whose associated double value is to be returned.
Returns:
a double to which the label maps the specified key. or Double.NaN if there is no mapping for the key.
See Also:
NetElement.getLabel(Object)

setBooleanLabel

public void setBooleanLabel(java.lang.Object key,
                            boolean i)
Description copied from interface: NetElement
Adds to this NetElement a boolean value label or changes it. Convenience method - equivalent to setLabel(key, new Boolean(i)).

Specified by:
setBooleanLabel in interface NetElement
Parameters:
key - an Object with which the boolean value is to be associated.
i - true or false to be associated with the specified key.
See Also:
NetElement.setLabel(Object, Object)

getBooleanLabel

public boolean getBooleanLabel(java.lang.Object key)
Description copied from interface: NetElement
Returns the label value associated with the passed key as boolean value. Convenience method - equivalent to containsLabel(key) ? ((Boolean)getLabel(key)).booleanValue() : false.

Specified by:
getBooleanLabel in interface NetElement
Parameters:
key - the key whose associated boolean value is to be returned.
Returns:
a boolean value to which the label maps the specified key.
See Also:
NetElement.getLabel(Object)

removeLabel

public java.lang.Object removeLabel(java.lang.Object key)
Description copied from interface: NetElement
Removes a property stored as label from this NetElement.

Specified by:
removeLabel in interface NetElement
Parameters:
key - the key of the property to remove.
Returns:
the previous value associated to that key or null.
See Also:
NetElement.setLabel(Object, Object)

clearLabels

public void clearLabels()
Description copied from interface: NetElement
Clears all labels of this NetElement.

Specified by:
clearLabels in interface NetElement

getGraphType

public GraphType getGraphType()
Description copied from interface: Graph
Returns the Type of this Graph.

Specified by:
getGraphType in interface Graph
Returns:
the Type of this Graph

clone

public java.lang.Object clone()
Description copied from interface: Graph
Delivers a deep copy of this Graph.

Specified by:
clone in interface Graph
Overrides:
clone in class java.lang.Object