Class TLcdXYGeoBuffer

All Implemented Interfaces:
ILcdBounded, ILcdGeoBuffer, ILcdShape, ILcd2DEditableGeoBuffer, ILcd2DEditableShape, ILcdCache, ILcdCloneable, Serializable, Cloneable

public class TLcdXYGeoBuffer extends ALcd2DEditableShape implements ILcd2DEditableGeoBuffer, ILcdCache
This class represents a buffer around a shape with a given width, in the cartesian space. To calculate the contour, the utility method TLcdCartesian.computeBufferContour2D can be used.

This class is thread-safe for concurrent read-only access of its contents. For read-write access, external locking must be used. Such locking is typically done at the model level.

See Also:
  • Constructor Details

    • TLcdXYGeoBuffer

      public TLcdXYGeoBuffer()
      Creates a new TLcdXYGeoBuffer with width 0.
    • TLcdXYGeoBuffer

      public TLcdXYGeoBuffer(ILcdShape aShape, double aWidth)
      Creates a new TLcdXYGeoBuffer with the specified parameters.
      Parameters:
      aShape - the base shape of the buffer, which must be of the type ILcd2DEditableShape and one of the following:
      • ILcdPoint
      • ILcdPolyline
      • ILcdPolygon
      or an ILcdEditableComplexPolygon that contains only editable polygons.
      aWidth - the width in meters of the corridor, expressed in meters and measured from the axis to the border.
      Throws:
      IllegalArgumentException - if the supplied base shape is not one of the supported shapes, or if the width is negative.
  • Method Details

    • move2D

      public void move2D(double aX, double aY)
      Description copied from class: ALcd2DEditableShape
      Translates this shape so that its focus point ends up at the specified position.
      Specified by:
      move2D in interface ILcd2DEditableShape
      Overrides:
      move2D in class ALcd2DEditableShape
      Parameters:
      aX - the x coordinate of the point.
      aY - the y coordinate of the point.
    • translate2D

      public void translate2D(double aX, double aY)
      Description copied from interface: ILcd2DEditableShape
      Translates this ILcd2DEditableShape from its current position over the given translation vector in the 2D space. Only the first two dimensions of the ILcdShape are considered. The third dimension is left unchanged.
      Specified by:
      translate2D in interface ILcd2DEditableShape
      Parameters:
      aX - the x coordinate of the translation vector.
      aY - the y coordinate of the translation vector.
    • getWidth

      public final double getWidth()
      Description copied from interface: ILcdGeoBuffer
      Returns the width of this buffer, expressed in meters and measured from the line segments of the base shape to the contour. The width is positive (width >= 0).
      Specified by:
      getWidth in interface ILcdGeoBuffer
      Returns:
      the width of the buffer.
    • setWidth

      public void setWidth(double aWidth)
      Description copied from interface: ILcd2DEditableGeoBuffer
      Sets the width of the buffer, expressed in meters and measured from the axis to the border.
      Specified by:
      setWidth in interface ILcd2DEditableGeoBuffer
      Parameters:
      aWidth - the width of the buffer.
    • getBaseShape

      public ILcdShape getBaseShape()
      Description copied from interface: ILcdGeoBuffer
      Returns the base shape of the buffer.
      Specified by:
      getBaseShape in interface ILcdGeoBuffer
      Returns:
      the base shape of the buffer.
    • setBaseShape

      public void setBaseShape(ILcdShape aShape)
      Description copied from interface: ILcd2DEditableGeoBuffer
      Sets the base shape of the buffer.
      Specified by:
      setBaseShape in interface ILcd2DEditableGeoBuffer
      Parameters:
      aShape - the base shape of the buffer.
    • invalidateShape

      public void invalidateShape()
      Description copied from interface: ILcd2DEditableGeoBuffer
      Indicates that the base shape has been changed, and that the buffer should be recalculated.
      Specified by:
      invalidateShape in interface ILcd2DEditableGeoBuffer
    • getEndCapStyle

      public int getEndCapStyle()
      Returns the end cap style of the buffer.

      The default is ILcdGeoBuffer.CAP_ROUND.

      Specified by:
      getEndCapStyle in interface ILcdGeoBuffer
      Returns:
      the end cap style of the buffer.
    • setEndCapStyle

      public void setEndCapStyle(int aEndCapStyle)
      Description copied from interface: ILcd2DEditableGeoBuffer
      Sets the end cap style of the buffer, which must be either ILcdGeoBuffer.CAP_BUTT or ILcdGeoBuffer.CAP_ROUND.
      Specified by:
      setEndCapStyle in interface ILcd2DEditableGeoBuffer
      Parameters:
      aEndCapStyle - the end cap style of the buffer.
    • getJoinStyle

      public int getJoinStyle()
      Description copied from interface: ILcdGeoBuffer
      Returns the join style for the contour of this buffer, which defines the representation of the contour at the joins between two line segments of the base shape. This is always ILcdGeoBuffer.JOIN_ROUND.
      Specified by:
      getJoinStyle in interface ILcdGeoBuffer
      Returns:
      the join style of the buffer.
    • setJoinStyle

      public void setJoinStyle(int aJoinStyle)
      Description copied from interface: ILcd2DEditableGeoBuffer
      Sets the join style of the buffer, which must be ILcdGeoBuffer.JOIN_ROUND.
      Specified by:
      setJoinStyle in interface ILcd2DEditableGeoBuffer
      Parameters:
      aJoinStyle - the join style of the buffer.
    • contains2D

      public boolean contains2D(ILcdPoint aPoint)
      Description copied from class: ALcdShape
      Checks whether this ALcdShape contains the given point in the 2D cartesian plane.
      Specified by:
      contains2D in interface ILcdShape
      Overrides:
      contains2D in class ALcdShape
      Parameters:
      aPoint - the point to test.
      Returns:
      the boolean result of the containment test.
      See Also:
    • contains2D

      public boolean contains2D(double x, double y)
      Description copied from interface: ILcdShape
      Checks whether this ILcdShape contains the given point in the 2D space. Only the first two dimensions of the ILcdShape are considered.
      Specified by:
      contains2D in interface ILcdShape
      Parameters:
      x - the x coordinate of the point.
      y - the y coordinate of the point.
      Returns:
      the boolean result of the containment test.
    • getFocusPoint

      public ILcdPoint getFocusPoint()
      Description copied from interface: ILcdShape
      Returns the focus point of this ILcdShape.
      Specified by:
      getFocusPoint in interface ILcdShape
      Returns:
      the focus point of this ILcdShape.
    • getBounds

      public ILcdBounds getBounds()
      Description copied from interface: ILcdBounded
      Returns the ILcdBounds by which the geometry of this ILcdBounded object is bounded.

      If the geometry does not allow retrieving valid bounds (for example a polyline with 0 points) the return value is unspecified. It is highly recommended to return an undefined bounds. You can create undefined bounds using the default constructors of TLcdLonLatBounds or TLcdXYBounds.

      Specified by:
      getBounds in interface ILcdBounded
      Returns:
      the ILcdBounds by which the geometry of this ILcdBounded object is bounded.
    • insertIntoCache

      public void insertIntoCache(Object aKey, Object aObject)
      Description copied from interface: ILcdCache
      Inserts a cache Object corresponding to the given key Object.
      Specified by:
      insertIntoCache in interface ILcdCache
      Parameters:
      aKey - the key Object that will be used to identify the Object. The key must therefore be a unique identifier, typically the caller itself: insertIntoCache(this, ...).
      aObject - the Object to be cached.
    • getCachedObject

      public Object getCachedObject(Object aKey)
      Description copied from interface: ILcdCache
      Looks up and returns the cached Object corresponding to the given key.
      Specified by:
      getCachedObject in interface ILcdCache
      Parameters:
      aKey - the key Object that was used for storing the cache Object.
      Returns:
      the cached Object, or null if there is no Object corresponding to the given key.
    • removeCachedObject

      public Object removeCachedObject(Object aKey)
      Description copied from interface: ILcdCache
      Looks up and removes the cached Object corresponding to the given key.
      Specified by:
      removeCachedObject in interface ILcdCache
      Parameters:
      aKey - the key Object that was used for storing the cache Object.
      Returns:
      the cached Object, or null if there was no Object corresponding to the given key.
    • clearCache

      public void clearCache()
      Description copied from interface: ILcdCache
      Clears the cache.
      Specified by:
      clearCache in interface ILcdCache
    • clone

      public Object clone()
      Creates and returns a copy of this object.

      The axis of the buffer is cloned.

      The calculation of the contour is not copied or cloned at all, but recalculated when needed.

      Specified by:
      clone in interface ILcdCloneable
      Overrides:
      clone in class ALcdShape
      See Also:
    • equals

      public boolean equals(Object aObject)
      Returns whether the given object has the same class, coordinates, and width.
      Overrides:
      equals in class ALcdShape
    • hashCode

      public int hashCode()
      Description copied from class: ALcdShape
      The hash code of this shape is the hash code of its class, in order to be consistent with the ALcdShape.equals(Object) method. Extensions should refine this implementation, based on their properties.
      Overrides:
      hashCode in class ALcdShape
    • toString

      public String toString()
      Overrides:
      toString in class Object