Class TLcdLabelLocation
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
TLcdGXYCurvedPathLabelLocation
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 :

- Since:
- 7.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intWhen thelabel edit modecontains this flag,getLocationX()andgetLocationY()return absolute values, otherwise they return values relative to the anchor point of the domain object that is labeled (determined byILcdGXYPainter.anchorPointSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Point)), or the anchor point returned bygetAnchorPoint(java.awt.Point).static final intWhen thelabel edit modecontains this flag, the label position was edited by for example aILcdGXYLabelEditor.static final intWhen thelabel edit modecontains this flag, the label position was edited by for example aILcdGXYLayerLabelPainteror aILcdGXYViewLabelPainter.static final intThis flag indicates that the label position is sticky.static final intThis flag indicates that the label position is temporarily sticky, for instance to facilitate the selection of a label. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newTLcdLabelLocation.TLcdLabelLocation(int aLocationX, int aLocationY, double aRotation, int aLocationIndex) Creates a newTLcdLabelLocationwith the given initial values. -
Method Summary
Modifier and TypeMethodDescriptionclone()Redefines the clone method to be public.voidcopyFrom(TLcdLabelLocation aSourceLabelLocation) Copies the properties ofaSourceLabelLocationinto this object.booleangetAnchorPoint(Point aAnchorPointSFCT) This method computes an anchor point for this label.intReturns the label edit mode.intThis property determines the location index of the label, as specified inILcdGXYLabelPainter.setLocationIndex(int).floatReturns the horizontal location information of the label, specified in view coordinates (pixels).floatReturns the vertical location information of the label, specified in view coordinates (pixels).Returns the rectangle of the parent bounds.doubleReturns the rotation of the parent bounds.Retrieve a label identifier that references the label on which this label depends.doubleReturns the rotation of the label around its label anchor point.booleanThis flag indicates that this label is used as the representation for its domain object.booleanThis field is used to indicate that a label is interactive.booleanisSticky()Returns whether or not one of the sticky flags was set.voidsetBodyLabel(boolean aBodyLabel) Sets if this label will be used as the representation for its domain object.voidsetInteractiveLabel(boolean aInteractiveLabel) Set totrueto indicate that this label is interactive.voidsetLabelEditMode(int aLabelEditMode) Sets the label edit mode.voidsetLocationIndex(int aLocationIndex) Sets the location index.voidsetLocationX(float aLocationX) Sets the horizontal location information.voidsetLocationY(float aLocationY) Sets the vertical location informationvoidsetParentBounds(Rectangle aParentBoundsRectangle, double aParentBoundsRotation) Sets the bounds of the parent label (seegetParentLabel().voidsetParentLabel(TLcdLabelIdentifier aParentLabel) Sets the parent label.voidsetRotation(double aRotation) Sets the rotation of the label around its label anchor point.toString()
-
Field Details
-
EDITED_BY_LABEL_EDITOR
public static final int EDITED_BY_LABEL_EDITORWhen thelabel edit modecontains this flag, the label position was edited by for example aILcdGXYLabelEditor.- See Also:
-
EDITED_BY_LAYER_OR_VIEW_LABEL_PAINTER
public static final int EDITED_BY_LAYER_OR_VIEW_LABEL_PAINTERWhen thelabel edit modecontains this flag, the label position was edited by for example aILcdGXYLayerLabelPainteror aILcdGXYViewLabelPainter.- See Also:
-
STICKY_LABEL_LOCATION
public static final int STICKY_LABEL_LOCATIONThis flag indicates that the label position is sticky. It indicates a more permanent stickiness than
TEMPORARY_STICKY_LABEL_LOCATION. For instance, when the label editor has moved a label, it could have indicated that the label should remain sticky afterward.When the
label edit modecontains this flag, the label position should not be altered by for example aILcdGXYLayerLabelPainterorILcdGXYViewLabelPainter. AILcdGXYLabelEditorhowever may still change the location- See Also:
-
TEMPORARY_STICKY_LABEL_LOCATION
public static final int TEMPORARY_STICKY_LABEL_LOCATIONThis flag indicates that the label position is temporarily sticky, for instance to facilitate the selection of a label.
When the
label edit modecontains this flag, the label position should not be altered by for example aILcdGXYLayerLabelPainterorILcdGXYViewLabelPainter. AILcdGXYLabelEditorhowever may still change the location- See Also:
-
ABSOLUTE_POSITION
public static final int ABSOLUTE_POSITIONWhen thelabel edit modecontains this flag,getLocationX()andgetLocationY()return absolute values, otherwise they return values relative to the anchor point of the domain object that is labeled (determined byILcdGXYPainter.anchorPointSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Point)), or the anchor point returned bygetAnchorPoint(java.awt.Point).- See Also:
-
-
Constructor Details
-
TLcdLabelLocation
public TLcdLabelLocation()Creates a newTLcdLabelLocation. -
TLcdLabelLocation
public TLcdLabelLocation(int aLocationX, int aLocationY, double aRotation, int aLocationIndex) Creates a newTLcdLabelLocationwith the given initial values.- Parameters:
aLocationX- the X-location, seesetLocationX(float).aLocationY- the Y-location, seesetLocationY(float).aRotation- the rotation, seesetRotation(double).aLocationIndex- the location index, seesetLocationIndex(int).
-
-
Method Details
-
copyFrom
Copies the properties ofaSourceLabelLocationinto this object. No reference toaSourceLabelLocationis 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- TheTLcdLabelLocationwhose 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,
-1to 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,-1to 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 modeindicates that this information is relative, this property determines the horizontal offset relative the anchor point of the labeled object or the anchor point retrieved usinggetAnchorPoint(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 modeindicates that this information is relative, this property determines the vertical offset relative the anchor point of the labeled object or the anchor point retrieved usinggetAnchorPoint(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
TLcdLabelLocationcontains 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
Retrieve a label identifier that references the label on which this label depends. If the returned label identifier isnull, 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 (seesetParentBounds(Rectangle, double). Examples of code that should do this are the label placer (seeILcdGXYViewLabelPlacer), 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
Sets the parent label.- Parameters:
aParentLabel- aTLcdLabelIdentifierreferencing the parent label.- See Also:
-
getParentBoundsRectangle
Returns the rectangle of the parent bounds.If the
label edit modeindicates 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
This method computes an anchor point for this label. It does so based on the bounds of its parent label (seegetParentBoundsRectangle()andgetParentBoundsRotation()).Code that alters a
TLcdLabelLocationshould always make sure that this method returns a correct anchor point. This can be done by setting the parent bounds to a correct value, seesetParentBounds(java.awt.Rectangle, double).If the
label edit modeindicates 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
falseand the user of this object should compute an anchor point.- Parameters:
aAnchorPointSFCT- the point in which the anchor point will be stored.- Returns:
trueif an anchor point could be calculated, andfalseotherwise.- See Also:
-
setParentBounds
Sets the bounds of the parent label (seegetParentLabel(). These bounds should be set before storing this label location in anALcdLabelLocationsinstance. Examples of code that should do this are the label placer (seeILcdGXYViewLabelPlacer), the label editor, or other code that manually adjusts offset labels. Not setting these bounds to the correct value for aTLcdLabelLocationcausesgetAnchorPoint(java.awt.Point)to return an incorrect anchor point for this label location.If the
label edit modeindicates 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:
trueif this label is used a the representation for its domain object, andfalseotherwise.- See Also:
-
setBodyLabel
public void setBodyLabel(boolean aBodyLabel) Sets if this label will be used as the representation for its domain object.- Parameters:
aBodyLabel-trueif this label will be used as the representation for its domain object andfalseotherwise.- 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 totrueto indicate that this label is interactive. Label painters should respect this field by not painting interactive labels. This value isfalseby default.- Parameters:
aInteractiveLabel-truefor interactive labels, orfalseotherwise.- 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:
trueif the label edit mode containedSTICKY_LABEL_LOCATIONorTEMPORARY_STICKY_LABEL_LOCATION,falseotherwise.
-
toString
-
clone
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:
clonein classObject- Returns:
- A clone of this
TLcdLabelLocationinstance. - Throws:
CloneNotSupportedException
-