public class TLcdXYText extends ALcd2DEditableShape implements ILcd2DEditableText, ILcdCache
ILcd2DEditableText
.bounds width = character width * text string lengthFor text that uses screen dimensions (for example, using a font size of 10pt), refer to the labeling API. This class implements
ILcdCache
to store expensive calculations, e.g. for painters
to store model-world transformations. The cache is cleared whenever the shape is modified.
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 ILcdBounds |
fBounds |
ALIGNMENT_BOTTOM, ALIGNMENT_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, ALIGNMENT_TOP
Constructor and Description |
---|
TLcdXYText(ILcdText aText)
Constructs a new text, initialized to match the values of the specified
text.
|
TLcdXYText(String aTextString,
double aX,
double aY,
double aCharacterWidth,
double aCharacterHeight,
int aHorizontalAlignment,
int aVerticalAlignment,
double aRotAngle)
Constructs and initializes a text with the specified parameters.
|
TLcdXYText(String aTextString,
ILcd2DEditablePoint aLocation,
double aCharacterWidth,
double aCharacterHeight,
int aHorizontalAlignment,
int aVerticalAlignment,
double aRotAngle)
Constructs and initializes a text with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
protected void |
calculateBounds() |
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 and the same
coordinates, text, and parameters.
|
ILcdBounds |
getBounds()
Returns the
ILcdBounds by which the geometry of this ILcdBounded object
is bounded. |
Object |
getCachedObject(Object aKey)
Looks up and returns the cached Object corresponding to the given key.
|
double |
getCharacterHeight()
Returns the height of the individual text characters.
|
double |
getCharacterWidth()
Returns the width of the individual text characters.
|
ILcdPoint |
getFocusPoint()
Returns the focus point of this
ILcdShape . |
int |
getHorizontalAlignment()
Returns the horizontal alignment of the text.
|
ILcdPoint |
getLocation()
Returns the location of the text.
|
double |
getRotAngle()
Returns the angle over which this text is rotated.
|
String |
getTextString()
Returns the text string of the text.
|
double |
getTextWidth()
Returns the width of the entire text string.
|
int |
getVerticalAlignment()
Returns the vertical alignment of the text.
|
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 |
insertIntoCache(Object aKey,
Object aObject)
Inserts a cache Object corresponding to the given key Object.
|
void |
move2D(double aX,
double aY)
Translates this shape so that its focus point ends up at the specified
position.
|
Object |
removeCachedObject(Object aKey)
Looks up and removes the cached Object corresponding to the given key.
|
void |
setCharacterHeight(double aCharacterHeight)
Sets the height of the individual text characters.
|
void |
setCharacterWidth(double aCharacterWidth)
Sets the width of the individual text characters.
|
void |
setHorizontalAlignment(int aHorizontalAlignment)
Sets the horizontal alignment of the text.
|
void |
setRotAngle(double aRotAngle)
Sets the angle over which this text is rotated (in degrees).
|
void |
setTextString(String aTextString)
Sets the text string.
|
void |
setVerticalAlignment(int aVerticalAlignment)
Sets the vertical alignment of the text.
|
String |
toString() |
void |
translate2D(double x,
double y)
Translates this
ILcd2DEditableShape 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
protected ILcdBounds fBounds
public TLcdXYText(String aTextString, ILcd2DEditablePoint aLocation, double aCharacterWidth, double aCharacterHeight, int aHorizontalAlignment, int aVerticalAlignment, double aRotAngle)
aTextString
- the text string.aLocation
- the location of the text.aCharacterWidth
- the width of the text, in model units.aCharacterHeight
- the height of the text, in model units.aHorizontalAlignment
- the horizontal alignment of the text.aVerticalAlignment
- the vertical alignment of the text.aRotAngle
- the rotation angle of the text, in degrees counter-clockwise from 3 o'clock.public TLcdXYText(String aTextString, double aX, double aY, double aCharacterWidth, double aCharacterHeight, int aHorizontalAlignment, int aVerticalAlignment, double aRotAngle)
aTextString
- the text string.aX
- the x coordinate of the location.aY
- the y coordinate of the location.aCharacterWidth
- the width of the text, in model units.aCharacterHeight
- the height of the text, in model units.aHorizontalAlignment
- the horizontal alignment of the text.aVerticalAlignment
- the vertical alignment of the text.aRotAngle
- the rotation angle of the text, in degrees counter-clockwise from 3 o'clock.public TLcdXYText(ILcdText aText)
aText
- a text from which to copy initial values.public final String getTextString()
ILcdText
getTextString
in interface ILcdText
public void setTextString(String aTextString)
ILcd2DEditableText
setTextString
in interface ILcd2DEditableText
public final ILcdPoint getLocation()
ILcdText
class javadoc
for an illustration how this related to alignment.getLocation
in interface ILcdText
public void translate2D(double x, double y)
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 ILcd2DEditableShape
x
- the x coordinate of the translation vector.y
- 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 final double getCharacterWidth()
ILcdText
getCharacterWidth
in interface ILcdText
public void setCharacterWidth(double aCharacterWidth)
ILcd2DEditableText
setCharacterWidth
in interface ILcd2DEditableText
aCharacterWidth
- the new width.public final double getTextWidth()
ILcdText
getTextWidth
in interface ILcdText
public final double getCharacterHeight()
ILcdText
getCharacterHeight
in interface ILcdText
public void setCharacterHeight(double aCharacterHeight)
ILcd2DEditableText
setCharacterHeight
in interface ILcd2DEditableText
aCharacterHeight
- the new height.public final int getHorizontalAlignment()
ILcdText
class javadoc
for an illustration.getHorizontalAlignment
in interface ILcdText
ALIGNMENT_LEFT
,
ALIGNMENT_CENTER
, or ALIGNMENT_RIGHT
.public void setHorizontalAlignment(int aHorizontalAlignment)
ILcd2DEditableText
setHorizontalAlignment
in interface ILcd2DEditableText
aHorizontalAlignment
- ALIGNMENT_LEFT
,
ALIGNMENT_CENTER
, or ALIGNMENT_RIGHT
.public final int getVerticalAlignment()
ILcdText
class javadoc
for an illustration.getVerticalAlignment
in interface ILcdText
ALIGNMENT_TOP
,
ALIGNMENT_CENTER
, or ALIGNMENT_BOTTOM
.public void setVerticalAlignment(int aVerticalAlignment)
ILcd2DEditableText
setVerticalAlignment
in interface ILcd2DEditableText
aVerticalAlignment
- ALIGNMENT_TOP
,
ALIGNMENT_CENTER
, or ALIGNMENT_BOTTOM
.public final double getRotAngle()
ILcdText
class javadoc
for an illustration how this relates to the text location
and alignment.getRotAngle
in interface ILcdText
public void setRotAngle(double aRotAngle)
ILcd2DEditableText
setRotAngle
in interface ILcd2DEditableText
aRotAngle
- the new arc angle.protected void calculateBounds()
public ILcdBounds getBounds()
ILcdBounded
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
.
getBounds
in interface ILcdBounded
ILcdBounds
by which the geometry of this ILcdBounded
object
is bounded.public ILcdPoint getFocusPoint()
ILcdShape
ILcdShape
.getFocusPoint
in interface ILcdShape
ILcdShape
.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 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 Object clone()
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.