@Override public Region getRegion() { return new Region(targetRegion.getLocation(), targetRegion.getSize(), CoordinatesType.CONTEXT_RELATIVE); } }, name, false, checkSettings);
/** * Get an offset region. * @param dx The X axis offset. * @param dy The Y axis offset. * @return A region with an offset location. */ public Region offset(int dx, int dy) { return new Region(getLocation().offset(dx, dy), getSize(), getCoordinatesType()); }
/** * Get an offset region. * @param dx The X axis offset. * @param dy The Y axis offset. * @return A region with an offset location. */ public Region offset(int dx, int dy) { return new Region(getLocation().offset(dx, dy), getSize(), getCoordinatesType()); }
/** * 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). * @param scaleRatio The ratio by which to scale the region. * @return A new region which is a scaled version of the current region. */ public Region scale(double scaleRatio) { return new Region(getLocation().scale(scaleRatio), getSize().scale(scaleRatio), getCoordinatesType()); }
/** * 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). * @param scaleRatio The ratio by which to scale the region. * @return A new region which is a scaled version of the current region. */ public Region scale(double scaleRatio) { return new Region(getLocation().scale(scaleRatio), getSize().scale(scaleRatio), getCoordinatesType()); }
public EyesWebDriverScreenshot getSubScreenshotForRegion(Region region, boolean throwIfClipped) { logger.verbose(String.format("getSubScreenshot([%s], %b)", region, throwIfClipped)); ArgumentGuard.notNull(region, "region"); // We calculate intersection based on as-is coordinates. Region asIsSubScreenshotRegion = getIntersectedRegion(region, CoordinatesType.SCREENSHOT_AS_IS); if (asIsSubScreenshotRegion.isEmpty() || (throwIfClipped && !asIsSubScreenshotRegion.getSize().equals( region.getSize()))) { throw new OutOfBoundsException(String.format( "Region [%s] is out of screenshot bounds [%s]", region, frameWindow)); } BufferedImage subScreenshotImage = ImageUtils.getImagePart(image, asIsSubScreenshotRegion); EyesWebDriverScreenshot result = new EyesWebDriverScreenshot(logger, driver, subScreenshotImage, new Region(region.getLocation(), new RectangleSize(subScreenshotImage.getWidth(), subScreenshotImage.getHeight()))); logger.verbose("Done!"); return result; }
cursorInScreenshot.offset(control.getLocation()); try { cursorInScreenshot = lastScreenshot.getLocationInScreenshot( Location l = controlScreenshotIntersect.getLocation(); cursorInScreenshot.offset(-l.getX(), -l.getY());
cursorInScreenshot.offset(control.getLocation()); try { cursorInScreenshot = lastScreenshot.getLocationInScreenshot( Location l = controlScreenshotIntersect.getLocation(); cursorInScreenshot.offset(-l.getX(), -l.getY());
cursorInScreenshot.offset(control.getLocation()); try { cursorInScreenshot = lastScreenshot.getLocationInScreenshot( Location l = controlScreenshotIntersect.getLocation(); cursorInScreenshot.offset(-l.getX(), -l.getY());
/** * Get sub screenshot. * @param region The region for which we should get the sub screenshot. * @param throwIfClipped Throw an EyesException if the region is not fully contained in the screenshot. * @return Sub screenshot. */ @Override public EyesScreenshot getSubScreenshot(Region region, boolean throwIfClipped) { ArgumentGuard.notNull(region, "region"); // We want to get the sub-screenshot in as-is coordinates type. Region subScreenshotRegion = getIntersectedRegion(region, CoordinatesType.SCREENSHOT_AS_IS); if (subScreenshotRegion.isSizeEmpty() || (throwIfClipped && !subScreenshotRegion.getSize().equals(region.getSize()))) { throw new OutOfBoundsException(String.format( "Region [%s] is out of screenshot bounds [%s]", region, bounds)); } BufferedImage subScreenshotImage = ImageUtils.getImagePart(image, subScreenshotRegion); // Notice that we need the bounds-relative coordinates as parameter // for new sub-screenshot. Region relativeSubScreenshotRegion = convertRegionLocation(subScreenshotRegion, CoordinatesType.SCREENSHOT_AS_IS, CoordinatesType.CONTEXT_RELATIVE); return new EyesImagesScreenshot(logger, subScreenshotImage, relativeSubScreenshotRegion.getLocation()); }
@Override public EyesScreenshot getSubScreenshot(Region region, CoordinatesType coordinatesType, boolean throwIfClipped) { ArgumentGuard.notNull(region, "region"); ArgumentGuard.notNull(coordinatesType, "coordinatesType"); // We want to get the sub-screenshot in as-is coordinates type. Region subScreenshotRegion = getIntersectedRegion(region, coordinatesType, CoordinatesType.SCREENSHOT_AS_IS); if (subScreenshotRegion.isEmpty() || (throwIfClipped && !subScreenshotRegion.getSize().equals(region.getSize()))) { throw new OutOfBoundsException(String.format( "Region [%s, (%s)] is out of screenshot bounds [%s]", region, coordinatesType, bounds)); } BufferedImage subScreenshotImage = ImageUtils.getImagePart(image, subScreenshotRegion); // Notice that we need the bounds-relative coordinates as parameter // for new sub-screenshot. Region relativeSubScreenshotRegion = convertRegionLocation(subScreenshotRegion, CoordinatesType.SCREENSHOT_AS_IS, CoordinatesType.CONTEXT_RELATIVE); return new EyesImagesScreenshot(subScreenshotImage, relativeSubScreenshotRegion.getLocation()); }
/** * Converts a region's location coordinates with the {@code from} * coordinates type to the {@code to} coordinates type. * * @param region The region which location's coordinates needs to be * converted. * @param from The current coordinates type for {@code region}. * @param to The target coordinates type for {@code region}. * @return A new region which is the transformation of {@code region} to * the {@code to} coordinates type. */ protected Region convertRegionLocation(Region region, CoordinatesType from, CoordinatesType to) { ArgumentGuard.notNull(region, "region"); if (region.isEmpty()) { return new Region(region); } ArgumentGuard.notNull(from, "from"); ArgumentGuard.notNull(to, "to"); Location updatedLocation = convertLocation(region.getLocation(), from, to); return new Region(updatedLocation, region.getSize()); } }
convertLocation(intersectedRegion.getLocation(), CoordinatesType.CONTEXT_RELATIVE, resultCoordinatesType));
convertLocation(intersectedRegion.getLocation(), CoordinatesType.CONTEXT_RELATIVE, resultCoordinatesType));
/** * Converts a region's location coordinates with the {@code from} * coordinates type to the {@code to} coordinates type. * @param region The region which location's coordinates needs to be converted. * @param from The current coordinates type for {@code region}. * @param to The target coordinates type for {@code region}. * @return A new region which is the transformation of {@code region} to * the {@code to} coordinates type. */ public Region convertRegionLocation(Region region, CoordinatesType from, CoordinatesType to) { ArgumentGuard.notNull(region, "region"); if (region.isSizeEmpty()) { return new Region(region); } ArgumentGuard.notNull(from, "from"); ArgumentGuard.notNull(to, "to"); Location originalLocation = region.getLocation(); logger.verbose("original location: " + originalLocation); Location updatedLocation = convertLocation(originalLocation, from, to); logger.verbose("updated location: " + updatedLocation); return new Region(updatedLocation, region.getSize()); } }
/** * Converts a region's location coordinates with the {@code from} * coordinates type to the {@code to} coordinates type. * @param region The region which location's coordinates needs to be converted. * @param from The current coordinates type for {@code region}. * @param to The target coordinates type for {@code region}. * @return A new region which is the transformation of {@code region} to * the {@code to} coordinates type. */ public Region convertRegionLocation(Region region, CoordinatesType from, CoordinatesType to) { ArgumentGuard.notNull(region, "region"); if (region.isSizeEmpty()) { return new Region(region); } ArgumentGuard.notNull(from, "from"); ArgumentGuard.notNull(to, "to"); Location originalLocation = region.getLocation(); logger.verbose("original location: " + originalLocation); Location updatedLocation = convertLocation(originalLocation, from, to); logger.verbose("updated location: " + updatedLocation); return new Region(updatedLocation, region.getSize()); } }
Location originPosition = positionProvider.setPosition(partRegion.getLocation()); Location targetPosition = originPosition.offset(-fullArea.getLeft(), -fullArea.getTop()); logger.verbose(String.format("Origin Position is set to %s", originPosition));