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
FieldsFields inherited from interface com.luciad.shape.ILcdText
ALIGNMENT_BOTTOM, ALIGNMENT_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, ALIGNMENT_TOP -
Constructor Summary
ConstructorsConstructorDescriptionTLcdXYText(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 voidvoidClears 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 and the same coordinates, text, and parameters.Returns theILcdBoundsby which the geometry of thisILcdBoundedobject is bounded.getCachedObject(Object aKey) Looks up and returns the cached Object corresponding to the given key.final doubleReturns the height of the individual text characters.final doubleReturns the width of the individual text characters.Returns the focus point of thisILcdShape.final intReturns the horizontal alignment of the text.final ILcdPointReturns the location of the text.final doubleReturns the angle over which this text is rotated.final StringReturns the text string of the text.final doubleReturns the width of the entire text string.final intReturns the vertical alignment of the text.inthashCode()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.voidmove2D(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.voidsetCharacterHeight(double aCharacterHeight) Sets the height of the individual text characters.voidsetCharacterWidth(double aCharacterWidth) Sets the width of the individual text characters.voidsetHorizontalAlignment(int aHorizontalAlignment) Sets the horizontal alignment of the text.voidsetRotAngle(double aRotAngle) Sets the angle over which this text is rotated (in degrees).voidsetTextString(String aTextString) Sets the text string.voidsetVerticalAlignment(int aVerticalAlignment) Sets the vertical alignment of the text.toString()voidtranslate2D(double x, double y) Translates thisILcd2DEditableShapefrom 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.ILcd2DEditableShape
move2DMethods 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:ILcdTextReturns the text string of the text.- Specified by:
getTextStringin interfaceILcdText- Returns:
- the text string of the text.
-
setTextString
Description copied from interface:ILcd2DEditableTextSets the text string.- Specified by:
setTextStringin interfaceILcd2DEditableText
-
getLocation
Description copied from interface:ILcdTextReturns the location of the text. Seeclass javadocfor an illustration how this related to alignment.- Specified by:
getLocationin interfaceILcdText- Returns:
- the location of the text.
-
translate2D
public void translate2D(double x, double y) 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 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: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.
-
getCharacterWidth
public final double getCharacterWidth()Description copied from interface:ILcdTextReturns the width of the individual text characters.- Specified by:
getCharacterWidthin interfaceILcdText- Returns:
- the width of the individual text characters.
-
setCharacterWidth
public void setCharacterWidth(double aCharacterWidth) Description copied from interface:ILcd2DEditableTextSets the width of the individual text characters.- Specified by:
setCharacterWidthin interfaceILcd2DEditableText- Parameters:
aCharacterWidth- the new width.
-
getTextWidth
public final double getTextWidth()Description copied from interface:ILcdTextReturns the width of the entire text string.- Specified by:
getTextWidthin interfaceILcdText- Returns:
- the width of the entire text string.
-
getCharacterHeight
public final double getCharacterHeight()Description copied from interface:ILcdTextReturns the height of the individual text characters.- Specified by:
getCharacterHeightin interfaceILcdText- Returns:
- the height of the individual text characters.
-
setCharacterHeight
public void setCharacterHeight(double aCharacterHeight) Description copied from interface:ILcd2DEditableTextSets the height of the individual text characters.- Specified by:
setCharacterHeightin interfaceILcd2DEditableText- Parameters:
aCharacterHeight- the new height.
-
getHorizontalAlignment
public final int getHorizontalAlignment()Description copied from interface:ILcdTextReturns the horizontal alignment of the text. Seeclass javadocfor an illustration.- Specified by:
getHorizontalAlignmentin interfaceILcdText- Returns:
- the horizontal alignment of the text:
ALIGNMENT_LEFT,ALIGNMENT_CENTER, orALIGNMENT_RIGHT.
-
setHorizontalAlignment
public void setHorizontalAlignment(int aHorizontalAlignment) Description copied from interface:ILcd2DEditableTextSets the horizontal alignment of the text.- Specified by:
setHorizontalAlignmentin interfaceILcd2DEditableText- Parameters:
aHorizontalAlignment-ALIGNMENT_LEFT,ALIGNMENT_CENTER, orALIGNMENT_RIGHT.
-
getVerticalAlignment
public final int getVerticalAlignment()Description copied from interface:ILcdTextReturns the vertical alignment of the text. Seeclass javadocfor an illustration.- Specified by:
getVerticalAlignmentin interfaceILcdText- Returns:
- the vertical alignment of the text:
ALIGNMENT_TOP,ALIGNMENT_CENTER, orALIGNMENT_BOTTOM.
-
setVerticalAlignment
public void setVerticalAlignment(int aVerticalAlignment) Description copied from interface:ILcd2DEditableTextSets the vertical alignment of the text.- Specified by:
setVerticalAlignmentin interfaceILcd2DEditableText- Parameters:
aVerticalAlignment-ALIGNMENT_TOP,ALIGNMENT_CENTER, orALIGNMENT_BOTTOM.
-
getRotAngle
public final double getRotAngle()Description copied from interface:ILcdTextReturns the angle over which this text is rotated. The angle is in degrees, positive counter-clockwise, starting a 3 o'clock. Seeclass javadocfor an illustration how this relates to the textlocationand alignment.- Specified by:
getRotAnglein interfaceILcdText- Returns:
- the rotation angle of the text.
-
setRotAngle
public void setRotAngle(double aRotAngle) Description copied from interface:ILcd2DEditableTextSets the angle over which this text is rotated (in degrees). The angle is positive counter-clockwise.- Specified by:
setRotAnglein interfaceILcd2DEditableText- Parameters:
aRotAngle- the new arc angle.
-
calculateBounds
protected void calculateBounds() -
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.
-
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.
-
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 contained editable point representing the location is cloned. The cache is not copied or cloned at all.- Specified by:
clonein interfaceILcdCloneable- Overrides:
clonein 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: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
-