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 int
Constant representing a horizontal orientation.static final int
Constant representing a vertical orientation. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newBoxLayoutAlgorithm
with horizontal orientation.BoxLayoutAlgorithm
(int orientation) Constructs a newBoxLayoutAlgorithm
with 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.int
void
setOrientation
(int orientation) Changes the orientation of thisBoxLayoutAlgorithm
to the given value, which may either beHORIZONTAL
orVERTICAL
.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 newBoxLayoutAlgorithm
with horizontal orientation. -
BoxLayoutAlgorithm
public BoxLayoutAlgorithm(int orientation) Constructs a newBoxLayoutAlgorithm
with the given orientation.- Parameters:
orientation
- EitherHORIZONTAL
orVERTICAL
.- Throws:
RuntimeException
- when the given orientation is neitherHORIZONTAL
norVERTICAL
.
-
-
Method Details
-
getOrientation
public int getOrientation()- Returns:
- The orientation of this
BoxLayoutAlgorithm
.
-
setOrientation
public void setOrientation(int orientation) Changes the orientation of thisBoxLayoutAlgorithm
to the given value, which may either beHORIZONTAL
orVERTICAL
.- Parameters:
orientation
- The new orientation for thisBoxLayoutAlgorithm
.- Throws:
RuntimeException
- when the given orientation is neitherHORIZONTAL
norVERTICAL
.
-
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 theaspect ratio
is 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:
calculateNumberOfRowsAndCols
in 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.
-