From: David G. <mu...@us...> - 2006-06-30 13:04:58
|
Update of /cvsroot/jfreechart/jfreechart/source/org/jfree/chart/plot In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv2618/source/org/jfree/chart/plot Modified Files: Tag: STABLE_1-0-0 Plot.java Log Message: 2006-06-30 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/Plot.java (backgroundImageAlpha): New field, (getBackgroundImageAlpha): New method, (setBackgroundImageAlpha): New method, (drawBackgroundImage): Use new alpha field, * source/org/jfree/chart/plot/junit/PlotTests.java (testEquals): Added check for new field. Index: Plot.java =================================================================== RCS file: /cvsroot/jfreechart/jfreechart/source/org/jfree/chart/plot/Plot.java,v retrieving revision 1.18.2.3 retrieving revision 1.18.2.4 diff -C2 -d -r1.18.2.3 -r1.18.2.4 *** Plot.java 25 Oct 2005 20:52:07 -0000 1.18.2.3 --- Plot.java 30 Jun 2006 13:04:52 -0000 1.18.2.4 *************** *** 3,7 **** * =========================================================== * ! * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html --- 3,7 ---- * =========================================================== * ! * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html *************** *** 28,32 **** * Plot.java * --------- ! * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); --- 28,32 ---- * Plot.java * --------- ! * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); *************** *** 36,39 **** --- 36,40 ---- * Gideon Krause; * Nicolas Brodu; + * Michal Krause; * * $Id$ *************** *** 113,116 **** --- 114,119 ---- * 06-Jun-2005 : Fixed bugs in equals() method (DG); * 01-Sep-2005 : Moved dataAreaRatio from here to ContourPlot (DG); + * ------------- JFREECHART 1.0.0 --------------------------------------------- + * 30-Jun-2006 : Added background image alpha - see bug report 1514904 (DG); * */ *************** *** 246,249 **** --- 249,255 ---- private int backgroundImageAlignment = Align.FIT; + /** The alpha value used to draw the background image. */ + private float backgroundImageAlpha = 0.5f; + /** The alpha-transparency for the plot. */ private float foregroundAlpha; *************** *** 587,590 **** --- 593,631 ---- /** + * Returns the alpha transparency used to draw the background image. This + * is a value in the range 0.0f to 1.0f, where 0.0f is fully transparent + * and 1.0f is fully opaque. + * + * @return The alpha transparency. + * + * @see #setBackgroundImageAlpha(float) + */ + public float getBackgroundImageAlpha() { + return this.backgroundImageAlpha; + } + + /** + * Sets the alpha transparency used when drawing the background image. + * + * @param alpha the alpha transparency (in the range 0.0f to 1.0f, where + * 0.0f is fully transparent, and 1.0f is fully opaque). + * + * @throws IllegalArgumentException if <code>alpha</code> is not within + * the specified range. + * + * @see #getBackgroundImageAlpha() + */ + public void setBackgroundImageAlpha(float alpha) + { + if (alpha < 0.0f || alpha > 1.0f) + throw new IllegalArgumentException( + "The 'alpha' value must be in the range 0.0f to 1.0f."); + if (this.backgroundImageAlpha != alpha) { + this.backgroundImageAlpha = alpha; + this.notifyListeners(new PlotChangeEvent(this)); + } + } + + /** * Returns the stroke used to outline the plot area. * *************** *** 787,808 **** * @param g2 the graphics device. * @param area the area. */ protected void drawBackgroundImage(Graphics2D g2, Rectangle2D area) { if (this.backgroundImage != null) { Composite originalComposite = g2.getComposite(); ! g2.setComposite(AlphaComposite.getInstance( ! AlphaComposite.SRC, this.backgroundAlpha ! )); ! Rectangle2D dest = new Rectangle2D.Double( ! 0.0, 0.0, ! this.backgroundImage.getWidth(null), ! this.backgroundImage.getHeight(null) ! ); Align.align(dest, area, this.backgroundImageAlignment); ! g2.drawImage( ! this.backgroundImage, ! (int) dest.getX(), (int) dest.getY(), ! (int) dest.getWidth() + 1, (int) dest.getHeight() + 1, null ! ); g2.setComposite(originalComposite); } --- 828,848 ---- * @param g2 the graphics device. * @param area the area. + * + * @see #getBackgroundImage() + * @see #getBackgroundImageAlignment() + * @see #getBackgroundImageAlpha() */ protected void drawBackgroundImage(Graphics2D g2, Rectangle2D area) { if (this.backgroundImage != null) { Composite originalComposite = g2.getComposite(); ! g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, ! this.backgroundImageAlpha)); ! Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0, ! this.backgroundImage.getWidth(null), ! this.backgroundImage.getHeight(null)); Align.align(dest, area, this.backgroundImageAlignment); ! g2.drawImage(this.backgroundImage, (int) dest.getX(), ! (int) dest.getY(), (int) dest.getWidth() + 1, ! (int) dest.getHeight() + 1, null); g2.setComposite(originalComposite); } *************** *** 997,1000 **** --- 1037,1043 ---- return false; } + if (this.backgroundImageAlpha != that.backgroundImageAlpha) { + return false; + } if (this.foregroundAlpha != that.foregroundAlpha) { return false; |