Package jsl.modeling.elements.spatial
Class SpatialModelElement
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.spatial.SpatialModelElement
-
- All Implemented Interfaces:
PositionIfc,SpatialElementIfc,ObservableIfc,GetNameIfc,IdentityIfc
- Direct Known Subclasses:
AbstractMover,ResourceLocation
public class SpatialModelElement extends SchedulingElement implements SpatialElementIfc
SpatialModelElement represents a ModelElement within a SpatialModel. A SpatialModelElement does not have the ability to move within the SpatialModel. Sub-classes may implement this behavior. A SpatialModelElement has a fixed location within the SpatialModel
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.simulation.ModelElement
ModelElement.EventBuilderIfc<T>, ModelElement.EventScheduler<T>, ModelElement.ModelElementComparator, ModelElement.RequestBuilder, ModelElement.RequestDurationIfc, ModelElement.RequestTimeIfc, ModelElement.RequestUsingIfc, ModelElement.TimedUpdateEventAction, ModelElement.TimeUnitIfc<T>, ModelElement.WarmUpEventAction
-
-
Field Summary
-
Fields inherited from class jsl.simulation.ModelElement
AFTER_EXPERIMENT, AFTER_REPLICATION, BEFORE_EXPERIMENT, BEFORE_REPLICATION, CONDITIONAL_ACTION_REGISTRATION, DEFAULT_TIMED_EVENT_PRIORITY, INITIALIZED, MONTE_CARLO, myAfterExperimentOption, myAfterReplicationOption, myBeforeExperimentOption, myBeforeReplicationOption, myInitializationOption, myLengthOfWarmUp, myModelElements, myMonteCarloOption, myObservableComponent, myReplicationEndedOption, myTimedUpdateActionListener, myTimedUpdateEvent, myTimedUpdateInterval, myTimedUpdateOption, myTimedUpdatePriority, myWarmUpActionListener, myWarmUpEvent, myWarmUpIndicator, myWarmUpOption, myWarmUpPriority, NONE, REMOVED_FROM_MODEL, REPLICATION_ENDED, TIME_UNIT_DAY, TIME_UNIT_HOUR, TIME_UNIT_MILLISECOND, TIME_UNIT_MINUTE, TIME_UNIT_SECOND, TIME_UNIT_WEEK, TIMED_UPDATE, UPDATE, WARMUP
-
-
Constructor Summary
Constructors Constructor Description SpatialModelElement(ModelElement parent)Creates a Location2D with (0.0, 0.0) position.SpatialModelElement(ModelElement parent, java.lang.String name)Creates a Location2D with (0.0, 0.0) position.SpatialModelElement(ModelElement parent, java.lang.String name, SpatialModel spatialModel)Creates a Location2D with the given parent and SpatialModel2D.SpatialModelElement(ModelElement parent, java.lang.String name, SpatialModel spatialModel, CoordinateIfc coordinate)Creates a Location2D with the given parent and SpatialModel2D.SpatialModelElement(ModelElement parent, CoordinateIfc position)Creates a Location2D with at the coordinates of the supplied position.SpatialModelElement(ModelElement parent, SpatialElementIfc position)Creates a Location2D with at the coordinates of the supplied position.SpatialModelElement(ModelElement parent, SpatialModel spatialModel)Creates a Location2D with the given parent and SpatialModel2D.SpatialModelElement(ModelElement parent, SpatialModel spatialModel, SpatialElementIfc element)Creates a Location2D with the given parent and SpatialModel2D.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattachPositionObserver(ObserverIfc observer)Implementor of this interface should allow Observers to be attached.voidchangeSpatialModel(SpatialModel spatialModel, CoordinateIfc coordinate)Changes the spatial model for this element and places the element at the supplied coordinate within the new spatial model.doubledistanceTo(CoordinateIfc coordinate)This is a "convenience" method for getting the distance from this element to the supplied coordinate within the underlying spatial modeldoubledistanceTo(SpatialElementIfc element)This is a "convenience" method for getting the distance from this element to the supplied element within the underlying spatial model Requirement: The elements must be in the same spatial model.CoordinateIfcgetInitialPosition()SpatialModelgetInitialSpatialModel()Returns the spatial model that should hold this element at the beginning of each replication of a simulationModelElementgetModelElement()Gets the ModelElement associated with this spatial element May be nullCoordinateIfcgetPosition()CoordinateIfcgetPreviousPosition()protected SpatialElementgetSpatialElement()Returns the spatial element associated with this spatial model elementprotected voidinitialize()This method should be overridden by subclasses that need actions performed to initialize prior to a replication.voidinitializeSpatialElement()This method should be called to initialize the spatial element prior to running a simulationbooleanisPositionEqualTo(CoordinateIfc coordinate)Returns true if the position of this element is the same as supplied coordinate within the underlying spatial model.booleanisPositionEqualTo(SpatialElementIfc element)Returns true if the position of this element is the same as the position of the supplied element within the underlying spatial model.voidremovePositionObserver(ObserverIfc observer)Remove the observer from this PositionIfcprotected voidsetCurrentPosition(CoordinateIfc currentPosition)voidsetInitialPosition(CoordinateIfc coordinate)Sets the initial position of the element.protected voidsetModelElement(ModelElement modelElement)protected voidsetSpatialElement(SpatialElement spatialElement)Sets the underlying SpatialElement-
Methods inherited from class jsl.simulation.SchedulingElement
cancelEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent
-
Methods inherited from class jsl.simulation.ModelElement
addObserver, addObserverToModelElements, afterExperiment, afterExperiment_, afterReplication, afterReplication_, asString, beforeExperiment, beforeExperiment_, beforeReplication, beforeReplication_, buildEventGenerator, cancelTimedUpdateEvent, cancelWarmUpEvent, changeParentModelElement, checkForAfterExperiment, checkForAfterReplication, checkForBeforeExperiment, checkForBeforeReplication, checkForConditionalActionRegistration, checkForInitialize, checkForMonteCarlo, checkForRemoveFromModel, checkForReplicationEnded, checkForTimedUpdate, checkForUpdate, checkForWarmUp, checkObserverState, checkWarmUpOption, clearModelElementObservers, contains, countObservers, createEntity, createEntity, createQObject, day, deleteObserver, deleteObserverFromModelElements, deleteObservers, findModelElementWithWarmUpEvent, getAfterExperimentOption, getAfterReplicationOption, getAllCounters, getAllModelElements, getAllRandomElements, getAllResponseVariables, getAllVariables, getBeforeExperimentOption, getBeforeReplicationOption, getChildModelElementIterator, getCurrentReplicationNumber, getDefaultEntityType, getExecutive, getExperiment, getId, getInitializationOption, getInitializationOrderAsString, getLeftPreOrderTraversalCount, getLengthOfWarmUp, getModel, getModelElementCompartor, getModelElementsAsString, getModelElementsAsString, getModelElementsAsString, getMonteCarloOption, getName, getNumberOfModelElements, getObserverState, getParentModelElement, getPreviousObserverState, getReplicationEndedOption, getRightPreOrderTraversalCount, getSimulation, getSpatialModel, getStringLabel, getThisElementsCounters, getThisElementsModelElements, getThisElementsRandomVariables, getThisElementsResponseVariables, getThisElementsVariables, getTime, getTimedUpdateInterval, getTimedUpdateOption, getUpdateNotificationFlag, getVariable, getWarmUpEventTime, getWarmUpOption, hour, indent, initialize_, isTimedUpdateEventScheduled, isWarmedUp, isWarmUpEventScheduled, isWarmUpScheduled, millisecond, minute, montecarlo, montecarlo_, notifyAfterExperimentObservers, notifyAfterReplicationObservers, notifyBeforeExperimentObservers, notifyBeforeReplicationObservers, notifyConditionalActionRegistrationObservers, notifyInitializationObservers, notifyMonteCarloObservers, notifyObservers, notifyObservers, notifyRemovingFromModelObservers, notifyReplicationEndedObservers, notifyTimedUpdateObservers, notifyUpdateObservers, notifyWarmUpObservers, registerConditionalActions, registerConditionalActions_, removedFromModel, removeFromModel, replicationEnded, replicationEnded_, schedule, second, seize, setAfterExperimentOption, setAfterExperimentOptionForModelElements, setAfterReplicationOption, setAfterReplicationOptionForModelElements, setBeforeExperimentOption, setBeforeExperimentOptionForModelElements, setBeforeReplicationOption, setBeforeReplicationOptionForModelElements, setInitializationOption, setInitializationOptionForModelElements, setLengthOfWarmUp, setModel, setMonteCarloOption, setMonteCarloOptionForModelElements, setName, setObserverState, setParentModelElement, setReplicationEndedOption, setReplicationEndedOptionForModelElements, setSpatialModel, setStringLabel, setTimedUpdateInterval, setTimedUpdateOption, setTimedUpdateOptionForModelElements, setUpdateNotificationFlag, setWarmUpOption, setWarmUpOptionForModelElements, stopExecutive, stopExecutive, timedUpdate, timedUpdate_, toString, update, useControls, warmUp, warmUp_, week
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsl.utilities.GetNameIfc
getName
-
Methods inherited from interface jsl.utilities.IdentityIfc
getId
-
Methods inherited from interface jsl.modeling.elements.spatial.SpatialElementIfc
getObserverState, getSpatialModel
-
-
-
-
Constructor Detail
-
SpatialModelElement
public SpatialModelElement(ModelElement parent)
Creates a Location2D with (0.0, 0.0) position. The SpatialModel2D of the parent is used as the SpatialModel2D. If the parent does not have a SpatialModel2D, then an IllegalArgumentException is thrown- Parameters:
parent-
-
SpatialModelElement
public SpatialModelElement(ModelElement parent, java.lang.String name)
Creates a Location2D with (0.0, 0.0) position. The SpatialModel2D of the parent is used as the SpatialModel2D. If the parent does not have a SpatialModel2D, then an IllegalArgumentException is thrown- Parameters:
parent-name-
-
SpatialModelElement
public SpatialModelElement(ModelElement parent, CoordinateIfc position)
Creates a Location2D with at the coordinates of the supplied position. The SpatialModel2D of the parent is used as the SpatialModel2D. If the parent does not have a SpatialModel2D, then an IllegalArgumentException is thrown- Parameters:
parent-position-
-
SpatialModelElement
public SpatialModelElement(ModelElement parent, SpatialElementIfc position)
Creates a Location2D with at the coordinates of the supplied position. The SpatialModel2D of the parent is used as the SpatialModel2D. If the parent does not have a SpatialModel2D, then an IllegalArgumentException is thrown- Parameters:
parent-position-
-
SpatialModelElement
public SpatialModelElement(ModelElement parent, java.lang.String name, SpatialModel spatialModel)
Creates a Location2D with the given parent and SpatialModel2D. The default position is (0.0, 0.0). If the SpatialModel2D is null, the SpatialModel2D of the parent is used as the SpatialModel2D. If the parent does not have a SpatialModel2D, then an IllegalArgumentException is thrown- Parameters:
parent-name-spatialModel-
-
SpatialModelElement
public SpatialModelElement(ModelElement parent, SpatialModel spatialModel)
Creates a Location2D with the given parent and SpatialModel2D. The default position is (0.0, 0.0). If the SpatialModel2D is null, the SpatialModel2D of the parent is used as the SpatialModel2D. If the parent does not have a SpatialModel2D, then an IllegalArgumentException is thrown- Parameters:
parent-spatialModel-
-
SpatialModelElement
public SpatialModelElement(ModelElement parent, SpatialModel spatialModel, SpatialElementIfc element)
Creates a Location2D with the given parent and SpatialModel2D. The default position is (0.0, 0.0). If the SpatialModel2D is null, the SpatialModel2D of the parent is used as the SpatialModel2D. If the parent does not have a SpatialModel2D, then an IllegalArgumentException is thrown- Parameters:
parent-spatialModel-element-
-
SpatialModelElement
public SpatialModelElement(ModelElement parent, java.lang.String name, SpatialModel spatialModel, CoordinateIfc coordinate)
Creates a Location2D with the given parent and SpatialModel2D. If the SpatialModel2D is null, the SpatialModel2D of the parent is used as the SpatialModel2D. If the parent does not have a SpatialModel2D, then an IllegalArgumentException is thrown- Parameters:
parent-name-spatialModel-coordinate-
-
-
Method Detail
-
getPosition
public final CoordinateIfc getPosition()
- Specified by:
getPositionin interfacePositionIfc- Specified by:
getPositionin interfaceSpatialElementIfc- Returns:
- Returns the current Position.
-
getInitialPosition
public final CoordinateIfc getInitialPosition()
- Specified by:
getInitialPositionin interfaceSpatialElementIfc- Returns:
- Returns the initialPosition.
-
getPreviousPosition
public final CoordinateIfc getPreviousPosition()
- Specified by:
getPreviousPositionin interfaceSpatialElementIfc- Returns:
- Returns the previousPosition.
-
distanceTo
public final double distanceTo(CoordinateIfc coordinate)
Description copied from interface:SpatialElementIfcThis is a "convenience" method for getting the distance from this element to the supplied coordinate within the underlying spatial model- Specified by:
distanceToin interfaceSpatialElementIfc- Parameters:
coordinate- the coordinate to check- Returns:
- the distance
-
isPositionEqualTo
public final boolean isPositionEqualTo(CoordinateIfc coordinate)
Description copied from interface:SpatialElementIfcReturns true if the position of this element is the same as supplied coordinate within the underlying spatial model. This is not necessarily object reference equality, but rather whether or not the positions within the underlying spatial model can be considered the same (equivalent).- Specified by:
isPositionEqualToin interfaceSpatialElementIfc- Parameters:
coordinate- the coordinate to check- Returns:
- true if position is equal
-
distanceTo
public final double distanceTo(SpatialElementIfc element)
Description copied from interface:SpatialElementIfcThis is a "convenience" method for getting the distance from this element to the supplied element within the underlying spatial model Requirement: The elements must be in the same spatial model. The distance should be calculated by the spatial model. If they are not in the same spatial model this method will throw and IllegalArgumentException- Specified by:
distanceToin interfaceSpatialElementIfc- Parameters:
element- the element to check- Returns:
- the distance
-
isPositionEqualTo
public final boolean isPositionEqualTo(SpatialElementIfc element)
Description copied from interface:SpatialElementIfcReturns true if the position of this element is the same as the position of the supplied element within the underlying spatial model. This is not necessarily object reference equality, but rather whether or not the positions within the underlying spatial model can be considered the same (equivalent). Requirement: The elements must be in the same spatial model. If they are not in the same spatial model, then this method should return false.- Specified by:
isPositionEqualToin interfaceSpatialElementIfc- Parameters:
element- the element to check- Returns:
- the distance
-
getInitialSpatialModel
public final SpatialModel getInitialSpatialModel()
Description copied from interface:SpatialElementIfcReturns the spatial model that should hold this element at the beginning of each replication of a simulation- Specified by:
getInitialSpatialModelin interfaceSpatialElementIfc- Returns:
- the spatial model
-
changeSpatialModel
public final void changeSpatialModel(SpatialModel spatialModel, CoordinateIfc coordinate)
Description copied from interface:SpatialElementIfcChanges the spatial model for this element and places the element at the supplied coordinate within the new spatial model. Throws IllegalArgumentException if the coordinate is not valid for the supplied spatial model. This spatial element becomes a child element of the new spatial model.- Specified by:
changeSpatialModelin interfaceSpatialElementIfc- Parameters:
spatialModel- the spatial modelcoordinate- the coordinate
-
getModelElement
public final ModelElement getModelElement()
Description copied from interface:SpatialElementIfcGets the ModelElement associated with this spatial element May be null- Specified by:
getModelElementin interfaceSpatialElementIfc- Returns:
- the model element
-
attachPositionObserver
public void attachPositionObserver(ObserverIfc observer)
Description copied from interface:SpatialElementIfcImplementor of this interface should allow Observers to be attached. For example, the observers should be notified when the position changes. It is the responsibility of implementers to properly notify the observers.- Specified by:
attachPositionObserverin interfaceSpatialElementIfc- Parameters:
observer- the observer
-
removePositionObserver
public void removePositionObserver(ObserverIfc observer)
Description copied from interface:SpatialElementIfcRemove the observer from this PositionIfc- Specified by:
removePositionObserverin interfaceSpatialElementIfc- Parameters:
observer- the observer
-
setInitialPosition
public void setInitialPosition(CoordinateIfc coordinate)
Description copied from interface:SpatialElementIfcSets the initial position of the element. This position should be used when initializeSpatialElement() is called, typically at the beginning of a replication.- Specified by:
setInitialPositionin interfaceSpatialElementIfc- Parameters:
coordinate- the coordinate
-
initializeSpatialElement
public void initializeSpatialElement()
Description copied from interface:SpatialElementIfcThis method should be called to initialize the spatial element prior to running a simulation- Specified by:
initializeSpatialElementin interfaceSpatialElementIfc
-
initialize
protected void initialize()
Description copied from class:ModelElementThis method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called- Overrides:
initializein classModelElement
-
getSpatialElement
protected final SpatialElement getSpatialElement()
Returns the spatial element associated with this spatial model element- Returns:
-
setSpatialElement
protected final void setSpatialElement(SpatialElement spatialElement)
Sets the underlying SpatialElement- Parameters:
spatialElement- the element
-
setModelElement
protected void setModelElement(ModelElement modelElement)
-
setCurrentPosition
protected final void setCurrentPosition(CoordinateIfc currentPosition)
-
-