Search this API

y.layout
Class LabelLayoutData

java.lang.Object
  extended by y.layout.LabelLayoutData
All Implemented Interfaces:
LabelLayoutConstants, LabelLayoutKeys

public class LabelLayoutData
extends java.lang.Object
implements LabelLayoutConstants, LabelLayoutKeys

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 IncrementalHierarchicLayouter 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.

 
Your browser does not support SVG content.

Field Summary
 
Fields inherited from interface y.layout.LabelLayoutConstants
PLACE_ANYWHERE, PLACE_AT_CENTER, PLACE_AT_SOURCE, PLACE_AT_SOURCE_PORT, PLACE_AT_TARGET, PLACE_AT_TARGET_PORT, PLACE_LEFT_OF_EDGE, PLACE_ON_EDGE, PLACE_RIGHT_OF_EDGE, PLACEMENT_ALONG_EDGE_MASK, PLACEMENT_ON_SIDE_OF_EDGE_MASK
 
Fields inherited from interface y.layout.LabelLayoutKeys
EDGE_LABEL_LAYOUT_KEY, IGNORE_LABEL_KEY, NODE_LABEL_LAYOUT_KEY
 
Constructor Summary
LabelLayoutData(double width, double height)
          Creates a new instance of LabelLayoutData for a label with the given width and height.
LabelLayoutData(double width, double height, byte preferredPlacement)
          Deprecated.  
LabelLayoutData(OrientedRectangle bounds)
          Creates a new instance of LabelLayoutData for a label with the given oriented box.
LabelLayoutData(OrientedRectangle bounds, byte preferredPlacement)
          Deprecated.  
LabelLayoutData(OrientedRectangle bounds, PreferredPlacementDescriptor preferredPlacement)
          Creates a new instance of LabelLayoutData for a label with the given oriented box and preferred placement descriptor.
 
Method Summary
 OrientedRectangle getBounds()
          Returns the oriented box of the label.
 double getHeight()
          Returns the height of the label's bounding box.
 byte getPreferredPlacement()
          Deprecated. use setPreferredPlacementDescriptor(PreferredPlacementDescriptor) instead
 PreferredPlacementDescriptor getPreferredPlacementDescriptor()
          Returns the preferred placement of this label.
 double getWidth()
          Returns the width of the label's bounding box.
 double getX()
          Returns the x-coordinate of the upper-left corner of the label's bounding box.
 double getY()
          Returns the y-coordinate of the upper-left corner of the label's bounding box.
 void setBounds(OrientedRectangle bounds)
          Specifies 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 setPreferredPlacement(byte placement)
          Deprecated. use setPreferredPlacementDescriptor(PreferredPlacementDescriptor) instead
 void setPreferredPlacementDescriptor(PreferredPlacementDescriptor placement)
          Specifies the preferred placement of this label.
 void setSize(double width, double height)
          Specifies the width and height of the oriented box of this label.
 java.lang.String toString()
          Returns a String representation of LabelLayoutData.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LabelLayoutData

public LabelLayoutData(double width,
                       double height)
Creates a new instance of LabelLayoutData for a label with the given width and height.

Parameters:
width - the width of the label
height - the height of the label

LabelLayoutData

public LabelLayoutData(double width,
                       double height,
                       byte preferredPlacement)
Deprecated. 

Creates a new instance of LabelLayoutData for a label with the given width, height and preferred placement.

Parameters:
width - the width of the label
height - the height of the label
preferredPlacement - a preferred placement specifier
See Also:
LabelLayoutConstants, setPreferredPlacement(byte)

LabelLayoutData

public LabelLayoutData(OrientedRectangle bounds)
Creates a new instance of LabelLayoutData for a label with the given oriented box.

Parameters:
bounds - the box of the label

LabelLayoutData

public LabelLayoutData(OrientedRectangle bounds,
                       byte preferredPlacement)
Deprecated. 

