@Override public Rectangle getBounds() { final Rectangle bounds = super.getBounds(); final Rectangle parent = getParentBounds(client.getWidget(widgetInfo)); if (parent.isEmpty()) { return bounds; } int x = bounds.x; int y = bounds.y; x = Math.max(parent.x, x); y = Math.max(parent.y, y); x = Math.min((int)parent.getMaxX() - bounds.width, x); y = Math.min((int)parent.getMaxY() - bounds.height, y); bounds.setLocation(x, y); return bounds; }
@Override public Dimension render(Graphics2D graphics) { final Widget widget = client.getWidget(widgetInfo); final Rectangle bounds = super.getBounds(); final Rectangle parent = getParentBounds(widget); if (parent.isEmpty()) { return null; } int x = bounds.x; int y = bounds.y; x = Math.max(parent.x, x); y = Math.max(parent.y, y); x = Math.min((int)parent.getMaxX() - bounds.width, x); y = Math.min((int)parent.getMaxY() - bounds.height, y); bounds.setLocation(x, y); widget.setOriginalX(0); widget.setOriginalY(0); widget.setRelativeX(bounds.x - parent.x); widget.setRelativeY(bounds.y - parent.y); return new Dimension(widget.getWidth(), widget.getHeight()); }
final Rectangle bounds = overlay.getBounds(); if (bounds.isEmpty())
private void doSetScreenArea(Rectangle screenArea) { if (screenArea == null || screenArea.isEmpty()) { this.screenArea = new Rectangle(); } else { this.screenArea = new Rectangle(screenArea); } setTransforms(false); }
/** * Checks if the view port bounds are empty (undefined). This will be {@code true} if either or * both of the world bounds and screen bounds are empty. * * @return {@code true} if empty */ public boolean isEmpty() { lock.readLock().lock(); try { return screenArea.isEmpty() || bounds.isEmpty(); } finally { lock.readLock().unlock(); } }
public boolean add(Rectangle rect) { if (bound.isEmpty()) { assert (rectList.size() == 0); bound.x = rect.x; bound.y = rect.y; bound.width = rect.width; bound.height = rect.height; rectList.add(rect); return true; } Rectangle rcInflated = new Rectangle(rect.x - 1, rect.y - 1, rect.width + 2, rect.height + 2); if (!bound.intersects(rcInflated)) return false; for (Rectangle r : rectList) { if (r.intersects(rcInflated)) { if (!r.contains(rect)) { enlargeBound(rect); rectList.add(rect); return true; } } } return false; }
if (!(r == null || r.isEmpty())) { int dx = 0; int dy = 0;
/** * Sets image to be processed. * * @param xsize width of image * @param ysize height of image * @param buf pixel data * @param rect the bounding rectangle defines the region of the image to be * recognized. A rectangle of zero dimension or <code>null</code> indicates * the whole image. * @param bpp bits per pixel, represents the bit depth of the image, with 1 * for binary bitmap, 8 for gray, and 24 for color RGB. */ protected void setImage(int xsize, int ysize, ByteBuffer buf, Rectangle rect, int bpp) { int bytespp = bpp / 8; int bytespl = (int) Math.ceil(xsize * bpp / 8.0); TessBaseAPISetImage(handle, buf, xsize, ysize, bytespp, bytespl); if (rect != null && !rect.isEmpty()) { TessBaseAPISetRectangle(handle, rect.x, rect.y, rect.width, rect.height); } }
/** * Sets image to be processed. * * @param xsize width of image * @param ysize height of image * @param buf pixel data * @param rect the bounding rectangle defines the region of the image to be * recognized. A rectangle of zero dimension or <code>null</code> indicates * the whole image. * @param bpp bits per pixel, represents the bit depth of the image, with 1 * for binary bitmap, 8 for gray, and 24 for color RGB. */ protected void setImage(int xsize, int ysize, ByteBuffer buf, Rectangle rect, int bpp) { int bytespp = bpp / 8; int bytespl = (int) Math.ceil(xsize * bpp / 8.0); api.TessBaseAPISetImage(handle, buf, xsize, ysize, bytespp, bytespl); if (rect != null && !rect.isEmpty()) { api.TessBaseAPISetRectangle(handle, rect.x, rect.y, rect.width, rect.height); } }
/** {@inheritDoc} */ @Override public void moveImage(int dx, int dy) { drawingLock.lock(); try { if (isShowing() && !getVisibleRect().isEmpty()) { imageOrigin.translate(dx, dy); baseImageMoved.set(true); repaint(); onImageMoved(); } } finally { drawingLock.unlock(); } }
if (screenArea.isEmpty()) { screenToWorld = worldToScreen = null; hasCenteringTransforms = false;
/** * Checks that the provided <code>dimensions</code> when intersected with the source region used * by the provided {@link ImageReadParam} instance does not result in an empty {@link * Rectangle}. * * <p>Input parameters cannot be null. * * @param readParameters an instance of {@link ImageReadParam} for which we want to check the * source region element. * @param dimensions an instance of {@link Rectangle} to use for the check. * @return <code>true</code> if the intersection is not empty, <code>false</code> otherwise. */ public static final boolean checkEmptySourceRegion( final ImageReadParam readParameters, final Rectangle dimensions) { Utilities.ensureNonNull("readDimension", dimensions); Utilities.ensureNonNull("readP", readParameters); final Rectangle sourceRegion = readParameters.getSourceRegion(); Rectangle.intersect(sourceRegion, dimensions, sourceRegion); if (sourceRegion.isEmpty()) return true; readParameters.setSourceRegion(sourceRegion); return false; }
private boolean renewCachedCoverage(DirectPosition centrePos) { final Rectangle queryRect = createQueryGridEnvelope(centrePos); if (queryRect.isEmpty()) { return false; } final GridCoverage2DReader reader = sourceRef.get(); GeneralParameterValue parameter = new Parameter( AbstractGridFormat.READ_GRIDGEOMETRY2D, new GridGeometry2D( new GridEnvelope2D(queryRect), reader.getOriginalGridToWorld(PixelInCell.CELL_CENTER), reader.getCoordinateReferenceSystem())); try { cachedCoverage = (GridCoverage2D) reader.read(new GeneralParameterValue[] {parameter}); return cachedCoverage != null; } catch (Exception ex) { throw new RuntimeException(ex); } }
/** * Checks that the provided {@code dimensions} when intersected with the source region used by * the provided {@link ImageReadParam} instance does not result in an empty {@link Rectangle}. * Finally, in case the region intersection is not empty, set it as new source region for the * provided {@link ImageReadParam}. * * <p>Input parameters cannot be null. * * @param readParameters an instance of {@link ImageReadParam} for which we want to check the * source region element. * @param dimensions an instance of {@link Rectangle} to use for the check. * @return {@code true} if the intersection is not empty, {@code false} otherwise. */ public static boolean checkEmptySourceRegion( final ImageReadParam readParameters, final Rectangle dimensions) { Utilities.ensureNonNull("readDimension", dimensions); Utilities.ensureNonNull("readP", readParameters); final Rectangle sourceRegion = readParameters.getSourceRegion(); Rectangle.intersect(sourceRegion, dimensions, sourceRegion); if (sourceRegion.isEmpty()) { return true; } readParameters.setSourceRegion(sourceRegion); return false; }
final Rectangle imageBounds = binaryImage.getBounds(); final Rectangle overlapArea = imageBounds.intersection(tileBounds); if (overlapArea.isEmpty()) { return false;
viewport.setMatchingAspectRatio(true); Rectangle rect = getVisibleRect(); if (!rect.isEmpty()) { viewport.setScreenArea(rect);
@Test public void fullCtor() { MapViewport vp = new MapViewport(WORLD_1_1, true); assertTrue(vp.isEmpty()); assertTrue(vp.isMatchingAspectRatio()); assertTrue(vp.getScreenArea().isEmpty()); assertTrue(WORLD_1_1.boundsEquals2D(vp.getBounds(), TOL)); }
@Test public void booleanCtor() { MapViewport vp = new MapViewport(true); assertTrue(vp.isEmpty()); assertTrue(vp.isMatchingAspectRatio()); assertTrue(vp.getBounds().isEmpty()); assertTrue(vp.getScreenArea().isEmpty()); }
@Test public void boundsCtor() { MapViewport vp = new MapViewport(WORLD_1_1); assertTrue(vp.isEmpty()); assertFalse(vp.isMatchingAspectRatio()); assertTrue(vp.getScreenArea().isEmpty()); assertTrue(WORLD_1_1.boundsEquals2D(vp.getBounds(), TOL)); }
@Test public void defaultCtor() { MapViewport vp = new MapViewport(); assertFalse(vp.isMatchingAspectRatio()); assertTrue(vp.isEmpty()); assertTrue(vp.getBounds().isEmpty()); assertTrue(vp.getScreenArea().isEmpty()); assertNull(vp.getCoordinateReferenceSystem()); }