Skip to content

Commit

Permalink
Merge pull request #279 from DJGummikuh/v1.5.x
Browse files Browse the repository at this point in the history
Add attribute for alpha fill
  • Loading branch information
jfree committed Jun 17, 2022
2 parents fc79c47 + bce0056 commit 2e7867a
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions src/main/java/org/jfree/chart/plot/SpiderWebPlot.java
Expand Up @@ -220,6 +220,9 @@ public class SpiderWebPlot extends Plot implements Cloneable, Serializable {
/** controls if the web polygons are filled or not */
private boolean webFilled = true;

/** The alpha value of the fill portion of a polygon. */
private float webFillAlpha = 0.1F;

/** A tooltip generator for the plot ({@code null} permitted). */
private CategoryToolTipGenerator toolTipGenerator;

Expand Down Expand Up @@ -360,6 +363,34 @@ public void setWebFilled(boolean flag) {
fireChangeEvent();
}


/**
* Method to set the alpha value for the fill of a plot polygon.
*
* @param alpha the new alpha value. If it is outsite [0,1] it will be corrected to fit the range.
* @see #getWebFillAlpha()
*/
public void setWebFillAlpha(float alpha) {
this.webFillAlpha = alpha;
if (webFillAlpha < 0f) {
webFillAlpha = 0f;
} else if (webFillAlpha > 1f) {
webFillAlpha = 1f;
}
fireChangeEvent();
}

/**
* Method to return the alpha value for filling a graph.
*
* @return The alpha value for filling a spider plot polygon.
*
* @see #setWebFillAlpha(float)
*/
public float getWebFillAlpha() {
return webFillAlpha;
}

/**
* Returns the data extract order (by row or by column).
*
Expand Down Expand Up @@ -616,8 +647,8 @@ public Paint getSeriesPaint() {
}

/**
* Sets the paint for ALL series in the plot. If this is set to
* {@code null}, then a list of paints is used instead (to allow different
* Sets the paint for ALL series in the plot. If this is set to
* {@code null}, then a list of paints is used instead (to allow different
* colors to be used for each series of the radar group).
*
* @param paint the paint ({@code null} permitted).
Expand Down Expand Up @@ -1311,7 +1342,7 @@ protected void drawRadarPoly(Graphics2D g2,

if (this.webFilled) {
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
0.1f));
webFillAlpha));
g2.fill(polygon);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
getForegroundAlpha()));
Expand Down

0 comments on commit 2e7867a

Please sign in to comment.