Class ColumnGroupUtils


  • public final class ColumnGroupUtils
    extends Object
    • Method Detail

      • getMoveDirection

        public static SelectionLayer.MoveDirectionEnum getMoveDirection​(int fromColumnPosition,
                                                                        int toColumnPosition)
        Calculates the move direction based on the from and to position.
        Parameters:
        fromColumnPosition - The column position from which a move is triggered.
        toColumnPosition - The column position to which a move is triggered.
        Returns:
        The direction of the triggered move operation.
      • isInTheSameGroup

        public static boolean isInTheSameGroup​(int fromColumnIndex,
                                               int toColumnIndex,
                                               ColumnGroupModel model)
      • isStaticOrFirstVisibleColumn

        @Deprecated
        public static boolean isStaticOrFirstVisibleColumn​(int columnIndex,
                                                           ILayer layer,
                                                           IUniqueIndexLayer underlyingLayer,
                                                           ColumnGroupModel model)
        Checks whether columnIndex is either a defined static column or (if not) the first visible column in the group containing group. This method provides downward compatibility for all group definitions without static columns. When no static columns are defined the first visible column will be used.
        Parameters:
        columnIndex - The column index to check.
        layer - unused
        underlyingLayer - The underlying layer.
        model - The column group model.
        Returns:
        TRUE if the given columnIndex is either a defined static column or (if not) the first visible column the it's group
      • isStaticOrFirstVisibleColumn

        public static boolean isStaticOrFirstVisibleColumn​(int columnIndex,
                                                           IUniqueIndexLayer underlyingLayer,
                                                           ColumnGroupModel model)
        Checks whether columnIndex is either a defined static column or (if not) the first visible column in the group containing group. This method provides downward compatibility for all group definitions without static columns. When no static columns are defined the first visible column will be used.
        Parameters:
        columnIndex - The column index to check.
        underlyingLayer - The underlying layer.
        model - The column group model.
        Returns:
        TRUE if the given columnIndex is either a defined static column or (if not) the first visible column the it's group
        Since:
        2.0
      • isFirstVisibleColumnIndexInGroup

        public static boolean isFirstVisibleColumnIndexInGroup​(int columnIndex,
                                                               IUniqueIndexLayer underlyingLayer,
                                                               ColumnGroupModel model)
        Parameters:
        columnIndex - The column index to check.
        underlyingLayer - The underlying layer.
        model - The column group model.
        Returns:
        true if the given column index is the first column in a column group.
        Since:
        2.0
      • isLastVisibleColumnIndexInGroup

        public static boolean isLastVisibleColumnIndexInGroup​(int columnIndex,
                                                              IUniqueIndexLayer underlyingLayer,
                                                              ColumnGroupModel model)
        Parameters:
        columnIndex - The column index to check.
        underlyingLayer - The underlying layer.
        model - The column group model.
        Returns:
        true if the given column index is the last column in a column group.
        Since:
        2.0
      • getVisibleIndexesToTheRight

        public static List<Integer> getVisibleIndexesToTheRight​(int columnIndex,
                                                                IUniqueIndexLayer underlyingLayer,
                                                                ColumnGroupModel model)
        Parameters:
        columnIndex - The index to check.
        underlyingLayer - The underlying layer to retrieve the visible columns to the right.
        model - The ColumnGroupModel to get the group from.
        Returns:
        The column indexes to the right of the given column index (inclusive)
        Since:
        2.0
      • isColumnIndexHiddenInUnderLyingLayer

        public static boolean isColumnIndexHiddenInUnderLyingLayer​(int columnIndex,
                                                                   IUniqueIndexLayer underlyingLayer)
        Parameters:
        columnIndex - The column index to check.
        underlyingLayer - The underlying layer to check against.
        Returns:
        true if the column is hidden in the underlying layer, false if not.
        Since:
        2.0
      • isColumnPositionHiddenInUnderLyingLayer

        @Deprecated
        public static boolean isColumnPositionHiddenInUnderLyingLayer​(int columnPosition,
                                                                      ILayer layer,
                                                                      IUniqueIndexLayer underlyingLayer)
        Parameters:
        columnPosition - The column position matching the underlying layer.
        layer - unused
        underlyingLayer - The underlying layer to check against.
        Returns:
        true if the column position is hidden in the underlying layer, false if not.
      • isColumnPositionHiddenInUnderLyingLayer

        public static boolean isColumnPositionHiddenInUnderLyingLayer​(int columnPosition,
                                                                      IUniqueIndexLayer underlyingLayer)
        Parameters:
        columnPosition - The column position matching the underlying layer.
        underlyingLayer - The underlying layer to check against.
        Returns:
        true if the column position is hidden in the underlying layer, false if not.
        Since:
        2.0
      • isRightEdgeOfAColumnGroup

        public static boolean isRightEdgeOfAColumnGroup​(ILayer natLayer,
                                                        int columnPosition,
                                                        int columnIndex,
                                                        ColumnGroupModel model)
        See ColumnGroupUtilsTest
        Returns:
        TRUE if the given column is the right most column in a group
      • isLeftEdgeOfAColumnGroup

        public static boolean isLeftEdgeOfAColumnGroup​(ILayer natLayer,
                                                       int columnPosition,
                                                       int columnIndex,
                                                       ColumnGroupModel model)
        See ColumnGroupUtilsTest
        Returns:
        TRUE if the given column is the left most column in a group
      • isBetweenTwoGroups

        public static boolean isBetweenTwoGroups​(ILayer natLayer,
                                                 int startX,
                                                 int endX,
                                                 ColumnGroupModel model)
        Returns:
        TRUE if there is a column group boundary between startX and endX
      • isInTheSameGroup

        public static boolean isInTheSameGroup​(ColumnGroupHeaderLayer layer,
                                               int level,
                                               int fromPosition,
                                               int toPosition)
        Checks if the two given column positions on the given layer belong to the same group at the given level on the given ColumnGroupHeaderLayer.
        Parameters:
        layer - The ColumnGroupHeaderLayer which is needed to perform the check against.
        level - The grouping level to check.
        fromPosition - The column position to check based on the position layer of the given ColumnGroupHeaderLayer.
        toPosition - The column position to check based on the position layer of the given ColumnGroupHeaderLayer.
        Returns:
        true if both given positions belong to the same group, false if not.
        Since:
        1.6
      • isBetweenTwoGroups

        public static boolean isBetweenTwoGroups​(ILayer natLayer,
                                                 int startX,
                                                 int endX,
                                                 ColumnGroupHeaderLayer layer,
                                                 int level)
        Checks if the column positions at the given x coordinates belong to the same group or not.
        Parameters:
        natLayer - The layer to which the given positions match. Typically the NatTable itself.
        startX - The x coordinate of the column that should be checked. Typically the drag start x coordinate.
        endX - The x coordinate of the column that should be checked. Typically the drag end x coordinate.
        layer - The ColumnGroupHeaderLayer which is needed to perform the check against.
        level - The grouping level to check.
        Returns:
        true if there is a column group boundary between startX and endX, false if both positions are in the same group.
        Since:
        1.6
      • isBetweenTwoGroups

        public static boolean isBetweenTwoGroups​(ColumnGroupHeaderLayer columnGroupHeaderLayer,
                                                 int toPosition,
                                                 boolean reorderToLeftEdge,
                                                 SelectionLayer.MoveDirectionEnum moveDirection)
        Checks if the edge of a column position is the left-most or the right most column on any level of a column group.
        Parameters:
        columnGroupHeaderLayer - The ColumnGroupHeaderLayer to handle the checks.
        toPosition - The position to check. Needs to be related to the positionLayer.
        reorderToLeftEdge - true if the check should be performed to the left edge or the right edge of the toPosition.
        moveDirection - The direction in which the reordering is performed.
        Returns:
        true if the destination would be between two groups, false if the destination would be inside a group.
        Since:
        1.6
      • isBetweenTwoGroups

        public static boolean isBetweenTwoGroups​(ColumnGroupHeaderLayer columnGroupHeaderLayer,
                                                 int level,
                                                 int toPosition,
                                                 boolean reorderToLeftEdge,
                                                 SelectionLayer.MoveDirectionEnum moveDirection)
        Checks if the edge of a column position for a specific grouping level is the left-most or the right most column of a column group.
        Parameters:
        columnGroupHeaderLayer - The ColumnGroupHeaderLayer to handle the checks.
        level - The grouping level on which the check should be performed.
        toPosition - The position to check. Needs to be related to the positionLayer.
        reorderToLeftEdge - true if the check should be performed to the left edge or the right edge of the toPosition.
        moveDirection - The direction in which the reordering is performed.
        Returns:
        true if the destination would be between two groups, false if the destination would be inside a group.
        Since:
        1.6
      • isReorderValid

        public static boolean isReorderValid​(ColumnGroupHeaderLayer columnGroupHeaderLayer,
                                             int fromPosition,
                                             int toPosition,
                                             boolean reorderToLeftEdge)
        Checks if a reorder operation is valid by checking the unbreakable states of the groups below the from and the to position.
        Parameters:
        columnGroupHeaderLayer - The ColumnGroupHeaderLayer to get the groups to check.
        fromPosition - The position from which a column should be reordered.
        toPosition - The position to which a column should be reordered.
        reorderToLeftEdge - true if the reorder should be performed to the left edge of the toPosition.
        Returns:
        true if the reorder operation would be valid, false if the either the source or the target belongs to an unbreakable group.
        Since:
        1.6
      • isReorderValid

        public static boolean isReorderValid​(ColumnGroupHeaderLayer columnGroupHeaderLayer,
                                             int level,
                                             int fromPosition,
                                             int toPosition,
                                             boolean reorderToLeftEdge)
        Checks if a reorder operation is valid by checking the unbreakable states of the groups below the from and the to position.
        Parameters:
        columnGroupHeaderLayer - The ColumnGroupHeaderLayer to get the groups to check.
        level - The grouping level that should be checked.
        fromPosition - The position from which a column should be reordered.
        toPosition - The position to which a column should be reordered.
        reorderToLeftEdge - true if the reorder should be performed to the left edge of the toPosition.
        Returns:
        true if the reorder operation would be valid, false if the either the source or the target belongs to an unbreakable group.
        Since:
        1.6
      • isGroupReordered

        public static boolean isGroupReordered​(GroupModel.Group fromGroup,
                                               int[] fromColumnPositions)
        Check if a complete group is reordered.
        Parameters:
        fromGroup - The group to check.
        fromColumnPositions - The column positions to check.
        Returns:
        true if the fromColumnPositions are all part of the given group.
        Since:
        1.6