Package com.luciad.shape.shape2D
Class TLcdXYText
java.lang.Object
com.luciad.shape.ALcdShape
com.luciad.shape.shape2D.ALcd2DEditableShape
com.luciad.shape.shape2D.TLcdXYText
- All Implemented Interfaces:
ILcdBounded
,ILcdShape
,ILcdText
,ILcd2DEditableShape
,ILcd2DEditableText
,ILcdCache
,ILcdCloneable
,Serializable
,Cloneable
- Direct Known Subclasses:
TLcdCGMText
,TLcdDGNDisplayableTag
,TLcdDGNText2D
,TLcdDWGText
The default implementation of
Although it was designed for cartesian space, it can also be used in geodetic space. Character width and height are defined in model units, such that:
ILcd2DEditableText
.Although it was designed for cartesian space, it can also be used in geodetic space. Character width and height are defined in model units, such that:
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.
- See Also:
-
Field Summary
Fields inherited from interface com.luciad.shape.ILcdText
ALIGNMENT_BOTTOM, ALIGNMENT_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, ALIGNMENT_TOP
-
Constructor Summary
ConstructorDescriptionTLcdXYText
(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. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
Clears the cache.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
Returns whether the given object has the same class and the same coordinates, text, and parameters.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.final double
Returns the height of the individual text characters.final double
Returns the width of the individual text characters.Returns the focus point of thisILcdShape
.final int
Returns the horizontal alignment of the text.final ILcdPoint
Returns the location of the text.final double
Returns the angle over which this text is rotated.final String
Returns the text string of the text.final double
Returns the width of the entire text string.final int
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 theALcdShape.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.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.toString()
void
translate2D
(double x, double y) Translates thisILcd2DEditableShape
from its current position over the given translation vector in the 2D space.Methods inherited from class com.luciad.shape.shape2D.ALcd2DEditableShape
contains3D, move2D
Methods inherited from class com.luciad.shape.ALcdShape
contains2D, contains3D, fromDomainObject
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.luciad.shape.shape2D.ILcd2DEditableShape
move2D
Methods inherited from interface com.luciad.shape.ILcdShape
contains2D, contains3D, contains3D
-
Field Details
-
fBounds
-
-
Constructor Details
-
TLcdXYText
public TLcdXYText(String aTextString, ILcd2DEditablePoint aLocation, double aCharacterWidth, double aCharacterHeight, int aHorizontalAlignment, int aVerticalAlignment, double aRotAngle) Constructs and initializes a text with the specified parameters.- Parameters:
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.
-
TLcdXYText
public 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.- Parameters:
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.
-
TLcdXYText
Constructs a new text, initialized to match the values of the specified text.- Parameters:
aText
- a text from which to copy initial values.
-
-
Method Details
-
getTextString
Description copied from interface:ILcdText
Returns the text string of the text.- Specified by:
getTextString
in interfaceILcdText
- Returns:
- the text string of the text.
-
setTextString
Description copied from interface:ILcd2DEditableText
Sets the text string.- Specified by:
setTextString
in interfaceILcd2DEditableText
-
getLocation
Description copied from interface:ILcdText
Returns the location of the text. Seeclass javadoc
for an illustration how this related to alignment.- Specified by:
getLocation
in interfaceILcdText
- Returns:
- the location of the text.
-
translate2D
public void translate2D(double x, double y) Description copied from interface:ILcd2DEditableShape
Translates thisILcd2DEditableShape
from its current position over the given translation vector in the 2D space. Only the first two dimensions of theILcdShape
are considered. The third dimension is left unchanged.- Specified by:
translate2D
in interfaceILcd2DEditableShape
- Parameters:
x
- the x coordinate of the translation vector.y
- the y coordinate of the translation vector.
-
move2D
public void move2D(double aX, double aY) Description copied from class:ALcd2DEditableShape
Translates this shape so that its focus point ends up at the specified position.- Specified by:
move2D
in interfaceILcd2DEditableShape
- Overrides:
move2D
in classALcd2DEditableShape
- Parameters:
aX
- the x coordinate of the point.aY
- the y coordinate of the point.
-
getCharacterWidth
public final double getCharacterWidth()Description copied from interface:ILcdText
Returns the width of the individual text characters.- Specified by:
getCharacterWidth
in interfaceILcdText
- Returns:
- the width of the individual text characters.
-
setCharacterWidth
public void setCharacterWidth(double aCharacterWidth) Description copied from interface:ILcd2DEditableText
Sets the width of the individual text characters.- Specified by:
setCharacterWidth
in interfaceILcd2DEditableText
- Parameters:
aCharacterWidth
- the new width.
-
getTextWidth
public final double getTextWidth()Description copied from interface:ILcdText
Returns the width of the entire text string.- Specified by:
getTextWidth
in interfaceILcdText
- Returns:
- the width of the entire text string.
-
getCharacterHeight
public final double getCharacterHeight()Description copied from interface:ILcdText
Returns the height of the individual text characters.- Specified by:
getCharacterHeight
in interfaceILcdText
- Returns:
- the height of the individual text characters.
-
setCharacterHeight
public void setCharacterHeight(double aCharacterHeight) Description copied from interface:ILcd2DEditableText
Sets the height of the individual text characters.- Specified by:
setCharacterHeight
in interfaceILcd2DEditableText
- Parameters:
aCharacterHeight
- the new height.
-
getHorizontalAlignment
public final int getHorizontalAlignment()Description copied from interface:ILcdText
Returns the horizontal alignment of the text. Seeclass javadoc
for an illustration.- Specified by:
getHorizontalAlignment
in interfaceILcdText
- Returns:
- the horizontal alignment of the text:
ALIGNMENT_LEFT
,ALIGNMENT_CENTER
, orALIGNMENT_RIGHT
.
-
setHorizontalAlignment
public void setHorizontalAlignment(int aHorizontalAlignment) Description copied from interface:ILcd2DEditableText
Sets the horizontal alignment of the text.- Specified by:
setHorizontalAlignment
in interfaceILcd2DEditableText
- Parameters:
aHorizontalAlignment
-ALIGNMENT_LEFT
,ALIGNMENT_CENTER
, orALIGNMENT_RIGHT
.
-
getVerticalAlignment
public final int getVerticalAlignment()Description copied from interface:ILcdText
Returns the vertical alignment of the text. Seeclass javadoc
for an illustration.- Specified by:
getVerticalAlignment
in interfaceILcdText
- Returns:
- the vertical alignment of the text:
ALIGNMENT_TOP
,ALIGNMENT_CENTER
, orALIGNMENT_BOTTOM
.
-
setVerticalAlignment
public void setVerticalAlignment(int aVerticalAlignment) Description copied from interface:ILcd2DEditableText
Sets the vertical alignment of the text.- Specified by:
setVerticalAlignment
in interfaceILcd2DEditableText
- Parameters:
aVerticalAlignment
-ALIGNMENT_TOP
,ALIGNMENT_CENTER
, orALIGNMENT_BOTTOM
.
-
getRotAngle
public final double getRotAngle()Description copied from interface:ILcdText
Returns the angle over which this text is rotated. The angle is in degrees, positive counter-clockwise, starting a 3 o'clock. Seeclass javadoc
for an illustration how this relates to the textlocation
and alignment.- Specified by:
getRotAngle
in interfaceILcdText
- Returns:
- the rotation angle of the text.
-
setRotAngle
public void setRotAngle(double aRotAngle) Description copied from interface:ILcd2DEditableText
Sets the angle over which this text is rotated (in degrees). The angle is positive counter-clockwise.- Specified by:
setRotAngle
in interfaceILcd2DEditableText
- Parameters:
aRotAngle
- the new arc angle.
-
calculateBounds
protected void calculateBounds() -
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
.
-
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.
-
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 contained editable point representing the location is cloned. The cache is not copied or cloned at all.- Specified by:
clone
in interfaceILcdCloneable
- Overrides:
clone
in classALcdShape
- See Also:
-
equals
Returns whether the given object has the same class and the same coordinates, text, and parameters. -
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. -
toString
-