cad.simcad.pathfinding.path
Class Path

java.lang.Object
  |
  +--cad.simcad.pathfinding.path.Path
All Implemented Interfaces:
java.lang.Cloneable, PathPlaceSet

public class Path
extends java.lang.Object
implements java.lang.Cloneable, PathPlaceSet

Mother class of any kind of path It defines the basic thing At creation a path is not consistent, even if origin and destination map places are adjacent

Version:
1.0
Author:
Charles-Philip Bentley

Field Summary
protected  PathPlace _dest
           
protected  java.util.Properties _historyOfComputing
           
protected  PathFindable _map
           
protected  PathPlace _origin
           
protected  PathUser _pathUser
           
protected  java.util.Vector _pathVector
          first element is destination
 
Constructor Summary
Path(PathFindable aMap, PathPlace origin, PathPlace dest, PathUser pathUser)
          Creates new Path Initialize.
 
Method Summary
 boolean addAdjacentPlaceToPath(PathPlace mp)
          Same method as addPlaceToPath.
 boolean addPlaceToPath(PathPlace mp)
          This method just add a PathPlace to the path this object represents.
 boolean addPlaceToPathSecured(PathPlace mp)
          Safest and slowest method to add a Place to a path The method checks for adjacency, origin and destination
 java.lang.Object clone()
          Clones this path
 java.util.Properties getComputingProperties()
          Returns Properties related to the conpuatation of the Path
 PathPlace getDest()
          Returns the destination Cell of the path
 PathPlace getLastInsertedPathPlace()
          Returns the last inserted PathPlace
 PathPlace getOrigin()
          Returns the origin Cell of the path
 java.util.Enumeration getPathEnum()
           
 java.util.Enumeration getPathEnumDestFirst()
          Enumeration of PathPlace Objects with Destination PathPlace first.
 java.util.Enumeration getPathEnumOriginFirst()
          Enumeration of PathPlace Objects with Origin PathPlace as first element in the emumeration.
 PathUser getPathUser()
          Return the PathUser walking this PathPlaceSet.
 boolean isComplete()
          Returns true if origin or destination ends this path and the path is not a singleton.
 boolean isConsistent()
          Check for path consistency We define path consistence as follows : a path is consistent if from any part of the path, there exists only one way to go to another part of the path An empty path is not consistent
 boolean isEmpty()
          Return true if the Path has no PathPlace That means no PathPlace has been added yet.
 boolean isPartOfPath(PathPlace mp)
          Return true if the PathPlace given in argument is part of the path.
 void setComputingProperties(java.util.Properties prop)
          Set properties for this Path
 void setPathUser(PathUser pathUser)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_pathUser

protected PathUser _pathUser

_pathVector

protected java.util.Vector _pathVector
first element is destination


_map

protected PathFindable _map

_origin

protected PathPlace _origin

_dest

protected PathPlace _dest

_historyOfComputing

protected java.util.Properties _historyOfComputing
Constructor Detail

Path

public Path(PathFindable aMap,
            PathPlace origin,
            PathPlace dest,
            PathUser pathUser)
Creates new Path Initialize. The PathPlace objects between origin and destination are unknown The path is empty. Origin and Destination are flags. Either origin or destination will have to be inserted using the addPlaceToPath() kind of method.

Method Detail

getPathUser

public PathUser getPathUser()
Description copied from interface: PathPlaceSet
Return the PathUser walking this PathPlaceSet. Remember that a Path is computed according a PathUser caracteristics.

Specified by:
getPathUser in interface PathPlaceSet
Returns:
PathUser

setPathUser

public void setPathUser(PathUser pathUser)

getOrigin

public PathPlace getOrigin()
Returns the origin Cell of the path

Specified by:
getOrigin in interface PathPlaceSet
Returns:
origin PathPlace

getDest

public PathPlace getDest()
Returns the destination Cell of the path

Specified by:
getDest in interface PathPlaceSet
Returns:
destination PathPlace

isComplete

public boolean isComplete()
Returns true if origin or destination ends this path and the path is not a singleton.


isConsistent

public boolean isConsistent()
Check for path consistency We define path consistence as follows : a path is consistent if from any part of the path, there exists only one way to go to another part of the path An empty path is not consistent

Specified by:
isConsistent in interface PathPlaceSet
Returns:
a boolean

addPlaceToPath

public boolean addPlaceToPath(PathPlace mp)
This method just add a PathPlace to the path this object represents. It checks if the PathPlace given in argument is the destination place of the path What this method does : - check for adjacency (check for duplicate implicitely) What this method does NOT : -check for origin and destination. So as long as the PathPlace given in argument is adjacent to the previous MapPlace, it will be added - check for duplicates explicitely

Pre:
A PathPlace
Post:
The PathPlace is now part of the path. The data structure holding the path info is updated. Return true if PathPlace is now part of the path If PathPlace is not adjacent to the previous PathPlace inserted return false PathPlace added if the path is empty

isEmpty

public boolean isEmpty()
Return true if the Path has no PathPlace That means no PathPlace has been added yet.


getLastInsertedPathPlace

public PathPlace getLastInsertedPathPlace()
Returns the last inserted PathPlace

Post:
null if there is no PathPlace yet (Path isEmpty)

addAdjacentPlaceToPath

public boolean addAdjacentPlaceToPath(PathPlace mp)
Same method as addPlaceToPath. But this method does not check for adjacency. Hence it is faster. This method actually checks nothing.

Pre:
an adjacent PathPlace to the PathPlace returned by getLastInsertedPathPlace()

addPlaceToPathSecured

public boolean addPlaceToPathSecured(PathPlace mp)
                              throws PathException
Safest and slowest method to add a Place to a path The method checks for adjacency, origin and destination

Pre:
an adjacent PathPlace to the PathPlace returned by getLastInsertedPathPlace()
Returns:
boolean
Throws:
PathException - If last inserted PathPlace is either the origin or the destination PathPlace of this Path
Post:
returns true if the Place has been added to the path returns false if the PathPlace was NOT adjacent to the previous Place

isPartOfPath

public boolean isPartOfPath(PathPlace mp)
Return true if the PathPlace given in argument is part of the path.


getPathEnumOriginFirst

public java.util.Enumeration getPathEnumOriginFirst()
Enumeration of PathPlace Objects with Origin PathPlace as first element in the emumeration. If Path is not complete, the method returns an enumeration consisting of one PathPlace : the origin of the path

Specified by:
getPathEnumOriginFirst in interface PathPlaceSet
Returns:
Enumeration of PathPlaces

getPathEnum

public java.util.Enumeration getPathEnum()

getPathEnumDestFirst

public java.util.Enumeration getPathEnumDestFirst()
Enumeration of PathPlace Objects with Destination PathPlace first. If Path is not complete, the method returns an enumeration consisting of one PathPlace : the destination of the path

Specified by:
getPathEnumDestFirst in interface PathPlaceSet
Returns:
Enumeration of PathPlaces

clone

public java.lang.Object clone()
Clones this path

Overrides:
clone in class java.lang.Object

setComputingProperties

public void setComputingProperties(java.util.Properties prop)
Set properties for this Path

Pre:
the path has new computed properties

getComputingProperties

public java.util.Properties getComputingProperties()
Returns Properties related to the conpuatation of the Path

Specified by:
getComputingProperties in interface PathPlaceSet
Returns:
a Properties object. Null if no Properties have been computed
Post:
Properties about the computation of the Path null if no Properties have been computed

Logo

With the help of www.sourceforge.net and www.info.ucl.ac.be