public abstract class ALcd2DEditablePolypoint extends ALcd2DEditableShape implements ILcd2DEditablePolypoint, ILcdPointList,ILcdPointList2, ILcdCache, ILcdInvalidateable
ILcd2DEditablePolypoint
interface.
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 shape is modified by
moving, inserting or removing points.
This class has a bounds cache.
For computing the bounds, implementations have to provide the method
calculate2DBounds()
.
This class also 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.
Modifier and Type | Field and Description |
---|---|
protected ILcd2DEditableBounds |
fBounds |
protected ILcd2DEditablePoint |
fFocusPoint |
Constructor and Description |
---|
ALcd2DEditablePolypoint() |
ALcd2DEditablePolypoint(ILcd2DEditablePointList a2DEditablePointList) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
calculateBounds()
Computes the bounds of the polypoint.
|
protected void |
calculateFocusPoint()
Computes the focus point as the center of the bounding box.
|
void |
clearCache()
Clears the cache.
|
Object |
clone()
Creates and returns a copy of this object.
|
boolean |
contains2D(double aX,
double aY)
Checks whether this
ILcdShape contains the given point in
the 2D space. |
boolean |
equals(Object aObject)
Returns whether the given object has the same class, the same focus point,
and the same coordinates.
|
ILcd2DEditablePointList |
get2DEditablePointList() |
ILcdBounds |
getBounds()
Returns the combined bounds of the points.
|
Object |
getCachedObject(Object aKey)
Looks up and returns the cached Object corresponding to the given key.
|
ILcdPoint |
getFocusPoint()
Returns the combined focus point of the points.
|
ILcdPoint |
getPoint(int aIndex)
Returns the
ILcdPoint at a given index. |
int |
getPointCount()
Returns the number of
ILcdPoint objects in the list. |
void |
getPointSFCT(int aIndex,
ILcd3DEditablePoint aPointSFCT)
Stores the coordinates of the point at
aIndex in the given point. |
double |
getX(int aIndex)
Returns the X coordinate of the point at
aIndex . |
double |
getY(int aIndex)
Returns the Y coordinate of the point at
aIndex . |
double |
getZ(int aIndex)
Returns the Z coordinate of the point at
aIndex . |
int |
hashCode()
The hash code of this shape is the hash code of its class, in order to
be consistent with the
ALcdShape.equals(Object) method. |
void |
insert2DPoint(int aIndex,
double aX,
double aY)
Inserts a point at the given index into this
ILcd2DEditablePointList . |
void |
insertIntoCache(Object aKey,
Object aObject)
Inserts a cache Object corresponding to the given key Object.
|
protected void |
invalidateBounds() |
void |
invalidateObject()
Invalidates all cached values of this object.
|
void |
move2D(double aX,
double aY)
Translates this shape so that its focus point ends up at the specified
position.
|
void |
move2DPoint(int aIndex,
double aX,
double aY)
Moves the specified point of this
ILcd2DEditablePointList to the given point in the 2D space. |
Object |
removeCachedObject(Object aKey)
Looks up and removes the cached Object corresponding to the given key.
|
void |
removePointAt(int aIndex)
Removes the point at the given index from this
ILcd2DEditablePointList . |
void |
set2DEditablePointList(ILcd2DEditablePointList a2DEditablePointList) |
void |
setFocusPoint(ILcd2DEditablePoint aFocusPoint) |
String |
toString() |
void |
translate2D(double aDeltaX,
double aDeltaY)
Translates this
ILcd2DEditableShape from its current position over the given translation
vector in the 2D space. |
void |
translate2DPoint(int aIndex,
double aDeltaX,
double aDeltaY)
Translates the specified point of this
ILcd2DEditablePointList from its current position
over the given translation vector in the 2D space. |
contains3D, move2D
contains2D, contains3D, fromDomainObject
finalize, getClass, notify, notifyAll, wait, wait, wait
move2D
contains2D, contains3D, contains3D
append2DPoint
protected ILcd2DEditableBounds fBounds
protected ILcd2DEditablePoint fFocusPoint
public ALcd2DEditablePolypoint()
public ALcd2DEditablePolypoint(ILcd2DEditablePointList a2DEditablePointList)
public final ILcd2DEditablePointList get2DEditablePointList()
public void set2DEditablePointList(ILcd2DEditablePointList a2DEditablePointList)
public void getPointSFCT(int aIndex, ILcd3DEditablePoint aPointSFCT)
ILcdPointList
aIndex
in the given point.getPointSFCT
in interface ILcdPointList
aIndex
- the index of the point for which to retrieve the coordinates.aPointSFCT
- the side-effect parameter in which to store the coordinates of the requested
point.public double getX(int aIndex)
ILcdPointList
aIndex
.getX
in interface ILcdPointList
aIndex
- the index of the point for which to return the X coordinate.aIndex
.public double getY(int aIndex)
ILcdPointList
aIndex
.getY
in interface ILcdPointList
aIndex
- the index of the point for which to return the Y coordinate.aIndex
.public double getZ(int aIndex)
ILcdPointList
aIndex
.getZ
in interface ILcdPointList
aIndex
- the index of the point for which to return the Z coordinate.aIndex
.public final int getPointCount()
ILcdPointList
ILcdPoint
objects in the list.getPointCount
in interface ILcdPointList
ILcdPoint
objects in the list.public final ILcdPoint getPoint(int aIndex)
ILcdPointList
ILcdPoint
at a given index.getPoint
in interface ILcdPointList
aIndex
- a valid index in the list of ILcdPoint
objects.ILcdPoint
at the given index.public void move2DPoint(int aIndex, double aX, double aY)
ILcd2DEditablePointList
ILcd2DEditablePointList
to the given point in the 2D space. Only the first
two dimensions of the ILcdShape
are considered.
The third dimension is left unchanged.move2DPoint
in interface ILcd2DEditablePointList
aIndex
- a valid index in the list of points.aX
- the x coordinate of the point.aY
- the y coordinate of the point.public void translate2DPoint(int aIndex, double aDeltaX, double aDeltaY)
ILcd2DEditablePointList
ILcd2DEditablePointList
from 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.translate2DPoint
in interface ILcd2DEditablePointList
aDeltaX
- the x coordinate of the translation vector.aDeltaY
- the y coordinate of the translation vector.public void insert2DPoint(int aIndex, double aX, double aY)
ILcd2DEditablePointList
ILcd2DEditablePointList
.insert2DPoint
in interface ILcd2DEditablePointList
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.public void removePointAt(int aIndex)
ILcd2DEditablePointList
ILcd2DEditablePointList
.removePointAt
in interface ILcd2DEditablePointList
aIndex
- a valid index in the list of ILcdPoint
objects.protected void invalidateBounds()
public ILcdBounds getBounds()
calculateBounds()
, if necessary, and then returns
the cached fBounds
.getBounds
in interface ILcdBounded
ILcdBounds
by which the geometry of this ILcdBounded
object
is bounded.protected abstract void calculateBounds()
fBounds
.public ILcdPoint getFocusPoint()
calculateFocusPoint()
, if necessary, and then returns
the cached fFocusPoint
.getFocusPoint
in interface ILcdShape
ILcdShape
.protected void calculateFocusPoint()
fFocusPoint
.public void setFocusPoint(ILcd2DEditablePoint aFocusPoint)
public boolean contains2D(double aX, double aY)
ILcdShape
ILcdShape
contains the given point in
the 2D space. Only the first two dimensions of the ILcdShape
are considered.contains2D
in interface ILcdShape
aX
- the x coordinate of the point.aY
- the y coordinate of the point.public void translate2D(double aDeltaX, double aDeltaY)
ILcd2DEditableShape
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.translate2D
in interface ILcd2DEditablePointList
translate2D
in interface ILcd2DEditableShape
aDeltaX
- the x coordinate of the translation vector.aDeltaY
- the y coordinate of the translation vector.public void move2D(double aX, double aY)
ALcd2DEditableShape
move2D
in interface ILcd2DEditableShape
move2D
in class ALcd2DEditableShape
aX
- the x coordinate of the point.aY
- the y coordinate of the point.public void insertIntoCache(Object aKey, Object aObject)
ILcdCache
insertIntoCache
in interface ILcdCache
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.public Object getCachedObject(Object aKey)
ILcdCache
getCachedObject
in interface ILcdCache
aKey
- the key Object that was used for storing the cache Object.public Object removeCachedObject(Object aKey)
ILcdCache
removeCachedObject
in interface ILcdCache
aKey
- the key Object that was used for storing the cache Object.public void clearCache()
ILcdCache
clearCache
in interface ILcdCache
public void invalidateObject()
ILcdInvalidateable
invalidateObject
in interface ILcdInvalidateable
public Object clone()
The contained editable points list is copied without being cloned.
The cache, the bounds and the focus point are not copied or cloned at all, but recalculated when needed.
clone
in interface ILcdCloneable
clone
in class ALcdShape
Object.clone()
public boolean equals(Object aObject)
public int hashCode()
ALcdShape
ALcdShape.equals(Object)
method.
Extensions should refine this implementation, based on their properties.