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
ConstructorsConstructorDescriptionConstructs aTLcdComplexPolygonthat doesn't have anyILcdPolygonobjects.TLcdComplexPolygon(ILcdPolygon[] aPolygonArray) Constructs aTLcdComplexPolygoncontaining the givenILcdPolygonobjects.TLcdComplexPolygon(TLcdComplexPolygon aComplexPolygon) Constructs aTLcdComplexPolygonthat is a clone of the givenTLcdComplexPolygon. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPolygon(int aIndex, ILcdPolygon aPolygon) Inserts the specified polygon at the specified position in thisILcdComplexPolygon.voidaddPolygon(ILcdPolygon aPolygon) Appends the specified polygon to the end of thisILcdComplexPolygon.voidaddPolygons(ILcdPolygon[] aPolygon) Appends the specified array of polygons to the end of thisILcdComplexPolygon.protected voidComputes the focus point as the center of the bounding box.voidClears the cache.voidRemoves all of the polygons from thisILcdComplexPolygon.clone()Creates and returns a copy of this object.booleancontains2D(double aX, double aY) Checks whether thisILcdShapecontains the given point in the 2D space.booleancontains3D(double aX, double aY, double aZ) Checks whether thisILcdShapecontains the given point in the 3D space.booleanAn object is considered equal to this shape if it has the same class.Returns theILcdBoundsby which the geometry of thisILcdBoundedobject 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 theILcdPointat a given index.intReturns the number ofILcdPointobjects in the list.final ILcdPolygongetPolygon(int aIndex) Returns theILcdPolygonat the given index.final intReturns the number ofILcdPolygonobjects in the list.getShape(int aIndex) Deprecated.intDeprecated.usegetPolygonCount()insteadinthashCode()The hash code of this shape is the hash code of its class, in order to be consistent with theALcdShape.equals(Object)method.voidinsertIntoCache(Object aKey, Object aObject) Inserts a cache Object corresponding to the given key Object.voidvoidInvalidates all cached values of this object.voidpolygonChanged(int aIndex) Notifies thisILcdComplexPolygonthat the polygon at the specified position has changed.voidpolygonChanged(ILcdPolygon aPolygon) Notifies thisILcdComplexPolygonthat the specified polygon has changed.voidNotifies thisILcdComplexPolygonthat 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.booleanremovePolygon(ILcdPolygon aPolygon) Removes the first occurrence of the specified polygon in thisILcdComplexPolygon.voidremovePolygons(ILcdPolygon[] aPolygon) Removes all polygons from thisILcdComplexPolygonthat are contained in the specified array of polygons.voidsetFocusPoint(ILcd3DEditablePoint aFocusPoint) Specifies the focus point value.setPolygon(int aIndex, ILcdPolygon aPolygon) Replaces the polygon at the specified position in thisILcdComplexPolygonwith the specified polygon.voidsetPolygon(ILcdPolygon[] aPolygonArray) Sets theILcdPolygonobjects associated with thisILcdComplexPolygon.voidsetPolygons(ILcdPolygon[] aPolygons) Replace the list of polygons contained in thisILcdComplexPolygonwith the specified array of polygons.voidDeprecated.usesetPolygons(ILcdPolygon[])insteadMethods inherited from class com.luciad.shape.ALcdShape
contains2D, contains3D, fromDomainObjectMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.shape.ILcdComplexPolygon
getPolygonsMethods inherited from interface com.luciad.shape.ILcdPointList
getPointSFCT, getX, getY, getZMethods inherited from interface com.luciad.shape.ILcdShape
contains2D, contains3D
-
Constructor Details
-
TLcdComplexPolygon
public TLcdComplexPolygon()Constructs aTLcdComplexPolygonthat doesn't have anyILcdPolygonobjects. -
TLcdComplexPolygon
Constructs aTLcdComplexPolygoncontaining the givenILcdPolygonobjects.- Parameters:
aPolygonArray- an array ofILcdPolygonobjects thisTLcdComplexPolygonis composed of.
-
TLcdComplexPolygon
Constructs aTLcdComplexPolygonthat is a clone of the givenTLcdComplexPolygon.- Parameters:
aComplexPolygon- the complex polygon to clone.
-
-
Method Details
-
invalidateBounds
public void invalidateBounds() -
getBounds
Description copied from interface:ILcdBoundedReturns theILcdBoundsby which the geometry of thisILcdBoundedobject 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
undefinedbounds. You can create undefined bounds using the default constructors ofTLcdLonLatBoundsorTLcdXYBounds.- Specified by:
getBoundsin interfaceILcdBounded- Returns:
- the
ILcdBoundsby which the geometry of thisILcdBoundedobject is bounded.
-
getFocusPoint
Description copied from interface:ILcdShapeReturns the focus point of thisILcdShape.- Specified by:
getFocusPointin interfaceILcdShape- Returns:
- the focus point of this
ILcdShape.
-
setPolygon
Sets theILcdPolygonobjects associated with thisILcdComplexPolygon. This method does exactly the same assetPolygons(ILcdPolygon[]).- Parameters:
aPolygonArray- theILcdPolygonobjects associated with thisILcdComplexPolygon.- See Also:
-
getPolygonCount
public final int getPolygonCount()Description copied from interface:ILcdComplexPolygonReturns the number ofILcdPolygonobjects in the list.- Specified by:
getPolygonCountin interfaceILcdComplexPolygon- Returns:
- the number of
ILcdPolygonobjects in the list.
-
getPolygon
Description copied from interface:ILcdComplexPolygonReturns theILcdPolygonat the given index.- Specified by:
getPolygonin interfaceILcdComplexPolygon- Parameters:
aIndex- a valid index in the list ofILcdPolygonobjects.- Returns:
- the
ILcdPolygonat the given index. - Throws:
IndexOutOfBoundsException- when the index is not valid.
-
contains2D
public boolean contains2D(double aX, double aY) Description copied from interface:ILcdShapeChecks whether thisILcdShapecontains the given point in the 2D space. Only the first two dimensions of theILcdShapeare considered.- Specified by:
contains2Din 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:ILcdShapeChecks whether thisILcdShapecontains the given point in the 3D space.- Specified by:
contains3Din 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:ILcdPointListReturns the number ofILcdPointobjects in the list.- Specified by:
getPointCountin interfaceILcdPointList- Returns:
- the number of
ILcdPointobjects in the list.
-
getPoint
Description copied from interface:ILcdPointListReturns theILcdPointat a given index.- Specified by:
getPointin interfaceILcdPointList- Parameters:
aIndex- a valid index in the list ofILcdPointobjects.- Returns:
- the
ILcdPointat the given index. - Throws:
IndexOutOfBoundsException- if the given index is out of bounds.
-
insertIntoCache
Description copied from interface:ILcdCacheInserts a cache Object corresponding to the given key Object.- Specified by:
insertIntoCachein 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:ILcdCacheLooks up and returns the cached Object corresponding to the given key.- Specified by:
getCachedObjectin 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:ILcdCacheLooks up and removes the cached Object corresponding to the given key.- Specified by:
removeCachedObjectin 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:ILcdCacheClears the cache.- Specified by:
clearCachein 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:
clonein interfaceILcdCloneable- Overrides:
clonein classALcdShape- See Also:
-
equals
Description copied from class:ALcdShapeAn 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:ALcdShapeThe 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:ILcdEditableComplexPolygonInserts the specified polygon at the specified position in thisILcdComplexPolygon.- Specified by:
addPolygonin interfaceILcdEditableComplexPolygon- Parameters:
aIndex- the index at which the polygon is to be inserted.aPolygon- the polygon to be inserted.
-
addPolygon
Description copied from interface:ILcdEditableComplexPolygonAppends the specified polygon to the end of thisILcdComplexPolygon.- Specified by:
addPolygonin interfaceILcdEditableComplexPolygon- Parameters:
aPolygon- the polygon to be appended to thisILcdComplexPolygon.
-
addPolygons
Description copied from interface:ILcdEditableComplexPolygonAppends the specified array of polygons to the end of thisILcdComplexPolygon.- Specified by:
addPolygonsin interfaceILcdEditableComplexPolygon- Parameters:
aPolygon- the array of polygons to be appended to thisILcdComplexPolygon.
-
clearPolygons
public void clearPolygons()Description copied from interface:ILcdEditableComplexPolygonRemoves all of the polygons from thisILcdComplexPolygon.- Specified by:
clearPolygonsin interfaceILcdEditableComplexPolygon
-
removePolygon
Description copied from interface:ILcdEditableComplexPolygonRemoves 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:
removePolygonin interfaceILcdEditableComplexPolygon- Parameters:
aIndex- the index of the polygon to removed.- Returns:
- the polygon previously at the specified position.
-
removePolygon
Description copied from interface:ILcdEditableComplexPolygonRemoves the first occurrence of the specified polygon in thisILcdComplexPolygon. If thisILcdComplexPolygondoes not contain the polygon, it is unchanged.- Specified by:
removePolygonin interfaceILcdEditableComplexPolygon- Parameters:
aPolygon- the polygon to be removed, if present.- Returns:
trueif thisILcdComplexPolygoncontained the specified element.
-
removePolygons
Description copied from interface:ILcdEditableComplexPolygonRemoves all polygons from thisILcdComplexPolygonthat are contained in the specified array of polygons.- Specified by:
removePolygonsin interfaceILcdEditableComplexPolygon- Parameters:
aPolygon- the array of polygons to be removed from thisILcdComplexPolygon.
-
setPolygon
Description copied from interface:ILcdEditableComplexPolygonReplaces the polygon at the specified position in thisILcdComplexPolygonwith the specified polygon.- Specified by:
setPolygonin 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:ILcdEditableComplexPolygonReplace the list of polygons contained in thisILcdComplexPolygonwith the specified array of polygons.- Specified by:
setPolygonsin interfaceILcdEditableComplexPolygon- Parameters:
aPolygons- the array of polygons to be stored in thisILcdComplexPolygon.
-
polygonChanged
public void polygonChanged(int aIndex) Description copied from interface:ILcdEditableComplexPolygonNotifies thisILcdComplexPolygonthat the polygon at the specified position has changed.- Specified by:
polygonChangedin interfaceILcdEditableComplexPolygon- Parameters:
aIndex- the index of the polygon that has changed.
-
polygonChanged
Description copied from interface:ILcdEditableComplexPolygonNotifies thisILcdComplexPolygonthat the specified polygon has changed.- Specified by:
polygonChangedin interfaceILcdEditableComplexPolygon- Parameters:
aPolygon- the polygon that has changed.
-
polygonsChanged
public void polygonsChanged()Description copied from interface:ILcdEditableComplexPolygonNotifies thisILcdComplexPolygonthat some (possibly all) of its polygons have changed.- Specified by:
polygonsChangedin interfaceILcdEditableComplexPolygon
-
invalidateObject
public void invalidateObject()Description copied from interface:ILcdInvalidateableInvalidates 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:
invalidateObjectin interfaceILcdInvalidateable
-
setShape
Deprecated.usesetPolygons(ILcdPolygon[])insteadSets theILcdShapeobjects associated with thisTLcdComplexPolygon.- Parameters:
aShapeArray- theILcdShapeobjects associated with thisTLcdComplexPolygon.- See Also:
-
getShapeCount
public int getShapeCount()Deprecated.usegetPolygonCount()insteadReturns the number ofILcdShapeobjects in the list.- Returns:
- the number of
ILcdShapeobjects in the list.
-
getShape
Deprecated.usegetPolygon(int)insteadReturns theILcdShapeat the given index.- Parameters:
aIndex- a valid index in the list ofILcdShapeobjects.- Returns:
- the
ILcdShapeat 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