Search this API

y.layout
Class LabelLayoutData

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

public class LabelLayoutData
extends Object
implements LabelLayoutConstants, LabelLayoutKeys

This class encapsulates layout data for a label. The data is used by clients to inform label aware layouters about labeling constraints like label size and preferred placement. Label aware layouters like HierarchicLayouter on the other hand return the calculated label positions by assigning the corresponding bounds to the passed in label layout data.

Data providers are being used to associate an array of LabelLayoutData with either the nodes or the edges of a layout graph. The data providers must be registered with the input graph by using one of the keys defined in LabelLayoutKeys.


Field Summary
 
Fields inherited from interface y.layout.LabelLayoutConstants
PLACE_ANYWHERE, PLACE_AT_CENTER, PLACE_AT_SOURCE, PLACE_AT_TARGET, 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, NODE_LABEL_LAYOUT_KEY
 
Constructor Summary
LabelLayoutData(double width, double height)
          Creates a new instance of LabelLayoutData.
LabelLayoutData(double width, double height, byte preferredPlacement)
          Deprecated.  
LabelLayoutData(OrientedRectangle bounds)
          Creates a new instance of LabelLayoutData.
LabelLayoutData(OrientedRectangle bounds, byte preferredPlacement)
          Deprecated.  
LabelLayoutData(OrientedRectangle bounds, PreferredPlacementDescriptor preferredPlacement)
          Creates a new instance of LabelLayoutData.
 
Method Summary
 OrientedRectangle getBounds()
          Returns the oriented bounds of the label.
 double getHeight()
          Returns the height of the label.
 byte getPreferredPlacement()
          Deprecated. use getPreferredPlacementDescriptor() instead.
 PreferredPlacementDescriptor getPreferredPlacementDescriptor()
          Returns the preferred placement for this label.
 double getWidth()
          Returns the width of the label.
 double getX()
          Returns the x-coordinate of the label's upper-left corner of the bounding box.
 double getY()
          Returns the y-coordinate of the label's upper-left corner of the bounding box.
 void setBounds(OrientedRectangle bounds)
          Sets the oriented bounds of the label.
 void setLocation(double x, double y)
          Sets 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)
          Sets the preferred placement for this label.
 void setSize(double width, double height)
          Sets the width and height of the oriented bounds of this label.
 String toString()
          Returns a string representation of this object.
 
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. LabelLayoutConstants.PLACE_ANYWHERE is used as preferred placement specifier.

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.

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.

Parameters:
bounds - the oriented bounds of the label
See Also:
LabelLayoutConstants

LabelLayoutData

public LabelLayoutData(OrientedRectangle bounds,
                       byte preferredPlacement)
Deprecated. 

Creates a new instance of LabelLayoutData.

Parameters:
bounds - the oriented bounds 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.

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

setBounds

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


getBounds

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


setSize

public void setSize(double width,
                    double height)
Sets the width and height of the oriented bounds of this label. Note that getWidth() and getHeight() in contrast yield the width and height of the bounding box of the oriented bounds, which only coincide with the size of the oriented bounds in the case where the oriented bounds are not rotated.


getWidth

public double getWidth()
Returns the width of the label.


getHeight

public double getHeight()
Returns the height of the label.


setLocation

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


getX

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


getY

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


setPreferredPlacement

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

Sets the preferred placement for this label.

Parameters:
placement - one of LabelLayoutConstants.PLACE_ANYWHERE, LabelLayoutConstants.PLACE_AT_SOURCE, LabelLayoutConstants.PLACE_AT_TARGET, or LabelLayoutConstants.PLACE_AT_CENTER.
See Also:
LabelLayoutConstants

getPreferredPlacement

public byte getPreferredPlacement()
Deprecated. use getPreferredPlacementDescriptor() instead.

Returns the preferred placement for this label.

Returns:
one of LabelLayoutConstants.PLACE_ANYWHERE, LabelLayoutConstants.PLACE_AT_SOURCE, LabelLayoutConstants.PLACE_AT_TARGET, or LabelLayoutConstants.PLACE_AT_CENTER.
See Also:
LabelLayoutConstants

setPreferredPlacementDescriptor

public void setPreferredPlacementDescriptor(PreferredPlacementDescriptor placement)
Sets the preferred placement for this label.

Throws:
IllegalArgumentException - if the specified descriptor is null.
Parameters:
placement - the descriptor that specifies preferred placements and orientations for this label.
See Also:
PreferredPlacementDescriptor, LabelLayoutConstants

getPreferredPlacementDescriptor

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

Returns:
the descriptor that specifies preferred placements and orientations for this label.
See Also:
PreferredPlacementDescriptor, LabelLayoutConstants

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object

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