public class UniformLinearMover extends SimEntityBase implements Mover
Modifications made per recommendations of Alistair Dickie.
TODO Re-evaluate the above idea. The real goal is to ensure that parameters are not set while the simulation is in progress, not to ensure parameters are not set after the entity is instantiated. There are two reasons to reconsider:
1. It impossible to construct objects using the Builder Pattern. This pattern typically instantiates objects with a zero argument constructor, and then uses setters to set up the object in whatever particular way that builder builds things. As we have seen, simkit models get complex enough that the Builder Pattern is useful.
2. In a multiple iteration scenario, if we stick with the exisiting paradigm of re-cycling entities and using the reset functionality, it is probable that you would want parameters to be settable so that a main program trying to execute a design of experiments can change the parameters for a new design point.
Modifier and Type | Field and Description |
---|---|
protected java.awt.geom.Point2D |
destination
The current location that this Mover is moving towards.
|
protected static java.text.DecimalFormat |
df
Default format
|
protected java.awt.geom.Point2D |
lastStopLocation
The point where this Mover last stopped.
|
protected double |
maxSpeed
The Mover should never travel faster than this speed,
even when asked to do so.
|
protected MovementState |
movementState
Possible values are PAUSED, STOPPED, and CRUISING
|
protected double |
moveTime
The length of time it will take this Mover to move from
the lastStopLocation to the destination at the current
velocity.
|
protected java.awt.geom.Point2D |
nextVelocity |
protected static java.awt.geom.Point2D |
ORIGIN
The (0,0) point
|
protected java.awt.geom.Point2D |
originalLocation
reset() will return Mover to this location
|
protected java.lang.Object[] |
param
Convenience array.
|
protected double |
startMoveTime
The time that the current movement started.
|
protected java.awt.geom.Point2D |
velocity
The current velocity of this Mover.
|
eventList, property
DEFAULT_ENTITY_NAME, DEFAULT_EVENT_NAME, DEFAULT_PRIORITY, EVENT_METHOD_PREFIX, NL
Constructor and Description |
---|
UniformLinearMover(java.awt.geom.Point2D location)
Creates a Mover that can't move.
|
UniformLinearMover(java.awt.geom.Point2D location,
double maxSpeed)
Constructs a new UniformLinearMover.
|
UniformLinearMover(java.lang.String name,
java.awt.geom.Point2D location)
Creates a Mover that can't move.
|
UniformLinearMover(java.lang.String name,
java.awt.geom.Point2D location,
double maxSpeed)
Constructs a new UniformLinearMover.
|
Modifier and Type | Method and Description |
---|---|
void |
accelerate(java.awt.geom.Point2D acceleration)
Does nothing in this implementation.
|
void |
accelerate(java.awt.geom.Point2D acceleration,
double speed)
Does nothing in this implementation
|
void |
doEndMove(Moveable mover)
Event that signals that this Mover has reached its desired location.
|
void |
doStartMove(Moveable mover)
Event that signals the start of a move to previously set destination
|
static java.lang.String |
formatPoint(java.awt.geom.Point2D point)
Formats Point2D with default format
|
static java.lang.String |
formatPoint(java.awt.geom.Point2D point,
java.text.DecimalFormat form)
Gives nicer view of a Point2D
|
java.awt.geom.Point2D |
getAcceleration()
Always returns (0,0) for a UniformLinearMover.
|
java.awt.geom.Point2D |
getLocation()
If moving, determine actual location by use of the equation of
motion.
|
double |
getMaxSpeed()
The speed that this Mover will never exceed.
|
MovementState |
getMovementState() |
protected java.awt.geom.Point2D |
getResetLocation() |
java.awt.geom.Point2D |
getVelocity()
The current velocity of this Mover
|
boolean |
isMoving() |
void |
magicMove(java.awt.geom.Point2D location)
Instantly moves this Mover to the given location.
|
static void |
main(java.lang.String[] args) |
void |
move(java.awt.geom.Point2D desiredVelocity)
Move with the desired velocity.
|
void |
moveTo(java.awt.geom.Point2D destination)
Command issued to move to given destination at the maximum speed.
|
void |
moveTo(java.awt.geom.Point2D destination,
double cruisingSpeed)
Move to the desired destination at the desired speed.
|
java.lang.String |
paramString()
Returns a String containing the Name, original location, and the
maximum speed of this Mover.
|
void |
pause()
Pauses this Mover at its current location.
|
void |
reset()
Cancels all pending SimEvents for this Mover and returns it to its
original location stopped.
|
void |
setLocation(java.awt.geom.Point2D location)
Added to support zero argument constructors and the ObjectMaker system.
|
void |
setMaxSpeed(double max)
Added to support zero argument constructors and the ObjectMaker system.
|
protected void |
setMovementState(MovementState state)
Sets the MovementState and fires a property change.
|
void |
stop()
Stops at the current location.
|
protected void |
stopHere()
Stops Mover.
|
java.lang.String |
toString()
Returns a String containing the Name, current location, and current
velocity of this Mover, if initialized.
|
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, 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
protected static final java.awt.geom.Point2D ORIGIN
protected static final java.text.DecimalFormat df
protected double maxSpeed
protected java.awt.geom.Point2D originalLocation
protected java.awt.geom.Point2D lastStopLocation
protected double startMoveTime
protected java.awt.geom.Point2D velocity
protected java.awt.geom.Point2D nextVelocity
protected java.awt.geom.Point2D destination
protected double moveTime
protected MovementState movementState
protected final java.lang.Object[] param
public UniformLinearMover(java.lang.String name, java.awt.geom.Point2D location, double maxSpeed)
name
- Name of the Moverlocation
- starting location of the MovermaxSpeed
- maximum possible speed of the Moverpublic UniformLinearMover(java.awt.geom.Point2D location, double maxSpeed)
location
- starting location of the MovermaxSpeed
- maximum possible speed of the Moverpublic UniformLinearMover(java.awt.geom.Point2D location)
location
- Location of Moverpublic UniformLinearMover(java.lang.String name, java.awt.geom.Point2D location)
name
- Name of the Moverlocation
- Starting location of the Moverpublic java.awt.geom.Point2D getVelocity()
getVelocity
in interface Moveable
public java.awt.geom.Point2D getLocation()
getLocation
in interface Moveable
public void stop()
Mover
public void doEndMove(Moveable mover)
Mover
public java.awt.geom.Point2D getAcceleration()
getAcceleration
in interface Moveable
public void doStartMove(Moveable mover)
doStartMove
in interface Mover
mover
- This Moverpublic void moveTo(java.awt.geom.Point2D destination)
public java.lang.String toString()
toString
in class BasicSimEntity
public java.lang.String paramString()
paramString
in interface Mover
protected java.awt.geom.Point2D getResetLocation()
public void reset()
reset
in interface ReRunnable
reset
in class BasicSimEntity
public boolean isMoving()
public void moveTo(java.awt.geom.Point2D destination, double cruisingSpeed)
public void pause()
protected void stopHere()
public void move(java.awt.geom.Point2D desiredVelocity)
public void magicMove(java.awt.geom.Point2D location) throws MagicMoveException
magicMove
in interface Mover
location
- The new location of magic moverMagicMoveException
- if Magic Moves are not allowed. Note:
Magic moves are only allowed at the beginning of the simulation.protected void setMovementState(MovementState state)
state
- Given MovementStatepublic MovementState getMovementState()
getMovementState
in interface Mover
public void accelerate(java.awt.geom.Point2D acceleration)
accelerate
in interface Mover
acceleration
- given accelerationpublic void accelerate(java.awt.geom.Point2D acceleration, double speed)
accelerate
in interface Mover
acceleration
- given accellerationspeed
- given speedpublic double getMaxSpeed()
getMaxSpeed
in interface Mover
public static java.lang.String formatPoint(java.awt.geom.Point2D point, java.text.DecimalFormat form)
point
- desired Point2D to formatform
- formatting Stringpublic static java.lang.String formatPoint(java.awt.geom.Point2D point)
point
- Point2D to formatpublic static void main(java.lang.String[] args)
public void setMaxSpeed(double max) throws MagicMoveException
Mover
setMaxSpeed
in interface Mover
max
- speed that this Mover should never exceed.MagicMoveException
- if this Mover doesn't support "magic movespublic void setLocation(java.awt.geom.Point2D location) throws MagicMoveException
Mover
setLocation
in interface Mover
location
- Given locationMagicMoveException
- if Mover doesn't support magic moves