Package cz.vutbr.fit.layout.api
Class AreaUtils
- java.lang.Object
-
- cz.vutbr.fit.layout.api.AreaUtils
-
public class AreaUtils extends Object
General purpose area analysis functions.- Author:
- burgetr
-
-
Constructor Summary
Constructors Constructor Description AreaUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanareasOverlap(Area a1, Area a2, double minPercentage)Tests whether an area overlaps with another areastatic booleanareasOverlap(Area a1, Collection<Area> areas2, double minPercentage)Tests a collection of areas for overlaps with another areastatic booleanareasOverlap(Collection<Area> areas1, Collection<Area> areas2, double minPercentage)Tests two collections of areas for overlaps.static voidfindAreasBeforeAfter(Area a, AreaTopology topology, List<ContentRect> destBefore, List<ContentRect> destAfter)Scans a list of areas and finds the areas that are befor or after a given area on the same line.static voidfindAreasBelow(Area a, AreaTopology topology, List<ContentRect> destBelow)static List<ContentRect>getChildrenAsContentRects(Area parent)Creates a list content rectangles from the child areas of a given area.static booleanintersectsWithAny(Area a, Collection<Area> col)Checks if a given area overlaps with any other area contained in a given collectionstatic booleanisAligned(Area a1, Area a2, AreaTopology topology)Checks if the given areas are aligned in row or column.static booleanisInSameColumn(Area a1, Area a2, AreaTopology topology)Checks if the given areas are in the same column.static booleanisLink(Area a)Checks if the given area has a target URL assigned (it acts as a link)static booleanisNeighbor(Area a1, Area a2)Checks if the given areas are in the same visual group (i.e.static booleanisOnSameLine(ContentRect a1, ContentRect a2)Checks if the given areas are on the same line.static booleanisOnSameLine(Rectangular r1, Rectangular r2)Checks if the given rectangles are on the same line.static floatstatRound(float value)
-
-
-
Method Detail
-
isNeighbor
public static boolean isNeighbor(Area a1, Area a2)
Checks if the given areas are in the same visual group (i.e. "are near each other").- Parameters:
a1-a2-- Returns:
-
isOnSameLine
public static boolean isOnSameLine(ContentRect a1, ContentRect a2)
Checks if the given areas are on the same line.- Parameters:
a1-a2-- Returns:
-
isOnSameLine
public static boolean isOnSameLine(Rectangular r1, Rectangular r2)
Checks if the given rectangles are on the same line.- Parameters:
r1-r2-- Returns:
-
isInSameColumn
public static boolean isInSameColumn(Area a1, Area a2, AreaTopology topology)
Checks if the given areas are in the same column.- Parameters:
a1-a2-- Returns:
-
isAligned
public static boolean isAligned(Area a1, Area a2, AreaTopology topology)
Checks if the given areas are aligned in row or column.- Parameters:
a1-a2-- Returns:
-
isLink
public static boolean isLink(Area a)
Checks if the given area has a target URL assigned (it acts as a link)- Parameters:
a-- Returns:
-
findAreasBeforeAfter
public static void findAreasBeforeAfter(Area a, AreaTopology topology, List<ContentRect> destBefore, List<ContentRect> destAfter)
Scans a list of areas and finds the areas that are befor or after a given area on the same line.- Parameters:
a- the given areatopology- the topology to be used for comparing the area positionsdestBefore- the destination collection of areas before the given areadestAfter- the destination collection of areas after the given area
-
findAreasBelow
public static void findAreasBelow(Area a, AreaTopology topology, List<ContentRect> destBelow)
-
intersectsWithAny
public static boolean intersectsWithAny(Area a, Collection<Area> col)
Checks if a given area overlaps with any other area contained in a given collection- Parameters:
a- the areacol- the collection of other areas for checking overlaps- Returns:
- true if the area a overlaps with any area from col
-
areasOverlap
public static boolean areasOverlap(Collection<Area> areas1, Collection<Area> areas2, double minPercentage)
Tests two collections of areas for overlaps.- Parameters:
areas1- the first area collectionareas2- the second area collectionminPercentage- the minimal percentage of the areas to be shared to say that the areas overlap- Returns:
truewhen some area from areas1 overlaps any area from areas2
-
areasOverlap
public static boolean areasOverlap(Area a1, Collection<Area> areas2, double minPercentage)
Tests a collection of areas for overlaps with another area- Parameters:
a1- the areaareas2- the area collectionminPercentage- the minimal percentage of the areas to be shared to say that the areas overlap- Returns:
truewhen some area from areas2 overlaps a1
-
areasOverlap
public static boolean areasOverlap(Area a1, Area a2, double minPercentage)
Tests whether an area overlaps with another area- Parameters:
a1- the first areaa2- the second areaminPercentage- the minimal percentage of the areas to be shared to say that the areas overlap- Returns:
truewhen a2 overlaps a1
-
getChildrenAsContentRects
public static List<ContentRect> getChildrenAsContentRects(Area parent)
Creates a list content rectangles from the child areas of a given area.- Parameters:
parent- the parent area- Returns:
- the list of its child areas
-
statRound
public static float statRound(float value)
-
-