Class CmsEditablePositionCalculator
- java.lang.Object
-
- org.opencms.ade.editprovider.client.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
CmsEditablePositionCalculator.LeftComparator
A comparator class which compares position beans by their left edge.
-
Constructor Summary
Constructors Constructor Description CmsEditablePositionCalculator(java.util.Map<java.lang.String,CmsPositionBean> positions)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,CmsPositionBean>
calculatePositions()
Calculates non-overlapping positions for the button bars and returns them in a map with the element ids as keys.protected boolean
checkCollision()
Checks whether a collision occurs and handle it if necessary.protected void
handleCollision(CmsPositionBean p1, CmsPositionBean p2)
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
intersectsHorizontally(CmsPositionBean p1, CmsPositionBean p2)
Checks whether two positions intersect horizontally.protected boolean
intersectsVertically(CmsPositionBean p1, CmsPositionBean p2)
Checks whether two positions intersect vertically.protected void
sortByLeft()
Sorts the internal list of positions by their left edge.
-
-
-
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,CmsPositionBean> 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
protected boolean checkCollision()
Checks whether a collision occurs and handle it if necessary.- Returns:
- true if a collision occured
-
handleCollision
protected void handleCollision(CmsPositionBean p1, CmsPositionBean p2)
Handles a collision by moving the lower position down.- Parameters:
p1
- the first positionp2
- the second position
-
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 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
protected boolean intersectsHorizontally(CmsPositionBean p1, CmsPositionBean p2)
Checks whether two positions intersect horizontally.- Parameters:
p1
- the first positionp2
- 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 positionp2
- the second position- Returns:
- if the positions intersect vertically
-
sortByLeft
protected void sortByLeft()
Sorts the internal list of positions by their left edge.
-
-