List of usage examples for java.awt.geom Rectangle2D getY
public abstract double getY();
From source file:org.jfree.experimental.chart.plot.dial.SimpleDialFrame.java
/** * Returns the shape for the window for this dial. Some dial layers will * request that their drawing be clipped within this window. * * @param frame the reference frame (<code>null</code> not permitted). * * @return The shape of the dial's window. *///from w w w . j a va2s. c o m public Shape getWindow(Rectangle2D frame) { Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, this.radius); return new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), f.getHeight()); }
From source file:org.jfree.experimental.chart.plot.dial.DialCap.java
/** * Draws the background to the specified graphics device. If the dial * frame specifies a window, the clipping region will already have been * set to this window before this method is called. * * @param g2 the graphics device (<code>null</code> not permitted). * @param plot the plot (ignored here). * @param frame the dial frame (ignored here). * @param view the view rectangle (<code>null</code> not permitted). *///from w ww .j av a 2 s. c om public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { g2.setPaint(this.fillPaint); Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, this.radius); Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), f.getHeight()); g2.fill(e); g2.setPaint(this.outlinePaint); g2.setStroke(this.outlineStroke); g2.draw(e); }
From source file:org.uva.itast.blended.omr.scanners.BarcodeScanner.java
/** * Generates an expanded boundingbox in milimeters * //from www .j av a 2 s.com * @see {@link #BARCODE_AREA_PERCENT} * @see {@value #BARCODE_AREA_PERCENT} * @param rect * @return milimeteres */ protected Rectangle2D getExpandedArea(Rectangle2D rect, double percent) { Rectangle expandedRect = new Rectangle(); expandedRect.setFrame((rect.getX() - rect.getWidth() * (percent) / 2), (rect.getY() - rect.getHeight() * (percent) / 2), (rect.getWidth() * (1 + percent)), (rect.getHeight() * (1 + percent))); return expandedRect; }
From source file:gda.plots.BlockWrapper.java
/** * JFreeChart will actually call this from its drawTitle method expecting the Block to draw itself at this point. * Our JComponent will already have been drawn as a consequence of being a simple child of the ChartPanel (which * extends JPanel). However we can use the information passed to the Block here to get the JComponents bounds set * correctly.//from w w w .j a v a 2s .co m * * @param g2 * the Graphics2D into which to draw (not used here) * @param area * the Rectangle2D into which the object should draw itself) * @param params * some parameters not yet understood * @return an Object else null */ @Override public Object draw(Graphics2D g2, Rectangle2D area, Object params) { logger.debug("BW area is " + area); logger.debug("BW params is " + params); logger.debug("BW g2 is " + g2); logger.debug("BW g2.transform is " + g2.getTransform()); jc.setBounds((int) Math.round(area.getX()), (int) Math.round(area.getY()), (int) Math.round(area.getWidth()), (int) Math.round(area.getHeight())); return null; }
From source file:org.jfree.experimental.chart.plot.dial.SimpleDialFrame.java
/** * Draws the frame. This method is called by the {@link DialPlot} class, * you shouldn't need to call it directly. * * @param g2 the graphics target (<code>null</code> not permitted). * @param plot the plot (<code>null</code> not permitted). * @param frame the frame (<code>null</code> not permitted). * @param view the view (<code>null</code> not permitted). *///w w w .j a v a2 s . co m public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { Shape window = getWindow(frame); Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius + 0.02, this.radius + 0.02); Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), f.getHeight()); Area area = new Area(e); Area area2 = new Area(window); area.subtract(area2); g2.setPaint(this.backgroundPaint); g2.fill(area); g2.setStroke(this.stroke); g2.setPaint(this.foregroundPaint); g2.draw(window); g2.draw(e); }
From source file:org.uva.itast.blended.omr.pages.PDFPageImage.java
/** * @param x// w ww. 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; }
From source file:org.uva.itast.blended.omr.pages.PageImage.java
/** * Convert box from Milimeters to Pixels relative to the PageImage in the preferred resolution * in case of alignment rotation the returned Rectangle is the minimum bounding box that contains * the original corners transformed.//from w ww . ja v a 2 s .c om * @param box in milimeters related to actual page * @return minimum bounding box in pixels related to image representation */ public Rectangle toPixels(Rectangle2D box) { Point p1 = toPixels(box.getX(), box.getY()); Point p2 = toPixels(box.getMaxX(), box.getMaxY()); Rectangle bboxPx = new Rectangle(p1); bboxPx.add(p2); return bboxPx; }
From source file:de.dakror.villagedefense.game.entity.struct.Struct.java
public void setBump(Rectangle2D r) { super.setBump(new Rectangle((int) Math.round(r.getX() * Tile.SIZE), (int) Math.round(r.getY() * Tile.SIZE), (int) Math.round(r.getWidth() * Tile.SIZE), (int) Math.round(r.getHeight() * Tile.SIZE))); }
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:figs.treeVisualization.gui.PhyloDateAxis.java
/** * Draws an axis line at the current cursor position and edge. * /*www . jav a 2 s . c om*/ * This always uses RectangleEdge.RIGHT, so the cursor is the x position. * * @param g2 the graphics device. * @param cursor the cursor position. * @param dataArea the data area. * @param edge the edge. * * Original method is in <code>org.jfree.chart.axis.ValueAxis</code> */ protected void drawAxisLine(Graphics2D g2, double cursor, Rectangle2D dataArea) { if (!isAxisLineVisible()) { // originally in drawTickMarksAndLabels return; } Line2D axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getHeight()); g2.setPaint(getAxisLinePaint()); g2.setStroke(getAxisLineStroke()); g2.draw(axisLine); }