Draw2D v2.0

org.eclipse.draw2d
Class XYLayout

java.lang.Object
  |
  +--org.eclipse.draw2d.AbstractLayout
        |
        +--org.eclipse.draw2d.XYLayout
All Implemented Interfaces:
LayoutManager
Direct Known Subclasses:
FreeformLayout

public class XYLayout
extends AbstractLayout

This class implements the

ILayoutManager
interface using the XY Layout algorithm. This lays out the components using the layout constraints as defined by each component.


Field Summary
protected  Map constraints
           
 
Constructor Summary
XYLayout()
           
 
Method Summary
protected  Dimension calculatePreferredSize(IFigure f)
          Calculates and returns the preferred size of the input figure.
 Object getConstraint(IFigure figure)
          Returns the constraint for the given figure.
 Point getOrigin(IFigure parent)
           
 void layout(IFigure parent)
          Lays out the given figure.
 void remove(IFigure figure)
          Removes the given figure from this LayoutManager's list of figures.
 void setConstraint(IFigure figure, Object newConstraint)
          Sets the layout constraint of the given figure.
 
Methods inherited from class org.eclipse.draw2d.AbstractLayout
calculatePreferredSize, getBorderPreferredSize, getMinimumSize, getPreferredSize, getPreferredSize, invalidate, invalidate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constraints

protected Map constraints
Constructor Detail

XYLayout

public XYLayout()
Method Detail

setConstraint

public void setConstraint(IFigure figure,
                          Object newConstraint)
Sets the layout constraint of the given figure. The constraints can only be of type Rectangle.
Overrides:
setConstraint in class AbstractLayout
Parameters:
figure - Figure for which the constarint is being set.
newConstraint - Constraint for the input figure.
Since:
2.0
See Also:
getConstraint(IFigure)

calculatePreferredSize

protected Dimension calculatePreferredSize(IFigure f)
Calculates and returns the preferred size of the input figure. Since in XYLayout the location of the child should be preserved, the preferred size would be a region which would hold all the children of the input figure. If no constraint is set, that child is ignored for calculation. If width and height are not positive, the preferred dimensions of the child are taken.
Overrides:
calculatePreferredSize in class AbstractLayout
Parameters:
f - Figure for which the preferred size is required.
Returns:
Preferred size of the input figure.
Since:
2.0

getConstraint

public Object getConstraint(IFigure figure)
Description copied from class: AbstractLayout
Returns the constraint for the given figure.
Overrides:
getConstraint in class AbstractLayout

getOrigin

public Point getOrigin(IFigure parent)

layout

public void layout(IFigure parent)
Description copied from interface: LayoutManager
Lays out the given figure.

remove

public void remove(IFigure figure)
Description copied from class: AbstractLayout
Removes the given figure from this LayoutManager's list of figures.
Overrides:
remove in class AbstractLayout

Draw2D v2.0