List of usage examples for java.awt.geom Arc2D OPEN
int OPEN
To view the source code for java.awt.geom Arc2D OPEN.
Click Source Link
From source file:com.bdaum.zoom.report.internal.jfree.custom.CylinderRenderer.java
/** * Draws a cylinder to represent one data item. * * @param g2 the graphics device.//from w ww . j a v a 2s .c o m * @param state the renderer state. * @param dataArea the area for plotting the data. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // check the value we are plotting... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } double value = dataValue.doubleValue(); Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, adjusted, domainAxis, state, row, column); double[] barL0L1 = calculateBarL0L1(value); if (barL0L1 == null) { return; // the bar is not visible } RectangleEdge edge = plot.getRangeAxisEdge(); float transL0 = (float) rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge); float transL1 = (float) rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge); float barL0 = Math.min(transL0, transL1); float barLength = Math.abs(transL1 - transL0); // draw the bar... GeneralPath bar = new GeneralPath(); Shape top = null; if (orientation == PlotOrientation.HORIZONTAL) { bar.moveTo((float) (barL0 + getXOffset() / 2), (float) barW0); bar.lineTo((float) (barL0 + barLength + getXOffset() / 2), (float) barW0); Arc2D arc = new Arc2D.Double(barL0 + barLength, barW0, getXOffset(), state.getBarWidth(), 90, 180, Arc2D.OPEN); bar.append(arc, true); bar.lineTo((float) (barL0 + getXOffset() / 2), (float) (barW0 + state.getBarWidth())); arc = new Arc2D.Double(barL0, barW0, getXOffset(), state.getBarWidth(), 270, -180, Arc2D.OPEN); bar.append(arc, true); bar.closePath(); top = new Ellipse2D.Double(barL0 + barLength, barW0, getXOffset(), state.getBarWidth()); } else { bar.moveTo((float) barW0, (float) (barL0 - getYOffset() / 2)); bar.lineTo((float) barW0, (float) (barL0 + barLength - getYOffset() / 2)); Arc2D arc = new Arc2D.Double(barW0, (barL0 + barLength - getYOffset()), state.getBarWidth(), getYOffset(), 180, 180, Arc2D.OPEN); bar.append(arc, true); bar.lineTo((float) (barW0 + state.getBarWidth()), (float) (barL0 - getYOffset() / 2)); arc = new Arc2D.Double(barW0, (barL0 - getYOffset()), state.getBarWidth(), getYOffset(), 0, -180, Arc2D.OPEN); bar.append(arc, true); bar.closePath(); top = new Ellipse2D.Double(barW0, barL0 - getYOffset(), state.getBarWidth(), getYOffset()); } Paint itemPaint = getItemPaint(row, column); if (getGradientPaintTransformer() != null && itemPaint instanceof GradientPaint) { GradientPaint gp = (GradientPaint) itemPaint; itemPaint = getGradientPaintTransformer().transform(gp, bar); } g2.setPaint(itemPaint); g2.fill(bar); if (itemPaint instanceof GradientPaint) { g2.setPaint(((GradientPaint) itemPaint).getColor2()); } else { g2.setPaint(PaintAlpha.darker(itemPaint)); // bd } if (top != null) { g2.fill(top); } if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { g2.setStroke(getItemOutlineStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(bar); if (top != null) { g2.draw(top); } } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar.getBounds2D(), (value < 0.0)); } // collect entity and tool tip information... if (state.getInfo() != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null) { String tip = null; CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); if (tipster != null) { tip = tipster.generateToolTip(dataset, row, column); } String url = null; if (getItemURLGenerator(row, column) != null) { url = getItemURLGenerator(row, column).generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(bar.getBounds2D(), tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); } } }
From source file:net.sf.jasperreports.chartthemes.spring.ScaledDialPointer.java
/** * Draws the pointer.// w ww . ja va2s. co 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.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.fspdfs.chartthemes.spring.ScaledDialPointer.java
/** * Draws the pointer./*from www. j av a 2 s. co 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: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). *//* ww w . j av a2 s .c o m*/ 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:org.jfree.experimental.chart.plot.dial.StandardDialRange.java
/** * Draws the range.//www . j a v a2s.c o m * * @param g2 the graphics target. * @param plot the plot. * @param frame the dial's reference frame (in Java2D space). * @param view the dial's view rectangle (in Java2D space). */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { Rectangle2D arcRectInner = DialPlot.rectangleByRadius(frame, this.innerRadius, this.innerRadius); Rectangle2D arcRectOuter = DialPlot.rectangleByRadius(frame, this.outerRadius, this.outerRadius); //double range = this.upperBound - this.lowerBound; DialScale scale = plot.getScaleForDataset(0); double angleMin = scale.valueToAngle(this.lowerBound); double angleMax = scale.valueToAngle(this.upperBound); Arc2D arcInner = new Arc2D.Double(arcRectInner, angleMin, angleMax - angleMin, Arc2D.OPEN); Arc2D arcOuter = new Arc2D.Double(arcRectOuter, angleMax, angleMin - angleMax, Arc2D.OPEN); g2.setPaint(this.paint); g2.setStroke(new BasicStroke(2.0f)); g2.draw(arcInner); g2.draw(arcOuter); }
From source file:org.jfree.experimental.chart.plot.dial.StandardDialFrame.java
/** * Returns the shape for the window for this dial. Some dial layers will * request that their drawing be clipped within this window. * * @param frame the reference frame (<code>null</code> not permitted). * * @return The shape of the dial's window. *//*www . j a v a 2 s .c o m*/ public Shape getWindow(Rectangle2D frame) { Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame, this.innerRadius, this.innerRadius); Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame, this.outerRadius, this.outerRadius); Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle, this.extent, Arc2D.OPEN); Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle + this.extent, -this.extent, Arc2D.OPEN); GeneralPath p = new GeneralPath(); Point2D point1 = inner.getStartPoint(); p.moveTo((float) point1.getX(), (float) point1.getY()); p.append(inner, true); p.append(outer, true); p.closePath(); return p; }
From source file:ShapeTest.java
public Shape makeShape(Point2D[] p) { double centerX = (p[0].getX() + p[1].getX()) / 2; double centerY = (p[0].getY() + p[1].getY()) / 2; double width = Math.abs(p[1].getX() - p[0].getX()); double height = Math.abs(p[1].getY() - p[0].getY()); double skewedStartAngle = Math .toDegrees(Math.atan2(-(p[2].getY() - centerY) * width, (p[2].getX() - centerX) * height)); double skewedEndAngle = Math .toDegrees(Math.atan2(-(p[3].getY() - centerY) * width, (p[3].getX() - centerX) * height)); double skewedAngleDifference = skewedEndAngle - skewedStartAngle; if (skewedStartAngle < 0) skewedStartAngle += 360;/*ww w . j a v a 2 s. c o m*/ if (skewedAngleDifference < 0) skewedAngleDifference += 360; Arc2D s = new Arc2D.Double(0, 0, 0, 0, skewedStartAngle, skewedAngleDifference, Arc2D.OPEN); s.setFrameFromDiagonal(p[0], p[1]); GeneralPath g = new GeneralPath(); g.append(s, false); Rectangle2D r = new Rectangle2D.Double(); r.setFrameFromDiagonal(p[0], p[1]); g.append(r, false); Point2D center = new Point2D.Double(centerX, centerY); g.append(new Line2D.Double(center, p[2]), false); g.append(new Line2D.Double(center, p[3]), false); return g; }
From source file:org.jfree.experimental.chart.plot.dial.StandardDialFrame.java
protected Shape getOuterWindow(Rectangle2D frame) { double radiusMargin = 0.02; double angleMargin = 1.5; Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame, this.innerRadius - radiusMargin, this.innerRadius - radiusMargin); Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame, this.outerRadius + radiusMargin, this.outerRadius + radiusMargin); Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle - angleMargin, this.extent + 2 * angleMargin, Arc2D.OPEN); Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle + angleMargin + this.extent, -this.extent - 2 * angleMargin, Arc2D.OPEN); GeneralPath p = new GeneralPath(); Point2D point1 = inner.getStartPoint(); p.moveTo((float) point1.getX(), (float) point1.getY()); p.append(inner, true);//from w w w .j av a 2 s .c om p.append(outer, true); p.closePath(); return p; }
From source file:org.jfree.experimental.chart.plot.dial.DialValueIndicator.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 a 2 s.co m 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(); // calculate the bounds of the template value FontMetrics fm = g2.getFontMetrics(this.font); String s = this.formatter.format(this.templateValue); Rectangle2D tb = TextUtilities.getTextBounds(s, g2, fm); // align this rectangle to the frameAnchor Rectangle2D bounds = RectangleAnchor.createRectangle(new Size2D(tb.getWidth(), tb.getHeight()), pt.getX(), pt.getY(), this.frameAnchor); // add the insets Rectangle2D fb = this.insets.createOutsetRectangle(bounds); // draw the background g2.setPaint(this.backgroundPaint); g2.fill(fb); // draw the border g2.setStroke(this.outlineStroke); g2.setPaint(this.outlinePaint); g2.draw(fb); // now find the text anchor point double value = plot.getValue(this.datasetIndex); String valueStr = this.formatter.format(value); Point2D pt2 = RectangleAnchor.coordinates(bounds, this.valueAnchor); g2.setPaint(this.paint); g2.setFont(this.font); TextUtilities.drawAlignedString(valueStr, g2, (float) pt2.getX(), (float) pt2.getY(), this.textAnchor); }
From source file:DefaultGraphics2D.java
/** * Draws the outline of a circular or elliptical arc covering the specified * rectangle./* w ww. j av a 2s .co m*/ * <p> * The resulting arc begins at <code>startAngle</code> and extends for * <code>arcAngle</code> degrees, using the current color. Angles are * interpreted such that 0 degrees is at the 3 o'clock position. A * positive value indicates a counter-clockwise rotation while a negative * value indicates a clockwise rotation. * <p> * The center of the arc is the center of the rectangle whose origin is (<i>x</i>, <i>y</i>) * and whose size is specified by the <code>width</code> and * <code>height</code> arguments. * <p> * The resulting arc covers an area <code>width + 1</code> pixels * wide by <code>height + 1</code> pixels tall. * <p> * The angles are specified relative to the non-square extents of the bounding * rectangle such that 45 degrees always falls on the line from the center of * the ellipse to the upper right corner of the bounding rectangle. As a * result, if the bounding rectangle is noticeably longer in one axis than the * other, the angles to the start and end of the arc segment will be skewed * farther along the longer axis of the bounds. * * @param x * the <i>x</i> coordinate of the upper-left corner of the arc to be * drawn. * @param y * the <i>y</i> coordinate of the upper-left corner of the arc to be * drawn. * @param width * the width of the arc to be drawn. * @param height * the height of the arc to be drawn. * @param startAngle * the beginning angle. * @param arcAngle * the angular extent of the arc, relative to the start angle. * @see java.awt.Graphics#fillArc */ public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { Arc2D arc = new Arc2D.Float(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN); draw(arc); }