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 int
HORIZONTAL
Constant representing a horizontal orientation.static int
VERTICAL
Constant representing a vertical orientation.
-
Constructor Summary
Constructors Constructor Description BoxLayoutAlgorithm()
Constructs a newBoxLayoutAlgorithm
with horizontal orientation.BoxLayoutAlgorithm(int orientation)
Constructs a newBoxLayoutAlgorithm
with 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.int
getOrientation()
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 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 newBoxLayoutAlgorithm
with horizontal orientation.
-
BoxLayoutAlgorithm
public BoxLayoutAlgorithm(int orientation)
Constructs a newBoxLayoutAlgorithm
with the given orientation.- Parameters:
orientation
- EitherHORIZONTAL
orVERTICAL
.- Throws:
java.lang.RuntimeException
- when the given orientation is neitherHORIZONTAL
norVERTICAL
.
-
-
Method Detail
-
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:
java.lang.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.
-
-