fdda.model.impl
Class Node

java.lang.Object
  |
  +--fdda.model.impl.WorkingPart
        |
        +--fdda.model.impl.Node
All Implemented Interfaces:
EventListener, Node, PropertyHolder, PropertyListener, WorkingPart

public class Node
extends WorkingPart
implements Node

The implementation of the Node interface.

Author:
Jörg Rüdenauer

Field Summary
protected  WorkingPart graphicalRepresentation
          the graphical representation of the part
 
Fields inherited from interface fdda.model.Node
ACTIVE_PROPERTY_NAME, LABEL_PROPERTY_NAME, NODE_TYPE_PROPERTY_NAME
 
Fields inherited from interface fdda.model.WorkingPart
WORKING_PROPERTY_NAME
 
Constructor Summary
Node(int nr, Project project, Node graphicalRepresentation)
          Constructor.
 
Method Summary
 void addConnection(Connection connection)
          Adds a connection to the node.
 void addProperty(Property property)
          Adds a property to the holder.
 void addPropertyListener(PropertyListener listener)
          Adds a PropertyListener (Observer pattern).
 boolean canSendMessageDirectlyTo(Node node)
          Returns whether the node can send a message through (exactly) one connections to another node.
 void changeProperty(Property property)
          Changes a property of the holder - i.e., replaces the property with the name of the parameter property with the parameter.
protected  void firePropertyAdded(Property property)
          Notifies the listeners that a property has been added.
 void firePropertyChanged(Property property)
          Informs the listeners that a property has been changed.
protected  void firePropertyRemoved(Property property)
          Notifies the listeners that a property has been removed.
 Node getAlgorithmicNode()
          Returns the algorithmic representation of the node.
 List getConnections()
          Returns all the connections starting or ending at the node.
 Node getGraphicalRepresentation()
          Returns the graphical representation of the node.
 List getIncomingConnections()
          Returns all directed connections ending at the node and all undirected connections of the node.
 String getLabel()
          Returns the label of the node, which can identify the node for an user.
 List getNeighbours()
          Returns all nodes that are directly connected to this node through a connection (either directed or undirected).
 int getNr()
          Returns the internal number of the node, which is unique.
 List getOutgoingConnections()
          Returns all directed connections starting at the node and all undirected connections of the node.
 Project getProject()
          Returns the project that contains this node.
 Iterator getProperties()
          Returns an Iterator over the properties of the holder.
 Property getProperty(String name)
          Returns a property of the holder.
 void initialize()
          Initializes the node.
 boolean isConnectedTo(Node node)
          Returns whether there exists a connection that may transport messages directly between this node and another node.
 boolean isNeighbouredTo(Node node)
          Returns whether the node is a neighbour of the node in the parameter.
 boolean isRepeater()
          Returns whether this node is a repeater.
 boolean isWorking()
          Returns whether the part is currently working.
 void propertyAdded(PropertyEvent pe)
          Called whenever a property is added to the PropertyHolder.
 void propertyChanged(PropertyEvent pe)
          Called whenever a property of the PropertyHolder is changed.
 void propertyRemoved(PropertyEvent pe)
          Called whenever a property is removed from the PropertyHolder.
 void removeConnection(Connection connection)
          Removes a connection from the node.
 void removeProperty(Property property)
          Removes a property from the holder.
 void removePropertyListener(PropertyListener listener)
          Removes a PropertyListener (Observer pattern).
 void setAlgorithmicNode(Node algorithmicNode)
          Specifies the algorithmic representation of the node.
 void setLabel(String label)
          Sets the label of the node.
 void setWorking(boolean working)
          Sets whether the part is currently working.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fdda.model.PropertyHolder
addProperty, addPropertyListener, changeProperty, firePropertyChanged, getProperties, getProperty, removeProperty, removePropertyListener
 
Methods inherited from interface fdda.model.WorkingPart
isWorking, setWorking
 

Field Detail

graphicalRepresentation

protected WorkingPart graphicalRepresentation
the graphical representation of the part

Constructor Detail

Node

public Node(int nr,
            Project project,
            Node graphicalRepresentation)
Constructor. The graphical representation must exist before the node can be created.

Parameters:
nr - the ID / internal number of the node
graphicalRepresentation - the graphical representation
Method Detail

