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
Modifier and TypeFieldDescriptionstatic final int
When thelabel edit mode
contains 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 int
When thelabel edit mode
contains this flag, the label position was edited by for example aILcdGXYLabelEditor
.static final int
When thelabel edit mode
contains this flag, the label position was edited by for example aILcdGXYLayerLabelPainter
or aILcdGXYViewLabelPainter
.static final int
This flag indicates that the label position is sticky.static final int
This flag indicates that the label position is temporarily sticky, for instance to facilitate the selection of a label. -
Constructor Summary
ConstructorDescriptionCreates a newTLcdLabelLocation
.TLcdLabelLocation
(int aLocationX, int aLocationY, double aRotation, int aLocationIndex) Creates a newTLcdLabelLocation
with the given initial values. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Redefines the clone method to be public.void
copyFrom
(TLcdLabelLocation aSourceLabelLocation) Copies the properties ofaSourceLabelLocation
into this object.boolean
getAnchorPoint
(Point aAnchorPointSFCT) This method computes an anchor point for this label.int
Returns the label edit mode.int
This property determines the location index of the label, as specified inILcdGXYLabelPainter.setLocationIndex(int)
.float
Returns the horizontal location information of the label, specified in view coordinates (pixels).float
Returns the vertical location information of the label, specified in view coordinates (pixels).Returns the rectangle of the parent bounds.double
Returns the rotation of the parent bounds.Retrieve a label identifier that references the label on which this label depends.double
Returns the rotation of the label around its label anchor point.boolean
This flag indicates that this label is used as the representation for its domain object.boolean
This field is used to indicate that a label is interactive.boolean
isSticky()
Returns whether or not one of the sticky flags was set.void
setBodyLabel
(boolean aBodyLabel) Sets if this label will be used as the representation for its domain object.void
setInteractiveLabel
(boolean aInteractiveLabel) Set totrue
to indicate that this label is interactive.void
setLabelEditMode
(int aLabelEditMode) Sets the label edit mode.void
setLocationIndex
(int aLocationIndex) Sets the location index.void
setLocationX
(float aLocationX) Sets the horizontal location information.void
setLocationY
(float aLocationY) Sets the vertical location informationvoid
setParentBounds
(Rectangle aParentBoundsRectangle, double aParentBoundsRotation) Sets the bounds of the parent label (seegetParentLabel()
.void
setParentLabel
(TLcdLabelIdentifier aParentLabel) Sets the parent label.void
setRotation
(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 mode
contains 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 mode
contains this flag, the label position was edited by for example aILcdGXYLayerLabelPainter
or 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 mode
contains this flag, the label position should not be altered by for example aILcdGXYLayerLabelPainter
orILcdGXYViewLabelPainter
. AILcdGXYLabelEditor
however 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 mode
contains this flag, the label position should not be altered by for example aILcdGXYLayerLabelPainter
orILcdGXYViewLabelPainter
. AILcdGXYLabelEditor
however may still change the location- See Also:
-
ABSOLUTE_POSITION
public static final int ABSOLUTE_POSITIONWhen thelabel edit mode
contains 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 newTLcdLabelLocation
with 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 ofaSourceLabelLocation
into this object. No reference toaSourceLabelLocation
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
- TheTLcdLabelLocation
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 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 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 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
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
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
- aTLcdLabelIdentifier
referencing the parent label.- See Also:
-
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
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
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, seesetParentBounds(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, andfalse
otherwise.- See Also:
-
setParentBounds
Sets the bounds of the parent label (seegetParentLabel()
. These bounds should be set before storing this label location in anALcdLabelLocations
instance. 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 aTLcdLabelLocation
causesgetAnchorPoint(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, andfalse
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 andfalse
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 totrue
to indicate that this label is interactive. Label painters should respect this field by not painting interactive labels. This value isfalse
by default.- Parameters:
aInteractiveLabel
-true
for interactive labels, orfalse
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 containedSTICKY_LABEL_LOCATION
orTEMPORARY_STICKY_LABEL_LOCATION
,false
otherwise.
-
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:
clone
in classObject
- Returns:
- A clone of this
TLcdLabelLocation
instance. - Throws:
CloneNotSupportedException
-