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 Modifier and Type Field Description static intHORIZONTALConstant representing a horizontal orientation.static intVERTICALConstant representing a vertical orientation.
-
Constructor Summary
Constructors Constructor Description BoxLayoutAlgorithm()Constructs a newBoxLayoutAlgorithmwith horizontal orientation.BoxLayoutAlgorithm(int orientation)Constructs a newBoxLayoutAlgorithmwith the given orientation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.intgetOrientation()voidsetOrientation(int orientation)Changes the orientation of thisBoxLayoutAlgorithmto the given value, which may either beHORIZONTALorVERTICAL.-
Methods inherited from class org.eclipse.gef.layout.algorithms.GridLayoutAlgorithm
applyLayout, calculateGrid, calculateNodeSize, calculateNumberOfRowsAndCols_rectangular, calculateNumberOfRowsAndCols_square, isResizing, setAspectRatio, setResizing, setRowPadding
-
-
-
-
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 newBoxLayoutAlgorithmwith horizontal orientation.
-
BoxLayoutAlgorithm
public BoxLayoutAlgorithm(int orientation)
Constructs a newBoxLayoutAlgorithmwith the given orientation.- Parameters:
orientation- EitherHORIZONTALorVERTICAL.- Throws:
java.lang.RuntimeException- when the given orientation is neitherHORIZONTALnorVERTICAL.
-
-
Method Detail
-
getOrientation
public int getOrientation()
- Returns:
- The orientation of this
BoxLayoutAlgorithm.
-
setOrientation
public void setOrientation(int orientation)
Changes the orientation of thisBoxLayoutAlgorithmto the given value, which may either beHORIZONTALorVERTICAL.- Parameters:
orientation- The new orientation for thisBoxLayoutAlgorithm.- Throws:
java.lang.RuntimeException- when the given orientation is neitherHORIZONTALnorVERTICAL.
-
calculateNumberOfRowsAndCols
protected int[] calculateNumberOfRowsAndCols(int numChildren, double boundX, double boundY, double boundWidth, double boundHeight)Description copied from class:GridLayoutAlgorithmCalculates and returns an array containing the number of columns and the number of rows. If theaspect ratiois set to1, then theGridLayoutAlgorithm.calculateNumberOfRowsAndCols_square(int, double, double, double, double)method is used for the computation. Otherwise, theGridLayoutAlgorithm.calculateNumberOfRowsAndCols_rectangular(int)is used for the computation.- Overrides:
calculateNumberOfRowsAndColsin classGridLayoutAlgorithm- 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.
-
-