Class TLcdXYText

All Implemented Interfaces:
ILcdBounded, ILcdShape, ILcdText, ILcd2DEditableShape, ILcd2DEditableText, ILcdCache, ILcdCloneable, Serializable, Cloneable
Direct Known Subclasses:
TLcdCGMText, TLcdDGNDisplayableTag, TLcdDGNText2D, TLcdDWGText

public class TLcdXYText extends ALcd2DEditableShape implements ILcd2DEditableText, ILcdCache
The default implementation of 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 length
 
For 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 Details

  • 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

      public TLcdXYText(ILcdText aText)
      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

      public final String getTextString()
      Description copied from interface: ILcdText
      Returns the text string of the text.
      Specified by:
      getTextString in interface ILcdText
      Returns:
      the text string of the text.
    • setTextString

      public void setTextString(String aTextString)
      Description copied from interface: ILcd2DEditableText
      Sets the text string.
      Specified by:
      setTextString in interface ILcd2DEditableText
    • getLocation

      public final ILcdPoint getLocation()
      Description copied from interface: ILcdText
      Returns the location of the text.

      See class javadoc for an illustration how this related to alignment.

      Specified by:
      getLocation in interface ILcdText
      Returns:
      the location of the text.
    • translate2D

      public void translate2D(double x, double y)
      Description copied from interface: ILcd2DEditableShape
      Translates this 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.
      Specified by:
      translate2D in interface ILcd2DEditableShape
      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 interface ILcd2DEditableShape
      Overrides:
      move2D in class ALcd2DEditableShape
      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 interface ILcdText
      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 interface ILcd2DEditableText
      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 interface ILcdText
      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 interface ILcdText
      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 interface ILcd2DEditableText
      Parameters:
      aCharacterHeight - the new height.
    • getHorizontalAlignment

      public final int getHorizontalAlignment()
      Description copied from interface: ILcdText
      Returns the horizontal alignment of the text.

      See class javadoc for an illustration.

      Specified by:
      getHorizontalAlignment in interface ILcdText
      Returns:
      the horizontal alignment of the text: ALIGNMENT_LEFT, ALIGNMENT_CENTER, or ALIGNMENT_RIGHT.
    • setHorizontalAlignment

      public void setHorizontalAlignment(int aHorizontalAlignment)
      Description copied from interface: ILcd2DEditableText
      Sets the horizontal alignment of the text.
      Specified by:
      setHorizontalAlignment in interface ILcd2DEditableText
      Parameters:
      aHorizontalAlignment - ALIGNMENT_LEFT, ALIGNMENT_CENTER, or ALIGNMENT_RIGHT.
    • getVerticalAlignment

      public final int getVerticalAlignment()
      Description copied from interface: ILcdText
      Returns the vertical alignment of the text.

      See class javadoc for an illustration.

      Specified by:
      getVerticalAlignment in interface ILcdText
      Returns:
      the vertical alignment of the text: ALIGNMENT_TOP, ALIGNMENT_CENTER, or ALIGNMENT_BOTTOM.
    • setVerticalAlignment

      public void setVerticalAlignment(int aVerticalAlignment)
      Description copied from interface: ILcd2DEditableText
      Sets the vertical alignment of the text.
      Specified by:
      setVerticalAlignment in interface ILcd2DEditableText
      Parameters:
      aVerticalAlignment - ALIGNMENT_TOP, ALIGNMENT_CENTER, or ALIGNMENT_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.

      See class javadoc for an illustration how this relates to the text location and alignment.

      Specified by:
      getRotAngle in interface ILcdText
      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 interface ILcd2DEditableText
      Parameters:
      aRotAngle - the new arc angle.
    • calculateBounds

      protected void calculateBounds()
    • getBounds

      public ILcdBounds getBounds()
      Description copied from interface: ILcdBounded
      Returns the 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.

      Specified by:
      getBounds in interface ILcdBounded
      Returns:
      the ILcdBounds by which the geometry of this ILcdBounded object is bounded.
    • getFocusPoint

      public ILcdPoint getFocusPoint()
      Description copied from interface: ILcdShape
      Returns the focus point of this ILcdShape.
      Specified by:
      getFocusPoint in interface ILcdShape
      Returns:
      the focus point of this ILcdShape.
    • contains2D

      public boolean contains2D(double aX, double aY)
      Description copied from interface: ILcdShape
      Checks whether this ILcdShape contains the given point in the 2D space. Only the first two dimensions of the ILcdShape are considered.
      Specified by:
      contains2D in interface ILcdShape
      Parameters:
      aX - the x coordinate of the point.
      aY - the y coordinate of the point.
      Returns:
      the boolean result of the containment test.
    • insertIntoCache

      public void insertIntoCache(Object aKey, Object aObject)
      Description copied from interface: ILcdCache
      Inserts a cache Object corresponding to the given key Object.
      Specified by:
      insertIntoCache in interface ILcdCache
      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

      public Object getCachedObject(Object aKey)
      Description copied from interface: ILcdCache
      Looks up and returns the cached Object corresponding to the given key.
      Specified by:
      getCachedObject in interface ILcdCache
      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

      public Object removeCachedObject(Object aKey)
      Description copied from interface: ILcdCache
      Looks up and removes the cached Object corresponding to the given key.
      Specified by:
      removeCachedObject in interface ILcdCache
      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 interface ILcdCache
    • clone

      public Object 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 interface ILcdCloneable
      Overrides:
      clone in class ALcdShape
      See Also:
    • equals

      public boolean equals(Object aObject)
      Returns whether the given object has the same class and the same coordinates, text, and parameters.
      Overrides:
      equals in class ALcdShape
    • 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 the ALcdShape.equals(Object) method. Extensions should refine this implementation, based on their properties.
      Overrides:
      hashCode in class ALcdShape
    • toString

      public String toString()
      Overrides:
      toString in class Object