org.eclipse.gef.layout.algorithms

## Class BoxLayoutAlgorithm

- java.lang.Object
- - org.eclipse.gef.layout.algorithms.GridLayoutAlgorithm
  - - org.eclipse.gef.layout.algorithms.BoxLayoutAlgorithm

All Implemented Interfaces:
  ILayoutAlgorithm

    public class BoxLayoutAlgorithm
    extends GridLayoutAlgorithm

Layout algorithm that places all elements in one column or one row, depending on set orientation.

### Field Summary

Fields
`static int` `HORIZONTAL` Constant representing a horizontal orientation.
`static int` `VERTICAL` Constant representing a vertical orientation.

### Constructor Summary

Constructors
Constructor and Description
`BoxLayoutAlgorithm()` Constructs a new `BoxLayoutAlgorithm` with horizontal orientation.
`BoxLayoutAlgorithm(int orientation)` Constructs a new `BoxLayoutAlgorithm` with the given orientation.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected int[]` `calculateNumberOfRowsAndCols(int numChildren, double boundX, double boundY, double boundWidth, double boundHeight)` Calculates and returns an array containing the number of columns and the number of rows.
`int` `getOrientation()` Returns the orientation of this `BoxLayoutAlgorithm`, either `HORIZONTAL` or `VERTICAL`.
`void` `setOrientation(int orientation)` Changes the orientation of this `BoxLayoutAlgorithm` to the given value, which may either be `HORIZONTAL` or `VERTICAL`.

### Methods inherited from class org.eclipse.gef.layout.algorithms.GridLayoutAlgorithm

`applyLayout, calculateGrid, calculateNodeSize, calculateNumberOfRowsAndCols_rectangular, calculateNumberOfRowsAndCols_square, isResizing, setAspectRatio, setResizing, setRowPadding`

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

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

### Field Detail

#### HORIZONTAL

    public static final int HORIZONTAL

Constant representing a horizontal orientation.

See Also:
  Constant Field Values

#### VERTICAL

    public static final int VERTICAL

Constant representing a vertical orientation.

See Also:
  Constant Field Values

### Constructor Detail

#### BoxLayoutAlgorithm

    public BoxLayoutAlgorithm()

Constructs a new `BoxLayoutAlgorithm` with horizontal orientation.

#### BoxLayoutAlgorithm

    public BoxLayoutAlgorithm(int orientation)

Constructs a new `BoxLayoutAlgorithm` with the given orientation.

Parameters:
  `orientation` - Either `HORIZONTAL` or `VERTICAL`.
Throws:
  `RuntimeException` - when the given orientation is neither `HORIZONTAL` nor `VERTICAL`.

### Method Detail

#### getOrientation

    public int getOrientation()

Returns the orientation of this `BoxLayoutAlgorithm`, either `HORIZONTAL` or `VERTICAL`.

Returns:
  The orientation of this `BoxLayoutAlgorithm`.

#### setOrientation

    public void setOrientation(int orientation)

Changes the orientation of this `BoxLayoutAlgorithm` to the given value, which may either be `HORIZONTAL` or `VERTICAL`.

Parameters:
  `orientation` - The new orientation for this `BoxLayoutAlgorithm`.
Throws:
  `RuntimeException` - when the given orientation is neither `HORIZONTAL` nor `VERTICAL`.

#### calculateNumberOfRowsAndCols

    protected int[] calculateNumberOfRowsAndCols(int numChildren,
                                                 double boundX,
                                                 double boundY,
                                                 double boundWidth,
                                                 double boundHeight)

Description copied from class: `GridLayoutAlgorithm`
Calculates and returns an array containing the number of columns and the number of rows. If the `aspect ratio` is set to `1`, then the `GridLayoutAlgorithm.calculateNumberOfRowsAndCols_square(int, double, double, double, double)` method is used for the computation. Otherwise, the `GridLayoutAlgorithm.calculateNumberOfRowsAndCols_rectangular(int)` is used for the computation.

Overrides:
  `calculateNumberOfRowsAndCols` in class `GridLayoutAlgorithm`
Parameters:
  `numChildren` - The number of nodes.
  `boundX` - The horizontal offset.
  `boundY` - The vertical offset.
  `boundWidth` - The bounds' width.
  `boundHeight` - The bounds' height.
Returns:
  An array containing the number of columns, and the number of rows.