/** * Check if a region is contained within the current region. * @param other The region to check if it is contained within the current * region. * @return True if {@code other} is contained within the current region, * false otherwise. */ @SuppressWarnings("UnusedDeclaration") public boolean contains(Region other) { int right = left + width; int otherRight = other.getLeft() + other.getWidth(); int bottom = top + height; int otherBottom = other.getTop() + other.getHeight(); return top <= other.getTop() && left <= other.getLeft() && bottom >= otherBottom && right >= otherRight; }
/** * Check if a region is contained within the current region. * @param other The region to check if it is contained within the current * region. * @return True if {@code other} is contained within the current region, * false otherwise. */ @SuppressWarnings("UnusedDeclaration") public boolean contains(Region other) { int right = left + width; int otherRight = other.getLeft() + other.getWidth(); int bottom = top + height; int otherBottom = other.getTop() + other.getHeight(); return top <= other.getTop() && left <= other.getLeft() && bottom >= otherBottom && right >= otherRight; }
/** * Check if a region is contained within the current region. * @param other The region to check if it is contained within the current * region. * @return True if {@code other} is contained within the current region, * false otherwise. */ @SuppressWarnings("UnusedDeclaration") public boolean contains(Region other) { int right = left + width; int otherRight = other.getLeft() + other.getWidth(); int bottom = top + height; int otherBottom = other.getTop() + other.getHeight(); return top <= other.getTop() && left <= other.getLeft() && bottom >= otherBottom && right >= otherRight; }
private void saveDebugScreenshotPart(BufferedImage image, Region region, String name) { String suffix = String.format("part-%s-%d_%d_%dx%d", name, region.getLeft(), region.getTop(), region.getWidth(), region.getHeight()); debugScreenshotsProvider.save(image, suffix); }
protected void makeEmpty() { left = EMPTY.getLeft(); top = EMPTY.getTop(); width = EMPTY.getWidth(); height = EMPTY.getHeight(); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof Region)) { return false; } Region other = (Region) obj; return (this.getLeft() == other.getLeft()) && (this.getTop() == other.getTop()) && (this.getWidth() == other.getWidth()) && (this.getHeight() == other.getHeight()); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof Region)) { return false; } Region other = (Region) obj; return (this.getLeft() == other.getLeft()) && (this.getTop() == other.getTop()) && (this.getWidth() == other.getWidth()) && (this.getHeight() == other.getHeight()); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof Region)) { return false; } Region other = (Region) obj; return (this.getLeft() == other.getLeft()) && (this.getTop() == other.getTop()) && (this.getWidth() == other.getWidth()) && (this.getHeight() == other.getHeight()); }
/** * Check if a region is intersected with the current region. * @param other The region to check intersection with. * @return True if the regions are intersected, false otherwise. */ public boolean isIntersected(Region other) { int right = left + width; int bottom = top + height; int otherLeft = other.getLeft(); int otherTop = other.getTop(); int otherRight = otherLeft + other.getWidth(); int otherBottom = otherTop + other.getHeight(); return (((left <= otherLeft && otherLeft <= right) || (otherLeft <= left && left <= otherRight)) && ((top <= otherTop && otherTop <= bottom) || (otherTop <= top && top <= otherBottom))); }
/** * Check if a region is intersected with the current region. * @param other The region to check intersection with. * @return True if the regions are intersected, false otherwise. */ public boolean isIntersected(Region other) { int right = left + width; int bottom = top + height; int otherLeft = other.getLeft(); int otherTop = other.getTop(); int otherRight = otherLeft + other.getWidth(); int otherBottom = otherTop + other.getHeight(); return (((left <= otherLeft && otherLeft <= right) || (otherLeft <= left && left <= otherRight)) && ((top <= otherTop && otherTop <= bottom) || (otherTop <= top && top <= otherBottom))); }
/** * Check if a region is intersected with the current region. * @param other The region to check intersection with. * @return True if the regions are intersected, false otherwise. */ @SuppressWarnings("WeakerAccess") public boolean isIntersected(Region other) { int right = left + width; int bottom = top + height; int otherLeft = other.getLeft(); int otherTop = other.getTop(); int otherRight = otherLeft + other.getWidth(); int otherBottom = otherTop + other.getHeight(); return (((left <= otherLeft && otherLeft <= right) || (otherLeft <= left && left <= otherRight)) && ((top <= otherTop && otherTop <= bottom) || (otherTop <= top && top <= otherBottom))); }
protected void makeEmpty() { left = EMPTY.getLeft(); top = EMPTY.getTop(); width = EMPTY.getWidth(); height = EMPTY.getHeight(); this.coordinatesType = EMPTY.getCoordinatesType(); }
protected void makeEmpty() { left = EMPTY.getLeft(); top = EMPTY.getTop(); width = EMPTY.getWidth(); height = EMPTY.getHeight(); this.coordinatesType = EMPTY.getCoordinatesType(); }
public Region(Region other) { ArgumentGuard.notNull(other, "other"); left = other.getLeft(); top = other.getTop(); width = other.getWidth(); height = other.getHeight(); }
public Region(Region other) { ArgumentGuard.notNull(other, "other"); left = other.getLeft(); top = other.getTop(); width = other.getWidth(); height = other.getHeight(); coordinatesType = other.getCoordinatesType(); }
public Region(Region other) { ArgumentGuard.notNull(other, "other"); left = other.getLeft(); top = other.getTop(); width = other.getWidth(); height = other.getHeight(); coordinatesType = other.getCoordinatesType(); }
/** * Get a copy of the part of the image given by region. * * @param image The image from which to get the part. * @param region The region which should be copied from the image. * @return The part of the image. */ public static BufferedImage getImagePart(BufferedImage image, Region region) { ArgumentGuard.notNull(image, "image"); // Get the clipped region as a BufferedImage. BufferedImage imagePart = image.getSubimage( region.getLeft(), region.getTop(), region.getWidth(), region.getHeight()); // IMPORTANT We copy the image this way because just using getSubImage // created a later problem (maybe an actual Java bug): the pixels // weren't what they were supposed to be. byte[] imagePartBytes = encodeAsPng(imagePart); return imageFromBytes(imagePartBytes); }