de.fhstralsund.vinets.structure
Class Face

java.lang.Object
  extended by de.fhstralsund.vinets.structure.Face
All Implemented Interfaces:
java.lang.Cloneable

public class Face
extends java.lang.Object
implements java.lang.Cloneable

A structure that may symbolize either a Face or also a Chain (a path through graph). Common property is, that Nodes and Edges alternate in enumerations of the structures elements. Also, when creating this structure, elements must be inserted in a way that preserves the alternating order.


Constructor Summary
Face()
           
 
Method Summary
 void addAll(Face face)
          Adds all NetElements of the passed Face to the end of this Face.
 void addAll(java.util.List list)
          Adds all NetElements of the passed List to the end of this Face.
 void addFirst(NetElement el)
          Adds an NetElement the the front of this Face.
 void addLast(NetElement el)
          Adds an NetElement the the end of this Face.
 java.lang.Object clone()
           
 boolean contains(NetElement element)
          Tests whether the Face contains the passed NetElement
 int countEdges()
          Returns the number of Edges contained in this Face
 int countNodes()
          Returns the number of Nodes contained in this Face
 java.util.List edgeList()
          Returns a List of the Edges contained in this Face.
 java.util.Iterator edges()
          Returns an Iterator over the Edges of the Face.
 java.util.Iterator elements()
          Returns an Iterator over the Elements of the Face.
 java.util.Iterator elementsCyclic()
          Returns an cyclic Iterator over the Face elements.
 boolean equals(java.lang.Object obj)
           
 NetElement getFirst()
          Returns the first NetElement of the Face
 NetElement getLast()
          Returns the last NetElement of the Face
 void insertAsChain(NetElement after, Face face)
          Inserts the passed Face into a selected position in this Face.
 int length()
          Returns the number of Elements contained in this Face
 java.util.List nodeList()
          Returns a List of the Nodes contained in this Face.
 java.util.Iterator nodes()
          Returns an Iterator over the Nodes of the Face.
 void remove(NetElement element)
          Removes either the first or the last NetElement of the Face.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Face

public Face()
Method Detail

addFirst

public void addFirst(NetElement el)
Adds an NetElement the the front of this Face. If the Face is not empty the passed NetElement must not be of the same type (Node-Node or Edge-Edge) as the current first Element.

Parameters:
el - The NetElement to be added to the front

addLast

public void addLast(NetElement el)
Adds an NetElement the the end of this Face. If the Face is not empty the passed NetElement must not be of the same type (Node-Node or Edge-Edge) as the current last Element.

Parameters:
el - The NetElement to be added to the end

addAll

public void addAll(java.util.List list)
Adds all NetElements of the passed List to the end of this Face. The required structural conditions must hold.

Parameters:
list - A List with NetElements to add

addAll

public void addAll(Face face)
Adds all NetElements of the passed Face to the end of this Face. The required structural conditions must hold.

Parameters:
face - A Face to add

insertAsChain

public void insertAsChain(NetElement after,
                          Face face)
Inserts the passed Face into a selected position in this Face. This position is given by passing an NetElement ('after'), after which the Face should be inserted. Required Preconditions are: 1. The NetElement after which the Face shall be appended must not be the same type as the first element of the face (Node-Node or Edge-Edge) 2. The last NetElement of the appended Face must not be the same type as the NetElement that follows the 'after' element If the 'after' NetElement is not contained in this Face, the passed Face is simply appended if Precondition #1 holds.

Parameters:
after - The NetElement in this Face, after which the Face shall be appended. if this is null 'face' will be appended to the end
face - The Face to be appended

remove

public void remove(NetElement element)
Removes either the first or the last NetElement of the Face. Elements in the inside can not be removed to ensure structural integrity. If an NetElement is passed that can not be removed an Exception is thrown.

Parameters:
element - The NetElement to be removed, should be the first or the last NetElement of this face.

getFirst

public NetElement getFirst()
Returns the first NetElement of the Face

Returns:
The first NetElement

getLast

public NetElement getLast()
Returns the last NetElement of the Face

Returns:
The last NetElement

elements

public java.util.Iterator elements()
Returns an Iterator over the Elements of the Face.

Returns:
The Iterator

elementsCyclic

public java.util.Iterator elementsCyclic()
Returns an cyclic Iterator over the Face elements. The Iterator will cycle continouusly, thus simulating a cyclic face

Returns:
The cyclic Iterator

nodes

public java.util.Iterator nodes()
Returns an Iterator over the Nodes of the Face.

Returns:
The Iterator

nodeList

public java.util.List nodeList()
Returns a List of the Nodes contained in this Face. This List is NOT live, structural modifications done to this list are not reflected in the Face.

Returns:
A List of the Nodes in the Face

edges

public java.util.Iterator edges()
Returns an Iterator over the Edges of the Face.

Returns:
The Iterator

edgeList

public java.util.List edgeList()
Returns a List of the Edges contained in this Face. This List is NOT live, structural modifications done to this list are not reflected in the Face.

Returns:
A List of the Edges in the Face

length

public int length()
Returns the number of Elements contained in this Face

Returns:
The number of Elements

countNodes

public int countNodes()
Returns the number of Nodes contained in this Face

Returns:
The number of Nodes

countEdges

public int countEdges()
Returns the number of Edges contained in this Face

Returns:
The number of Edges

contains

public boolean contains(NetElement element)
Tests whether the Face contains the passed NetElement

Parameters:
element - The NetElement
Returns:
True if the element is contained int his Face, false otherwise

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object