Package org.eclipse.draw2d
Class GridLayout
java.lang.Object
org.eclipse.draw2d.AbstractLayout
org.eclipse.draw2d.AbstractHintLayout
org.eclipse.draw2d.GridLayout
- All Implemented Interfaces:
- LayoutManager
Lays out children into a Grid arrangement in which overall aligment and
 spacing can be configured, as well as specific layout requirements for the
 each individual member of the GridLayout. This layout is a Draw2D port of the
 swt GridLayout.
 
GridLayout has a number of configuration fields, and the Figures
 it lays out can have an associated layout data object, called
 GridData (similar to the SWT GridData object). The power of
 GridLayout lies in the ability to configure
 GridData for each Figure in the layout.
 
 The following code creates a container Figure managed by a
 GridLayout with 2 columns, containing 3 RectangleFigure shapes,
 the last of which has been given further layout instructions. Note that it is
 the GridLayout method setConstraint that binds the
 child Figure to its layout GridData object.
 
Figure container = new Figure(); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; container.setLayout(gridLayout); Shape rect; rect = new RectangleFigure(); container.add(rect); rect = new RectangleFigure(); container.add(rect); rect = new RectangleFigure(); GridData gridData = new GridData(); gridData.widthHint = 150; layout.setConstraint(rect, gridData); container.add(rect);
 The numColumns field is the most important field in a
 GridLayout. Widgets are laid out in columns from left to right,
 and a new row is created when numColumns+ 1 figures are added to
 the Figure parent container.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionThe layout contraintsinthorizontalSpacing specifies the number of pixels between the right edge of one cell and the left edge of its neighbouring cell to the right.booleanmakeColumnsEqualWidth specifies whether all columns in the layout will be forced to have the same width.intmarginHeight specifies the number of pixels of vertical margin that will be placed along the top and bottom edges of the layout.intmarginWidth specifies the number of pixels of horizontal margin that will be placed along the left and right edges of the layout.intnumColumns specifies the number of cell columns in the layout.intverticalSpacing specifies the number of pixels between the bottom edge of one cell and the top edge of its neighbouring cell underneath.Fields inherited from class org.eclipse.draw2d.AbstractLayoutisObservingVisibility, preferredSize
- 
Constructor SummaryConstructorsConstructorDescriptionDefault ConstructorGridLayout(int numColumns, boolean makeColumnsEqualWidth) Constructs a new instance of this class given the number of columns, and whether or not the columns should be forced to have the same width.
- 
Method SummaryModifier and TypeMethodDescriptionprotected DimensioncalculatePreferredSize(IFigure container, int wHint, int hHint) Calculates the preferred size of the given figure, using width and height hints.protected DimensiongetChildSize(IFigure child, int wHint, int hHint) getConstraint(IFigure child) Returns the constraint for the given figure.voidLays out the given figure.voidsetConstraint(IFigure figure, Object newConstraint) Sets the layout constraint of the given figure.Methods inherited from class org.eclipse.draw2d.AbstractHintLayoutcalculateMinimumSize, getMinimumSize, getPreferredSize, invalidate, isSensitiveHorizontally, isSensitiveVerticallyMethods inherited from class org.eclipse.draw2d.AbstractLayoutcalculatePreferredSize, getBorderPreferredSize, getMinimumSize, getPreferredSize, invalidate, isObservingVisibility, remove, setObserveVisibility
- 
Field Details- 
numColumnspublic int numColumnsnumColumns specifies the number of cell columns in the layout. The default value is 1.
- 
makeColumnsEqualWidthpublic boolean makeColumnsEqualWidthmakeColumnsEqualWidth specifies whether all columns in the layout will be forced to have the same width. The default value is false.
- 
marginWidthpublic int marginWidthmarginWidth specifies the number of pixels of horizontal margin that will be placed along the left and right edges of the layout. The default value is 5.
- 
marginHeightpublic int marginHeightmarginHeight specifies the number of pixels of vertical margin that will be placed along the top and bottom edges of the layout. The default value is 5.
- 
horizontalSpacingpublic int horizontalSpacinghorizontalSpacing specifies the number of pixels between the right edge of one cell and the left edge of its neighbouring cell to the right. The default value is 5.
- 
verticalSpacingpublic int verticalSpacingverticalSpacing specifies the number of pixels between the bottom edge of one cell and the top edge of its neighbouring cell underneath. The default value is 5.
- 
constraintsThe layout contraints
 
- 
- 
Constructor Details- 
GridLayoutpublic GridLayout()Default Constructor
- 
GridLayoutpublic GridLayout(int numColumns, boolean makeColumnsEqualWidth) Constructs a new instance of this class given the number of columns, and whether or not the columns should be forced to have the same width.- Parameters:
- numColumns- the number of columns in the grid
- makeColumnsEqualWidth- whether or not the columns will have equal width
 
 
- 
- 
Method Details- 
getChildSize- Parameters:
- child-
- wHint-
- hHint-
- Returns:
- the child size.
 
- 
calculatePreferredSizeDescription copied from class:AbstractLayoutCalculates the preferred size of the given figure, using width and height hints.- Specified by:
- calculatePreferredSizein class- AbstractLayout
- Parameters:
- container- The figure
- wHint- The width hint
- hHint- The height hint
- Returns:
- The preferred size
 
- 
layoutDescription copied from interface:LayoutManagerLays out the given figure.- Parameters:
- container- The figure
 
- 
getConstraintDescription copied from class:AbstractLayoutReturns the constraint for the given figure.- Specified by:
- getConstraintin interface- LayoutManager
- Overrides:
- getConstraintin class- AbstractLayout
- Parameters:
- child- The figure
- Returns:
- The constraint
 
- 
setConstraintSets the layout constraint of the given figure. The constraints can only be of typeGridData.- Specified by:
- setConstraintin interface- LayoutManager
- Overrides:
- setConstraintin class- AbstractLayout
- Parameters:
- figure- the child
- newConstraint- the child's new constraint
- See Also:
 
 
-