Class BoxLayoutAlgorithm
java.lang.Object
org.eclipse.gef.layout.algorithms.GridLayoutAlgorithm
org.eclipse.gef.layout.algorithms.BoxLayoutAlgorithm
- All Implemented Interfaces:
ILayoutAlgorithm
Layout algorithm that places all elements in one column or one row, depending
on set orientation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant representing a horizontal orientation.static final intConstant representing a vertical orientation. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newBoxLayoutAlgorithmwith horizontal orientation.BoxLayoutAlgorithm(int orientation) Constructs a newBoxLayoutAlgorithmwith the given orientation. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.intvoidsetOrientation(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 Details
-
HORIZONTAL
public static final int HORIZONTALConstant representing a horizontal orientation.- See Also:
-
VERTICAL
public static final int VERTICALConstant representing a vertical orientation.- See Also:
-
-
Constructor Details
-
BoxLayoutAlgorithm
public BoxLayoutAlgorithm()Constructs a newBoxLayoutAlgorithmwith horizontal orientation. -
BoxLayoutAlgorithm
public BoxLayoutAlgorithm(int orientation) Constructs a newBoxLayoutAlgorithmwith the given orientation.- Parameters:
orientation- EitherHORIZONTALorVERTICAL.- Throws:
RuntimeException- when the given orientation is neitherHORIZONTALnorVERTICAL.
-
-
Method Details
-
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:
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.
-