List of usage examples for java.awt.geom Point2D getY
public abstract double getY();
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
private void moveMask(Point2D point) { if (maskMovePoint != null && getSelectedMask() != null) { Rectangle2D frame = getSelectedMask().getRectangleFrame(); getSelectedMask().setRectangleFrame(new Rectangle2D.Double( frame.getMinX() + point.getX() - maskMovePoint.getX(), frame.getMinY() + point.getY() - maskMovePoint.getY(), frame.getWidth(), frame.getHeight())); maskMovePoint = point;/*from w w w . jav a2 s . co m*/ fireMaskUpdateEvent(getSelectedMask()); } }
From source file:lcmc.common.ui.ResourceGraph.java
/** Returns position of the last vertex. */ protected final Point2D getLastPosition() { double lastX = 0; double lastY = 0; final Map<Vertex, Point2D> vl = getVertexLocations(); for (final Map.Entry<Vertex, Point2D> localtionEntry : vl.entrySet()) { final Point2D last = localtionEntry.getValue(); if (last != null) { if (last.getX() > lastX) { lastX = last.getX();/*from w w w . ja v a 2 s .co m*/ } if (last.getY() > lastY) { lastY = last.getY(); } } } putVertexLocations(); return new Point2D.Double(lastX, lastY + 40); }
From source file:com.munch.exchange.ExchangeChartComposite.java
/** * Translates a Java2D point on the chart to a screen location. * * @param java2DPoint the Java2D point. * * @return The screen location./* w w w . ja va 2 s .c o m*/ */ public Point translateJava2DToScreen(Point2D java2DPoint) { Rectangle insets = this.getClientArea(); int x = (int) (java2DPoint.getX() * this.scaleX + insets.x); int y = (int) (java2DPoint.getY() * this.scaleY + insets.y); return new Point(x, y); }
From source file:lcmc.gui.ResourceGraph.java
/** * Scales the graph, so that all vertices can be seen. The graph can * get smaller but not bigger.//from www . j a v a 2 s .c o m */ public void scale() { final Point2D max = getLastPosition(); final float maxXPos = (float) max.getX(); final float maxYPos = (float) max.getY(); if (maxXPos <= 0 || maxYPos <= 0) { return; } final Float vvX = new Float(getLayout().getSize().getWidth()); final Float vvY = new Float(getLayout().getSize().getHeight()); if (maxXPos > vvX || maxYPos > vvY) { final float x = maxXPos > vvX ? maxXPos : vvX; final float y = maxYPos > vvY ? maxYPos : vvY; getLayout().setSize(new Dimension((int) x, (int) y)); vv.setGraphLayout(getLayout()); } if (changed) { somethingChangedReset(); } vv.repaint(); }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
private void moveLegend(Point2D point) { if (isInternalLegendEnabled && isInternalLegendSelected && legendPoint != null) { internalLegendSetup.setRect(internalLegendSetup.getX() + legendPoint.getX() - point.getX(), internalLegendSetup.getY() - legendPoint.getY() + point.getY(), internalLegendSetup.getWidth(), internalLegendSetup.getHeight()); legendPoint = point;//from w ww . j a v a 2 s .c om } }
From source file:org.apache.fop.svg.AbstractFOPTextPainter.java
/** * Paint a single text run on the Graphics2D at a given location. * @param run the text run to paint/*from w w w.j a v a 2 s . c om*/ * @param g2d the Graphics2D to paint to * @param loc the current location of the "cursor" * @return the new location of the "cursor" after painting the text run */ protected Point2D paintTextRun(StrokingTextPainter.TextRun run, Graphics2D g2d, Point2D loc) { AttributedCharacterIterator aci = run.getACI(); aci.first(); updateLocationFromACI(aci, loc); AffineTransform at = g2d.getTransform(); loc = at.transform(loc, null); // font Font font = getFont(aci); if (font != null) { nativeTextHandler.setOverrideFont(font); } // color TextPaintInfo tpi = (TextPaintInfo) aci .getAttribute(GVTAttributedCharacterIterator.TextAttribute.PAINT_INFO); if (tpi == null) { return loc; } Paint foreground = tpi.fillPaint; if (foreground instanceof Color) { Color col = (Color) foreground; g2d.setColor(col); } g2d.setPaint(foreground); // text anchor TextNode.Anchor anchor = (TextNode.Anchor) aci .getAttribute(GVTAttributedCharacterIterator.TextAttribute.ANCHOR_TYPE); // text String txt = getText(aci); float advance = getStringWidth(txt, font); float tx = 0; if (anchor != null) { switch (anchor.getType()) { case TextNode.Anchor.ANCHOR_MIDDLE: tx = -advance / 2; break; case TextNode.Anchor.ANCHOR_END: tx = -advance; break; default: //nop } } // draw string double x = loc.getX(); double y = loc.getY(); try { try { nativeTextHandler.drawString(g2d, txt, (float) x + tx, (float) y); } catch (IOException ioe) { if (g2d instanceof AFPGraphics2D) { ((AFPGraphics2D) g2d).handleIOException(ioe); } } } finally { nativeTextHandler.setOverrideFont(null); } loc.setLocation(loc.getX() + advance, loc.getY()); return loc; }
From source file:org.pentaho.reporting.designer.core.editor.report.AbstractRenderComponent.java
protected RootLevelBand findRootBandForPosition(final Point2D point) { if (getElementRenderer() == null) { return null; }//from w ww . ja va 2 s. c om final Element[] elementsAt = getElementRenderer().getElementsAt(point.getX(), point.getY()); for (int i = elementsAt.length - 1; i >= 0; i -= 1) { final Element element = elementsAt[i]; if (element instanceof RootLevelBand) { return (RootLevelBand) element; } } final Section section = getElementRenderer().getElement(); if (section instanceof RootLevelBand) { return (RootLevelBand) section; } return null; }
From source file:genlab.gui.jfreechart.EnhancedSpiderWebPlot.java
/** * Draws the label for one axis./* ww w. j a v a 2 s .c o m*/ * * @param g2 the graphics device. * @param plotArea the plot area * @param value the value of the label (ignored). * @param cat the category (zero-based index). * @param startAngle the starting angle. * @param extent the extent of the arc. */ protected void drawLabel(Graphics2D g2, Rectangle2D plotArea, double value, int cat, double startAngle, double extent) { FontRenderContext frc = g2.getFontRenderContext(); String label = null; if (this.dataExtractOrder == TableOrder.BY_ROW) { // if series are in rows, then the categories are the column keys label = this.labelGenerator.generateColumnLabel(this.dataset, cat); } else { // if series are in columns, then the categories are the row keys label = this.labelGenerator.generateRowLabel(this.dataset, cat); } Rectangle2D labelBounds = getLabelFont().getStringBounds(label, frc); LineMetrics lm = getLabelFont().getLineMetrics(label, frc); double ascent = lm.getAscent(); Point2D labelLocation = calculateLabelLocation(labelBounds, ascent, plotArea, startAngle); Composite saveComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f)); g2.setPaint(getLabelPaint()); g2.setFont(getLabelFont()); g2.drawString(label, (float) labelLocation.getX(), (float) labelLocation.getY()); g2.setComposite(saveComposite); }
From source file:org.pentaho.reporting.designer.core.editor.report.AbstractRenderComponent.java
public Element getElementForLocation(final Point2D point, final boolean onlySelected) { final ElementRenderer rendererRoot = getElementRenderer(); final Element[] allNodes = rendererRoot.getElementsAt(point.getX(), point.getY()); for (int i = allNodes.length - 1; i >= 0; i -= 1) { final Element element = allNodes[i]; if (ModelUtility.isHideInLayoutGui(element) == true) { continue; }/*from w ww . j a va 2 s. c om*/ styleResolver.resolve(element, resolvedStyle); if (resolvedStyle.getBooleanStyleProperty(ElementStyleKeys.VISIBLE) == false) { continue; } if (onlySelected == false || getRenderContext().getSelectionModel().isSelected(element)) { return element; } } return null; }
From source file:org.mwc.cmap.grideditor.chart.FixedChartComposite.java
/** * Translates a Java2D point on the chart to a screen location. * //from w w w . ja v a 2s.co m * @param java2DPoint * the Java2D point. * * @return The screen location. */ public Point translateJava2DToScreen(final Point2D java2DPoint) { final Rectangle insets = this.getClientArea(); final int x = (int) (java2DPoint.getX() * this.scaleX + insets.x); final int y = (int) (java2DPoint.getY() * this.scaleY + insets.y); return new Point(x, y); }