List of usage examples for java.awt.geom Point2D getX
public abstract double getX();
From source file:org.jfree.experimental.chart.plot.dial.DialTextAnnotation.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 www . j a v a2 s. com public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { // work out the anchor point Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, this.radius); Arc2D arc = new Arc2D.Double(f, this.angle, 0.0, Arc2D.OPEN); Point2D pt = arc.getStartPoint(); g2.setPaint(this.paint); g2.setFont(this.font); TextUtilities.drawAlignedString(this.label, g2, (float) pt.getX(), (float) pt.getY(), this.anchor); }
From source file:graph.eventhandlers.MyEditingGraphMousePlugin.java
private void transformArrowShape(Point2D down, Point2D out) { float x1 = (float) down.getX(); float y1 = (float) down.getY(); float x2 = (float) out.getX(); float y2 = (float) out.getY(); AffineTransform xform = AffineTransform.getTranslateInstance(x2, y2); float dx = x2 - x1; float dy = y2 - y1; float thetaRadians = (float) Math.atan2(dy, dx); xform.rotate(thetaRadians);// ww w . j a va2 s . co m arrowShape = xform.createTransformedShape(rawArrowShape); }
From source file:net.panthema.BispanningGame.MyEditingGraphMousePlugin.java
/** * If startVertex is non-null, and the mouse is released over an existing * vertex, create an undirected edge from startVertex to the vertex under * the mouse pointer. If shift was also pressed, create a directed edge * instead.// w ww. j a v a 2 s . com */ @SuppressWarnings("unchecked") public void mouseReleased(MouseEvent e) { if (checkModifiers(e)) { final VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource(); final Point2D p = e.getPoint(); Layout<V, E> layout = vv.getModel().getGraphLayout(); GraphElementAccessor<V, E> pickSupport = vv.getPickSupport(); if (pickSupport != null) { final V vertex = pickSupport.getVertex(layout, p.getX(), p.getY()); if (vertex != null && startVertex != null && startVertex != vertex) { Graph<V, E> graph = vv.getGraphLayout().getGraph(); graph.addEdge(edgeFactory.create(), startVertex, vertex, EdgeType.UNDIRECTED); vv.getRenderContext().getParallelEdgeIndexFunction().reset(); if (graph instanceof MyGraph) ((MyGraph) graph).graphChanged(); vv.repaint(); } } startVertex = null; down = null; vv.removePostRenderPaintable(edgePaintable); } }
From source file:org.uva.itast.blended.omr.pages.PageImage.java
/** * @param pointMM * @return */ public Point toPixels(Point2D pointMM) { return toPixels(pointMM.getX(), pointMM.getY()); }
From source file:org.jfree.experimental.chart.annotations.XYTitleAnnotation.java
/** * Draws the annotation. This method is called by the drawing code in the * {@link XYPlot} class, you don't normally need to call this method * directly.//from w w w .j ava 2s. c om * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info if supplied, this info object will be populated with * entity information. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); AxisLocation domainAxisLocation = plot.getDomainAxisLocation(); AxisLocation rangeAxisLocation = plot.getRangeAxisLocation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(domainAxisLocation, orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(rangeAxisLocation, orientation); Range xRange = domainAxis.getRange(); Range yRange = rangeAxis.getRange(); double anchorX = 0.0; double anchorY = 0.0; if (this.coordinateType == XYCoordinateType.RELATIVE) { anchorX = xRange.getLowerBound() + (this.x * xRange.getLength()); anchorY = yRange.getLowerBound() + (this.y * yRange.getLength()); } else { anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge); anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge); } float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea, domainEdge); float j2DY = (float) rangeAxis.valueToJava2D(anchorY, dataArea, rangeEdge); float xx = 0.0f; float yy = 0.0f; if (orientation == PlotOrientation.HORIZONTAL) { xx = j2DY; yy = j2DX; } else if (orientation == PlotOrientation.VERTICAL) { xx = j2DX; yy = j2DY; } double maxW = dataArea.getWidth(); double maxH = dataArea.getHeight(); if (this.coordinateType == XYCoordinateType.RELATIVE) { if (this.maxWidth > 0.0) { maxW = maxW * this.maxWidth; } if (this.maxHeight > 0.0) { maxH = maxH * this.maxHeight; } } if (this.coordinateType == XYCoordinateType.DATA) { maxW = this.maxWidth; maxH = this.maxHeight; } RectangleConstraint rc = new RectangleConstraint(new Range(0, maxW), new Range(0, maxH)); Size2D size = this.title.arrange(g2, rc); Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width, size.height); Point2D anchorPoint = RectangleAnchor.coordinates(titleRect, this.anchor); xx = xx - (float) anchorPoint.getX(); yy = yy - (float) anchorPoint.getY(); titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight()); BlockParams p = new BlockParams(); if (info != null) { if (info.getOwner().getEntityCollection() != null) { p.setGenerateEntities(true); } } Object result = this.title.draw(g2, titleRect, p); if (result instanceof EntityBlockResult) { EntityBlockResult ebr = (EntityBlockResult) result; info.getOwner().getEntityCollection().addAll(ebr.getEntityCollection()); } String toolTip = getToolTipText(); String url = getURL(); if (toolTip != null || url != null) { addEntity(info, new Rectangle2D.Float(xx, yy, (float) size.width, (float) size.height), rendererIndex, toolTip, url); } }
From source file:graph.eventhandlers.MyEditingGraphMousePlugin.java
/** * code lifted from PluggableRenderer to move an edge shape into an * arbitrary position//from w w w.ja va 2 s . co m */ private void transformEdgeShape(Point2D down, Point2D out) { float x1 = (float) down.getX(); float y1 = (float) down.getY(); float x2 = (float) out.getX(); float y2 = (float) out.getY(); AffineTransform xform = AffineTransform.getTranslateInstance(x1, y1); float dx = x2 - x1; float dy = y2 - y1; float thetaRadians = (float) Math.atan2(dy, dx); xform.rotate(thetaRadians); float dist = (float) Math.sqrt(dx * dx + dy * dy); xform.scale(dist / rawEdge.getBounds().getWidth(), 1.0); edgeShape = xform.createTransformedShape(rawEdge); }
From source file:Visualizer.FRWeightedLayout.java
protected void calcAttraction(Functionality.Edge e) { Pair<Functionality.Node> endpoints = getGraph().getEndpoints(e); Functionality.Node v1 = endpoints.getFirst(); Functionality.Node v2 = endpoints.getSecond(); boolean v1_locked = isLocked(v1); boolean v2_locked = isLocked(v2); if (v1_locked && v2_locked) { // both locked, do nothing return;// w w w.ja va 2 s .c o m } Point2D p1 = transform(v1); Point2D p2 = transform(v2); if (p1 == null || p2 == null) return; double xDelta = p1.getX() - p2.getX(); double yDelta = p1.getY() - p2.getY(); double deltaLength = Math.max(EPSILON, Math.sqrt((xDelta * xDelta) + (yDelta * yDelta))); double force = (deltaLength * deltaLength) / attraction_constant; if (DataModule.displayedGraph.edgeIsDotted(v1, v1)) { force = force / 2.5; } if (DataModule.displayedGraph.edgeIsNormal(v1, v2)) { force = force / 1.7; } if (Double.isNaN(force)) { throw new IllegalArgumentException( "Unexpected mathematical result in FRWeightedLayout:calcPositions [force]"); } double dx = (xDelta / deltaLength) * force; double dy = (yDelta / deltaLength) * force; if (v1_locked == false) { FRVertexData fvd1 = getFRData(v1); fvd1.offset(-dx, -dy); } if (v2_locked == false) { FRVertexData fvd2 = getFRData(v2); fvd2.offset(dx, dy); } }
From source file:gov.nih.nci.caintegrator.application.geneexpression.BoxAndWhiskerCoinPlotRenderer.java
private void drawMultipleEllipse(Point2D point, double boxWidth, double oRadius, Graphics2D g2) { Ellipse2D dot1 = new Ellipse2D.Double(point.getX() - (boxWidth / 2) + oRadius, point.getY(), oRadius, oRadius);/* w w w . j a v a2s .co m*/ Ellipse2D dot2 = new Ellipse2D.Double(point.getX() + (boxWidth / 2), point.getY(), oRadius, oRadius); g2.draw(dot1); g2.draw(dot2); }
From source file:org.apache.pdfbox.contentstream.operator.graphics.CurveToReplicateInitialPoint.java
@Override public void process(Operator operator, List<COSBase> operands) throws IOException { COSNumber x2 = (COSNumber) operands.get(0); COSNumber y2 = (COSNumber) operands.get(1); COSNumber x3 = (COSNumber) operands.get(2); COSNumber y3 = (COSNumber) operands.get(3); Point2D currentPoint = context.getCurrentPoint(); Point2D.Float point2 = context.transformedPoint(x2.floatValue(), y2.floatValue()); Point2D.Float point3 = context.transformedPoint(x3.floatValue(), y3.floatValue()); if (currentPoint == null) { LOG.warn("curveTo (" + point3.x + "," + point3.y + ") without initial MoveTo"); context.moveTo(point3.x, point3.y); } else {/* w ww. ja va 2s .co m*/ context.curveTo((float) currentPoint.getX(), (float) currentPoint.getY(), point2.x, point2.y, point3.x, point3.y); } }
From source file:net.sf.maltcms.chromaui.charts.events.XYAnnotationAdder.java
/** * * @param name/*from w ww . ja va 2s . c o m*/ * @param visible * @param min * @param max * @param cp */ public XYAnnotationAdder(String name, boolean visible, Point2D min, Point2D max, ChartPanel cp) { this.qt = new QuadTree<>(min.getX(), min.getY(), max.getX() - min.getX(), max.getY() - min.getY(), 3); this.cp = cp; this.name = name; this.visible = visible; }