y.layout
Class LabelLayoutData

java.lang.Object
  |
  +--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 dataproviders 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
 
Constructor Summary
LabelLayoutData(double width, double height)
          Creates a new instance of LabelLayoutData.
LabelLayoutData(double width, double height, byte preferredPlacement)
          Creates a new instance of LabelLayoutData.
 
Method Summary
 YRectangle getBounds()
          Retruns the bounds of the label.
 double getHeight()
          Returns the height of the label.
 byte getPreferredPlacement()
          Returns the preferred placement for this label.
 double getWidth()
          Returns the width of the label.
 double getX()
          Returns the x-coordinate of the upper-left label location.
 double getY()
          Returns the y-coordinate of the upper-left label location.
 void setBounds(YRectangle bounds)
          Sets the bounds of the label.
 void setLocation(double x, double y)
          Sets the coordinate of the upper left corner of the label.
 void setPreferredPlacement(byte placement)
          Sets the preferred placement for this label.
 void setSize(double width, double height)
          Sets the size of the 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)
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, LabelLayoutData.setPreferredPlacement(byte)
Method Detail

setBounds

public void setBounds(YRectangle bounds)
Sets the bounds of the label. The bounds must be given in absolute graph coordinates.


getBounds

public YRectangle getBounds()
Retruns the bounds of the label. The bounds are returned in absolute graph coordinates.


setSize

public void setSize(double width,
                    double height)
Sets the size of the label.


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 coordinate of the upper left corner of the label.


getX

public double getX()
Returns the x-coordinate of the upper-left label location.


getY

public double getY()
Returns the y-coordinate of the upper-left label location.


setPreferredPlacement

public void setPreferredPlacement(byte placement)
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()
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

toString

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

Overrides:
toString in class Object

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

2003