fdda.model.impl
Class Connection

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

public class Connection
extends WorkingPart
implements Connection, PropertyListener

The implementation of the Connection interface.

Author:
Jörg Rüdenauer
See Also:
Connection

Field Summary
protected  WorkingPart graphicalRepresentation
          the graphical representation of the part
 
Fields inherited from interface fdda.model.Connection
DIRECTED_PROPERTY_NAME, SPEED_PROPERTY_NAME
 
Fields inherited from interface fdda.model.WorkingPart
WORKING_PROPERTY_NAME
 
Constructor Summary
Connection(int nr, boolean directed, Node startNode, Node endNode, Line graphicalRepresentation)
          The constructor.
 
Method Summary
 void addProperty(Property property)
          Adds a property to the holder.
 void addPropertyListener(PropertyListener listener)
          Adds a PropertyListener (Observer pattern).
 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 getEndNode()
          Returns the node where the connection ends.
 Line getGraphicalRepresentation()
          Returns the graphical representation of the connection
 int getNr()
          Returns the internal number of the connection, which is unique.
 Iterator getProperties()
          Returns an Iterator over the properties of the holder.
 Property getProperty(String name)
          Returns a property of the holder.
 double getSpeed()
          Returns the speed of the connection.
 Node getStartNode()
          Returns the node where the connection starts.
 boolean isDirected()
          Returns whether the connection is directed
 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 removeProperty(Property property)
          Removes a property from the holder.
 void removePropertyListener(PropertyListener listener)
          Removes a PropertyListener (Observer pattern).
 void setDirected(boolean directed)
          Specifies whether the connection is directed.
 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
 
Methods inherited from interface fdda.model.PropertyListener
propertyAdded, propertyRemoved
 

Field Detail

graphicalRepresentation

protected WorkingPart graphicalRepresentation
the graphical representation of the part

Constructor Detail

Connection

public Connection(int nr,
                  boolean directed,
                  Node startNode,
                  Node endNode,
                  Line graphicalRepresentation)
The constructor. Start and end node as well as the graphical representation of the connection must exist before the connection can be created.

Parameters:
nr - the internal number (ID) of the connection
directed - whether the connection shall be directed
startNode - the start node
endNode - the end node
graphicalRepresentation - the graphical representation
Method Detail

getNr

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

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

getStartNode

public Node getStartNode()
Description copied from interface: Connection
Returns the node where the connection starts. (Even undirected connections have a 'start' and an 'end' node).

Specified by:
getStartNode in interface Connection
Returns:
the start node of the connection

getEndNode

public Node getEndNode()
Description copied from interface: Connection
Returns the node where the connection ends. (Even undirected connections have a 'start' and an 'end' node).

Specified by:
getEndNode in interface Connection
Returns:
the end node of the connection

getGraphicalRepresentation

public Line getGraphicalRepresentation()
Description copied from interface: Connection
Returns the graphical representation of the connection

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

isDirected

public boolean isDirected()
Description copied from interface: Connection
Returns whether the connection is directed

Specified by:
isDirected in interface Connection
Returns:
whether the connection is directed

setDirected

public void setDirected(boolean directed)
Description copied from interface: Connection
Specifies whether the connection is directed. Changes the corresponding property.

Specified by:
setDirected in interface Connection
Parameters:
directed - whether the connection shall be directed

getSpeed

public double getSpeed()
Description copied from interface: Connection
Returns the speed of the connection. The usual speed is 1.0, 2.0 would be two times as fast, 0.0 would be no speed at all, etc.

Specified by:
getSpeed in interface Connection
Returns:
the speed of the 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

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

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
Parameters:
pe - the PropertyEvent

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.