List of usage examples for java.awt.geom Arc2D getEndPoint
public Point2D getEndPoint()
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; int w = getSize().width; int h = getSize().height; Arc2D arc = new Arc2D.Double(0.0, 0.5, w, h, 0.0, 60.0, Arc2D.CHORD); System.out.println(arc.getEndPoint()); g2.draw(arc);//from w w w .j a v a2 s. c om arc = new Arc2D.Float(0.0f, 0.0f, w, h, 80.0f, 110.0f, Arc2D.PIE); g2.fill(arc); arc = new Arc2D.Float(0.0f, 0.0f, w, h, 210.0f, 130.0f, Arc2D.OPEN); g2.draw(arc); }
From source file:net.sf.fspdfs.chartthemes.spring.ScaledDialPointer.java
/** * Draws the pointer.//from w w w . j a va 2s. c o m * * @param g2 the graphics target. * @param plot the plot. * @param frame the dial's reference frame. * @param view the dial's view. */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { g2.setStroke(new BasicStroke(1.0f)); Rectangle2D lengthRect = DialPlot.rectangleByRadius(frame, this.getRadius(), this.getRadius()); Rectangle2D widthRect = DialPlot.rectangleByRadius(frame, this.getWidthRadius(), this.getWidthRadius()); double value = ChartThemesUtilities.getScaledValue(plot.getValue(this.getDatasetIndex()), scale); DialScale scale = plot.getScaleForDataset(this.getDatasetIndex()); double angle = scale.valueToAngle(value); Arc2D arc1 = new Arc2D.Double(lengthRect, angle, 0, Arc2D.OPEN); Point2D pt1 = arc1.getEndPoint(); Arc2D arc2 = new Arc2D.Double(widthRect, angle - 90.0, 180.0, Arc2D.OPEN); Point2D pt2 = arc2.getStartPoint(); Point2D pt3 = arc2.getEndPoint(); Arc2D arc3 = new Arc2D.Double(widthRect, angle - 180.0, 0.0, Arc2D.OPEN); Point2D pt4 = arc3.getStartPoint(); GeneralPath gp = new GeneralPath(); gp.moveTo((float) pt1.getX(), (float) pt1.getY()); gp.lineTo((float) pt2.getX(), (float) pt2.getY()); gp.lineTo((float) pt4.getX(), (float) pt4.getY()); gp.lineTo((float) pt3.getX(), (float) pt3.getY()); gp.closePath(); g2.setPaint(this.fillPaint); g2.fill(gp); g2.setPaint(this.getOutlinePaint()); Line2D line = new Line2D.Double(frame.getCenterX(), frame.getCenterY(), pt1.getX(), pt1.getY()); // g2.draw(line); line.setLine(pt2, pt3); g2.draw(line); line.setLine(pt3, pt1); g2.draw(line); line.setLine(pt2, pt1); g2.draw(line); line.setLine(pt2, pt4); g2.draw(line); line.setLine(pt3, pt4); g2.draw(line); }
From source file:net.sf.jasperreports.chartthemes.spring.ScaledDialPointer.java
/** * Draws the pointer.// w w w .java2 s. com * * @param g2 the graphics target. * @param plot the plot. * @param frame the dial's reference frame. * @param view the dial's view. */ @Override public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { g2.setStroke(new BasicStroke(1.0f)); Rectangle2D lengthRect = DialPlot.rectangleByRadius(frame, this.getRadius(), this.getRadius()); Rectangle2D widthRect = DialPlot.rectangleByRadius(frame, this.getWidthRadius(), this.getWidthRadius()); double value = ChartThemesUtilities.getScaledValue(plot.getValue(this.getDatasetIndex()), scale); DialScale scale = plot.getScaleForDataset(this.getDatasetIndex()); double angle = scale.valueToAngle(value); Arc2D arc1 = new Arc2D.Double(lengthRect, angle, 0, Arc2D.OPEN); Point2D pt1 = arc1.getEndPoint(); Arc2D arc2 = new Arc2D.Double(widthRect, angle - 90.0, 180.0, Arc2D.OPEN); Point2D pt2 = arc2.getStartPoint(); Point2D pt3 = arc2.getEndPoint(); Arc2D arc3 = new Arc2D.Double(widthRect, angle - 180.0, 0.0, Arc2D.OPEN); Point2D pt4 = arc3.getStartPoint(); GeneralPath gp = new GeneralPath(); gp.moveTo((float) pt1.getX(), (float) pt1.getY()); gp.lineTo((float) pt2.getX(), (float) pt2.getY()); gp.lineTo((float) pt4.getX(), (float) pt4.getY()); gp.lineTo((float) pt3.getX(), (float) pt3.getY()); gp.closePath(); g2.setPaint(this.fillPaint); g2.fill(gp); g2.setPaint(this.getOutlinePaint()); Line2D line = new Line2D.Double(frame.getCenterX(), frame.getCenterY(), pt1.getX(), pt1.getY()); // g2.draw(line); line.setLine(pt2, pt3); g2.draw(line); line.setLine(pt3, pt1); g2.draw(line); line.setLine(pt2, pt1); g2.draw(line); line.setLine(pt2, pt4); g2.draw(line); line.setLine(pt3, pt4); g2.draw(line); }
From source file:com.bdb.weather.display.current.WindDirPointer.java
/** * Draws the pointer./* ww w.j ava2 s. c o m*/ * * @param g2 The graphics target. * @param plot The plot. * @param frame The dial's reference frame. * @param view The dial's view. */ @Override public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { g2.setPaint(Color.blue); g2.setStroke(new BasicStroke(1.0f)); DialScale scale = plot.getScaleForDataset(getDatasetIndex()); double value = plot.getValue(getDatasetIndex()); double angle = scale.valueToAngle(value % 360.0); Rectangle2D outerRect = DialPlot.rectangleByRadius(frame, outerRadius, outerRadius); Rectangle2D innerRect = DialPlot.rectangleByRadius(frame, outerRadius - innerOffset, outerRadius - innerOffset); g2.setPaint(getOutlinePaint()); Arc2D arc1 = new Arc2D.Double(outerRect, angle - (ARC_LENGTH / 2), ARC_LENGTH, Arc2D.OPEN); g2.draw(arc1); Arc2D arc2 = new Arc2D.Double(innerRect, angle, 0.0, Arc2D.OPEN); GeneralPath gp = new GeneralPath(); gp.moveTo(arc1.getStartPoint().getX(), arc1.getStartPoint().getY()); gp.lineTo(arc2.getStartPoint().getX(), arc2.getStartPoint().getY()); gp.lineTo(arc1.getEndPoint().getX(), arc1.getEndPoint().getY()); g2.draw(gp); if (fill) { g2.setPaint(getFillPaint()); g2.fill(gp); } }
From source file:net.sf.fspdfs.chartthemes.spring.ScaledDialScale.java
/** * Draws the scale on the dial plot.//ww w .j a v a 2 s . c om * * @param g2 the graphics target (<code>null</code> not permitted). * @param plot the dial plot (<code>null</code> not permitted). * @param frame the reference frame that is used to construct the * geometry of the plot (<code>null</code> not permitted). * @param view the visible part of the plot (<code>null</code> not * permitted). */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { Rectangle2D arcRect = DialPlot.rectangleByRadius(frame, this.getTickRadius(), this.getTickRadius()); Rectangle2D arcRectMajor = DialPlot.rectangleByRadius(frame, this.getTickRadius() - this.getMajorTickLength(), this.getTickRadius() - this.getMajorTickLength()); Rectangle2D arcRectMinor = arcRect; if (this.getMinorTickCount() > 0 && this.getMinorTickLength() > 0.0) { arcRectMinor = DialPlot.rectangleByRadius(frame, this.getTickRadius() - this.getMinorTickLength(), this.getTickRadius() - this.getMinorTickLength()); } Rectangle2D arcRectForLabels = DialPlot.rectangleByRadius(frame, this.getTickRadius() - this.getTickLabelOffset(), this.getTickRadius() - this.getTickLabelOffset()); boolean firstLabel = true; Arc2D arc = new Arc2D.Double(); Line2D workingLine = new Line2D.Double(); Stroke arcStroke = new BasicStroke(0.75f); for (double v = this.getLowerBound(); v <= this.getUpperBound(); v += this.getMajorTickIncrement()) { arc.setArc(arcRect, this.getStartAngle(), valueToAngle(v) - this.getStartAngle(), Arc2D.OPEN); g2.setPaint(this.getMajorTickPaint()); g2.setStroke(arcStroke); g2.draw(arc); Point2D pt0 = arc.getEndPoint(); arc.setArc(arcRectMajor, this.getStartAngle(), valueToAngle(v) - this.getStartAngle(), Arc2D.OPEN); Point2D pt1 = arc.getEndPoint(); g2.setPaint(this.getMajorTickPaint()); g2.setStroke(this.getMajorTickStroke()); workingLine.setLine(pt0, pt1); g2.draw(workingLine); arc.setArc(arcRectForLabels, this.getStartAngle(), valueToAngle(v) - this.getStartAngle(), Arc2D.OPEN); Point2D pt2 = arc.getEndPoint(); if (this.getTickLabelsVisible()) { if (!firstLabel || this.getFirstTickLabelVisible()) { g2.setFont(this.getTickLabelFont()); TextUtilities.drawAlignedString(this.getTickLabelFormatter().format(v), g2, (float) pt2.getX(), (float) pt2.getY(), TextAnchor.CENTER); } } firstLabel = false; // now do the minor tick marks if (this.getMinorTickCount() > 0 && this.getMinorTickLength() > 0.0) { double minorTickIncrement = this.getMajorTickIncrement() / (this.getMinorTickCount() + 1); for (int i = 0; i < this.getMinorTickCount(); i++) { double vv = v + ((i + 1) * minorTickIncrement); if (vv >= this.getUpperBound()) { break; } double angle = valueToAngle(vv); arc.setArc(arcRect, this.getStartAngle(), angle - this.getStartAngle(), Arc2D.OPEN); pt0 = arc.getEndPoint(); arc.setArc(arcRectMinor, this.getStartAngle(), angle - this.getStartAngle(), Arc2D.OPEN); Point2D pt3 = arc.getEndPoint(); g2.setStroke(this.getMinorTickStroke()); g2.setPaint(this.getMinorTickPaint()); workingLine.setLine(pt0, pt3); g2.draw(workingLine); } } } }
From source file:net.sf.jasperreports.chartthemes.spring.ScaledDialScale.java
/** * Draws the scale on the dial plot./* ww w .j a va2 s. co m*/ * * @param g2 the graphics target (<code>null</code> not permitted). * @param plot the dial plot (<code>null</code> not permitted). * @param frame the reference frame that is used to construct the * geometry of the plot (<code>null</code> not permitted). * @param view the visible part of the plot (<code>null</code> not * permitted). */ @Override public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { Rectangle2D arcRect = DialPlot.rectangleByRadius(frame, this.getTickRadius(), this.getTickRadius()); Rectangle2D arcRectMajor = DialPlot.rectangleByRadius(frame, this.getTickRadius() - this.getMajorTickLength(), this.getTickRadius() - this.getMajorTickLength()); Rectangle2D arcRectMinor = arcRect; if (this.getMinorTickCount() > 0 && this.getMinorTickLength() > 0.0) { arcRectMinor = DialPlot.rectangleByRadius(frame, this.getTickRadius() - this.getMinorTickLength(), this.getTickRadius() - this.getMinorTickLength()); } Rectangle2D arcRectForLabels = DialPlot.rectangleByRadius(frame, this.getTickRadius() - this.getTickLabelOffset(), this.getTickRadius() - this.getTickLabelOffset()); boolean firstLabel = true; Arc2D arc = new Arc2D.Double(); Line2D workingLine = new Line2D.Double(); Stroke arcStroke = new BasicStroke(0.75f); for (double v = this.getLowerBound(); v <= this.getUpperBound(); v += this.getMajorTickIncrement()) { arc.setArc(arcRect, this.getStartAngle(), valueToAngle(v) - this.getStartAngle(), Arc2D.OPEN); g2.setPaint(this.getMajorTickPaint()); g2.setStroke(arcStroke); g2.draw(arc); Point2D pt0 = arc.getEndPoint(); arc.setArc(arcRectMajor, this.getStartAngle(), valueToAngle(v) - this.getStartAngle(), Arc2D.OPEN); Point2D pt1 = arc.getEndPoint(); g2.setPaint(this.getMajorTickPaint()); g2.setStroke(this.getMajorTickStroke()); workingLine.setLine(pt0, pt1); g2.draw(workingLine); arc.setArc(arcRectForLabels, this.getStartAngle(), valueToAngle(v) - this.getStartAngle(), Arc2D.OPEN); Point2D pt2 = arc.getEndPoint(); if (this.getTickLabelsVisible()) { if (!firstLabel || this.getFirstTickLabelVisible()) { g2.setFont(this.getTickLabelFont()); TextUtilities.drawAlignedString(this.getTickLabelFormatter().format(v), g2, (float) pt2.getX(), (float) pt2.getY(), TextAnchor.CENTER); } } firstLabel = false; // now do the minor tick marks if (this.getMinorTickCount() > 0 && this.getMinorTickLength() > 0.0) { double minorTickIncrement = this.getMajorTickIncrement() / (this.getMinorTickCount() + 1); for (int i = 0; i < this.getMinorTickCount(); i++) { double vv = v + ((i + 1) * minorTickIncrement); if (vv >= this.getUpperBound()) { break; } double angle = valueToAngle(vv); arc.setArc(arcRect, this.getStartAngle(), angle - this.getStartAngle(), Arc2D.OPEN); pt0 = arc.getEndPoint(); arc.setArc(arcRectMinor, this.getStartAngle(), angle - this.getStartAngle(), Arc2D.OPEN); Point2D pt3 = arc.getEndPoint(); g2.setStroke(this.getMinorTickStroke()); g2.setPaint(this.getMinorTickPaint()); workingLine.setLine(pt0, pt3); g2.draw(workingLine); } } } }
From source file:genlab.gui.jfreechart.EnhancedSpiderWebPlot.java
/** * Returns the location for a label//from w w w.j av a 2s . co m * * @param labelBounds the label bounds. * @param ascent the ascent (height of font). * @param plotArea the plot area * @param startAngle the start angle for the pie series. * * @return The location for a label. */ protected Point2D calculateLabelLocation(Rectangle2D labelBounds, double ascent, Rectangle2D plotArea, double startAngle) { Arc2D arc1 = new Arc2D.Double(plotArea, startAngle, 0, Arc2D.OPEN); Point2D point1 = arc1.getEndPoint(); double deltaX = -(point1.getX() - plotArea.getCenterX()) * this.axisLabelGap; double deltaY = -(point1.getY() - plotArea.getCenterY()) * this.axisLabelGap; double labelX = point1.getX() - deltaX; double labelY = point1.getY() - deltaY; if (labelX < plotArea.getCenterX()) { labelX -= labelBounds.getWidth(); } if (labelX == plotArea.getCenterX()) { labelX -= labelBounds.getWidth() / 2; } if (labelY > plotArea.getCenterY()) { labelY += ascent; } return new Point2D.Double(labelX, labelY); }
From source file:org.amanzi.awe.render.network.NetworkRenderer.java
/** * Draw black border around selected sector * /*from ww w . j av a 2 s. co m*/ * @param destination * @param point * @param model * @param sector */ private void renderSelectionBorder(Graphics2D destination, Point point, ISectorElement sector, int index, int count) { Pair<Double, Double> sectorParameters = getSectorParameters(sector, index, count); int size = getSize(); double azimuth = sectorParameters.getLeft(); double beamwidth = sectorParameters.getRight(); GeneralPath path = new GeneralPath(); path.moveTo(getSectorXCoordinate(point, size), getSectorYCoordinate(point, size)); Arc2D a = createSector(point, networkRendererStyle.getLargeElementSize(), getAngle(azimuth, beamwidth), beamwidth); path.append(a.getPathIterator(null), true); path.closePath(); destination .setColor(networkRendererStyle.changeColor(SELECTED_SECTOR_COLOR, networkRendererStyle.getAlpha())); destination.draw(path); destination.drawString(sector.getName(), (int) a.getEndPoint().getX() + 10, (int) a.getEndPoint().getY()); }