[solved] custom foregroundAlpha for an XYStepAreaRenderer

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
BigDong
Posts: 7
Joined: Tue Jul 24, 2012 4:46 pm
antibot: No, of course not.

[solved] custom foregroundAlpha for an XYStepAreaRenderer

Post by BigDong » Tue Jul 24, 2012 4:54 pm

Hi everyone,

I am trying to render a nice chart, with 3 datasets.
2 of them are sensibly identique, it's not a stacked renderer, so i need to make it more readable.

If I can find a way to customize the alphaforeground for each plot, It would really help.

I have checked all the differents demos, and none of them can fit the configuration I need.

Do you know if there is a way to customize ?

Ex : Image
Last edited by BigDong on Wed Jul 25, 2012 2:48 pm, edited 1 time in total.

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: custom foregroundAlpha for an XYStepAreaRenderer

Post by John Matthews » Wed Jul 25, 2012 5:02 am

Have you tried overriding getItemPaint()?

BigDong
Posts: 7
Joined: Tue Jul 24, 2012 4:46 pm
antibot: No, of course not.

Re: custom foregroundAlpha for an XYStepAreaRenderer

Post by BigDong » Wed Jul 25, 2012 8:22 am

How would that help ?
getItemPaint wrote:Returns the paint used to fill data items as they are drawn.

Returns:
The paint (never null).

brimborium
Posts: 23
Joined: Mon Dec 13, 2010 10:23 am
antibot: No, of course not.

Re: custom foregroundAlpha for an XYStepAreaRenderer

Post by brimborium » Wed Jul 25, 2012 11:37 am

By overriding it, you could apply some alpha value to the paint before forwarding it. Whenever the paint is needed from the painting methods, they will use that modified paint.

That's at least what I think he meant by his suggestion. ;) Sounds like a good idea, that might work.

BigDong
Posts: 7
Joined: Tue Jul 24, 2012 4:46 pm
antibot: No, of course not.

Re: custom foregroundAlpha for an XYStepAreaRenderer

Post by BigDong » Wed Jul 25, 2012 2:47 pm

Hi again, thanks, it work.

I didn't use getItemPaint, I just had to change my colorList with Color(r,g,b,a) and it worked great.

Thanks for the idea ;)

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: [solved] custom foregroundAlpha for an XYStepAreaRendere

Post by John Matthews » Fri Jul 27, 2012 12:01 am

brimborium wrote, "That's at least what I think he meant by his suggestion."

Exactly. The API goes on to say "You can override this method if you require different behaviour." There's a related example here that varies saturation, rather than alpha.

Locked