List of usage examples for java.awt.geom Rectangle2D setFrame
public void setFrame(double x, double y, double w, double h)
From source file:org.esa.snap.graphbuilder.gpf.ui.worldmap.NestWorldMapPane.java
public void zoomToProduct(Product product) { final GeoPos[][] selGeoBoundaries = dataModel.getSelectedGeoBoundaries(); if ((product == null || product.getSceneGeoCoding() == null) && selGeoBoundaries.length == 0) { return;//from w w w . j a va 2s . c o m } //NESTMOD final GeneralPath[] generalPaths; if (product != null && product.getSceneGeoCoding() != null) { generalPaths = getGeoBoundaryPaths(product); } else { final ArrayList<GeneralPath> pathList = assemblePathList(selGeoBoundaries[0]); generalPaths = pathList.toArray(new GeneralPath[pathList.size()]); } Rectangle2D modelArea = new Rectangle2D.Double(); final Viewport viewport = layerCanvas.getViewport(); for (GeneralPath generalPath : generalPaths) { final Rectangle2D rectangle2D = generalPath.getBounds2D(); if (modelArea.isEmpty()) { if (!viewport.isModelYAxisDown()) { modelArea.setFrame(rectangle2D.getX(), rectangle2D.getMaxY(), rectangle2D.getWidth(), rectangle2D.getHeight()); } modelArea = rectangle2D; } else { modelArea.add(rectangle2D); } } Rectangle2D modelBounds = modelArea.getBounds2D(); modelBounds.setFrame(modelBounds.getX() - 2, modelBounds.getY() - 2, modelBounds.getWidth() + 4, modelBounds.getHeight() + 4); modelBounds = cropToMaxModelBounds(modelBounds); viewport.zoom(modelBounds); }
From source file:org.evors.rs.ui.sandpit.SandPitCamera.java
public Rectangle2D getViewPortInWorldCoords() { Vector2D screenZeroZeroInWorldCoords = convertScreenToWorldCoords(Vector2D.ZERO); Vector2D screenWidthHeightInWorldCoords = convertScreenToWorldCoords(new Vector2D(2, getWindowSize())); Rectangle2D rect = new Rectangle2D.Double(); rect.setFrame(screenZeroZeroInWorldCoords.getX(), screenZeroZeroInWorldCoords.getY(), screenWidthHeightInWorldCoords.getX(), screenWidthHeightInWorldCoords.getY()); return rect;/*from ww w. j a v a2 s . co m*/ }
From source file:org.uva.itast.blended.omr.pages.PageImage.java
/** * Obtain a subimage from the pageimage (in milimeters and related to actual paper) * Place to make optimizations when rendering high resolution files. * It takes into account the traslation and rotation of the physical page. * // w ww . j a va2 s . c o m * Default implementation uses getImage() which should decode entire image. * @param x mm * @param y mm * @param w mm * @param h mm * @param imageType * @return SubImage * @see SubImage */ public SubImage getSubimage(double x, double y, double w, double h, int imageType) { Rectangle2D rectMM = new Rectangle2D.Double(); rectMM.setFrame(x, y, w, h); return getSubimage(rectMM, imageType); }
From source file:org.uva.itast.blended.omr.pages.PDFPageImage.java
private Rectangle2D toPDFUnits(Rectangle2D rect) { float ratioHeight = PREFERRED_PIXELS_HEIGHT_A4 / getPage().getHeight(); float ratioWidth = PREFERRED_PIXELS_WIDTH_A4 / getPage().getWidth(); Rectangle2D rectNew = new Rectangle(); rectNew.setFrame(rect.getX() / ratioWidth, rect.getY() / ratioHeight, rect.getWidth() / ratioWidth, rect.getHeight() / ratioHeight); return rectNew; }
From source file:org.uva.itast.blended.omr.pages.PDFPageImage.java
/** * @param x//w w w.j a v a 2 s .c o m * @param y * @param w * @param h * @return */ private SubImage getSubimageWithPartialRendering(Rectangle2D rect, int imageType) { double pageHeight = getPage().getHeight(); // Area in pixels according to preferred resolution Point upperLeft = toPixels(rect.getX(), rect.getY()); Rectangle imageBBox = this.toPixels(rect); // subImage Bounding Box in pixels Rectangle2D pdfAreaBBox = toPDFUnits(imageBBox); // subImage Bounding Box in PDF units Rectangle imageSize = new Rectangle(imageBBox.width, imageBBox.height); // subImage Size in pixels Rectangle2D clippingArea = new Rectangle(); // area of interest in the PDF clippingArea.setFrame(pdfAreaBBox.getX(), pageHeight - pdfAreaBBox.getY() - pdfAreaBBox.getHeight(), //PDF-Page coordinate space counts from bottomleft pdfAreaBBox.getWidth(), pdfAreaBBox.getHeight()); SubImage img_pdf = new SubImage(imageSize.width, imageSize.height, imageType); // se configura la imagen con las medidas necesarias Graphics2D g2 = img_pdf.createGraphics(); // se crea un objeto grfico en dos dimensiones g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); // prefer to get sharp edges PDFRenderer renderer = new PDFRenderer(getPage(), g2, imageSize, clippingArea, Color.RED); // se renderiza la imgen try { getPage().waitForFinish(); } catch (InterruptedException e) { e.printStackTrace(); throw new RuntimeException(e); } renderer.run(); img_pdf.setReference(upperLeft); img_pdf.setBoundingBox(imageBBox); return img_pdf; }