Creates a new instance of LabelLayoutData for a label with the given oriented box and preferred placement.

Parameters:
bounds - the box of the label
preferredPlacement - a preferred placement specifier
See Also:
LabelLayoutConstants, setPreferredPlacement(byte)

LabelLayoutData

public LabelLayoutData(OrientedRectangle bounds,
                       PreferredPlacementDescriptor preferredPlacement)
Creates a new instance of LabelLayoutData for a label with the given oriented box and preferred placement descriptor.

Parameters:
bounds - the box of the label
preferredPlacement - a preferred placement descriptor
Throws:
java.lang.IllegalArgumentException - if the specified descriptor is null
See Also:
PreferredPlacementDescriptor, setPreferredPlacementDescriptor(PreferredPlacementDescriptor)
Method Detail

setBounds

public void setBounds(OrientedRectangle bounds)
Specifies the oriented box of the label.

Parameters:
bounds - the box of the label

getBounds

public OrientedRectangle getBounds()
Returns the oriented box of the label.

Returns:
the bounds of the label
See Also:
setBounds(OrientedRectangle)

setSize

public void setSize(double width,
                    double height)
Specifies the width and height of the oriented box of this label.

 
getWidth() and getHeight() 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.
Parameters:
width - the width of the oriented box
height - the height of the oriented box
See Also:
setBounds(OrientedRectangle)

getWidth

public double getWidth()
Returns the width of the label's bounding box.

Returns:
the width of the bounding box of the label
See Also:
OrientedRectangle.getBoundingBox()

getHeight

public double getHeight()
Returns the height of the label's bounding box.

Returns:
the height of the bounding box of the label
See Also:
OrientedRectangle.getBoundingBox()

setLocation

public void setLocation(double x,
                        double y)
Specifies the coordinates of the upper-left corner of the bounding box of the label.

Parameters:
x - the new x-coordinate of the upper-left corner
y - the new y-coordinate of the upper-left corner
See Also:
getX(), getY(), OrientedRectangle.getBoundingBox()

getX

public double getX()
Returns the x-coordinate of the upper-left corner of the label's bounding box.

Returns:
the x-coordinate of the upper-left corner
See Also:
OrientedRectangle.getBoundingBox()

getY

public double getY()
Returns the y-coordinate of the upper-left corner of the label's bounding box.

Returns:
the y-coordinate of the upper-left corner
See Also:
OrientedRectangle.getBoundingBox()

setPreferredPlacement

public void setPreferredPlacement(byte placement)
Deprecated. use setPreferredPlacementDescriptor(PreferredPlacementDescriptor) instead

Specifies the preferred placement of this label.

Default Value:
The default value is LabelLayoutConstants.PLACE_ANYWHERE
Parameters:
placement - the preferred placement

getPreferredPlacement

public byte getPreferredPlacement()
Deprecated. use setPreferredPlacementDescriptor(PreferredPlacementDescriptor) instead

Returns the preferred placement of this label.

Returns:
the preferred placement
See Also:
setPreferredPlacement(byte)

setPreferredPlacementDescriptor

public void setPreferredPlacementDescriptor(PreferredPlacementDescriptor placement)
Specifies the preferred placement of this label.

Default Value:
The default value is PreferredPlacementDescriptor. A descriptor that allows all placements LabelLayoutConstants.PLACE_ANYWHERE
Parameters:
placement - the desired placement
Throws:
java.lang.IllegalArgumentException - if the specified descriptor is null

getPreferredPlacementDescriptor

public PreferredPlacementDescriptor getPreferredPlacementDescriptor()
Returns the preferred placement of this label.

Returns:
the desired placement
See Also:
setPreferredPlacementDescriptor(PreferredPlacementDescriptor)

toString

public java.lang.String toString()
Returns a String representation of LabelLayoutData. The String contains the bounds of the label and the preferred placement

Overrides:
toString in class java.lang.Object
Returns:
the String representation of LabelLayoutData

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.