This is interesting to include in the main distribution. > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Johannes Rudolph > Sent: Wednesday, November 09, 2005 9:14 AM > To: [email protected] > Subject: Re: [iText-questions] PdfGraphics2D.setComposite: > Problems with jasperreports, jfreechart > > >> Any other possibility? > > > No. > > That's right in general, but jfreechart uses only > AlphaComposite.SRCOVER, so there is a quite simple > workaround: Just change all > 'incoming' Paints so that the alpha value specified in > AlphaComposite is applied to the alpha value of the Paint. > > I've done that here for Color (for texture and Gradient > Paints it should possible as well): > > (put it into PdfGraphics2D) > > private float alphaValue=1; > private Composite composite=null; > /** > * @see Graphics2D#setComposite(Composite) > */ > public void setComposite(Composite comp) { > if (comp instanceof AlphaComposite){ > AlphaComposite composite = (AlphaComposite) comp; > if (composite.getRule()==AlphaComposite.SRC_OVER){ > alphaValue=composite.getAlpha(); > this.composite=composite; > return; > } > } > this.composite=comp; > alphaValue=1f; > if (comp!=null) > System.out.println("Composite not currently supported: > "+comp.toString()); > } > private Paint realPaint=null; > /** > * @see Graphics2D#setPaint(Paint) > */ > public void setPaint(Paint paint) { > if (paint == null) > return; > this.paint = paint; > > realPaint=null; > > if (composite instanceof AlphaComposite&&paint > instanceof Color) { > AlphaComposite co = (AlphaComposite) composite; > if (co.getRule()==AlphaComposite.SRC_OVER){ > Color c=(Color)paint; > this.paint=new > Color(c.getRed(),c.getGreen(),c.getBlue(),(int)(c.getAlpha()*a > lphaValue)); > this.realPaint=paint; > } > } > } > > /** > * @see Graphics2D#getPaint() > */ > public Paint getPaint() { > if (realPaint!=null) > return realPaint; > return paint; > } > > /** > * @see Graphics2D#getComposite() > */ > public Composite getComposite() { > return composite; > } > > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App > Server. Download > it for free - -and be entered to win a 42" plasma tv or your very own > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions >
------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
