From 64877ac92b1503e6f5261e2483ca5d96210b9d39 Mon Sep 17 00:00:00 2001 From: DJGummikuh Date: Sat, 26 Feb 2022 11:45:00 +0100 Subject: [PATCH] Adding possibility to set the web fill alpha value so it's not locked to 0.1f --- .../org/jfree/chart/plot/SpiderWebPlot.java | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jfree/chart/plot/SpiderWebPlot.java b/src/main/java/org/jfree/chart/plot/SpiderWebPlot.java index 6a71e689c4..9abfa0ae57 100644 --- a/src/main/java/org/jfree/chart/plot/SpiderWebPlot.java +++ b/src/main/java/org/jfree/chart/plot/SpiderWebPlot.java @@ -252,6 +252,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; @@ -392,6 +395,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). * @@ -648,8 +679,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). @@ -1343,7 +1374,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()));