Class TLcdComplexPolygon

java.lang.Object
com.luciad.shape.ALcdShape
com.luciad.shape.TLcdComplexPolygon
All Implemented Interfaces:
ILcdBounded, ILcdComplexPolygon, ILcdEditableComplexPolygon, ILcdPointList, ILcdShape, ILcdCache, ILcdCloneable, ILcdInvalidateable, Serializable, Cloneable
Direct Known Subclasses:
TLcdS57Area

public class TLcdComplexPolygon extends ALcdShape implements ILcdEditableComplexPolygon, ILcdCache
This class provides an implementation of ILcdComplexPolygon. This implementation uses an array of the right size to store the list of shapes, which is memory efficient, but inefficient for adding and removing shapes.

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

    • TLcdComplexPolygon

      public TLcdComplexPolygon()
      Constructs a TLcdComplexPolygon that doesn't have any ILcdPolygon objects.
    • TLcdComplexPolygon

      public TLcdComplexPolygon(ILcdPolygon[] aPolygonArray)
      Constructs a TLcdComplexPolygon containing the given ILcdPolygon objects.
      Parameters:
      aPolygonArray - an array of ILcdPolygon objects this TLcdComplexPolygon is composed of.
    • TLcdComplexPolygon

      public TLcdComplexPolygon(TLcdComplexPolygon aComplexPolygon)
      Constructs a TLcdComplexPolygon that is a clone of the given TLcdComplexPolygon.
      Parameters:
      aComplexPolygon - the complex polygon to clone.
  • Method Details

    • invalidateBounds

      public void invalidateBounds()
    • 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.
    • 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.
    • setPolygon

      public void setPolygon(ILcdPolygon[] aPolygonArray)
      Sets the ILcdPolygon objects associated with this ILcdComplexPolygon. This method does exactly the same as setPolygons(ILcdPolygon[]).
      Parameters:
      aPolygonArray - the ILcdPolygon objects associated with this ILcdComplexPolygon.
      See Also:
    • getPolygonCount

      public final int getPolygonCount()
      Description copied from interface: ILcdComplexPolygon
      Returns the number of ILcdPolygon objects in the list.
      Specified by:
      getPolygonCount in interface ILcdComplexPolygon
      Returns:
      the number of ILcdPolygon objects in the list.
    • getPolygon

      public final ILcdPolygon getPolygon(int aIndex) throws IndexOutOfBoundsException
      Description copied from interface: ILcdComplexPolygon
      Returns the ILcdPolygon at the given index.
      Specified by:
      getPolygon in interface ILcdComplexPolygon
      Parameters:
      aIndex - a valid index in the list of ILcdPolygon objects.
      Returns:
      the ILcdPolygon at the given index.
      Throws:
      IndexOutOfBoundsException - when the index is not valid.
    • contains2D

      public boolean contains2D(double aX, double aY)
      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:
      aX - the x coordinate of the point.
      aY - the y coordinate of the point.
      Returns:
      the boolean result of the containment test.
    • contains3D

      public boolean contains3D(double aX, double aY, double aZ)
      Description copied from interface: ILcdShape
      Checks whether this ILcdShape contains the given point in the 3D space.
      Specified by:
      contains3D in interface ILcdShape
      Parameters:
      aX - the x coordinate of the point.
      aY - the y coordinate of the point.
      aZ - the z coordinate of the point.
      Returns:
      the boolean result of the containment test.
    • getPointCount

      public int getPointCount()
      Description copied from interface: ILcdPointList
      Returns the number of ILcdPoint objects in the list.
      Specified by:
      getPointCount in interface ILcdPointList
      Returns:
      the number of ILcdPoint objects in the list.
    • getPoint

      public ILcdPoint getPoint(int aIndex) throws IndexOutOfBoundsException
      Description copied from interface: ILcdPointList
      Returns the ILcdPoint at a given index.
      Specified by:
      getPoint in interface ILcdPointList
      Parameters:
      aIndex - a valid index in the list of ILcdPoint objects.
      Returns:
      the ILcdPoint at the given index.
      Throws:
      IndexOutOfBoundsException - if the given index is out of bounds.
    • 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 polygon array is deep cloned.

      The cache is not copied or cloned at all.

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

      public boolean equals(Object aObject)
      Description copied from class: ALcdShape
      An object is considered equal to this shape if it has the same class. Extensions should refine this comparison, based on their properties.
      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
    • addPolygon

      public void addPolygon(int aIndex, ILcdPolygon aPolygon)
      Description copied from interface: ILcdEditableComplexPolygon
      Inserts the specified polygon at the specified position in this ILcdComplexPolygon.
      Specified by:
      addPolygon in interface ILcdEditableComplexPolygon
      Parameters:
      aIndex - the index at which the polygon is to be inserted.
      aPolygon - the polygon to be inserted.
    • addPolygon

      public void addPolygon(ILcdPolygon aPolygon)
      Description copied from interface: ILcdEditableComplexPolygon
      Appends the specified polygon to the end of this ILcdComplexPolygon.
      Specified by:
      addPolygon in interface ILcdEditableComplexPolygon
      Parameters:
      aPolygon - the polygon to be appended to this ILcdComplexPolygon.
    • addPolygons

      public void addPolygons(ILcdPolygon[] aPolygon)
      Description copied from interface: ILcdEditableComplexPolygon
      Appends the specified array of polygons to the end of this ILcdComplexPolygon.
      Specified by:
      addPolygons in interface ILcdEditableComplexPolygon
      Parameters:
      aPolygon - the array of polygons to be appended to this ILcdComplexPolygon.
    • clearPolygons

      public void clearPolygons()
      Description copied from interface: ILcdEditableComplexPolygon
      Removes all of the polygons from this ILcdComplexPolygon.
      Specified by:
      clearPolygons in interface ILcdEditableComplexPolygon
    • removePolygon

      public ILcdPolygon removePolygon(int aIndex)
      Description copied from interface: ILcdEditableComplexPolygon
      Removes the polygon at the specified position in this ILcdComplexPolygon. Shifts any subsequent polygons to the left. Returns the polygon that was removed from this ILcdComplexPolygon.
      Specified by:
      removePolygon in interface ILcdEditableComplexPolygon
      Parameters:
      aIndex - the index of the polygon to removed.
      Returns:
      the polygon previously at the specified position.
    • removePolygon

      public boolean removePolygon(ILcdPolygon aPolygon)
      Description copied from interface: ILcdEditableComplexPolygon
      Removes the first occurrence of the specified polygon in this ILcdComplexPolygon. If this ILcdComplexPolygon does not contain the polygon, it is unchanged.
      Specified by:
      removePolygon in interface ILcdEditableComplexPolygon
      Parameters:
      aPolygon - the polygon to be removed, if present.
      Returns:
      true if this ILcdComplexPolygon contained the specified element.
    • removePolygons

      public void removePolygons(ILcdPolygon[] aPolygon)
      Description copied from interface: ILcdEditableComplexPolygon
      Removes all polygons from this ILcdComplexPolygon that are contained in the specified array of polygons.
      Specified by:
      removePolygons in interface ILcdEditableComplexPolygon
      Parameters:
      aPolygon - the array of polygons to be removed from this ILcdComplexPolygon.
    • setPolygon

      public ILcdPolygon setPolygon(int aIndex, ILcdPolygon aPolygon)
      Description copied from interface: ILcdEditableComplexPolygon
      Replaces the polygon at the specified position in this ILcdComplexPolygon with the specified polygon.
      Specified by:
      setPolygon in interface ILcdEditableComplexPolygon
      Parameters:
      aIndex - index of polygon to replace.
      aPolygon - the polygon to be stored at the specified position.
      Returns:
      the polygon previously at the specified position.
    • setPolygons

      public void setPolygons(ILcdPolygon[] aPolygons)
      Description copied from interface: ILcdEditableComplexPolygon
      Replace the list of polygons contained in this ILcdComplexPolygon with the specified array of polygons.
      Specified by:
      setPolygons in interface ILcdEditableComplexPolygon
      Parameters:
      aPolygons - the array of polygons to be stored in this ILcdComplexPolygon.
    • polygonChanged

      public void polygonChanged(int aIndex)
      Description copied from interface: ILcdEditableComplexPolygon
      Notifies this ILcdComplexPolygon that the polygon at the specified position has changed.
      Specified by:
      polygonChanged in interface ILcdEditableComplexPolygon
      Parameters:
      aIndex - the index of the polygon that has changed.
    • polygonChanged

      public void polygonChanged(ILcdPolygon aPolygon)
      Description copied from interface: ILcdEditableComplexPolygon
      Notifies this ILcdComplexPolygon that the specified polygon has changed.
      Specified by:
      polygonChanged in interface ILcdEditableComplexPolygon
      Parameters:
      aPolygon - the polygon that has changed.
    • polygonsChanged

      public void polygonsChanged()
      Description copied from interface: ILcdEditableComplexPolygon
      Notifies this ILcdComplexPolygon that some (possibly all) of its polygons have changed.
      Specified by:
      polygonsChanged in interface ILcdEditableComplexPolygon
    • invalidateObject

      public void invalidateObject()
      Description copied from interface: ILcdInvalidateable
      Invalidates all cached values of this object. Call this method whenever one or more of this object's compositing values has been changed, to notify this object it needs to recompute its cached values.
      Specified by:
      invalidateObject in interface ILcdInvalidateable
    • setShape

      public void setShape(ILcdShape[] aShapeArray)
      Deprecated.
      Sets the ILcdShape objects associated with this TLcdComplexPolygon.
      Parameters:
      aShapeArray - the ILcdShape objects associated with this TLcdComplexPolygon.
      See Also:
    • getShapeCount

      public int getShapeCount()
      Deprecated.
      use getPolygonCount() instead
      Returns the number of ILcdShape objects in the list.
      Returns:
      the number of ILcdShape objects in the list.
    • getShape

      public ILcdShape getShape(int aIndex) throws IndexOutOfBoundsException
      Deprecated.
      use getPolygon(int) instead
      Returns the ILcdShape at the given index.
      Parameters:
      aIndex - a valid index in the list of ILcdShape objects.
      Returns:
      the ILcdShape at the given index.
      Throws:
      IndexOutOfBoundsException - when the index is not valid.
    • calculateFocusPoint

      protected void calculateFocusPoint()
      Computes the focus point as the center of the bounding box. The resulting point is stored in the focus point cache.
    • setFocusPoint

      public void setFocusPoint(ILcd3DEditablePoint aFocusPoint)
      Specifies the focus point value.
      Parameters:
      aFocusPoint - the new focus point value.
      See Also: