Class PositionUtil
java.lang.Object
org.eclipse.nebula.widgets.nattable.coordinate.PositionUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[][]
getGroupedByContiguous
(int... numbers) Finds contiguous numbers in a group of numbers.getGroupedByContiguous
(Collection<Integer> numberCollection) Finds contiguous numbers in a group of numbers.getHorizontalMoveDirection
(int fromPosition, int toPosition) Calculates the horizontal move direction based on the from and to column position.static int[]
getPositions
(Collection<Range> ranges) Creates an array of positions from the given set ofRange
s.static int[]
getPositions
(Range... ranges) Creates an array of positions from the given set ofRange
s.getRanges
(int... numbers) CreatesRange
s out of list of numbers.getRanges
(Collection<Integer> numbers) CreatesRange
s out of list of numbers.getVerticalMoveDirection
(int fromRowPosition, int toRowPosition) Calculates the vertical move direction based on the from and to row position.static Range
joinConsecutiveRanges
(Collection<Range> ranges) Join a set of ranges if they describe a consecutive range when combined.mergeRanges
(Collection<Range> ranges)
-
Method Details
-
getGroupedByContiguous
Finds contiguous numbers in a group of numbers.- Parameters:
numberCollection
- The numbers that should be grouped.- Returns:
- Collection of groups with contiguous numbers.
-
getGroupedByContiguous
public static int[][] getGroupedByContiguous(int... numbers) Finds contiguous numbers in a group of numbers.- Parameters:
numbers
- The numbers that should be grouped.- Returns:
- A two-dimensional array that contains int arrays for contiguous numbers.
- Since:
- 2.0
-
getRanges
CreatesRange
s out of list of numbers. The contiguous numbers are grouped together in Ranges.Example: 0, 1, 2, 4, 5, 6 will return [[Range(0 - 3)][Range(4 - 7)]]
The last number in the Range is not inclusive.
- Parameters:
numbers
- The numbers to create the Range collection.- Returns:
- List of Ranges for the given Collection of numbers.
-
getRanges
CreatesRange
s out of list of numbers. The contiguous numbers are grouped together in Ranges.Example: 0, 1, 2, 4, 5, 6 will return [[Range(0 - 3)][Range(4 - 7)]]
The last number in the Range is not inclusive.
- Parameters:
numbers
- The numbers to create the Range collection.- Returns:
- List of Ranges for the given Collection of numbers.
-
getPositions
Creates an array of positions from the given set ofRange
s. Negative values will be filtered.Example: [[Range(0 - 3)][Range(4 - 7)]] will return [0, 1, 2, 4, 5, 6].
The last number in the Range is not inclusive.
- Parameters:
ranges
- a set of ranges to retrieve positions- Returns:
- an array of positions retrieved from ranges
- Since:
- 1.6
-
getPositions
Creates an array of positions from the given set ofRange
s. Negative values will be filtered.Example: [[Range(0 - 3)][Range(4 - 7)]] will return [0, 1, 2, 4, 5, 6].
The last number in the Range is not inclusive.
- Parameters:
ranges
- a set of ranges to retrieve positions- Returns:
- an array of positions retrieved from ranges
- Since:
- 1.6
-
joinConsecutiveRanges
Join a set of ranges if they describe a consecutive range when combined. -
mergeRanges
-
getHorizontalMoveDirection
public static SelectionLayer.MoveDirectionEnum getHorizontalMoveDirection(int fromPosition, int toPosition) Calculates the horizontal move direction based on the from and to column position.- Parameters:
fromPosition
- The position from which a move is triggered.toPosition
- The position to which a move is triggered.- Returns:
- The direction of the triggered move operation.
- Since:
- 1.6
- See Also:
-
getVerticalMoveDirection
public static SelectionLayer.MoveDirectionEnum getVerticalMoveDirection(int fromRowPosition, int toRowPosition) Calculates the vertical move direction based on the from and to row position.- Parameters:
fromRowPosition
- The row position from which a move is triggered.toRowPosition
- The row position to which a move is triggered.- Returns:
- The direction of the triggered move operation.
- Since:
- 1.6
- See Also:
-