Everyday Coder

eve·ry·day cod·er [ev-ree-dey koh-der, noun]
a person who designs, writes and tests computer programs daily

Soft Clipping with Java 2D

The current application that I'm coding uses an interface composed mostly of rounded rectangles. Initially it looked really cool. I later added transparency to some of the panels so that the parent panel's background would show through. On the Mac, it looked really great. I had since ran the application on Windows and a few of my decisions regarding how I made the rounded rectangle backgrounds came back to haunt me.

With a little more testing, I discovered that the issues lied with anti-aliasing and clipping using Graphics2D. Since this issue was purely asthetic, I moved on to more pressing issues. Then, about a week later I got my monthly Tech Tips from Sun. Talk about reading my mind. The Java 2D Trickery - Core Java Technologies Technical Tips contains 2 excellent Java 2D tips. The first one titled Java 2D Soft Clipping was the answer I needed.

After about 5 minutes, the problem was resolved and it now looks great on both platforms. Excellent tip! Well done Chris Campbell! I suggest you check it out and subscribe if you haven't already done so.

Trackback URI | Comments RSS

Post a Comment