Class PositionUtil
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.coordinate.PositionUtil
-
public class PositionUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int[][]
getGroupedByContiguous(int... numbers)
Finds contiguous numbers in a group of numbers.static List<List<Integer>>
getGroupedByContiguous(Collection<Integer> numberCollection)
Finds contiguous numbers in a group of numbers.static SelectionLayer.MoveDirectionEnum
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.static List<Range>
getRanges(int... numbers)
CreatesRange
s out of list of numbers.static List<Range>
getRanges(Collection<Integer> numbers)
CreatesRange
s out of list of numbers.static SelectionLayer.MoveDirectionEnum
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.static List<Range>
mergeRanges(Collection<Range> ranges)
-
-
-
Method Detail
-
getGroupedByContiguous
public static List<List<Integer>> getGroupedByContiguous(Collection<Integer> numberCollection)
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
public static List<Range> getRanges(Collection<Integer> numbers)
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
public static List<Range> getRanges(int... numbers)
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
public static int[] getPositions(Collection<Range> ranges)
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
public static int[] getPositions(Range... ranges)
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
public static Range joinConsecutiveRanges(Collection<Range> ranges)
Join a set of ranges if they describe a consecutive range when combined.
-
mergeRanges
public static List<Range> mergeRanges(Collection<Range> ranges)
-
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:
SelectionLayer.MoveDirectionEnum.LEFT
,SelectionLayer.MoveDirectionEnum.RIGHT
,SelectionLayer.MoveDirectionEnum.NONE
-
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:
SelectionLayer.MoveDirectionEnum.UP
,SelectionLayer.MoveDirectionEnum.DOWN
,SelectionLayer.MoveDirectionEnum.NONE
-
-