Package com.luciad.shape
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
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 Summary
ConstructorDescriptionConstructs aTLcdComplexPolygon
that doesn't have anyILcdPolygon
objects.TLcdComplexPolygon
(ILcdPolygon[] aPolygonArray) Constructs aTLcdComplexPolygon
containing the givenILcdPolygon
objects.TLcdComplexPolygon
(TLcdComplexPolygon aComplexPolygon) Constructs aTLcdComplexPolygon
that is a clone of the givenTLcdComplexPolygon
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPolygon
(int aIndex, ILcdPolygon aPolygon) Inserts the specified polygon at the specified position in thisILcdComplexPolygon
.void
addPolygon
(ILcdPolygon aPolygon) Appends the specified polygon to the end of thisILcdComplexPolygon
.void
addPolygons
(ILcdPolygon[] aPolygon) Appends the specified array of polygons to the end of thisILcdComplexPolygon
.protected void
Computes the focus point as the center of the bounding box.void
Clears the cache.void
Removes all of the polygons from thisILcdComplexPolygon
.clone()
Creates and returns a copy of this object.boolean
contains2D
(double aX, double aY) Checks whether thisILcdShape
contains the given point in the 2D space.boolean
contains3D
(double aX, double aY, double aZ) Checks whether thisILcdShape
contains the given point in the 3D space.boolean
An object is considered equal to this shape if it has the same class.Returns theILcdBounds
by which the geometry of thisILcdBounded
object is bounded.getCachedObject
(Object aKey) Looks up and returns the cached Object corresponding to the given key.Returns the focus point of thisILcdShape
.getPoint
(int aIndex) Returns theILcdPoint
at a given index.int
Returns the number ofILcdPoint
objects in the list.final ILcdPolygon
getPolygon
(int aIndex) Returns theILcdPolygon
at the given index.final int
Returns the number ofILcdPolygon
objects in the list.getShape
(int aIndex) Deprecated.int
Deprecated.usegetPolygonCount()
insteadint
hashCode()
The hash code of this shape is the hash code of its class, in order to be consistent with theALcdShape.equals(Object)
method.void
insertIntoCache
(Object aKey, Object aObject) Inserts a cache Object corresponding to the given key Object.void
void
Invalidates all cached values of this object.void
polygonChanged
(int aIndex) Notifies thisILcdComplexPolygon
that the polygon at the specified position has changed.void
polygonChanged
(ILcdPolygon aPolygon) Notifies thisILcdComplexPolygon
that the specified polygon has changed.void
Notifies thisILcdComplexPolygon
that some (possibly all) of its polygons have changed.removeCachedObject
(Object aKey) Looks up and removes the cached Object corresponding to the given key.removePolygon
(int aIndex) Removes the polygon at the specified position in thisILcdComplexPolygon
.boolean
removePolygon
(ILcdPolygon aPolygon) Removes the first occurrence of the specified polygon in thisILcdComplexPolygon
.void
removePolygons
(ILcdPolygon[] aPolygon) Removes all polygons from thisILcdComplexPolygon
that are contained in the specified array of polygons.void
setFocusPoint
(ILcd3DEditablePoint aFocusPoint) Specifies the focus point value.setPolygon
(int aIndex, ILcdPolygon aPolygon) Replaces the polygon at the specified position in thisILcdComplexPolygon
with the specified polygon.void
setPolygon
(ILcdPolygon[] aPolygonArray) Sets theILcdPolygon
objects associated with thisILcdComplexPolygon
.void
setPolygons
(ILcdPolygon[] aPolygons) Replace the list of polygons contained in thisILcdComplexPolygon
with the specified array of polygons.void
Deprecated.usesetPolygons(ILcdPolygon[])
insteadMethods inherited from class com.luciad.shape.ALcdShape
contains2D, contains3D, fromDomainObject
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.shape.ILcdPointList
getPointSFCT, getX, getY, getZ
Methods inherited from interface com.luciad.shape.ILcdShape
contains2D, contains3D
-
Constructor Details
-
TLcdComplexPolygon
public TLcdComplexPolygon()Constructs aTLcdComplexPolygon
that doesn't have anyILcdPolygon
objects. -
TLcdComplexPolygon
Constructs aTLcdComplexPolygon
containing the givenILcdPolygon
objects.- Parameters:
aPolygonArray
- an array ofILcdPolygon
objects thisTLcdComplexPolygon
is composed of.
-
TLcdComplexPolygon
Constructs aTLcdComplexPolygon
that is a clone of the givenTLcdComplexPolygon
.- Parameters:
aComplexPolygon
- the complex polygon to clone.
-
-
Method Details
-
invalidateBounds
public void invalidateBounds() -
getBounds
Description copied from interface:ILcdBounded
Returns theILcdBounds
by which the geometry of thisILcdBounded
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 ofTLcdLonLatBounds
orTLcdXYBounds
.- Specified by:
getBounds
in interfaceILcdBounded
- Returns:
- the
ILcdBounds
by which the geometry of thisILcdBounded
object is bounded.
-
getFocusPoint
Description copied from interface:ILcdShape
Returns the focus point of thisILcdShape
.- Specified by:
getFocusPoint
in interfaceILcdShape
- Returns:
- the focus point of this
ILcdShape
.
-
setPolygon
Sets theILcdPolygon
objects associated with thisILcdComplexPolygon
. This method does exactly the same assetPolygons(ILcdPolygon[])
.- Parameters:
aPolygonArray
- theILcdPolygon
objects associated with thisILcdComplexPolygon
.- See Also:
-
getPolygonCount
public final int getPolygonCount()Description copied from interface:ILcdComplexPolygon
Returns the number ofILcdPolygon
objects in the list.- Specified by:
getPolygonCount
in interfaceILcdComplexPolygon
- Returns:
- the number of
ILcdPolygon
objects in the list.
-
getPolygon
Description copied from interface:ILcdComplexPolygon
Returns theILcdPolygon
at the given index.- Specified by:
getPolygon
in interfaceILcdComplexPolygon
- Parameters:
aIndex
- a valid index in the list ofILcdPolygon
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 thisILcdShape
contains the given point in the 2D space. Only the first two dimensions of theILcdShape
are considered.- Specified by:
contains2D
in interfaceILcdShape
- 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 thisILcdShape
contains the given point in the 3D space.- Specified by:
contains3D
in interfaceILcdShape
- 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 ofILcdPoint
objects in the list.- Specified by:
getPointCount
in interfaceILcdPointList
- Returns:
- the number of
ILcdPoint
objects in the list.
-
getPoint
Description copied from interface:ILcdPointList
Returns theILcdPoint
at a given index.- Specified by:
getPoint
in interfaceILcdPointList
- Parameters:
aIndex
- a valid index in the list ofILcdPoint
objects.- Returns:
- the
ILcdPoint
at the given index. - Throws:
IndexOutOfBoundsException
- if the given index is out of bounds.
-
insertIntoCache
Description copied from interface:ILcdCache
Inserts a cache Object corresponding to the given key Object.- Specified by:
insertIntoCache
in interfaceILcdCache
- 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
Description copied from interface:ILcdCache
Looks up and returns the cached Object corresponding to the given key.- Specified by:
getCachedObject
in interfaceILcdCache
- 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
Description copied from interface:ILcdCache
Looks up and removes the cached Object corresponding to the given key.- Specified by:
removeCachedObject
in interfaceILcdCache
- 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 interfaceILcdCache
-
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 interfaceILcdCloneable
- Overrides:
clone
in classALcdShape
- See Also:
-
equals
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. -
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 theALcdShape.equals(Object)
method. Extensions should refine this implementation, based on their properties. -
addPolygon
Description copied from interface:ILcdEditableComplexPolygon
Inserts the specified polygon at the specified position in thisILcdComplexPolygon
.- Specified by:
addPolygon
in interfaceILcdEditableComplexPolygon
- Parameters:
aIndex
- the index at which the polygon is to be inserted.aPolygon
- the polygon to be inserted.
-
addPolygon
Description copied from interface:ILcdEditableComplexPolygon
Appends the specified polygon to the end of thisILcdComplexPolygon
.- Specified by:
addPolygon
in interfaceILcdEditableComplexPolygon
- Parameters:
aPolygon
- the polygon to be appended to thisILcdComplexPolygon
.
-
addPolygons
Description copied from interface:ILcdEditableComplexPolygon
Appends the specified array of polygons to the end of thisILcdComplexPolygon
.- Specified by:
addPolygons
in interfaceILcdEditableComplexPolygon
- Parameters:
aPolygon
- the array of polygons to be appended to thisILcdComplexPolygon
.
-
clearPolygons
public void clearPolygons()Description copied from interface:ILcdEditableComplexPolygon
Removes all of the polygons from thisILcdComplexPolygon
.- Specified by:
clearPolygons
in interfaceILcdEditableComplexPolygon
-
removePolygon
Description copied from interface:ILcdEditableComplexPolygon
Removes the polygon at the specified position in thisILcdComplexPolygon
. Shifts any subsequent polygons to the left. Returns the polygon that was removed from thisILcdComplexPolygon
.- Specified by:
removePolygon
in interfaceILcdEditableComplexPolygon
- Parameters:
aIndex
- the index of the polygon to removed.- Returns:
- the polygon previously at the specified position.
-
removePolygon
Description copied from interface:ILcdEditableComplexPolygon
Removes the first occurrence of the specified polygon in thisILcdComplexPolygon
. If thisILcdComplexPolygon
does not contain the polygon, it is unchanged.- Specified by:
removePolygon
in interfaceILcdEditableComplexPolygon
- Parameters:
aPolygon
- the polygon to be removed, if present.- Returns:
true
if thisILcdComplexPolygon
contained the specified element.
-
removePolygons
Description copied from interface:ILcdEditableComplexPolygon
Removes all polygons from thisILcdComplexPolygon
that are contained in the specified array of polygons.- Specified by:
removePolygons
in interfaceILcdEditableComplexPolygon
- Parameters:
aPolygon
- the array of polygons to be removed from thisILcdComplexPolygon
.
-
setPolygon
Description copied from interface:ILcdEditableComplexPolygon
Replaces the polygon at the specified position in thisILcdComplexPolygon
with the specified polygon.- Specified by:
setPolygon
in interfaceILcdEditableComplexPolygon
- 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
Description copied from interface:ILcdEditableComplexPolygon
Replace the list of polygons contained in thisILcdComplexPolygon
with the specified array of polygons.- Specified by:
setPolygons
in interfaceILcdEditableComplexPolygon
- Parameters:
aPolygons
- the array of polygons to be stored in thisILcdComplexPolygon
.
-
polygonChanged
public void polygonChanged(int aIndex) Description copied from interface:ILcdEditableComplexPolygon
Notifies thisILcdComplexPolygon
that the polygon at the specified position has changed.- Specified by:
polygonChanged
in interfaceILcdEditableComplexPolygon
- Parameters:
aIndex
- the index of the polygon that has changed.
-
polygonChanged
Description copied from interface:ILcdEditableComplexPolygon
Notifies thisILcdComplexPolygon
that the specified polygon has changed.- Specified by:
polygonChanged
in interfaceILcdEditableComplexPolygon
- Parameters:
aPolygon
- the polygon that has changed.
-
polygonsChanged
public void polygonsChanged()Description copied from interface:ILcdEditableComplexPolygon
Notifies thisILcdComplexPolygon
that some (possibly all) of its polygons have changed.- Specified by:
polygonsChanged
in interfaceILcdEditableComplexPolygon
-
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 interfaceILcdInvalidateable
-
setShape
Deprecated.usesetPolygons(ILcdPolygon[])
insteadSets theILcdShape
objects associated with thisTLcdComplexPolygon
.- Parameters:
aShapeArray
- theILcdShape
objects associated with thisTLcdComplexPolygon
.- See Also:
-
getShapeCount
public int getShapeCount()Deprecated.usegetPolygonCount()
insteadReturns the number ofILcdShape
objects in the list.- Returns:
- the number of
ILcdShape
objects in the list.
-
getShape
Deprecated.usegetPolygon(int)
insteadReturns theILcdShape
at the given index.- Parameters:
aIndex
- a valid index in the list ofILcdShape
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
Specifies the focus point value.- Parameters:
aFocusPoint
- the new focus point value.- See Also:
-
getPolygon(int)
instead