java.lang.Object
org.eclipse.nebula.widgets.nattable.coordinate.PositionUtil

public class PositionUtil extends Object
  • Method Details

    • 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)
      Creates Ranges 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)
      Creates Ranges 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 of Ranges. 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 of Ranges. 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.
      Parameters:
      ranges - Collection of Ranges that should be joined.
      Returns:
      The joined Range or null if Ranges do not describe a consecutive Range when combined.
      Since:
      1.6
    • mergeRanges

      public static List<Range> mergeRanges(Collection<Range> ranges)
      Takes a collection of Ranges and merges them to get Ranges without overlapping. If there are no gaps between the Ranges a single Range will be the result, otherwise multiple Ranges will be in the resulting collection.
      Parameters:
      ranges - The Ranges to merge.
      Returns:
      Collection of Ranges without overlapping.
      Since:
      1.6
    • 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: