Package jsl.modeling.elements.spatial
Class ResourceLocation
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.spatial.SpatialModelElement
-
- jsl.modeling.elements.spatial.ResourceLocation
-
- All Implemented Interfaces:
PositionIfc
,SpatialElementIfc
,ObservableIfc
,GetNameIfc
,IdentityIfc
public class ResourceLocation extends SpatialModelElement
A ResourceLocation holds a set of resources that are assigned to this location in a spatial model. A ResourceLocation serves a "home base" for the SpatialResource. Clients can use the ResourceLocation to get idle resources that have been assigned to that location Since a ResourceLocation is a SpatialModelElement it is represented in a spatial model and can thus be visited by clients in search of resources that are assigned to the location. SpatialResource are assigned to the location, but that does not mean that the SpatialResource is currently physically located at the ResourceLocation.
-
-
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 Modifier and Type Field Description protected java.util.Set<SpatialResource>
myResources
Holds the resoures assigned to this location-
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 ResourceLocation(ModelElement parent)
Creates a ResourceLocation with (0.0, 0.0) position.ResourceLocation(ModelElement parent, double x, double y)
Creates a ResourceLocation with the given (x,y) position.ResourceLocation(ModelElement parent, java.lang.String name)
Creates a ResourceLocation with (0.0, 0.0) position.ResourceLocation(ModelElement parent, java.lang.String name, double x, double y)
Creates a ResourceLocation with the given (x,y) position.ResourceLocation(ModelElement parent, java.lang.String name, CoordinateIfc position)
Creates a ResourceLocation with at the coordinates of the supplied position.ResourceLocation(ModelElement parent, java.lang.String name, SpatialModel spatialModel)
Creates a ResourceLocation with the given parent and SpatialModel2D.ResourceLocation(ModelElement parent, java.lang.String name, SpatialModel spatialModel, double x, double y, double z)
Creates a ResourceLocation with the given parent and SpatialModel2D.ResourceLocation(ModelElement parent, java.lang.String name, SpatialModel spatialModel, CoordinateIfc coordinate)
Creates a ResourceLocation with the given parent and SpatialModel2D.ResourceLocation(ModelElement parent, CoordinateIfc position)
Creates a ResourceLocation with at the coordinates of the supplied position.ResourceLocation(ModelElement parent, SpatialModel spatialModel)
Creates a ResourceLocation with the given parent and SpatialModel2D.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(SpatialResource resource)
Adds the supplied resource to this location and sets the CURRENT position of the resource to this location.boolean
addInitialResource(SpatialResource resource)
Adds the supplied resource to this location and sets the initial position of the resource to this coordinates.boolean
contains(SpatialResource resource)
Checks if the supplied resource is assigned to this locationSpatialResource
findIdleResource2D()
This finds an idle resource assigned to this location.java.util.List<SpatialResource>
findIdleResources2D()
Returns a list of the idle resources assigned to this locationint
getNumberOfIdleResources()
Returns the number of idle resources currently assigned to this locationint
getNumberOfResources()
Returns the number of resources assigned to this locationboolean
isEmpty()
Indicates whether or not this location has resources assigned to itjava.util.Iterator<SpatialResource>
iterator()
Returns an iterator to the resources assigned to this locationboolean
remove(SpatialResource resource)
Removes the supplied resource from this location.-
Methods inherited from class jsl.modeling.elements.spatial.SpatialModelElement
attachPositionObserver, changeSpatialModel, distanceTo, distanceTo, getInitialPosition, getInitialSpatialModel, getModelElement, getPosition, getPreviousPosition, getSpatialElement, initialize, initializeSpatialElement, isPositionEqualTo, isPositionEqualTo, removePositionObserver, setCurrentPosition, setInitialPosition, setModelElement, setSpatialElement
-
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
-
-
-
-
Field Detail
-
myResources
protected java.util.Set<SpatialResource> myResources
Holds the resoures assigned to this location
-
-
Constructor Detail
-
ResourceLocation
public ResourceLocation(ModelElement parent)
Creates a ResourceLocation 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
-
-
ResourceLocation
public ResourceLocation(ModelElement parent, java.lang.String name)
Creates a ResourceLocation 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
-
-
ResourceLocation
public ResourceLocation(ModelElement parent, java.lang.String name, double x, double y)
Creates a ResourceLocation with the given (x,y) 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
-x
-y
-
-
ResourceLocation
public ResourceLocation(ModelElement parent, double x, double y)
Creates a ResourceLocation with the given (x,y) 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
-x
-y
-
-
ResourceLocation
public ResourceLocation(ModelElement parent, java.lang.String name, CoordinateIfc position)
Creates a ResourceLocation 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
-name
-position
-
-
ResourceLocation
public ResourceLocation(ModelElement parent, CoordinateIfc position)
Creates a ResourceLocation 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
-
-
ResourceLocation
public ResourceLocation(ModelElement parent, java.lang.String name, SpatialModel spatialModel)
Creates a ResourceLocation 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
-
-
ResourceLocation
public ResourceLocation(ModelElement parent, SpatialModel spatialModel)
Creates a ResourceLocation 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
-
-
ResourceLocation
public ResourceLocation(ModelElement parent, java.lang.String name, SpatialModel spatialModel, double x, double y, double z)
Creates a ResourceLocation 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
-x
-y
-z
-
-
ResourceLocation
public ResourceLocation(ModelElement parent, java.lang.String name, SpatialModel spatialModel, CoordinateIfc coordinate)
Creates a ResourceLocation 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
-
addInitialResource
public boolean addInitialResource(SpatialResource resource)
Adds the supplied resource to this location and sets the initial position of the resource to this coordinates. Only sets the initial position if the add was successful. A SpatialResource can only be assigned to one location at a time. An attempt to add a SpatialResource to a location when it is already assigned to another location will cause an exception. First check the getResourceLocation() method on SpatialResource to see if it is assigned a location. If so, remove it from that location prior to assigning it to this location.- Parameters:
resource
-- Returns:
-
add
public boolean add(SpatialResource resource)
Adds the supplied resource to this location and sets the CURRENT position of the resource to this location. Only sets the position if the add was successful A SpatialResource can only be assigned to one location at a time. An attempt to assign a SpatialResource to a location when it is already assigned to another location will cause an exception. First check the getResourceLocation() method on SpatialResource to see if it is assigned a location. If so, remove it from that location prior to assigning it to this location.- Parameters:
resource
-- Returns:
-
contains
public boolean contains(SpatialResource resource)
Checks if the supplied resource is assigned to this location- Parameters:
resource
-- Returns:
-
isEmpty
public boolean isEmpty()
Indicates whether or not this location has resources assigned to it- Returns:
-
iterator
public java.util.Iterator<SpatialResource> iterator()
Returns an iterator to the resources assigned to this location- Returns:
-
remove
public boolean remove(SpatialResource resource)
Removes the supplied resource from this location. The resource is no longer assigned to this location- Parameters:
resource
-- Returns:
- Returns true if the remove was successful
-
getNumberOfResources
public int getNumberOfResources()
Returns the number of resources assigned to this location- Returns:
-
getNumberOfIdleResources
public int getNumberOfIdleResources()
Returns the number of idle resources currently assigned to this location- Returns:
-
findIdleResource2D
public SpatialResource findIdleResource2D()
This finds an idle resource assigned to this location. Returns and idle resource or null if none found. This method does not remove the resource from this location.- Returns:
-
findIdleResources2D
public java.util.List<SpatialResource> findIdleResources2D()
Returns a list of the idle resources assigned to this location- Returns:
-
-