initialize

public void initialize()
Description copied from interface: Node
Initializes the node. Calls using the created instance of the node (this) are not possible in the constructor. They must be made here. This method is called immediately after node creation.

Specified by:
initialize in interface Node

getGraphicalRepresentation

public Node getGraphicalRepresentation()
Description copied from interface: Node
Returns the graphical representation of the node.

Specified by:
getGraphicalRepresentation in interface Node
Returns:
the graphical representation

getAlgorithmicNode

public Node getAlgorithmicNode()
Description copied from interface: Node
Returns the algorithmic representation of the node.

Specified by:
getAlgorithmicNode in interface Node
Returns:
the algorithmic representation

setAlgorithmicNode

public void setAlgorithmicNode(Node algorithmicNode)
Description copied from interface: Node
Specifies the algorithmic representation of the node.

Specified by:
setAlgorithmicNode in interface Node
Parameters:
algorithmicNode - the algorithmic representation

getNr

public int getNr()
Description copied from interface: Node
Returns the internal number of the node, which is unique.

Specified by:
getNr in interface Node
Returns:
the internal number

getLabel

public String getLabel()
Description copied from interface: Node
Returns the label of the node, which can identify the node for an user.

Specified by:
getLabel in interface Node
Returns:
the label of the node

setLabel

public void setLabel(String label)
Description copied from interface: Node
Sets the label of the node.

Specified by:
setLabel in interface Node
Parameters:
label - the new label.

getConnections

public List getConnections()
Description copied from interface: Node
Returns all the connections starting or ending at the node.

Specified by:
getConnections in interface Node
Returns:
the connections of the node

getOutgoingConnections

public List getOutgoingConnections()
Description copied from interface: Node
Returns all directed connections starting at the node and all undirected connections of the node.

Specified by:
getOutgoingConnections in interface Node
Returns:
all connections on which a message can leave the node

getIncomingConnections

public List getIncomingConnections()
Description copied from interface: Node
Returns all directed connections ending at the node and all undirected connections of the node.

Specified by:
getIncomingConnections in interface Node
Returns:
all connections on which a message can reach the node

getNeighbours

public List getNeighbours()
Description copied from interface: Node
Returns all nodes that are directly connected to this node through a connection (either directed or undirected).

Specified by:
getNeighbours in interface Node
Returns:
all neighbours of the node

isNeighbouredTo

public boolean isNeighbouredTo(Node node)
Description copied from interface: Node
Returns whether the node is a neighbour of the node in the parameter.

Specified by:
isNeighbouredTo in interface Node
Parameters:
node - a node
Returns:
whether the two nodes are neighboured

canSendMessageDirectlyTo

public boolean canSendMessageDirectlyTo(Node node)
Description copied from interface: Node
Returns whether the node can send a message through (exactly) one connections to another node. This is the case iff there exists an outgoing connection between this node and the node in the parameter, and the connection is working.

Specified by:
canSendMessageDirectlyTo in interface Node
Parameters:
node - a node
Returns:
whether this node can send a message directly to the other node

isConnectedTo

public boolean isConnectedTo(Node node)
Description copied from interface: Node
Returns whether there exists a connection that may transport messages directly between this node and another node. The working property is not regarded here.

Specified by:
isConnectedTo in interface Node
Parameters:
node - a node
Returns:
true, iff a connection exists between the node that has the right direction.

addConnection

public void addConnection(Connection connection)
Description copied from interface: Node
Adds a connection to the node. No check whether the connection already was added; in this case, it gets added a second time.

Specified by:
addConnection in interface Node
Parameters:
connection - a connection

removeConnection

public void removeConnection(Connection connection)
Description copied from interface: Node
Removes a connection from the node. If the connection isn't attached to the node, nothing happens. If the connection is attached to the node more than once, only the first attachement is removed.

Specified by:
removeConnection in interface Node
Parameters:
connection - a connection

propertyChanged

public void propertyChanged(PropertyEvent pe)
Description copied from interface: PropertyListener
Called whenever a property of the PropertyHolder is changed.

Specified by:
propertyChanged in interface PropertyListener
Overrides:
propertyChanged in class WorkingPart
Parameters:
pe - the PropertyEvent

