public class LabelLayoutData extends Object
LabelLayoutData
encapsulates layout information for a label.
The information is used by clients to inform label-aware layout algorithms
about labeling
constraints like label size and preferred placement.
Label-aware algorithms like HierarchicLayout
return the calculated label
positions by assigning the corresponding box to the provided LabelLayoutData
instances.
DataProviders
are used for associating an array of LabelLayoutData
instances with either the nodes or the edges of a LayoutGraph
. The DataProviders
must be registered with the input graph using one of the keys defined in LabelLayoutKeys
.
Constructor and Description |
---|
LabelLayoutData(double width,
double height)
Creates a new instance of
LabelLayoutData for a label with the given width and height. |
LabelLayoutData(YOrientedRectangle bounds)
Creates a new instance of
LabelLayoutData for a label with the given oriented box and preferred placement
descriptor. |
LabelLayoutData(YOrientedRectangle bounds,
PreferredPlacementDescriptor preferredPlacement)
Creates a new instance of
LabelLayoutData for a label with the given oriented box and preferred placement
descriptor. |
Modifier and Type | Method and Description |
---|---|
YOrientedRectangle |
getBounds()
Gets the
oriented box of the label. |
double |
getHeight()
Gets the height of the label's bounding box.
|
PreferredPlacementDescriptor |
getPreferredPlacementDescriptor()
Gets the preferred placement of this label.
|
double |
getWidth()
Gets the width of the label's bounding box.
|
double |
getX()
Gets the x-coordinate of the upper-left corner of the label's bounding box.
|
double |
getY()
Gets the y-coordinate of the upper-left corner of the label's bounding box.
|
void |
setBounds(YOrientedRectangle value)
Sets the
oriented box of the label. |
void |
setLocation(double x,
double y)
Specifies the coordinates of the upper-left corner of the bounding box of the label.
|
void |
setPreferredPlacementDescriptor(PreferredPlacementDescriptor value)
Sets the preferred placement of this label.
|
void |
setSize(double width,
double height)
Specifies the width and height of the
oriented box of this label. |
String |
toString()
Returns a
String representation of LabelLayoutData . |
public LabelLayoutData(double width, double height)
LabelLayoutData
for a label with the given width and height.width
- the width of the labelheight
- the height of the labelpublic LabelLayoutData(YOrientedRectangle bounds)
LabelLayoutData
for a label with the given oriented box and preferred placement
descriptor.IllegalArgumentException
- if the specified descriptor is null
bounds
- the box of the labelPreferredPlacementDescriptor
,
setPreferredPlacementDescriptor(PreferredPlacementDescriptor)
public LabelLayoutData(YOrientedRectangle bounds, PreferredPlacementDescriptor preferredPlacement)
LabelLayoutData
for a label with the given oriented box and preferred placement
descriptor.IllegalArgumentException
- if the specified descriptor is null
bounds
- the box of the labelpreferredPlacement
- a preferred placement descriptorPreferredPlacementDescriptor
,
setPreferredPlacementDescriptor(PreferredPlacementDescriptor)
public YOrientedRectangle getBounds()
oriented box
of the label.setBounds(YOrientedRectangle)
public double getHeight()
YOrientedRectangle.getBoundingBox()
public PreferredPlacementDescriptor getPreferredPlacementDescriptor()
IllegalArgumentException
- if the specified descriptor is null
PreferredPlacementDescriptor
. A descriptor that allows all placements LabelPlacements.ANYWHERE
setPreferredPlacementDescriptor(PreferredPlacementDescriptor)
public double getWidth()
YOrientedRectangle.getBoundingBox()
public double getX()
YOrientedRectangle.getBoundingBox()
public double getY()
YOrientedRectangle.getBoundingBox()
public void setBounds(YOrientedRectangle value)
oriented box
of the label.value
- the bounds of the labelgetBounds()
public void setLocation(double x, double y)
x
- the new x-coordinate of the upper-left cornery
- the new y-coordinate of the upper-left cornergetX()
,
getY()
,
YOrientedRectangle.getBoundingBox()
public void setPreferredPlacementDescriptor(PreferredPlacementDescriptor value)
IllegalArgumentException
- if the specified descriptor is null
PreferredPlacementDescriptor
. A descriptor that allows all placements LabelPlacements.ANYWHERE
value
- the desired placementgetPreferredPlacementDescriptor()
public void setSize(double width, double height)
oriented box
of this label.Width
and Height
in contrast yield the width and height of the paraxial
bounding box of the oriented box. Both sizes only coincide in the case the oriented box is not rotated.width
- the width of the oriented boxheight
- the height of the oriented boxsetBounds(YOrientedRectangle)
public String toString()
String
representation of LabelLayoutData
.
The String
contains the bounds of the label and the preferred placement
toString
in class Object
String
representation of LabelLayoutData