Skip to content

Commit

Permalink
Don't allow arc to be null, simplifies code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfree committed Feb 18, 2023
1 parent 976d680 commit 9578494
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions src/main/java/org/jfree/svg/SVGGraphics2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,9 @@ public final class SVGGraphics2D extends Graphics2D {
private Ellipse2D oval;

/**
* An instance that is lazily instantiated in draw/fillArc and then
* subsequently reused to avoid creating a lot of garbage.
* An instance that is reused in draw/fillArc to avoid creating a lot of garbage.
*/
private Arc2D arc;
private Arc2D arc = new Arc2D.Double();

/**
* If the current paint is an instance of {@link GradientPaint}, this
Expand Down Expand Up @@ -2205,7 +2204,7 @@ public void fillOval(int x, int y, int width, int height) {
@Override
public void drawArc(int x, int y, int width, int height, int startAngle,
int arcAngle) {
setArc(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN);
this.arc.setArc(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN);
draw(this.arc);
}

Expand All @@ -2227,7 +2226,7 @@ public void drawArc(int x, int y, int width, int height, int startAngle,
@Override
public void fillArc(int x, int y, int width, int height, int startAngle,
int arcAngle) {
setArc(x, y, width, height, startAngle, arcAngle, Arc2D.PIE);
this.arc.setArc(x, y, width, height, startAngle, arcAngle, Arc2D.PIE);
fill(this.arc);
}

Expand Down Expand Up @@ -2971,29 +2970,6 @@ private void setRoundRect(int x, int y, int width, int height, int arcWidth,
arcWidth, arcHeight);
}
}

/**
* Sets the attributes of the reusable {@link Arc2D} object that is used by
* {@link #drawArc(int, int, int, int, int, int)} and
* {@link #fillArc(int, int, int, int, int, int)} methods.
*
* @param x the x-coordinate.
* @param y the y-coordinate.
* @param width the width.
* @param height the height.
* @param startAngle the start angle in degrees, 0 = 3 o'clock.
* @param arcAngle the angle (anticlockwise) in degrees.
* @param arcStyle the arc style.
*/
private void setArc(int x, int y, int width, int height, int startAngle,
int arcAngle, int arcStyle) {
if (this.arc == null) {
this.arc = new Arc2D.Double(x, y, width, height, startAngle,
arcAngle, arcStyle);
} else {
this.arc.setArc(x, y, width, height, startAngle, arcAngle, arcStyle);
}
}

/**
* Sets the attributes of the reusable {@link Ellipse2D} object that is
Expand Down

0 comments on commit 9578494

Please sign in to comment.