Class ALcd2DEditableLine
- All Implemented Interfaces:
ILcdBounded,ILcdPointList,ILcdPolyline,ILcdShape,ILcd2DEditablePointList,ILcd2DEditablePolyline,ILcd2DEditableShape,ILcdCache,ILcdCloneable,Serializable,Cloneable
- Direct Known Subclasses:
ALcd3DEditableLine,TLcdLonLatLine,TLcdXYLine
ILcd2DEditablePolyline
interface, where the polyline is a simple line with two vertices.
It implements ILcdCache, thus providing a cache
to store expensive calculations, e.g. for painters,
to store model-world transformations. The cache is cleared whenever the line is moved or
translated.
This class has a focus point cache.
For for computing the focus point, implementations may override the method
calculateFocusPoint(). The default implementation computes the
center of the bounding box.
The result of calculateFocusPoint() is only used if the focus point
has not been set explicitly using setFocusPoint(ILcdPoint).
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ILcdBoundsprotected ILcd2DEditablePointprotected ILcd2DEditablePointprotected ILcd2DEditablePoint -
Constructor Summary
ConstructorsConstructorDescriptionALcd2DEditableLine(ILcd2DEditablePoint aPoint1, ILcd2DEditablePoint aPoint2) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidThis method should compute the bounds of the polypoint.protected voidComputes the focus point as the center of the bounding box.voidClears the cache.clone()Creates and returns a copy of this object.booleancontains2D(double aX, double aY) Checks whether thisILcdShapecontains the given point in the 2D space.booleanReturns whether the given object has the same class, the same focus point, and the same coordinates.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.final ILcdPointgetPoint(int aIndex) Returns theILcdPointat a given index.final intReturns the number ofILcdPointobjects in the list.inthashCode()The hash code of this shape is the hash code of its class, in order to be consistent with theALcdShape.equals(Object)method.voidinsert2DPoint(int aIndex, double aX, double aY) Is not allowed, as a TLcdXYLine always contains two points.voidinsertIntoCache(Object aKey, Object aObject) Inserts a cache Object corresponding to the given key Object.protected voidvoidmove2D(double aX, double aY) Translates this shape so that its focus point ends up at the specified position.voidmove2DPoint(int aIndex, double aX, double aY) Moves the specified point of thisILcd2DEditablePointListto the given point in the 2D space.removeCachedObject(Object aKey) Looks up and removes the cached Object corresponding to the given key.voidremovePointAt(int aIndex) Is not allowed, as a TLcdXYLine always contains two points.voidsetFocusPoint(ILcd2DEditablePoint aFocusPoint) toString()voidtranslate2D(double aDeltaX, double aDeltaY) Translates thisILcd2DEditableShapefrom its current position over the given translation vector in the 2D space.voidtranslate2DPoint(int aIndex, double aDeltaX, double aDeltaY) Translates the specified point of thisILcd2DEditablePointListfrom its current position over the given translation vector in the 2D space.Methods inherited from class com.luciad.shape.shape2D.ALcd2DEditableShape
contains3D, move2DMethods inherited from class com.luciad.shape.ALcdShape
contains2D, contains3D, fromDomainObjectMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.luciad.shape.shape2D.ILcd2DEditablePointList
append2DPointMethods inherited from interface com.luciad.shape.shape2D.ILcd2DEditableShape
move2DMethods inherited from interface com.luciad.shape.ILcdPointList
getPointSFCT, getX, getY, getZMethods inherited from interface com.luciad.shape.ILcdShape
contains2D, contains3D, contains3D
-
Field Details
-
fPoint1
-
fPoint2
-
fBounds
-
fFocusPoint
-
-
Constructor Details
-
ALcd2DEditableLine
-
-
Method Details
-
getPointCount
public final 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.
-
move2DPoint
public void move2DPoint(int aIndex, double aX, double aY) Description copied from interface:ILcd2DEditablePointListMoves the specified point of thisILcd2DEditablePointListto the given point in the 2D space. Only the first two dimensions of theILcdShapeare considered. The third dimension is left unchanged.- Specified by:
move2DPointin interfaceILcd2DEditablePointList- Parameters:
aIndex- a valid index in the list of points.aX- the x coordinate of the point.aY- the y coordinate of the point.
-
translate2DPoint
public void translate2DPoint(int aIndex, double aDeltaX, double aDeltaY) Description copied from interface:ILcd2DEditablePointListTranslates the specified point of thisILcd2DEditablePointListfrom its current position over the given translation vector in the 2D space. Only the first two dimensions of the points are considered. The third dimension is left unchanged.- Specified by:
translate2DPointin interfaceILcd2DEditablePointList- Parameters:
aDeltaX- the x coordinate of the translation vector.aDeltaY- the y coordinate of the translation vector.
-
insert2DPoint
public void insert2DPoint(int aIndex, double aX, double aY) Is not allowed, as a TLcdXYLine always contains two points.- Specified by:
insert2DPointin interfaceILcd2DEditablePointList- Parameters:
aIndex- a valid new index in the list of points.aX- the x coordinate of the new point.aY- the y coordinate of the new point.
-
removePointAt
public void removePointAt(int aIndex) Is not allowed, as a TLcdXYLine always contains two points.- Specified by:
removePointAtin interfaceILcd2DEditablePointList- Parameters:
aIndex- a valid index in the list ofILcdPointobjects.
-
invalidateBounds
protected void invalidateBounds() -
calculateBounds
protected abstract void calculateBounds()This method should compute the bounds of the polypoint. The resultingILcd2DEditableBoundsshould be stored infBounds. -
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.
-
calculateFocusPoint
protected void calculateFocusPoint()Computes the focus point as the center of the bounding box. The resultingILcd2DEditablePointis stored infFocusPoint. -
getFocusPoint
Description copied from interface:ILcdShapeReturns the focus point of thisILcdShape.- Specified by:
getFocusPointin interfaceILcdShape- Returns:
- the focus point of this
ILcdShape.
-
setFocusPoint
-
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.
-
translate2D
public void translate2D(double aDeltaX, double aDeltaY) Description copied from interface:ILcd2DEditableShapeTranslates thisILcd2DEditableShapefrom its current position over the given translation vector in the 2D space. Only the first two dimensions of theILcdShapeare considered. The third dimension is left unchanged.- Specified by:
translate2Din interfaceILcd2DEditablePointList- Specified by:
translate2Din interfaceILcd2DEditableShape- Parameters:
aDeltaX- the x coordinate of the translation vector.aDeltaY- the y coordinate of the translation vector.
-
move2D
public void move2D(double aX, double aY) Description copied from class:ALcd2DEditableShapeTranslates this shape so that its focus point ends up at the specified position.- Specified by:
move2Din interfaceILcd2DEditableShape- Overrides:
move2Din classALcd2DEditableShape- Parameters:
aX- the x coordinate of the point.aY- the y coordinate of the point.
-
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 points are copied without being cloned. The cache, the bounds and the focus point are not copied or cloned at all, but recalculated when needed.- Specified by:
clonein interfaceILcdCloneable- Overrides:
clonein classALcdShape- See Also:
-
equals
Returns whether the given object has the same class, the same focus point, and the same coordinates. -
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. -
toString
-