public class PathMoverManager extends SimEntityBase implements MoverManager
Modifier and Type | Field and Description |
---|---|
private static double |
EPSILON
When comparing the location of waypoints, distances
less than EPSILON are considered zero.
|
private Mover |
mover
The Movers controlled by this MoverManager.
|
protected java.util.Iterator<WayPoint> |
nextWayPoint
Iterates over the wayPoints.
|
private boolean |
startOnReset
If true, then when reset is called on this MoverManager,
the Mover will be restarted on the path.
|
protected java.util.List<WayPoint> |
wayPoints
The path for the Mover to follow.
|
eventList, property
DEFAULT_ENTITY_NAME, DEFAULT_EVENT_NAME, DEFAULT_PRIORITY, EVENT_METHOD_PREFIX, NL
Constructor and Description |
---|
PathMoverManager() |
PathMoverManager(Mover m)
Constructs a new PathMoverManager with no path specified.
|
PathMoverManager(Mover m,
java.util.List<WayPoint> path)
Constructs a new PathMoverManager.
|
PathMoverManager(Mover m,
java.awt.geom.Point2D[] path)
Constructs a new PathMoverManager.
|
PathMoverManager(Mover m,
WayPoint[] path)
Constructs a new PathMoverManager.
|
Modifier and Type | Method and Description |
---|---|
void |
addWayPoint(java.awt.geom.Point2D point)
Adds the Point2D to the end of the path with the Mover's maximum speed.
|
void |
addWayPoint(java.awt.geom.Point2D point,
double speed)
Adds the given Point2D to the end of the current path with the
given speed.
|
void |
addWayPoint(WayPoint wayPoint)
Adds the given WayPoint to the end of the current path.
|
void |
clearPath()
Stops the Mover and clears the waypoint list.
|
void |
doEndMove(Mover m)
When an EndMove event is heard, move to next WayPoint, if there
are any remaining; else, stop.
|
void |
doStart()
Starts Mover on the current path.
|
Mover |
getMover()
The Mover controlled by this PathMoverManager
|
java.util.List<WayPoint> |
getWayPoints()
Creates a shallow copy of the current path
|
boolean |
isMoving()
Returns true if the Mover is currently moving.
|
boolean |
isStartOnReset()
If true, when reset, the PathMoverManger will start the Mover
on the current path.
|
void |
removeWayPoint(java.awt.geom.Point2D point)
Removes the given point from the path.
|
void |
reset()
Cancels all pending events for this MoverManager and
if startOnReset is true, schedule Start event.
|
void |
setMover(Mover newMover)
Sets the Mover that this MoverManager controls.
|
void |
setStartOnReset(boolean b)
If true, when reset, the PathMoverManger will start the Mover
on the current path.
|
void |
setWayPoints(java.util.List<WayPoint> path)
Takes the given list of waypoints and makes them the path
for this MoverManager.
|
void |
start()
Start by moving to first WayPoint.
|
void |
stop()
Stops the Mover at its current location.
|
coldReset, dumpDoMethods, dumpDoMethodsStr, dumpNamesAndSignatures, dumpNamesAndSignaturesStr, getFullMethodName, getSignatureString, handleSimEvent, isAssignableFrom, isDebug, processSimEvent, setDebug, stopAtTime, stopOnTime
addPropertyChangeListener, addPropertyChangeListener, attemptSchedule, clearAddedProperty, compareTo, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAddedProperties, getEventList, getEventListID, getName, getPriority, getPropertiesString, getProperty, getProperty, getPropertyChangeListeners, getSerial, interrupt, interrupt, interruptAll, interruptAll, interruptAll, interruptAllWithArgs, interruptAllWithArgs, isClearAddedPropertiesOnReset, isJustDefinedProperties, isPersistant, isReRunnable, isVerbose, parametersMatch, removePropertyChangeListener, removePropertyChangeListener, resetNextSerial, setClearAddedPropertiesOnReset, setEventList, setEventListID, setJustDefinedProperties, setName, setPersistant, setPriority, setProperty, setVerbose, toString, waitDelay, waitDelay, waitDelay, waitDelay
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getEventListID, setEventListID
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
processSimEvent
isPersistant, isReRunnable, setPersistant
getEventList, getPriority, getSerial, handleSimEvent, interrupt, interrupt, interruptAll, interruptAll, interruptAll, interruptAllWithArgs, interruptAllWithArgs, setPriority, waitDelay, waitDelay
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, getAddedProperties, getProperty, getProperty, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener, setProperty
private static final double EPSILON
protected java.util.List<WayPoint> wayPoints
private Mover mover
protected java.util.Iterator<WayPoint> nextWayPoint
private boolean startOnReset
public PathMoverManager()
public PathMoverManager(Mover m, WayPoint[] path)
m
- Mover this instance is managingpath
- Array of WayPoints for mover to followpublic PathMoverManager(Mover m, java.awt.geom.Point2D[] path)
m
- Mover this instance is managingpath
- Array of waypointspublic PathMoverManager(Mover m, java.util.List<WayPoint> path)
m
- Mover this instance is managingpath
- List of WayPointspublic PathMoverManager(Mover m)
m
- Mover this instance is managingpublic void start()
start
in interface MoverManager
public void stop()
stop
in interface MoverManager
public void doEndMove(Mover m)
doEndMove
in interface MoverManager
m
- Should be this instance's Moverpublic boolean isMoving()
isMoving
in interface MoverManager
public void setWayPoints(java.util.List<WayPoint> path)
Point2D
or a WayPoint
are
ignored and not added as part of the new path.
If a point in the path is a Point2D
, then the
speed for that segment is set to the maximum speed of the Mover.
WayPoints
contain speed information.path
- List of WayPointsjava.lang.IllegalArgumentException
- If the given path is null
WayPoint
,
Point2D
public void clearPath()
public void addWayPoint(WayPoint wayPoint)
wayPoint
- The WayPoint added to end of path - WayPoint includes
the Point2D and the desired speedpublic void addWayPoint(java.awt.geom.Point2D point, double speed)
point
- The next destination, added to end of current pathspeed
- The desired speed to move to this pointpublic void addWayPoint(java.awt.geom.Point2D point)
point
- Location added to end of path - speed is assumed to be maximum speed.public void removeWayPoint(java.awt.geom.Point2D point)
point
- Point to be removedpublic java.util.List<WayPoint> getWayPoints()
public Mover getMover()
getMover
in interface MoverManager
public void setStartOnReset(boolean b)
setStartOnReset
in interface MoverManager
b
- Whether to invoke start() in reset().public boolean isStartOnReset()
isStartOnReset
in interface MoverManager
public void reset()
reset
in interface ReRunnable
reset
in class BasicSimEntity
public void doStart()
public void setMover(Mover newMover)
setMover
in interface MoverManager
newMover
- The new Mover to manage