edu.wpi.cs.cs509.graph.processors.graphcustomizer
Class Vertex

java.lang.Object
  |
  +--edu.wpi.cs.cs509.graph.processors.graphcustomizer.Vertex
All Implemented Interfaces:
IMetaInformation, INode, IVisitable, java.io.Serializable

public class Vertex
extends java.lang.Object
implements INode

Represents a Vertex in a Graph.

Each vertex has a unique String label (unique within its Graph). Each vertex has an x and y coordinate for the location of the vertex when drawn to the screen.

A vertex has an associated color (defaults to Color.black).

Note that each vertex is simply a placeholder for simple information; in particular, a vertex is unaware of its incident edges or its neighboring vertices.

Version:
1.9
Author:
George T. Heineman (heineman@cs.wpi.edu)
See Also:
Serialized Form

Field Summary
protected  java.awt.Color color
          vertex color.
protected  int id
          id of this vertex.
protected  PropertyManager properties
          Manages the properties for IMetaInformation
protected  int status
          Status number of a graph.
 
Constructor Summary
Vertex(INode n)
          Vertex constructor copying an existing Vertex object.
Vertex(int id)
          Default Vertex constructor.
 
Method Summary
 void accept(IGraphVisitor gv)
          Implement visitor pattern by allowing any GraphVisitor to visit.
 void copyProperty(java.lang.String key, IMetaInformation base)
          Copy given property value from the base object.
 java.lang.String getProperty(java.lang.String key)
          Return the value of a property identified by key.
 int getStatus()
          Return status number of this vertex.
 int getX()
          Return x coordinate of this vertex.
 int getY()
          Return x coordinate of this vertex.
 java.util.Iterator keys()
          Return the used keys for the available meta information.
 int nodeId()
          Return the unique identifier for this node.
 void removeProperty(java.lang.String key)
          Removes the value of a specific property identified by key.
 void setProperty(java.lang.String key, java.lang.String value)
          Sets the value of a specific property identified by key.
 void setStatus(int s)
          Set status number of this vertex.
 void setX(int x)
          Set x position of this vertex.
 void setY(int y)
          Set y position of this vertex.
 java.lang.String toString()
          Return string representation of vertex.
 java.lang.String toXML()
          Output an XML representation of the meta information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected int id
id of this vertex.


status

protected int status
Status number of a graph. Equal to the sum of the shortest distance to all other vertices in the same (connected) graph.


color

protected java.awt.Color color
vertex color.


properties

protected PropertyManager properties
Manages the properties for IMetaInformation

Constructor Detail

Vertex

public Vertex(int id)
Default Vertex constructor.


Vertex

public Vertex(INode n)
Vertex constructor copying an existing Vertex object.

The only information copied is the label. Note: no Properties are copied.

Method Detail

accept

public void accept(IGraphVisitor gv)
            throws java.lang.Exception
Implement visitor pattern by allowing any GraphVisitor to visit.

Specified by:
accept in interface INode
Parameters:
gv - a GraphVisitor object.
Throws:
java.lang.Exception - if visitor sequence interrupted unexpectedly.

copyProperty

public void copyProperty(java.lang.String key,
                         IMetaInformation base)
                  throws java.lang.Exception
Copy given property value from the base object.
PRE: The parameter base should contain a key that is matching the name of the key passed as parameter.
POST: The value of the property key for the current object is set to the value of the corresponding property. in the object passed as base

Specified by:
copyProperty in interface IMetaInformation
Parameters:
key - a String representing the key to the Meta Information.
base - The IMetaInformation object containing the property to be copied.
Throws:
java.lang.Exception - if key or base is invalid.

getProperty

public java.lang.String getProperty(java.lang.String key)
                             throws java.lang.Exception
Return the value of a property identified by key.

Specified by:
getProperty in interface IMetaInformation
Parameters:
key - the String identifying the property of interest.
Returns:
the value of the property identified by key.
Throws:
java.lang.Exception - if key is null or invalid

getStatus

public int getStatus()
Return status number of this vertex.


getX

public int getX()
Return x coordinate of this vertex.


getY

public int getY()
Return x coordinate of this vertex.


keys

public java.util.Iterator keys()
                        throws java.lang.Exception
Return the used keys for the available meta information.

Specified by:
keys in interface IMetaInformation
Returns:
Iterator Iterator of the String keys of the properties available for the current object.
Throws:
java.lang.Exception - for unforeseen error while processing Iterator.

nodeId

public int nodeId()
           throws java.lang.Exception
Return the unique identifier for this node.

Specified by:
nodeId in interface INode
Returns:
int
Throws:
java.lang.Exception - if the current node has been deleted from its IGraph or is otherwise unassociated with a valid IGraph object.

removeProperty

public void removeProperty(java.lang.String key)
                    throws java.lang.Exception
Removes the value of a specific property identified by key.
PRE: none.
POST: If the current object contains a value for the given key, the (key, value) pair is removed. Otherwise no action is taken.

Specified by:
removeProperty in interface IMetaInformation
Parameters:
key - a String representing the key of the property whose data is to be removed.
Throws:
java.lang.Exception - if key is null or invalid.

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
                 throws java.lang.Exception
Sets the value of a specific property identified by key.

If the value is 'null' then the property is removed

Specified by:
setProperty in interface IMetaInformation
Parameters:
key - a String identifying the key in a (key, value) pair to be set.
value - a String identifying the value in a (key, value) pair to be set.
Throws:
java.lang.Exception - if (1) key is null; (2) key is invalid

setStatus

public void setStatus(int s)
Set status number of this vertex.


setX

public void setX(int x)
Set x position of this vertex.

Uses Meta Information Graph.XString


setY

public void setY(int y)
Set y position of this vertex. Uses Meta Information Graph.YString


toString

public java.lang.String toString()
Return string representation of vertex.

Overrides:
toString in class java.lang.Object
Returns:
String label

toXML

public java.lang.String toXML()
                       throws java.lang.Exception
Output an XML representation of the meta information.

Specified by:
toXML in interface IMetaInformation
Returns:
java.lang.String
Throws:
java.lang.Exception