Class AreaUtils


  • public class AreaUtils
    extends Object
    General purpose area analysis functions.
    Author:
    burgetr
    • Constructor Detail

      • AreaUtils

        public AreaUtils()
    • 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 area
        topology - the topology to be used for comparing the area positions
        destBefore - the destination collection of areas before the given area
        destAfter - the destination collection of areas after the given area
      • 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 area
        col - 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 collection
        areas2 - the second area collection
        minPercentage - the minimal percentage of the areas to be shared to say that the areas overlap
        Returns:
        true when 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 area
        areas2 - the area collection
        minPercentage - the minimal percentage of the areas to be shared to say that the areas overlap
        Returns:
        true when 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 area
        a2 - the second area
        minPercentage - the minimal percentage of the areas to be shared to say that the areas overlap
        Returns:
        true when 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)