Class CmsEditablePositionCalculator
java.lang.Object
org.opencms.ade.editprovider.client.CmsEditablePositionCalculator
This class is used to calculate positions for a set of direct edit buttons so that
they don't overlap.
- Since:
- 8.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
A comparator class which compares position beans by their left edge. -
Constructor Summary
ConstructorDescriptionCmsEditablePositionCalculator
(Map<String, CmsPositionBean> positions) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionCalculates non-overlapping positions for the button bars and returns them in a map with the element ids as keys.protected boolean
Checks whether a collision occurs and handle it if necessary.protected void
Handles a collision by moving the lower position down.protected boolean
intersectIntervals
(int a1, int a2, int b1, int b2) Checks for intersection of two one-dimensional intervals.protected boolean
Checks whether two positions intersect horizontally.protected boolean
Checks whether two positions intersect vertically.protected void
Sorts the internal list of positions by their left edge.
-
Constructor Details
-
CmsEditablePositionCalculator
Creates a new instance.- Parameters:
positions
- the map of original positions by element id (will not be altered)
-
-
Method Details
-
calculatePositions
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
Checks whether a collision occurs and handle it if necessary.- Returns:
- true if a collision occured
-
handleCollision
Handles a collision by moving the lower position down.- Parameters:
p1
- the first positionp2
- the second position
-
intersectIntervals
Checks for intersection of two one-dimensional intervals.- Parameters:
a1
- the left edge of the first intervala2
- the right edge of the first intervalb1
- the left edge of the second intervalb2
- the right edge of the second interval- Returns:
- true if the intervals intersect
-
intersectsHorizontally
Checks whether two positions intersect horizontally.- Parameters:
p1
- the first positionp2
- the second position- Returns:
- true if the positions intersect horizontally
-
intersectsVertically
Checks whether two positions intersect vertically.- Parameters:
p1
- the first positionp2
- the second position- Returns:
- if the positions intersect vertically
-
sortByLeft
Sorts the internal list of positions by their left edge.
-