propertyAdded

public void propertyAdded(PropertyEvent pe)
Description copied from interface: PropertyListener
Called whenever a property is added to the PropertyHolder.

Specified by:
propertyAdded in interface PropertyListener
Overrides:
propertyAdded in class WorkingPart
Parameters:
pe - the PropertyEvent

getProject

public Project getProject()
Description copied from interface: Node
Returns the project that contains this node.

Specified by:
getProject in interface Node
Returns:
the project

isRepeater

public boolean isRepeater()
Description copied from interface: Node
Returns whether this node is a repeater. A repeater is a special node (it can also be shown differently in the graphics) that is passive normally and forwards any incoming message to all other neighbours.

Specified by:
isRepeater in interface Node
Returns:
true iff the node is a repeater

isWorking

public boolean isWorking()
Description copied from interface: WorkingPart
Returns whether the part is currently working.

Specified by:
isWorking in interface WorkingPart
Returns:
whether the part is working

setWorking

public final void setWorking(boolean working)
Description copied from interface: WorkingPart
Sets whether the part is currently working.

Specified by:
setWorking in interface WorkingPart
Parameters:
working - whether the part is working

getProperties

public Iterator getProperties()
Description copied from interface: PropertyHolder
Returns an Iterator over the properties of the holder.

Specified by:
getProperties in interface PropertyHolder
Returns:
an Iterator over the properties

getProperty

public Property getProperty(String name)
Description copied from interface: PropertyHolder
Returns a property of the holder. If no property with the specified name exists, null is returned.

Specified by:
getProperty in interface PropertyHolder
Parameters:
name - the name of the property
Returns:
the property

addProperty

public void addProperty(Property property)
Description copied from interface: PropertyHolder
Adds a property to the holder. If a property with the same name already exists, it is removed.

Specified by:
addProperty in interface PropertyHolder

removeProperty

public void removeProperty(Property property)
Description copied from interface: PropertyHolder
Removes a property from the holder. The key for removal is the name of the property; if no property with that name exists, nothing happens.

Specified by:
removeProperty in interface PropertyHolder
Parameters:
property - the property to be removed, must not be null

changeProperty

public void changeProperty(Property property)
Description copied from interface: PropertyHolder
Changes a property of the holder - i.e., replaces the property with the name of the parameter property with the parameter. If no such property exists, the property is simply added to the holder; in this case, a propertyAdded event instead of a propertyChanged event is fired.

Specified by:
changeProperty in interface PropertyHolder
Parameters:
property - the new property, must not be null

addPropertyListener

public void addPropertyListener(PropertyListener listener)
Description copied from interface: PropertyHolder
Adds a PropertyListener (Observer pattern).

Specified by:
addPropertyListener in interface PropertyHolder
Parameters:
listener - the listener to be added
See Also:
EventListenerList

removePropertyListener

public void removePropertyListener(PropertyListener listener)
Description copied from interface: PropertyHolder
Removes a PropertyListener (Observer pattern).

Specified by:
removePropertyListener in interface PropertyHolder
Parameters:
listener - the listener to be removed
See Also:
EventListenerList

firePropertyChanged

public void firePropertyChanged(Property property)
Description copied from interface: PropertyHolder
Informs the listeners that a property has been changed. Note that the property holder can't determine by himself whether a property is changed internally; therefore, the property must inform its holder of any changes. This method must only be called by implementing classes of either PropertyHolder or Property.

Specified by:
firePropertyChanged in interface PropertyHolder
Parameters:
property - the property that was changed.

firePropertyAdded

protected void firePropertyAdded(Property property)
Notifies the listeners that a property has been added.

Parameters:
property - the added property
See Also:
EventListenerList

firePropertyRemoved

protected void firePropertyRemoved(Property property)
Notifies the listeners that a property has been removed.

Parameters:
property - the added property
See Also:
EventListenerList

propertyRemoved

public void propertyRemoved(PropertyEvent pe)
Description copied from interface: PropertyListener
Called whenever a property is removed from the PropertyHolder.

Specified by:
propertyRemoved in interface PropertyListener
Parameters:
pe - the PropertyEvent


API documentation for FDDA version 0.9. Generated on 17/02/2004 14:12.