Class CmsEditablePositionCalculator


  • public class CmsEditablePositionCalculator
    extends java.lang.Object
    This class is used to calculate positions for a set of direct edit buttons so that they don't overlap.

    Since:
    8.0.0
    • Constructor Detail

      • CmsEditablePositionCalculator

        public CmsEditablePositionCalculator​(java.util.Map<java.lang.String,​CmsPositionBean> positions)
        Creates a new instance.

        Parameters:
        positions - the map of original positions by element id (will not be altered)
    • Method Detail

      • calculatePositions

        public java.util.Map<java.lang.String,​CmsPositionBeancalculatePositions()
        Calculates non-overlapping positions for the button bars and returns them in a map with the element ids as keys.

        Returns:
        the map of non-overlapping positions
      • checkCollision

        protected boolean checkCollision()
        Checks whether a collision occurs and handle it if necessary.

        Returns:
        true if a collision occured
      • intersectIntervals

        protected boolean intersectIntervals​(int a1,
                                             int a2,
                                             int b1,
                                             int b2)
        Checks for intersection of two one-dimensional intervals.

        Parameters:
        a1 - the left edge of the first interval
        a2 - the right edge of the first interval
        b1 - the left edge of the second interval
        b2 - the right edge of the second interval
        Returns:
        true if the intervals intersect
      • intersectsHorizontally

        protected boolean intersectsHorizontally​(CmsPositionBean p1,
                                                 CmsPositionBean p2)
        Checks whether two positions intersect horizontally.

        Parameters:
        p1 - the first position
        p2 - the second position
        Returns:
        true if the positions intersect horizontally
      • intersectsVertically

        protected boolean intersectsVertically​(CmsPositionBean p1,
                                               CmsPositionBean p2)
        Checks whether two positions intersect vertically.

        Parameters:
        p1 - the first position
        p2 - the second position
        Returns:
        if the positions intersect vertically
      • sortByLeft

        protected void sortByLeft()
        Sorts the internal list of positions by their left edge.