List of usage examples for java.awt.geom Point2D getY
public abstract double getY();
From source file:org.jcurl.core.swing.RockLocationDisplayBase.java
/** * Convert display to world-coordinates. * /*from w w w. j a v a 2 s . c om*/ * @param dc * @param wc * @return world coordinates */ public Point2D dc2wc(final Point2D dc, Point2D wc) { try { wc = wc_mat.inverseTransform(dc, wc); wc.setLocation(wc.getX() / SCALE, wc.getY() / SCALE); return wc; } catch (NoninvertibleTransformException e) { throw new RuntimeException("Why uninvertible?", e); } }
From source file:org.uva.itast.blended.omr.scanners.MarkScanner.java
/** * Return boundingBox of//from ww w. j ava 2 s .c o m * * @param coords * @return */ private Rectangle getRectArea(double[] coords) { Point2D coordUpperLeft = pageImage.toPixels(coords[0], coords[1]); Point2D coordBottomRight = pageImage.toPixels(coords[0] + coords[2], coords[1] + coords[2]); int x = (int) Math.min(coordUpperLeft.getX(), coordBottomRight.getX()); int y = (int) Math.min(coordUpperLeft.getY(), coordBottomRight.getY()); int xm = (int) Math.max(coordUpperLeft.getX(), coordBottomRight.getX()); int ym = (int) Math.max(coordUpperLeft.getY(), coordBottomRight.getY()); int width = xm - x; // anchura en pxeles int height = ym - y; // altura en pxeles return new Rectangle(x, y, width, height); }
From source file:edu.uci.ics.jung.visualization.VisualizationViewer.java
/** * called by the superclass to display tooltips *///from w w w . ja va 2 s .c om public String getToolTipText(MouseEvent event) { Layout<V, E> layout = getGraphLayout(); Point2D p = null; if (vertexToolTipTransformer != null) { p = event.getPoint(); //renderContext.getBasicTransformer().inverseViewTransform(event.getPoint()); V vertex = getPickSupport().getVertex(layout, p.getX(), p.getY()); if (vertex != null) { return vertexToolTipTransformer.transform(vertex); } } if (edgeToolTipTransformer != null) { if (p == null) p = renderContext.getMultiLayerTransformer().inverseTransform(Layer.VIEW, event.getPoint()); E edge = getPickSupport().getEdge(layout, p.getX(), p.getY()); if (edge != null) { return edgeToolTipTransformer.transform(edge); } } if (mouseEventToolTipTransformer != null) { return mouseEventToolTipTransformer.transform(event); } return super.getToolTipText(event); }
From source file:inet.CalculationNetworkEditor.visual.control.listener.BothGraphActions.java
public void relocateVertexes() { Layout<V, E> layout = visViewBoth.getGraphLayout(); Collection<V> physical = logic.getAllVertOfType(IStorage.Type.PHYSICAL); for (V phy : physical) { Collection<V> mapping = logic.getVertexStack(phy); for (V visual : visualPhysicalV.keySet()) { if (visualPhysicalV.get(visual) == phy) { mapping.add(visual);/* w w w .j a va2s. co m*/ } } Point2D pAct = layout.transform(phy); for (V mapped : mapping) { if (!mapped.equals(phy)) { // all vertices of mapping but the phisical vertex pAct.setLocation(pAct.getX() + mapDistance, pAct.getY() + mapDistance); layout.setLocation(mapped, pAct); } } } //printLocationOfAllVertices(); }
From source file:org.jcurl.core.swing.RockLocationDisplayBase.java
/** * Convert world- to display coordinates. * /*from w w w .ja v a 2 s . c o m*/ * @param wc * @param dc * @return display coordinates */ public Point2D wc2dc(final Point2D wc, Point2D dc) { if (dc == null) dc = new Point2D.Float(); dc.setLocation(wc.getX() * SCALE, wc.getY() * SCALE); return wc_mat.transform(dc, dc); }
From source file:org.apache.fop.render.pdf.PDFDocumentHandler.java
/** {@inheritDoc} */ public void startPage(int index, String name, String pageMasterName, Dimension size) throws IFException { this.pdfResources = this.pdfDoc.getResources(); PageBoundaries boundaries = new PageBoundaries(size, getContext().getForeignAttributes()); Rectangle trimBox = boundaries.getTrimBox(); Rectangle bleedBox = boundaries.getBleedBox(); Rectangle mediaBox = boundaries.getMediaBox(); Rectangle cropBox = boundaries.getCropBox(); // set scale attributes double scaleX = 1; double scaleY = 1; String scale = (String) getContext().getForeignAttribute(PageScale.EXT_PAGE_SCALE); Point2D scales = PageScale.getScale(scale); if (scales != null) { scaleX = scales.getX();// w w w .jav a 2 s . co m scaleY = scales.getY(); } //PDF uses the lower left as origin, need to transform from FOP's internal coord system AffineTransform boxTransform = new AffineTransform(scaleX / 1000, 0, 0, -scaleY / 1000, 0, scaleY * size.getHeight() / 1000); this.currentPage = this.pdfDoc.getFactory().makePage(this.pdfResources, index, toPDFCoordSystem(mediaBox, boxTransform), toPDFCoordSystem(cropBox, boxTransform), toPDFCoordSystem(bleedBox, boxTransform), toPDFCoordSystem(trimBox, boxTransform)); if (accessEnabled) { logicalStructureHandler.startPage(currentPage); } pdfUtil.generatePageLabel(index, name); currentPageRef = new PageReference(currentPage, size); this.pageReferences.put(Integer.valueOf(index), currentPageRef); this.generator = new PDFContentGenerator(this.pdfDoc, this.outputStream, this.currentPage); // Transform the PDF's default coordinate system (0,0 at lower left) to the PDFPainter's AffineTransform basicPageTransform = new AffineTransform(1, 0, 0, -1, 0, (scaleY * size.height) / 1000f); basicPageTransform.scale(scaleX, scaleY); generator.saveGraphicsState(); generator.concatenate(basicPageTransform); }
From source file:net.bioclipse.model.ScatterPlotMouseHandler.java
private Number getRangeY(ChartPanel chartPanel, XYPlot plot, Point2D mousePoint) { ChartRenderingInfo info = chartPanel.getChartRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); Number y = plot.getRangeAxis().java2DToValue(mousePoint.getY(), dataArea, plot.getRangeAxisEdge()); return y;/*from w w w . j av a 2s . c om*/ }
From source file:org.nuxeo.pdf.service.PDFTransformationServiceImpl.java
@Override public Blob applyImageWatermark(Blob input, Blob watermark, WatermarkProperties properties) { // Set up the graphic state to handle transparency // Define a new extended graphic state PDExtendedGraphicsState extendedGraphicsState = new PDExtendedGraphicsState(); // Set the transparency/opacity extendedGraphicsState.setNonStrokingAlphaConstant((float) properties.getAlphaColor()); try (PDDocument pdfDoc = PDDocument.load(input.getStream())) { BufferedImage image = ImageIO.read(watermark.getStream()); PDXObjectImage ximage = new PDPixelMap(pdfDoc, image); for (Object o : pdfDoc.getDocumentCatalog().getAllPages()) { PDPage page = (PDPage) o;//from w w w . j a va 2 s . co m PDRectangle pageSize = page.findMediaBox(); PDResources resources = page.findResources(); // Get the defined graphic states. HashMap<String, PDExtendedGraphicsState> graphicsStateDictionary = (HashMap<String, PDExtendedGraphicsState>) resources .getGraphicsStates(); if (graphicsStateDictionary != null) { graphicsStateDictionary.put("TransparentState", extendedGraphicsState); resources.setGraphicsStates(graphicsStateDictionary); } else { Map<String, PDExtendedGraphicsState> m = new HashMap<>(); m.put("TransparentState", extendedGraphicsState); resources.setGraphicsStates(m); } try (PDPageContentStream contentStream = new PDPageContentStream(pdfDoc, page, true, true)) { contentStream.appendRawCommands("/TransparentState gs\n"); contentStream.endMarkedContentSequence(); double watermarkWidth = ximage.getWidth() * properties.getScale(); double watermarkHeight = ximage.getHeight() * properties.getScale(); Point2D position = computeTranslationVector(pageSize.getWidth(), watermarkWidth, pageSize.getHeight(), watermarkHeight, properties); contentStream.drawXObject(ximage, (float) position.getX(), (float) position.getY(), (float) watermarkWidth, (float) watermarkHeight); } } return saveInTempFile(pdfDoc); } catch (COSVisitorException | IOException e) { throw new NuxeoException(e); } }
From source file:org.owasp.benchmark.score.report.ScatterScores.java
private void makeDataLabels(List<Report> toolResults, XYPlot xyplot) { HashMap<Point2D, String> map = makePointList(toolResults); for (Entry<Point2D, String> e : map.entrySet()) { if (e.getValue() != null) { Point2D p = e.getKey(); String label = sort(e.getValue()); XYTextAnnotation annotation = new XYTextAnnotation(label, p.getX(), p.getY()); annotation.setTextAnchor(p.getX() < 3 ? TextAnchor.TOP_LEFT : TextAnchor.TOP_CENTER); annotation.setBackgroundPaint(Color.white); annotation.setPaint(Color.blue); annotation.setFont(theme.getRegularFont()); xyplot.addAnnotation(annotation); }/* ww w . j a va2s. c o m*/ } }
From source file:com.projity.pm.graphic.network.NetworkRenderer.java
protected void translateShape(GraphicNode node, double dx, double dy) { Point2D v = scaleVector_1(new Point2D.Double(dx, dy)); translateNonScaledShape(node, v.getX(), v.getY()); }