Interface SpatialElementIfc

    • Method Detail

      • getInitialPosition

        CoordinateIfc getInitialPosition()
        Returns:
        Returns the initialPosition.
      • setInitialPosition

        void setInitialPosition​(CoordinateIfc coordinate)
        Sets the initial position of the element. This position should be used when initializeSpatialElement() is called, typically at the beginning of a replication.
        Parameters:
        coordinate - the coordinate
      • getPreviousPosition

        CoordinateIfc getPreviousPosition()
        Returns:
        Returns the previousPosition.
      • getObserverState

        int getObserverState()
        Observers can call this to get an integer representing the state of the element after the observers have been notified
        Returns:
        the observer state
      • distanceTo

        double distanceTo​(CoordinateIfc coordinate)
        This is a "convenience" method for getting the distance from this element to the supplied coordinate within the underlying spatial model
        Parameters:
        coordinate - the coordinate to check
        Returns:
        the distance
      • isPositionEqualTo

        boolean isPositionEqualTo​(CoordinateIfc coordinate)
        Returns 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).
        Parameters:
        coordinate - the coordinate to check
        Returns:
        true if position is equal
      • distanceTo

        double distanceTo​(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. The distance should be calculated by the spatial model. If they are not in the same spatial model this method will throw and IllegalArgumentException
        Parameters:
        element - the element to check
        Returns:
        the distance
      • isPositionEqualTo

        boolean isPositionEqualTo​(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. 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.
        Parameters:
        element - the element to check
        Returns:
        the distance
      • getSpatialModel

        SpatialModel getSpatialModel()
        Returns the current spatial model that contains this element
        Returns:
        the spatial model
      • getInitialSpatialModel

        SpatialModel getInitialSpatialModel()
        Returns the spatial model that should hold this element at the beginning of each replication of a simulation
        Returns:
        the spatial model
      • changeSpatialModel

        void changeSpatialModel​(SpatialModel spatialModel,
                                CoordinateIfc coordinate)
        Changes 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.
        Parameters:
        spatialModel - the spatial model
        coordinate - the coordinate
      • getModelElement

        ModelElement getModelElement()
        Gets the ModelElement associated with this spatial element May be null
        Returns:
        the model element
      • initializeSpatialElement

        void initializeSpatialElement()
        This method should be called to initialize the spatial element prior to running a simulation
      • attachPositionObserver

        void attachPositionObserver​(ObserverIfc observer)
        Implementor 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.
        Parameters:
        observer - the observer
      • removePositionObserver

        void removePositionObserver​(ObserverIfc observer)
        Remove the observer from this PositionIfc
        Parameters:
        observer - the observer