Here is an applet that demonstrates most of the possible variables at play:
This applet (source included) is available here.
Also there are several AlphaComposite types where it makes a huge difference whether you're rendering images vs shapes. In this applet if "Use Images" is selected then the shapes you see are first rendered in a BufferedImage, and then those images are rendered together.
That's all. This is a clean, short article -- as much for my benefit as anyone else's.

applets are dead =)
ReplyDeletewell, may be they are not, but if possible, can you provide a webstart version too?
for me applets are dead too :(
ReplyDeleteApplets are not my favorite things in the world: but they work and are very low-maintenance from my end.
ReplyDeleteCan you sell me on the idea of providing webstart versions? (What is it about webstarts that you need that applets don't provide?)
This applet is very much alive and OK :)
ReplyDeleteWhy is there a difference between images and shapes? Is this a Java bug or feature?
I'm not sure, but I think it's a feature.
ReplyDeleteShapes should only affect pixels inside their shape. If they affected pixels outside the shape: this would ruin simple SrcOver painting operations.
And it makes sense that when images are composited: every pixel should be taken into account.
... therefore: I think the current behavior is working as designed. The applet above highlights some strange side effects of these rules, but I can't think of any other rules to govern things by.
(If you can, then maybe I'm mistaken and this is a bug?)