jcreek.util.graph
Class Node

java.lang.Object
  extended byjcreek.util.graph.Node
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
VisualEntity

public abstract class Node
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This class represents a node with a 2D integer position. The node may also be a member of a graph.

Version:
1.0
Author:
Frode Sørmo
See Also:
Graph, Serialized Form

Field Summary
protected  Graph graph
           
 
Constructor Summary
Node()
          Creates a new node.
Node(int x, int y)
          Creates a new node with the given initial position.
 
Method Summary
 void addEdge(Edge edge)
          Adds an edge to this node.
protected  void addEdgeP(Edge e)
          Called from Graph to tell this node to add an edge to its list of edges from or to this node.
 java.lang.Object clone()
          Returns a clone of this node.
 int edgeSize()
          Gives the number of edges from/to this node.
 java.util.Iterator getEdgeIterator()
          Returns an iterator for the list of edges from/to this node.
 Graph getGraph()
          Returns the Graph this Node is a part of.
 java.awt.Point getPosition()
          Returns the position of this node.
 void remove()
          Tells this node to remove itself from its current graph.
 void removeEdge(Edge edge)
          Removes an edge from the node.
protected  void removeEdgeP(Edge e)
          Called from Graph to tell this node to remove an edge to its list of edges from or to this node.
 void removeP()
          Called by the Graph object to notify the node that it has been removed from the graph.
 void setPosition(int newX, int newY)
          Returns the position of this node.
 void setPosition(java.awt.Point p)
          Sets the position of this node.
 void suspendEventReport(boolean suspend)
          Suspends the reporting of "move" events for this node.
 void translate(int dx, int dy)
          Moves the Node by dx, dy.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graph

protected Graph graph
Constructor Detail

Node

public Node()
Creates a new node. It will by default not be a member of any graph.


Node

public Node(int x,
            int y)
Creates a new node with the given initial position.

Method Detail

getPosition

public java.awt.Point getPosition()
Returns the position of this node.


setPosition

public void setPosition(int newX,
                        int newY)
Returns the position of this node.


setPosition

public void setPosition(java.awt.Point p)
Sets the position of this node.


translate

public void translate(int dx,
                      int dy)
Moves the Node by dx, dy.


getGraph

public Graph getGraph()
Returns the Graph this Node is a part of. Null is returned if it is not part of any graphs.


addEdge

public void addEdge(Edge edge)
Adds an edge to this node. This will fail if the node is not attached to a graph.


addEdgeP

protected void addEdgeP(Edge e)
Called from Graph to tell this node to add an edge to its list of edges from or to this node. Note that this method should always be a result of calling the addEdge() method, but edges may also be added from the Graph object directly.


removeEdge

public void removeEdge(Edge edge)
Removes an edge from the node.


removeEdgeP

protected void removeEdgeP(Edge e)
Called from Graph to tell this node to remove an edge to its list of edges from or to this node. Note that this method should always be a result of calling the removeEdge() method, but edges may also be added from the Graph object directly.


remove

public void remove()
Tells this node to remove itself from its current graph.


removeP

public void removeP()
Called by the Graph object to notify the node that it has been removed from the graph.


getEdgeIterator

public java.util.Iterator getEdgeIterator()
Returns an iterator for the list of edges from/to this node.


edgeSize

public int edgeSize()
Gives the number of edges from/to this node.


suspendEventReport

public void suspendEventReport(boolean suspend)
Suspends the reporting of "move" events for this node. When turned off, any movement made in the meantime is reported in an event.


clone

public java.lang.Object clone()
Returns a clone of this node.



Created at IDI, NTNU by the Artificial Intelligence and Learning group