Class TLcdLabelLocation

java.lang.Object
com.luciad.view.TLcdLabelLocation
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
TLcdGXYCurvedPathLabelLocation

public class TLcdLabelLocation extends Object implements Cloneable

Instances of this class contain the location information about a specific label. It is used as the data transfer object between ALcdLabelLocations and the various parties that need to know the location of a label.

This class can be sub-classed if you want to add extra properties about the location of a label. When doing so, also overwrite the copyFrom(com.luciad.view.TLcdLabelLocation) method to make sure your extra properties are copied. By overwriting ALcdLabelLocations.createLabelLocation() to return instances of your subclass, all classes will use the extension to exchange the label location information.

When using free placement (getLocationIndex() == -1), the label location represents a label using a location and a rotation. This location is the label anchor point of the label. The label is then rotated around this label anchor point, see illustration :

TLcdLabelLocation

Since:
7.0
See Also:
  • Field Details

  • Constructor Details

    • TLcdLabelLocation

      public TLcdLabelLocation()
      Creates a new TLcdLabelLocation.
    • TLcdLabelLocation

      public TLcdLabelLocation(int aLocationX, int aLocationY, double aRotation, int aLocationIndex)
      Creates a new TLcdLabelLocation with the given initial values.
      Parameters:
      aLocationX - the X-location, see setLocationX(float).
      aLocationY - the Y-location, see setLocationY(float).
      aRotation - the rotation, see setRotation(double).
      aLocationIndex - the location index, see setLocationIndex(int).
  • Method Details

    • copyFrom

      public void copyFrom(TLcdLabelLocation aSourceLabelLocation)
      Copies the properties of aSourceLabelLocation into this object. No reference to aSourceLabelLocation is kept when this method returns. In other words, this method creates a clone in an already existing instance, hence avoiding the overhead of creating a new instance.
      Parameters:
      aSourceLabelLocation - The TLcdLabelLocation whose properties you wish to copy.
      See Also:
    • getLocationIndex

      public int getLocationIndex()

      This property determines the location index of the label, as specified in ILcdGXYLabelPainter.setLocationIndex(int). Unlike that specification however, this location index can be less than 0, to indicate free label placement.

      Returns:
      An integer larger or equal to 0 to indicate a predefined label location, -1 to indicate free label placement.
    • setLocationIndex

      public void setLocationIndex(int aLocationIndex)
      Sets the location index.
      Parameters:
      aLocationIndex - An integer larger than or equal to 0 to indicate a predefined label location, -1 to indicate free label placement.
      See Also:
    • getLocationX

      public float getLocationX()

      Returns the horizontal location information of the label, specified in view coordinates (pixels). This location represents the position of the label anchor point of the label. Although specified as a float, users of this method can simply cast the value to an integer.

      If the label edit mode indicates that this information is relative, this property determines the horizontal offset relative the anchor point of the labeled object or the anchor point retrieved using getAnchorPoint(java.awt.Point). If the label edit mode indicates this information is absolute, this property defines the absolute horizontal position in the view.

      This value is only relevant if the location index indicates that the label is freely placed, ie. the location index is smaller than 0.

      Returns:
      The location information along the X axis.
    • setLocationX

      public void setLocationX(float aLocationX)
      Sets the horizontal location information.
      Parameters:
      aLocationX - The horizontal position.
      See Also:
    • getLocationY

      public float getLocationY()

      Returns the vertical location information of the label, specified in view coordinates (pixels). This location represents the position of the label anchor point of the label. Although specified as a float, users of this method can simply cast the value to an integer.

      If the label edit mode indicates that this information is relative, this property determines the vertical offset relative the anchor point of the labeled object or the anchor point retrieved using getAnchorPoint(java.awt.Point). If the label edit mode indicates this information is absolute, this property defines the absolute vertical position in the view.

      This value is only relevant if the location index indicates that the label is freely placed, ie. the location index is smaller than 0.

      Returns:
      The location information along the Y axis.
    • setLocationY

      public void setLocationY(float aLocationY)
      Sets the vertical location information
      Parameters:
      aLocationY - The vertical position.
      See Also:
    • getRotation

      public double getRotation()

      Returns the rotation of the label around its label anchor point. This rotation is given in radians, clockwise and with 0 radians at 3 o'clock.

      This value is only relevant if the location index indicates that the label is freely placed, ie. the location index is smaller than 0.

      Returns:
      The rotation of the label in radians.
      See Also:
    • setRotation

      public void setRotation(double aRotation)

      Sets the rotation of the label around its label anchor point. This rotation is given in radians, clockwise and with 0 radians at 3 o'clock. Since the y-axis points down in AWT, it means that rotating with a positive angle rotates points on the positive x axis toward the positive y axis, which is clockwise visually.

      This value is only relevant if the location index indicates that the label is freely placed, ie. the location index is smaller than 0.

      Parameters:
      aRotation - The rotation of the label.
      See Also:
    • getLabelEditMode

      public int getLabelEditMode()

      Returns the label edit mode. This mode is a bitwise combination of the static constants in this class.

      For example, to check if this TLcdLabelLocation contains absolute information, you should check if the ABSOLUTE_POSITION flag is set in the label edit mode:

      
       boolean absolute = ( ABSOLUTE_POSITION & getLabelEditMode() ) != 0;
       

      Returns:
      A bitwise or of the constants in this class.
      See Also:
    • setLabelEditMode

      public void setLabelEditMode(int aLabelEditMode)
      Sets the label edit mode.
      Parameters:
      aLabelEditMode - A bitwise or of the constants in this class
      See Also:
    • getParentLabel

      public TLcdLabelIdentifier getParentLabel()
      Retrieve a label identifier that references the label on which this label depends. If the returned label identifier is null, it doesn't depend on an other label.

      Before storing this label location in an ALcdLabelLocations, one should make sure that the bounds of the parent label are set (see setParentBounds(Rectangle, double). Examples of code that should do this are the label placer (see ILcdGXYViewLabelPlacer), the label editor, or other code that manually adjusts offset labels.

      By default the returned label identifier is null.

      Returns:
      the label identifier that references the label on which this label depends.
      See Also:
    • setParentLabel

      public void setParentLabel(TLcdLabelIdentifier aParentLabel)
      Sets the parent label.
      Parameters:
      aParentLabel - a TLcdLabelIdentifier referencing the parent label.
      See Also:
    • getParentBoundsRectangle

      public Rectangle getParentBoundsRectangle()
      Returns the rectangle of the parent bounds.

      If the label edit mode indicates that this information is relative, the bounds are relative to the anchor point of the labeled object. If the label edit mode indicates this information is absolute, the bounds are absolute in the view.

      Returns:
      the rectangle of the parent bounds.
      See Also:
    • getParentBoundsRotation

      public double getParentBoundsRotation()
      Returns the rotation of the parent bounds.
      Returns:
      the rotation of the parent bounds.
      See Also:
    • getAnchorPoint

      public boolean getAnchorPoint(Point aAnchorPointSFCT)
      This method computes an anchor point for this label. It does so based on the bounds of its parent label (see getParentBoundsRectangle() and getParentBoundsRotation()).

      Code that alters a TLcdLabelLocation should always make sure that this method returns a correct anchor point. This can be done by setting the parent bounds to a correct value, see setParentBounds(java.awt.Rectangle, double).

      If the label edit mode indicates that this information is relative, the retrieved anchor point is relative to the anchor point of the labeled object. If the label edit mode indicates this information is absolute, anchor point is absolute in the view.

      If this label has no parent label, this method returns false and the user of this object should compute an anchor point.

      Parameters:
      aAnchorPointSFCT - the point in which the anchor point will be stored.
      Returns:
      true if an anchor point could be calculated, and false otherwise.
      See Also:
    • setParentBounds

      public void setParentBounds(Rectangle aParentBoundsRectangle, double aParentBoundsRotation)
      Sets the bounds of the parent label (see getParentLabel(). These bounds should be set before storing this label location in an ALcdLabelLocations instance. Examples of code that should do this are the label placer (see ILcdGXYViewLabelPlacer), the label editor, or other code that manually adjusts offset labels. Not setting these bounds to the correct value for a TLcdLabelLocation causes getAnchorPoint(java.awt.Point) to return an incorrect anchor point for this label location.

      If the label edit mode indicates that this information is relative, the bounds should be relative to the anchor point of the labeled object. If the label edit mode indicates this information is absolute, the parent bounds are absolute in the view.

      Parameters:
      aParentBoundsRectangle - the rectangle of the parent bounds.
      aParentBoundsRotation - the rotation of the parent bounds.
    • isBodyLabel

      public boolean isBodyLabel()
      This flag indicates that this label is used as the representation for its domain object. This hint can be used to determine the semantics when editing the label, or to determine the Z-order when painting the label.
      Returns:
      true if this label is used a the representation for its domain object, and false otherwise.
      See Also:
    • setBodyLabel

      public void setBodyLabel(boolean aBodyLabel)
      Sets if this label will be used as the representation for its domain object.
      Parameters:
      aBodyLabel - true if this label will be used as the representation for its domain object and false otherwise.
      See Also:
    • isInteractiveLabel

      public boolean isInteractiveLabel()
      This field is used to indicate that a label is interactive. Label painters should respect this field by not painting interactive labels.
      Returns:
      if this label is interactive.
      See Also:
    • setInteractiveLabel

      public void setInteractiveLabel(boolean aInteractiveLabel)
      Set to true to indicate that this label is interactive. Label painters should respect this field by not painting interactive labels. This value is false by default.
      Parameters:
      aInteractiveLabel - true for interactive labels, or false otherwise.
      See Also:
    • isSticky

      public boolean isSticky()

      Returns whether or not one of the sticky flags was set. This method can be overridden to take extra parameters into consideration.

      Returns:
      true if the label edit mode contained STICKY_LABEL_LOCATION or TEMPORARY_STICKY_LABEL_LOCATION, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • clone

      public Object clone() throws CloneNotSupportedException
      Redefines the clone method to be public. Returns a clone of this instance. Since there are no references to other objects, no other objects are cloned in the default implementation.
      Overrides:
      clone in class Object
      Returns:
      A clone of this TLcdLabelLocation instance.
      Throws:
      CloneNotSupportedException