Refine search
public BufferedImage getCroppedImage() throws IOException { //out if croppedArea == 0 or file is null Rectangle goal = new Rectangle( (int)this.getCropAreaWidth(), (int) this.getCropAreaHeight()); //Then intersect it with the dimensions of your image: Rectangle clip = goal.intersection(new Rectangle(originalFile.getWidth(), originalFile.getHeight())); //Now, clip corresponds to the portion of bi that will fit within your goal. In this case 100 x50. //Now get the subImage using the value of clip. BufferedImage clippedImg = originalFile.getSubimage(clip.x, clip.y, clip.width, clip.height); return clippedImg; }
/** * Calculates the position and size of the enclosed region, relative to the * enclosing region. * <p> * The portions of the enclosed region which lies outside of the enclosing * region are ignored. Effectively, the {@link Rectangle} returned by this * method is a intersection of the enclosing and enclose regions. * * @param width Width of the enclosing region. * @param height Height of the enclosing region. * @return Position and size of the enclosed region. */ public Rectangle calculate(int width, int height) { Dimension d = size.calculate(width, height); Point p = position.calculate( width, height, d.width, d.height, 0, 0, 0, 0 ); Rectangle outerRectangle = new Rectangle(0, 0, width, height); Rectangle innerRectangle = new Rectangle(p, d); return outerRectangle.intersection(innerRectangle); }
Rectangle rect1 = new Rectangle(100, 100, 200, 240); Rectangle rect2 = new Rectangle(120, 80, 80, 120); Rectangle intersection = rect1.intersection(rect2);
public Element intersection(Element elem) { Rectangle r1 = new Rectangle(x, y, w, h); Rectangle r2 = new Rectangle(elem.x, elem.y, elem.w, elem.h); return new Element(r1.intersection(r2)); }
public static Rectangle getSourceRegion(final IIOParam pParam, final int pSrcWidth, final int pSrcHeight) { Rectangle sourceRegion = new Rectangle(pSrcWidth, pSrcHeight); // If param is present, calculate region if (pParam != null) { // Get intersection with source region Rectangle region = pParam.getSourceRegion(); if (region != null) { sourceRegion = sourceRegion.intersection(region); } // Scale according to subsampling offsets int subsampleXOffset = pParam.getSubsamplingXOffset(); int subsampleYOffset = pParam.getSubsamplingYOffset(); sourceRegion.x += subsampleXOffset; sourceRegion.y += subsampleYOffset; sourceRegion.width -= subsampleXOffset; sourceRegion.height -= subsampleYOffset; } return sourceRegion; }
sourceRegion.setRect(sourceRegion.intersection(baseGridRange.toRectangle())); sourceRegion.setBounds(new Rectangle(0, 0, Integer.MIN_VALUE, Integer.MIN_VALUE));
private Rectangle getDisplayableRect(Rectangle trackRectangle, Rectangle visibleRect) { Rectangle rect = null; if (visibleRect != null) { Rectangle intersectedRect = trackRectangle.intersection(visibleRect); if (intersectedRect.height > 15) { rect = intersectedRect; } else { rect = new Rectangle(trackRectangle); } } return rect; }
private Rectangle getDisplayableRect(Rectangle trackRectangle, Rectangle visibleRect) { Rectangle rect = null; if (visibleRect != null) { Rectangle intersectedRect = trackRectangle.intersection(visibleRect); if (intersectedRect.height > 15) { rect = intersectedRect; } else { rect = new Rectangle(trackRectangle); } } return rect; }
begin_t = new Date().getTime(); int margin = ((int) target.getResizeFactor()) + 1; Rectangle rSub = new Rectangle(Math.max(0, maxLocX - margin), Math.max(0, maxLocY - margin), Math.min(target.w + 2 * margin, mBase.width()), Math.min(target.h + 2 * margin, mBase.height())); rSub = new Rectangle(0, 0, mBase.cols(), mBase.rows()).intersection(rSub); Rect rectSub = new Rect(rSub.x, rSub.y, rSub.width, rSub.height); mResult = doFindMatch(target, mBase.submat(rectSub), null);
Rectangle getChunkRect(Point chunkIndex) { return new Rectangle(sceneWidth, sceneHeight).intersection(new Rectangle( chunkIndex.x * chunkWidth, chunkIndex.y * chunkHeight, chunkWidth, chunkHeight)); }
public Shape getDirtyRegion(int srcIndex, Rectangle inputRgn) { if (srcIndex != 0) throw new IndexOutOfBoundsException ("Nonexistant source requested."); // Return empty rect if they don't intersect. if ( ! inputRgn.intersects(bounds) ) return new Rectangle(); // Changes in the input region don't propogate outside our // bounds. return inputRgn.intersection(bounds); }
public Shape getDirtyRegion(int srcIndex, Rectangle inputRgn) { if (srcIndex != 0) throw new IndexOutOfBoundsException ("Nonexistant source requested."); // Return empty rect if they don't intersect. if ( ! inputRgn.intersects(bounds) ) return new Rectangle(); // Changes in the input region don't propogate outside our // bounds. return inputRgn.intersection(bounds); }
rect = new Rectangle(comp.getBounds()); continue; }else { rect.add(comp.getBounds()); }else if (relationship == INTERSECTION){ rect = rect.intersection(comp.getBounds());
public Shape getDirtyRegion(int srcIndex, Rectangle inputRgn) { if (srcIndex != 0) throw new IndexOutOfBoundsException ("Nonexistant source requested."); // Return empty rect if they don't intersect. if ( ! inputRgn.intersects(bounds) ) return new Rectangle(); // Changes in the input region don't propogate outside our // bounds. return inputRgn.intersection(bounds); }
public Shape getDirtyRegion(int srcIndex, Rectangle inputRgn) { if (srcIndex != 0) { throw new IndexOutOfBoundsException( "Nonexistent source requested."); } // Return empty rect if they don't intersect. if (!inputRgn.intersects(bounds)) { return new Rectangle(); } // Changes in the input region don't propogate outside our // bounds. return inputRgn.intersection(bounds); }
public Shape getDependencyRegion(int srcIndex, Rectangle outputRgn) { if ((srcIndex < 0) || (srcIndex > srcs.size())) throw new IndexOutOfBoundsException ("Nonexistant source requested."); // Return empty rect if they don't intersect. if ( ! outputRgn.intersects(bounds) ) return new Rectangle(); // We only depend on our source for stuff that is inside // our bounds... return outputRgn.intersection(bounds); }
public Shape getDependencyRegion(int srcIndex, Rectangle outputRgn) { if ((srcIndex < 0) || (srcIndex > srcs.size())) throw new IndexOutOfBoundsException ("Nonexistant source requested."); // Return empty rect if they don't intersect. if ( ! outputRgn.intersects(bounds) ) return new Rectangle(); // We only depend on our source for stuff that is inside // our bounds... return outputRgn.intersection(bounds); }
public Shape getDependencyRegion(int srcIndex, Rectangle outputRgn) { if ((srcIndex < 0) || (srcIndex > srcs.size())) throw new IndexOutOfBoundsException ("Nonexistant source requested."); // Return empty rect if they don't intersect. if ( ! outputRgn.intersects(bounds) ) return new Rectangle(); // We only depend on our source for stuff that is inside // our bounds... return outputRgn.intersection(bounds); }
Rectangle rect1 = new Rectangle(20, 300, 400, 160); Rectangle rect2 = new Rectangle(150, 60, 230, 450); Rectangle intersection = rect1.intersection(rect2); System.out.println(intersection);
public Shape getDependencyRegion(int srcIndex, Rectangle outputRgn) { if ((srcIndex < 0) || (srcIndex > srcs.size())) { throw new IndexOutOfBoundsException( "Nonexistent source requested."); } // Return empty rect if they don't intersect. if (!outputRgn.intersects(bounds)) { return new Rectangle(); } // We only depend on our source for stuff that is inside // our bounds... return outputRgn.intersection(bounds); }