/** * Get the intersection of the given region with the screenshot. * * @param region The region to intersect. * @param coordinatesType The coordinates type of {@code region}. * @return The intersected region, in {@code coordinatesType} coordinates. */ protected Region getIntersectedRegion(Region region, CoordinatesType coordinatesType) { return getIntersectedRegion(region, coordinatesType, coordinatesType); }
control = lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);
control = lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);
control = lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);
private Region getRegionInScreenshot(Region region, BufferedImage image, double pixelRatio) { if (region.isSizeEmpty()) { return region; } logger.verbose("Creating screenshot object..."); // We need the screenshot to be able to convert the region to screenshot coordinates. EyesScreenshot screenshot = screenshotFactory.makeScreenshot(image); logger.verbose("Getting region in screenshot..."); // Region regionInScreenshot = screenshot.convertRegionLocation(regionProvider.getRegion(), regionProvider.getCoordinatesType(), CoordinatesType.SCREENSHOT_AS_IS); Region regionInScreenshot = screenshot.getIntersectedRegion(region, CoordinatesType.SCREENSHOT_AS_IS); logger.verbose("Region in screenshot: " + regionInScreenshot); regionInScreenshot = regionInScreenshot.scale(pixelRatio); logger.verbose("Scaled region: " + regionInScreenshot); regionInScreenshot = regionPositionCompensation.compensateRegionPosition(regionInScreenshot, pixelRatio); // Handling a specific case where the region is actually larger than // the screenshot (e.g., when body width/height are set to 100%, and // an internal div is set to value which is larger than the viewport). regionInScreenshot.intersect(new Region(0, 0, image.getWidth(), image.getHeight())); logger.verbose("Region after intersect: " + regionInScreenshot); return regionInScreenshot; } }
elementRegion = lastScreenshot.getIntersectedRegion (elementRegion, CoordinatesType.CONTEXT_RELATIVE);
lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);
lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);
lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);