Package 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 `LayoutManager` interface using the XY Layout algorithm. This lays out the components using the layout constraints as defined by each component.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Map<IFigure,Rectangle>`
`constraints`
The layout contraints

### Fields inherited from class org.eclipse.draw2d.AbstractLayout

`isObservingVisibility, preferredSize`

## Constructor Summary

Constructors
Constructor
Description
`XYLayout()`

## Method Summary

Modifier and Type
Method
Description
`protected Dimension`
`calculatePreferredSize(IFigure f, int wHint, int hHint)`
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)`
Returns the origin for the given figure.
`void`
`layout(IFigure parent)`
Implements the algorithm to layout the components of the given container 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, getMinimumSize, getPreferredSize, getPreferredSize, invalidate, invalidate, isObservingVisibility, setObserveVisibility`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### constraints

protected Map<IFigure,Rectangle> constraints
The layout contraints

## Constructor Details

### XYLayout

public XYLayout()

## Method Details

### calculatePreferredSize

protected Dimension calculatePreferredSize(IFigure f, int wHint, int hHint)
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.

Specified by:
  `calculatePreferredSize` in class `AbstractLayout`
Parameters:
  `f` - The figure
  `wHint` - The width hint
  `hHint` - The height hint
Returns:
  The preferred size
Since:
  2.0
See Also:
  - `AbstractLayout.calculatePreferredSize(IFigure, int, int)`

### getConstraint

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

Specified by:
  `getConstraint` in interface `LayoutManager`
Overrides:
  `getConstraint` in class `AbstractLayout`
Parameters:
  `figure` - The figure
Returns:
  The constraint
See Also:
  - `LayoutManager.getConstraint(IFigure)`

### getOrigin

public Point getOrigin(IFigure parent)
Returns the origin for the given figure.

Parameters:
  `parent` - the figure whose origin is requested
Returns:
  the origin

### layout

public void layout(IFigure parent)
Implements the algorithm to layout the components of the given container figure. Each component is laid out using its own layout constraint specifying its size and position.

Parameters:
  `parent` - The figure
See Also:
  - `LayoutManager.layout(IFigure)`

### remove

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

Specified by:
  `remove` in interface `LayoutManager`
Overrides:
  `remove` in class `AbstractLayout`
Parameters:
  `figure` - The figure to remove
See Also:
  - `LayoutManager.remove(IFigure)`

### setConstraint

public void setConstraint(IFigure figure, Object newConstraint)
Sets the layout constraint of the given figure. The constraints can only be of type `Rectangle`.

Specified by:
  `setConstraint` in interface `LayoutManager`
Overrides:
  `setConstraint` in class `AbstractLayout`
Parameters:
  `figure` - the child
  `newConstraint` - the child's new constraint
Since:
  2.0
See Also:
  - `LayoutManager.setConstraint(IFigure, Object)`