List of usage examples for java.awt.geom Point2D getY
public abstract double getY();
From source file:views.network.MyRadialTreeLayout.java
public void setLocation(V v, Point2D location) { Point2D c = getCenter();//from w ww.j a v a2 s .co m Point2D pv = new Point2D.Double(location.getX() - c.getX(), location.getY() - c.getY()); PolarPoint newLocation = PolarPoint.cartesianToPolar(pv); polarLocations.get(v).setLocation(newLocation); }
From source file:com.anrisoftware.globalpom.format.point.PointFormat.java
private void formatPoint(StringBuffer buff, Point2D point) { buff.append("("); numberFormat.format(point.getX(), buff, new FieldPosition(0)); buff.append(", "); numberFormat.format(point.getY(), buff, new FieldPosition(0)); buff.append(")"); }
From source file:at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction.CurveToReplicateInitialPoint.java
@Override public void process(Operator operator, List<COSBase> operands) throws IOException { try {// ww w . j a v a 2s .c om PDFPage pdfPage = (PDFPage) context; 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 = pdfPage.getCurrentPath().getCurrentPoint(); Point2D p2 = transform(x2.doubleValue(), y2.doubleValue()); Point2D p3 = transform(x3.doubleValue(), y3.doubleValue()); pdfPage.getCurrentPath().curveTo((float) currentPoint.getX(), (float) currentPoint.getY(), (float) p2.getX(), (float) p2.getY(), (float) p3.getX(), (float) p3.getY()); if (log.isTraceEnabled()) { log.trace("Appending cubic Bezier curve with x2:" + p2.getX() + ",y2:" + p2.getY() + ", x3:" + p3.getX() + ",y3:" + p3.getY() + ", using current point x:" + currentPoint.getX() + ",y:" + currentPoint.getY()); } } catch (Exception e) { log.warn("Error processing operator 'v'.", e); } }
From source file:peakml.util.jfreechart.FastSpectrumPlot.java
public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor) { if (useAnchor) { // get the source coordinate - this plot has always a VERTICAL orientation double sourceY = source.getY(); double anchorY = yaxis.java2DToValue(sourceY, state.getDataArea(), RectangleEdge.LEFT); yaxis.resizeRange2(factor, anchorY); } else {/*from www . java2s . c o m*/ yaxis.resizeRange(factor); } }
From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.ExtendedBoxAndWhiskerRenderer.java
/** * Creates a triangle to indicate the presence of far-out values when the * plot orientation is vertical./*www . j av a 2s . c o m*/ * * @param foRadius the far-out radius. * @param point the location. */ private Shape createTriangleVertical(Point2D point, double foRadius) { double side = foRadius * 2; double x = point.getX(); double y = point.getY(); int[] xpoints = { (int) (x), (int) (x + side), (int) (x + (side / 2.0)) }; int[] ypoints = { (int) (y), (int) (y), (int) (y + side) }; return new Polygon(xpoints, ypoints, 3); }
From source file:fr.crnan.videso3d.trajectography.Track2DView.java
public Track2DView(VidesoTrack track) { if (track instanceof LPLNTrack) { XYSeries dataset = new XYSeries(track.getName()); List<ValueMarker> markers = new LinkedList<ValueMarker>(); double distance = 0; LPLNTrackPoint last = null;/*from w ww . j a v a 2 s . co m*/ for (LPLNTrackPoint p : ((LPLNTrack) track).getTrackPoints()) { if (last != null) { distance += Position.ellipsoidalDistance(last.getPosition(), p.getPosition(), Earth.WGS84_EQUATORIAL_RADIUS, Earth.WGS84_POLAR_RADIUS) / LatLonCautra.NM; } dataset.add(distance, p.getElevation() / 30.48); ValueMarker marker = new ValueMarker(distance); marker.setLabel(p.getName()); marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); marker.setLabelTextAnchor(TextAnchor.TOP_CENTER); markers.add(marker); last = p; } JFreeChart chart = ChartFactory.createXYLineChart("Coupe 2D", "NM", "FL", new XYSeriesCollection(dataset), PlotOrientation.VERTICAL, false, false, false); for (ValueMarker m : markers) { chart.getXYPlot().addDomainMarker(m); } //ajout des secteurs AIP avec des XYPolygonAnnotation Collection<Object> secteurs; AIPController controller = (AIPController) DatasManager.getController(DatasManager.Type.AIP); secteurs = controller.getObjects(AIP.CTL); for (int i = 0; i <= 600; i += 10) { last = null; Secteur3D lastSecteur = null; double lastBoundary = 0.0; for (LPLNTrackPoint point : ((LPLNTrack) track).getTrackPoints()) { Position p = new Position(point.getPosition(), i * 30.48); //calcul du secteur contenant le point en cours Iterator<Object> iterator = secteurs.iterator(); boolean contain = false; Secteur3D secteur = null; while (iterator.hasNext() && !contain) { Secteur3D temp = (Secteur3D) iterator.next(); if (temp.contains(p)) { contain = true; secteur = temp; } } //si premier point, on enregistre simplement le secteur trouv if (last == null) { lastSecteur = secteur; } else { if (lastSecteur != secteur) { //si le secteur a chang, on dessine le secteur prcdent //sauf si ce dernier n'existait pas if (lastSecteur != null) { //dans ce cas, on calcule le point d'intersection entre le secteur et le segment form par les deux points //lastSecteur != null => last !=null Set<Point2D> intersects = lastSecteur .getIntersections(new Line2D.Double(last.getLatitude(), last.getLongitude(), p.getLatitude().degrees, p.getLongitude().degrees), true); if (!intersects.isEmpty()) { Point2D intersect = intersects.iterator().next(); distance = Position.ellipsoidalDistance( new LatLonCautra(intersect.getX(), intersect.getY()), last.getPosition(), Earth.WGS84_EQUATORIAL_RADIUS, Earth.WGS84_POLAR_RADIUS) / LatLonCautra.NM; //et ajout de l'annotation XYPolygonAnnotation annotation = new XYPolygonAnnotation( new double[] { lastBoundary, i, lastBoundary + distance, i, lastBoundary + distance, i + 10, lastBoundary, i + 10 }); chart.getXYPlot().addAnnotation(annotation); lastBoundary += distance; } } lastSecteur = secteur; } } last = point; } } //espace en haut pour les marqueurs chart.getXYPlot().getRangeAxis().setUpperMargin(0.05); ChartPanel chartPanel = new ChartPanel(chart); this.setContentPane(chartPanel); this.pack(); } }
From source file:hudson.util.NoOverlapCategoryAxis.java
@Override protected AxisState drawCategoryLabels(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState) { if (state == null) { throw new IllegalArgumentException("Null 'state' argument."); }//from w w w . java 2 s. co m if (isTickLabelsVisible()) { java.util.List ticks = refreshTicks(g2, state, plotArea, edge); state.setTicks(ticks); // remember the last drawn label so that we can avoid drawing overlapping labels. Rectangle2D r = null; int categoryIndex = 0; Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { CategoryTick tick = (CategoryTick) iterator.next(); g2.setFont(getTickLabelFont(tick.getCategory())); g2.setPaint(getTickLabelPaint(tick.getCategory())); CategoryLabelPosition position = this.getCategoryLabelPositions().getLabelPosition(edge); double x0 = 0.0; double x1 = 0.0; double y0 = 0.0; double y1 = 0.0; if (edge == RectangleEdge.TOP) { x0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, edge); x1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, edge); y1 = state.getCursor() - this.getCategoryLabelPositionOffset(); y0 = y1 - state.getMax(); } else if (edge == RectangleEdge.BOTTOM) { x0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, edge); x1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, edge); y0 = state.getCursor() + this.getCategoryLabelPositionOffset(); y1 = y0 + state.getMax(); } else if (edge == RectangleEdge.LEFT) { y0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, edge); y1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, edge); x1 = state.getCursor() - this.getCategoryLabelPositionOffset(); x0 = x1 - state.getMax(); } else if (edge == RectangleEdge.RIGHT) { y0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, edge); y1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, edge); x0 = state.getCursor() + this.getCategoryLabelPositionOffset(); x1 = x0 - state.getMax(); } Rectangle2D area = new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); if (r == null || !r.intersects(area)) { Point2D anchorPoint = RectangleAnchor.coordinates(area, position.getCategoryAnchor()); TextBlock block = tick.getLabel(); block.draw(g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getLabelAnchor(), (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getAngle()); Shape bounds = block.calculateBounds(g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getLabelAnchor(), (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getAngle()); if (plotState != null && plotState.getOwner() != null) { EntityCollection entities = plotState.getOwner().getEntityCollection(); if (entities != null) { String tooltip = getCategoryLabelToolTip(tick.getCategory()); entities.add(new CategoryLabelEntity(tick.getCategory(), bounds, tooltip, null)); } } r = bounds.getBounds2D(); } categoryIndex++; } if (edge.equals(RectangleEdge.TOP)) { double h = state.getMax(); state.cursorUp(h); } else if (edge.equals(RectangleEdge.BOTTOM)) { double h = state.getMax(); state.cursorDown(h); } else if (edge == RectangleEdge.LEFT) { double w = state.getMax(); state.cursorLeft(w); } else if (edge == RectangleEdge.RIGHT) { double w = state.getMax(); state.cursorRight(w); } } return state; }
From source file:org.sejda.impl.sambox.component.PageImageWriter.java
public void write(PDPage page, PDImageXObject image, Point2D position, float width, float height) throws TaskIOException { try {//from w w w .ja v a2s.c o m try (PDPageContentStream contentStream = new PDPageContentStream(document, page, PDPageContentStream.AppendMode.APPEND, true, true)) { contentStream.drawImage(image, (float) position.getX(), (float) position.getY(), width, height); contentStream.close(); } } catch (IOException e) { throw new TaskIOException("An error occurred writing image to the page.", e); } }
From source file:inflor.core.gates.ui.PolygonGateAnnotation.java
@Override public boolean matchesVertex(Point2D v, double xHandleSize, double yHandleSize) { double[] x = getDomainPoints(); double[] y = getRangePoints(); double xMin = v.getX() - xHandleSize; double xMax = v.getX() + xHandleSize; double yMin = v.getY() - yHandleSize; double yMax = v.getY() + yHandleSize; for (int i = 0; i < x.length; i++) { if (xMin <= x[i] && x[i] <= xMax && yMin <= y[i] && y[i] <= yMax) { return true; }// ww w . j a v a 2 s. c o m } return false; }
From source file:edu.uci.ics.jung.io.PajekNetWriter.java
/** * Writes <code>graph</code> to <code>w</code>. Labels for vertices may * be supplied by <code>vs</code> (defaults to no labels if null), * edge weights may be specified by <code>nev</code> * (defaults to weights of 1.0 if null), * and vertex locations may be specified by <code>vld</code> (defaults * to no locations if null). //from w w w .ja v a2 s . c o m */ public void save(Graph<V, E> graph, Writer w, Transformer<V, String> vs, Transformer<E, Number> nev, Transformer<V, Point2D> vld) throws IOException { /* * TODO: Changes we might want to make: * - optionally writing out in list form */ BufferedWriter writer = new BufferedWriter(w); if (nev == null) nev = new Transformer<E, Number>() { public Number transform(E e) { return 1; } }; writer.write("*Vertices " + graph.getVertexCount()); writer.newLine(); List<V> id = new ArrayList<V>(graph.getVertices());//Indexer.getIndexer(graph); for (V currentVertex : graph.getVertices()) { // convert from 0-based to 1-based index int v_id = id.indexOf(currentVertex) + 1; writer.write("" + v_id); if (vs != null) { String label = vs.transform(currentVertex); if (label != null) writer.write(" \"" + label + "\""); } if (vld != null) { Point2D location = vld.transform(currentVertex); if (location != null) writer.write(" " + location.getX() + " " + location.getY() + " 0.0"); } writer.newLine(); } Collection<E> d_set = new HashSet<E>(); Collection<E> u_set = new HashSet<E>(); boolean directed = graph instanceof DirectedGraph; boolean undirected = graph instanceof UndirectedGraph; // if it's strictly one or the other, no need to create extra sets if (directed) d_set.addAll(graph.getEdges()); if (undirected) u_set.addAll(graph.getEdges()); if (!directed && !undirected) // mixed-mode graph { u_set.addAll(graph.getEdges()); d_set.addAll(graph.getEdges()); for (E e : graph.getEdges()) { if (graph.getEdgeType(e) == EdgeType.UNDIRECTED) { d_set.remove(e); } else { u_set.remove(e); } } } // write out directed edges if (!d_set.isEmpty()) { writer.write("*Arcs"); writer.newLine(); } for (E e : d_set) { int source_id = id.indexOf(graph.getEndpoints(e).getFirst()) + 1; int target_id = id.indexOf(graph.getEndpoints(e).getSecond()) + 1; float weight = nev.transform(e).floatValue(); writer.write(source_id + " " + target_id + " " + weight); writer.newLine(); } // write out undirected edges if (!u_set.isEmpty()) { writer.write("*Edges"); writer.newLine(); } for (E e : u_set) { Pair<V> endpoints = graph.getEndpoints(e); int v1_id = id.indexOf(endpoints.getFirst()) + 1; int v2_id = id.indexOf(endpoints.getSecond()) + 1; float weight = nev.transform(e).floatValue(); writer.write(v1_id + " " + v2_id + " " + weight); writer.newLine(); } writer.close(); }