Class SpatialModelElement

    • 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

      • distanceTo

        public final double distanceTo​(CoordinateIfc coordinate)
        Description copied from interface: SpatialElementIfc
        This is a "convenience" method for getting the distance from this element to the supplied coordinate within the underlying spatial model
        Specified by:
        distanceTo in interface SpatialElementIfc
        Parameters:
        coordinate - the coordinate to check
        Returns:
        the distance
      • isPositionEqualTo

        public final boolean isPositionEqualTo​(CoordinateIfc coordinate)
        Description copied from interface: SpatialElementIfc
        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).
        Specified by:
        isPositionEqualTo in interface SpatialElementIfc
        Parameters:
        coordinate - the coordinate to check
        Returns:
        true if position is equal
      • distanceTo

        public final double distanceTo​(SpatialElementIfc element)
        Description copied from interface: SpatialElementIfc
        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
        Specified by:
        distanceTo in interface SpatialElementIfc
        Parameters:
        element - the element to check
        Returns:
        the distance
      • isPositionEqualTo

        public final boolean isPositionEqualTo​(SpatialElementIfc element)
        Description copied from interface: SpatialElementIfc
        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.
        Specified by:
        isPositionEqualTo in interface SpatialElementIfc
        Parameters:
        element - the element to check
        Returns:
        the distance
      • changeSpatialModel

        public final void changeSpatialModel​(SpatialModel spatialModel,
                                             CoordinateIfc coordinate)
        Description copied from interface: SpatialElementIfc
        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.
        Specified by:
        changeSpatialModel in interface SpatialElementIfc
        Parameters:
        spatialModel - the spatial model
        coordinate - the coordinate
      • attachPositionObserver

        public void attachPositionObserver​(ObserverIfc observer)
        Description copied from interface: SpatialElementIfc
        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.
        Specified by:
        attachPositionObserver in interface SpatialElementIfc
        Parameters:
        observer - the observer
      • setInitialPosition

        public void setInitialPosition​(CoordinateIfc coordinate)
        Description copied from interface: SpatialElementIfc
        Sets the initial position of the element. This position should be used when initializeSpatialElement() is called, typically at the beginning of a replication.
        Specified by:
        setInitialPosition in interface SpatialElementIfc
        Parameters:
        coordinate - the coordinate
      • initialize

        protected void initialize()
        Description copied from class: ModelElement
        This 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:
        initialize in class ModelElement
      • 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)