List of usage examples for java.awt.geom Rectangle2D getX
public abstract double getX();
From source file:grafix.telas.MolduraAreaDados.java
protected void descartarEvento(final java.awt.event.MouseEvent evt) { Rectangle2D areaDados = getAreaData(); evt.translatePoint(arred(areaDados.getX()), arred(areaDados.getY())); // this.getPanelMolduras().dispatchEvent(evt); Controle.getJanelaAtiva().getPanelGraficos().dispatchEvent(evt); // Em teste }
From source file:XMLWriteTest.java
/** * Writers an SVG document of the current drawing. * @param writer the document destination *///from www . j a va 2 s. c o m public void writeDocument(XMLStreamWriter writer) throws XMLStreamException { writer.writeStartDocument(); writer.writeDTD("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20000802//EN\" " + "\"http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd\">"); writer.writeStartElement("svg"); writer.writeAttribute("width", "" + getWidth()); writer.writeAttribute("height", "" + getHeight()); for (int i = 0; i < rects.size(); i++) { Color c = colors.get(i); Rectangle2D r = rects.get(i); writer.writeEmptyElement("rect"); writer.writeAttribute("x", "" + r.getX()); writer.writeAttribute("y", "" + r.getY()); writer.writeAttribute("width", "" + r.getWidth()); writer.writeAttribute("height", "" + r.getHeight()); writer.writeAttribute("fill", colorToString(c)); } writer.writeEndDocument(); // closes svg element }
From source file:net.sourceforge.processdash.ui.lib.chart.PaddedAxisHelper.java
public Rectangle2D removePadding(Rectangle2D area, RectangleEdge edge) { boolean inverted = axis.isInverted(); if (RectangleEdge.isTopOrBottom(edge)) { double xPad = inverted ? upperPad : lowerPad; double width = area.getWidth() - upperPad - lowerPad; return new Rectangle2D.Double(area.getX() + xPad, area.getY(), width, area.getHeight()); } else {/*from w w w . ja va 2 s . c o m*/ double yPad = inverted ? lowerPad : upperPad; double height = area.getHeight() - upperPad - lowerPad; return new Rectangle2D.Double(area.getX(), area.getY() + yPad, area.getWidth(), height); } }
From source file:XMLWriteTest.java
/** * Creates an SVG document of the current drawing. * @return the DOM tree of the SVG document *//* w w w .java2s . c om*/ public Document buildDocument() { Document doc = builder.newDocument(); Element svgElement = doc.createElement("svg"); doc.appendChild(svgElement); svgElement.setAttribute("width", "" + getWidth()); svgElement.setAttribute("height", "" + getHeight()); for (int i = 0; i < rects.size(); i++) { Color c = colors.get(i); Rectangle2D r = rects.get(i); Element rectElement = doc.createElement("rect"); rectElement.setAttribute("x", "" + r.getX()); rectElement.setAttribute("y", "" + r.getY()); rectElement.setAttribute("width", "" + r.getWidth()); rectElement.setAttribute("height", "" + r.getHeight()); rectElement.setAttribute("fill", colorToString(c)); svgElement.appendChild(rectElement); } return doc; }
From source file:net.sf.jasperreports.engine.JRImageRenderer.java
@Override public void render(JasperReportsContext jasperReportsContext, Graphics2D grx, Rectangle2D rectangle) throws JRException { Image img = getImage(jasperReportsContext); grx.drawImage(img, (int) rectangle.getX(), (int) rectangle.getY(), (int) rectangle.getWidth(), (int) rectangle.getHeight(), null); }
From source file:org.fhcrc.cpl.toolbox.gui.chart.ChartMouseAndMotionListener.java
/** * Transform a value in the units of the X axis of the chart into a mouse x value * Note: if there were multiple subplots, this would need to take a MouseEvent to determine which one * @param xValue/*from w ww . ja v a 2 s .c o m*/ * @return */ protected double transformXValueToMouse(double xValue) { Rectangle2D screenDataArea = _chartPanel.getScreenDataArea(); double leftmostOnAxis = domainAxis.getLowerBound(); double rightmostOnAxis = domainAxis.getUpperBound(); double leftmostonscreen = screenDataArea.getX(); double rightmostonscreen = leftmostonscreen + screenDataArea.getWidth(); double slope = (rightmostOnAxis - leftmostOnAxis) / (rightmostonscreen - leftmostonscreen); double result = ((xValue - leftmostOnAxis) / slope) + leftmostonscreen; //System.err.println("***Transform: " + xValue + ", left=" + leftmostOnAxis + ", right=" + rightmostOnAxis + // ", screenl=" + leftmostonscreen + ", screenr=" + rightmostonscreen + ", slope=" + slope + ", result=" + result); return result; }
From source file:org.uva.itast.blended.omr.scanners.BarcodeScanner.java
/** * Generates an expanded boundingbox in milimeters * //from ww w .ja v a 2s . c om * @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:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.ColoredBlockContainer.java
/** * Disclaimer: this is a "works for me" implementation, and probably only works as long as the * items are arranged horizontally in exactly one line, since it brutally enforces the items to * be aligned vertically centered.//w w w. j a va 2s . c o m */ @Override public Object draw(Graphics2D g2, Rectangle2D area, Object params) { area = drawFill(g2, area); // check if we need to collect chart entities from the container EntityBlockParams ebp = null; StandardEntityCollection sec = null; if (params instanceof EntityBlockParams) { ebp = (EntityBlockParams) params; if (ebp.getGenerateEntities()) { sec = new StandardEntityCollection(); } } Rectangle2D contentArea = (Rectangle2D) area.clone(); contentArea = trimMargin(contentArea); drawBorder(g2, contentArea); contentArea = trimBorder(contentArea); contentArea = trimPadding(contentArea); Iterator iterator = getBlocks().iterator(); while (iterator.hasNext()) { Block block = (Block) iterator.next(); Rectangle2D bounds = block.getBounds(); // enforce vertically centered alignment double y = area.getY() + (area.getHeight() - bounds.getHeight()) / 2.0; Rectangle2D drawArea = new Rectangle2D.Double(bounds.getX() + area.getX(), y, bounds.getWidth(), bounds.getHeight()); Object r = block.draw(g2, drawArea, params); if (sec != null) { if (r instanceof EntityBlockResult) { EntityBlockResult ebr = (EntityBlockResult) r; EntityCollection ec = ebr.getEntityCollection(); sec.addAll(ec); } } } BlockResult result = null; if (sec != null) { result = new BlockResult(); result.setEntityCollection(sec); } return result; }
From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java
@Override public void drawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { float x0 = (float) dataArea.getX(); float x1 = x0 + (float) Math.abs(getXOffset()); float x3 = (float) dataArea.getMaxX(); float x2 = x3 - (float) Math.abs(getXOffset()); float y0 = (float) dataArea.getMaxY(); float y1 = y0 - (float) Math.abs(getYOffset()); float y3 = (float) dataArea.getMinY(); float y2 = y3 + (float) Math.abs(getYOffset()); GeneralPath clip = new GeneralPath(); clip.moveTo(x0, y0);/*from w w w . ja v a 2 s. co m*/ clip.lineTo(x0, y2); clip.lineTo(x1, y3); clip.lineTo(x3, y3); clip.lineTo(x3, y1); clip.lineTo(x2, y0); clip.closePath(); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, plot.getBackgroundAlpha())); // fill background... Paint backgroundPaint = plot.getBackgroundPaint(); if (backgroundPaint != null) { g2.setPaint(backgroundPaint); g2.fill(clip); } GeneralPath bottomWall = new GeneralPath(); bottomWall.moveTo(x0, y0); bottomWall.lineTo(x1, y1); bottomWall.lineTo(x3, y1); bottomWall.lineTo(x2, y0); bottomWall.closePath(); g2.setPaint(getWallPaint()); g2.fill(bottomWall); // draw background image, if there is one... Image backgroundImage = plot.getBackgroundImage(); if (backgroundImage != null) { Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX() + getXOffset(), dataArea.getY(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); plot.drawBackgroundImage(g2, adjusted); } g2.setComposite(originalComposite); }
From source file:ucar.unidata.idv.control.chart.MyTimeSeriesPlot.java
/** * Override this method because it gets called after the graphics clip * has been reset.// w w w .j av a 2 s . c o m * TODO: We end up drawing the annotations twice. Figure something out to * only draw once. * * @param g2 the graphics * @param dataArea the data area */ public void drawOutline(Graphics2D g2, Rectangle2D dataArea) { super.drawOutline(g2, dataArea); Shape originalClip = g2.getClip(); double y = dataArea.getY(); Rectangle2D.Double newClip = new Rectangle2D.Double(dataArea.getX(), 0, dataArea.getWidth(), dataArea.getHeight() + y); g2.clip(newClip); drawAnnotations(g2, dataArea, null); g2.clip(originalClip); }