Package com.applitools.eyes
Class Region
- java.lang.Object
-
- com.applitools.eyes.Region
-
-
Constructor Summary
Constructors Constructor Description Region(int left, int top, int width, int height)Instantiates a new Region.Region(int left, int top, int width, int height, CoordinatesType coordinatesType)Instantiates a new Region.Region(IRegion other)Instantiates a new Region.Region(Location location, RectangleSize size)Instantiates a new Region.Region(Location location, RectangleSize size, CoordinatesType coordinatesType)Instantiates a new Region.Region(Rectangle rectangle)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RegionaddPadding(Padding padding)booleancontains(Location location)Check if a specified location is contained within this region.booleancontains(Region other)Check if a region is contained within the current region.booleanequals(Object obj)RegionexpandToContain(Region region)Expand to contain region.intgetArea()intgetBottom()CoordinatesTypegetCoordinatesType()Gets coordinates type.intgetHeight()Gets height.RegiongetIntersected(Region other)intgetLeft()Gets left.LocationgetLocation()Gets location.LocationgetMiddleOffset()Gets middle offset.LocationgetNegativeLocation()Gets negative location.StringgetRegionId()intgetRight()RectangleSizegetSize()Gets size.Iterable<Region>getSubRegions(RectangleSize subRegionSize)Gets sub regions.Iterable<Region>getSubRegions(RectangleSize subRegionSize, boolean isFixedSize)Returns a list of sub-regions which compose the current region.SubregionForStitching[]getSubRegions(RectangleSize maxSubRegionSize, int logicalOverlap, double l2pScaleRatio, Rectangle physicalRectInScreenshot, Logger logger)intgetTop()Gets top.intgetWidth()Gets width.inthashCode()voidintersect(Region other)Replaces this region with the intersection of itself andotherbooleanisEmpty()Is empty boolean.booleanisIntersected(Region other)Check if a region is intersected with the current region.booleanisSizeEmpty()Is size empty boolean.protected voidmakeEmpty()Make empty.Regionoffset(int dx, int dy)Get an offset region.Regionoffset(Location location)Get an offset region.RegionregionId(String regionId)Regionscale(double scaleRatio)Get a region which is a scaled version of the current region.voidsetCoordinatesType(CoordinatesType value)Sets coordinates type.voidsetHeight(int value)Sets height.voidsetLeft(int value)Sets left.voidsetLocation(Location location)Set the (top,left) position of the current regionvoidsetSize(RectangleSize size)Sets size.voidsetTop(int value)Sets top.voidsetWidth(int value)Sets width.voidsetX(int x)voidsetY(int y)StringtoString()
-
-
-
Field Detail
-
EMPTY
public static final Region EMPTY
The constant EMPTY.
-
-
Constructor Detail
-
Region
public Region(int left, int top, int width, int height)Instantiates a new Region.- Parameters:
left- the lefttop- the topwidth- the widthheight- the height
-
Region
public Region(int left, int top, int width, int height, CoordinatesType coordinatesType)Instantiates a new Region.- Parameters:
left- the lefttop- the topwidth- the widthheight- the heightcoordinatesType- the coordinates type
-
Region
public Region(Rectangle rectangle)
-
Region
public Region(Location location, RectangleSize size)
Instantiates a new Region.- Parameters:
location- the locationsize- the size
-
Region
public Region(Location location, RectangleSize size, CoordinatesType coordinatesType)
Instantiates a new Region.- Parameters:
location- the locationsize- the sizecoordinatesType- the coordinates type
-
Region
public Region(IRegion other)
Instantiates a new Region.- Parameters:
other- the other
-
-
Method Detail
-
makeEmpty
protected void makeEmpty()
Make empty.
-
isEmpty
public boolean isEmpty()
Is empty boolean.- Returns:
- true if the region is empty, false otherwise.
-
isSizeEmpty
public boolean isSizeEmpty()
Is size empty boolean.- Returns:
- true if the region's size is 0, false otherwise.
-
getLocation
public Location getLocation()
Gets location.- Specified by:
getLocationin interfaceIRegion- Returns:
- The (left, top) position of the current region.
-
getNegativeLocation
public Location getNegativeLocation()
Gets negative location.- Returns:
- The (-left, -top) position of the current region.
-
offset
public Region offset(int dx, int dy)
Get an offset region.
-
offset
public Region offset(Location location)
Get an offset region.- Parameters:
location- the amount by which to offset.- Returns:
- A region with an offset location.
-
scale
public Region scale(double scaleRatio)
Get a region which is a scaled version of the current region. IMPORTANT: This also scales the LOCATION(!!) of the region (not just its size).- Parameters:
scaleRatio- The ratio by which to scale the region.- Returns:
- A new region which is a scaled version of the current region.
-
getSize
public RectangleSize getSize()
Gets size.
-
getCoordinatesType
public CoordinatesType getCoordinatesType()
Gets coordinates type.- Specified by:
getCoordinatesTypein interfaceIRegion- Returns:
- The region's coordinate type.
-
setCoordinatesType
public void setCoordinatesType(CoordinatesType value)
Sets coordinates type.- Parameters:
value- the value
-
setSize
public void setSize(RectangleSize size)
Sets size.- Parameters:
size- The updated size of the region.
-
setLocation
public void setLocation(Location location)
Set the (top,left) position of the current region- Parameters:
location- The (top,left) position to set.
-
getSubRegions
public Iterable<Region> getSubRegions(RectangleSize subRegionSize, boolean isFixedSize)
Returns a list of sub-regions which compose the current region.- Parameters:
subRegionSize- The default sub-region size to use.isFixedSize- Iffalse, then sub-regions might have a size which is smaller thensubRegionSize(thus there will be no overlap of regions). Otherwise, all sub-regions will have the same size, but sub-regions might overlap.- Returns:
- The sub-regions composing the current region. If
subRegionSizeis equal or greater than the current region, only a single region is returned.
-
getSubRegions
public Iterable<Region> getSubRegions(RectangleSize subRegionSize)
Gets sub regions.- Parameters:
subRegionSize- the sub region size- Returns:
- the sub regions
- See Also:
#getSubRegions(RectangleSize, boolean). defaults to .
-
contains
public boolean contains(Region other)
Check if a region is contained within the current region.- Parameters:
other- The region to check if it is contained within the current region.- Returns:
- True if
otheris contained within the current region, false otherwise.
-
contains
public boolean contains(Location location)
Check if a specified location is contained within this region.- Parameters:
location- The location to test.- Returns:
- True if the location is contained within this region, false otherwise.
-
isIntersected
public boolean isIntersected(Region other)
Check if a region is intersected with the current region.- Parameters:
other- The region to check intersection with.- Returns:
- True if the regions are intersected, false otherwise.
-
intersect
public void intersect(Region other)
Replaces this region with the intersection of itself andother- Parameters:
other- The region with which to intersect.
-
getLeft
public int getLeft()
Gets left.
-
getWidth
public int getWidth()
Gets width.
-
getHeight
public int getHeight()
Gets height.
-
setLeft
public void setLeft(int value)
Sets left.- Parameters:
value- the value
-
setTop
public void setTop(int value)
Sets top.- Parameters:
value- the value
-
getBottom
public int getBottom()
-
getRight
public int getRight()
-
setWidth
public void setWidth(int value)
Sets width.- Parameters:
value- the value
-
setHeight
public void setHeight(int value)
Sets height.- Parameters:
value- the value
-
getMiddleOffset
public Location getMiddleOffset()
Gets middle offset.- Returns:
- the middle offset
-
expandToContain
public Region expandToContain(Region region)
Expand to contain region.- Parameters:
region- the region- Returns:
- the region
-
setX
public void setX(int x)
-
setY
public void setY(int y)
-
getSubRegions
public SubregionForStitching[] getSubRegions(RectangleSize maxSubRegionSize, int logicalOverlap, double l2pScaleRatio, Rectangle physicalRectInScreenshot, Logger logger)
-
getRegionId
public String getRegionId()
-
-