private void drawProgressArc(Graphics2D graphics, int x, int y, int w, int h, double radiusStart, double radiusEnd, int strokeWidth, Color color) { Stroke stroke = graphics.getStroke(); graphics.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); graphics.setColor(color); graphics.draw(new Arc2D.Double( x, y, w, h, radiusStart, radiusEnd, Arc2D.OPEN)); graphics.setStroke(stroke); }
final Arc2D.Double arc = new Arc2D.Double(); arc.x = cx - rx; arc.y = cy - ry;
private void renderRegen(Graphics2D g, WidgetInfo widgetInfo, double percent, Color color) { Widget widget = client.getWidget(widgetInfo); if (widget == null || widget.isHidden()) { return; } Rectangle bounds = widget.getBounds(); Arc2D.Double arc = new Arc2D.Double(bounds.x + OFFSET, bounds.y + (bounds.height / 2 - DIAMETER / 2), DIAMETER, DIAMETER, 90.d, -360.d * percent, Arc2D.OPEN); final Stroke STROKE = new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); g.setStroke(STROKE); g.setColor(color); g.draw(arc); } }
Arc2D arc = new Arc2D.Double(x, y - 197 * eh / 700, ew, eh, 0, 360, Arc2D.OPEN); Arc2D innerarc = new Arc2D.Double(x + 1, y - 197 * eh / 700 + 1, ew - 2, eh - 2, 0, 360, Arc2D.OPEN);
public static Shape getDonutSliceShape( Rectangle2D pieBounds, double thickness, double start, double extent) { thickness = thickness / 2; GeneralPath generalPath = new GeneralPath(); GeneralPath dummy = new GeneralPath(); // used to find arc endpoints double x = pieBounds.getX(); double y = pieBounds.getY(); double width = pieBounds.getWidth(); double height = pieBounds.getHeight(); Shape outer = new Arc2D.Double(x, y, width, height, start, extent, Arc2D.OPEN); double wt = width * thickness; double ht = height * thickness; Shape inner = new Arc2D.Double( x + wt, y + ht, width - 2 * wt, height - 2 * ht, start + extent, -extent, Arc2D.OPEN); generalPath.append(outer, false); dummy.append( new Arc2D.Double( x + wt, y + ht, width - 2 * wt, height - 2 * ht, start, extent, Arc2D.OPEN), false); Point2D point = dummy.getCurrentPoint(); if (point != null) { generalPath.lineTo(point.getX(), point.getY()); } generalPath.append(inner, false); dummy.append(new Arc2D.Double(x, y, width, height, start + extent, -extent, Arc2D.OPEN), false); point = dummy.getCurrentPoint(); generalPath.lineTo(point.getX(), point.getY()); return generalPath; }
/** * Create an arc at the given position. * <p/> * Arcs rotate in the opposite direction from Java's Arc2D to be compatible with our transform functions. * * @param position The position of the arc. * @param width The arc width. * @param height The arc height. * @param startAngle The start angle. * @param degrees The amount of degrees. * @param arcType The type of arc. Either "chord", "pie", or "open" * @return The new arc. */ public static Path arc(Point position, double width, double height, double startAngle, double degrees, String arcType) { int awtType; if (arcType.equals("chord")) { awtType = Arc2D.CHORD; } else if (arcType.equals("pie")) { awtType = Arc2D.PIE; } else { awtType = Arc2D.OPEN; } return new Path(new Arc2D.Double(position.x - width / 2, position.y - height / 2, width, height, -startAngle, -degrees, awtType)); }
private static Shape quarterCircle() { // Top-left quarter Shape d = new Arc2D.Double(new Rectangle2D.Double(-.5, -.5, 1., 1.), 180, 90, Arc2D.PIE); ExplicitBoundsShape shape = new ExplicitBoundsShape(d); shape.setBounds(new Rectangle2D.Double(-.5, .5, 1., 1.)); return shape; }
private static Shape thirdCircle() { // Top-left third Arc2D.Double d = new Arc2D.Double(new Rectangle2D.Double(-.5, -.5, 1., 1.), 150., 120., Arc2D.PIE); ExplicitBoundsShape shape = new ExplicitBoundsShape(d); shape.setBounds(new Rectangle2D.Double(-.5, .5, 1., 1.)); return shape; }
private static Shape semiCircle() { // Top half Arc2D.Double d = new Arc2D.Double(new Rectangle2D.Double(-.5, -.5, 1., 1.), 180., 180., Arc2D.PIE); ExplicitBoundsShape shape = new ExplicitBoundsShape(d); shape.setBounds(new Rectangle2D.Double(-.5, .5, 1., 1.)); return shape; }
/** * Converts a rectangle to an arc. * * @param pRectangle the framing rectangle * @param pStartAngle start angle in degrees (starting from 12'o clock, this differs from Java) * @param pArcAngle rotation angle in degrees (starting from {@code pStartAngle}, this differs from Java arcs) * @param pClosed specifies if the arc should be closed * @return the arc */ private static Arc2D.Double toArc(final Rectangle2D pRectangle, int pStartAngle, int pArcAngle, final boolean pClosed) { return new Arc2D.Double(pRectangle, 90 - pStartAngle, -pArcAngle, pClosed ? Arc2D.PIE : Arc2D.OPEN); }
case 2: g2d.fill(new Arc2D.Double(currX,currY,SHAPE_SIZE,SHAPE_SIZE,315,225,Arc2D.PIE)); break; case 3: break; case 2: g2d.fill(new Arc2D.Double(distractorX,distractorY,SHAPE_SIZE,SHAPE_SIZE,315,225,Arc2D.PIE)); break; case 3:
Arc2D arc = new Arc2D.Double(cx - rx, cy - ry, rx * 2, ry * 2, -startAngle, sweep, Arc2D.OPEN);
Arc2D.Double arc = new Arc2D.Double( point.getX() - totalWidth / 2 + currentPosX - bgPadding, point.getY() - icon.getHeight() / 2 - OVERLAY_ICON_DISTANCE - bgPadding,
Arc2D arc = new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN); draw(arc);
Arc2D arc = new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.PIE); fill(arc);
final Shape arc = new Arc2D.Double(x, y, ellipse.getWidth(), ellipse.getHeight(), round(ellipse.getStart()), round(ellipse.getExtend()), Arc2D.OPEN); if (color != null) {
Arc2D arc = new Arc2D.Double(x0, y0 - radius, chordLength, 2 * radius, 180, x0 < x ? 180 : -180, Arc2D.OPEN);
@Override public void execute(Path2D.Double path, Context ctx){ double rx = ctx.getValue(wr); double ry = ctx.getValue(hr); double ooStart = ctx.getValue(stAng) / OOXML_DEGREE; double ooExtent = ctx.getValue(swAng) / OOXML_DEGREE; // skew the angles for AWT output double awtStart = convertOoxml2AwtAngle(ooStart, rx, ry); double awtSweep = convertOoxml2AwtAngle(ooStart+ooExtent, rx, ry)-awtStart; // calculate the inverse angle - taken from the (reversed) preset definition double radStart = Math.toRadians(ooStart); double invStart = Math.atan2(rx * Math.sin(radStart), ry * Math.cos(radStart)); Point2D pt = path.getCurrentPoint(); // calculate top/left corner double x0 = pt.getX() - rx * Math.cos(invStart) - rx; double y0 = pt.getY() - ry * Math.sin(invStart) - ry; Arc2D arc = new Arc2D.Double(x0, y0, 2 * rx, 2 * ry, awtStart, awtSweep, Arc2D.OPEN); path.append(arc, true); }
/** * Draws a circular arc of the specified radius, * centered at (<em>x</em>, <em>y</em>), from angle1 to angle2 (in degrees). * * @param x the <em>x</em>-coordinate of the center of the circle * @param y the <em>y</em>-coordinate of the center of the circle * @param radius the radius of the circle * @param angle1 the starting angle. 0 would mean an arc beginning at 3 o'clock. * @param angle2 the angle at the end of the arc. For example, if * you want a 90 degree arc, then angle2 should be angle1 + 90. * @throws IllegalArgumentException if {@code radius} is negative */ public static void arc(double x, double y, double radius, double angle1, double angle2) { if (radius < 0) throw new IllegalArgumentException("arc radius must be nonnegative"); while (angle2 < angle1) angle2 += 360; double xs = scaleX(x); double ys = scaleY(y); double ws = factorX(2*radius); double hs = factorY(2*radius); if (ws <= 1 && hs <= 1) pixel(x, y); else offscreen.draw(new Arc2D.Double(xs - ws/2, ys - hs/2, ws, hs, angle1, angle2 - angle1, Arc2D.OPEN)); draw(); }
/** * Draws an arc of radius r, centered on (x, y), from angle1 to angle2 (in degrees). * * @param x the x-coordinate of the center of the circle * @param y the y-coordinate of the center of the circle * @param r the radius of the circle * @param angle1 the starting angle. 0 would mean an arc beginning at 3 o'clock. * @param angle2 the angle at the end of the arc. For example, if * you want a 90 degree arc, then angle2 should be angle1 + 90. * @throws IllegalArgumentException if the radius of the circle is negative */ public void arc(double x, double y, double r, double angle1, double angle2) { if (r < 0) throw new IllegalArgumentException("arc radius can't be negative"); while (angle2 < angle1) angle2 += 360; double xs = scaleX(x); double ys = scaleY(y); double ws = factorX(2*r); double hs = factorY(2*r); if (ws <= 1 && hs <= 1) pixel(x, y); else offscreen.draw(new Arc2D.Double(xs - ws/2, ys - hs/2, ws, hs, angle1, angle2 - angle1, Arc2D.OPEN)); draw(); }