Thursday, August 2, 2007

API changes

The icon demo was a great experience, but, it did bring up some API issues.

First the getScaledInstance() call in the original code. I getScaledInstance() because it's one line and rather self documenting. It didn't get in the way by adding any complexity. The alternative would be to use a BufferedImage and a Graphics object. The best quality approach from Chris Campbell's article was a lot more code then I wanted to add. This demo is about Icons after all not Java2D. In the end I compromised on about 8 lines of code to do a simple bilinear downscaling. I think a more robust version of this faster method of resizing should be packaged up in a nice neat single call.

Something like this ..

public static BufferedImage BufferedImage.getScaledImage(BufferedImage src, width, height,
Object hint, boolean multipass);

I'm not sure if BufferedImage is the correct place for it or not.

Also while SwingWorker is very useful I really hate having to return null at the end of doInBackground(). I wish there was an "IntermediateSwingWroker" that just didn't return anything from doInBackground().

Other then that things went smoothly. I'm glad my changes had zero impact on Java Web Start.

Wednesday, August 1, 2007

I got published!

My first post on this blog was complaining about the current state of the icon demo app from the Java tutorial page. I even wrote some replacement code. It received a lot more attention then I ever thought was possible. I got some great comments, Mikael Grev (of MiG Layout fame), blogged about it on javalobby and finally I was contacted by Sharon Zakhour of Sun. She asked if they could include my code in the tutorial. I was very happy to say yes. I revised my code a little more, helped rewrite some of the page and submitted my code and documentation to Sharon. It went through an engineering review. There was some discussion about my usage of Image.getScaledInstance() and a tweak was added to use the resizing strategy put forth in The Perils of Image.getScaledInstance(). All in all it was an enjoyable experience. And now my code has actually been pushed to the web. It's now officially part of the How to Use Icons section of the Java tutorial.

Would I do it again? Yes, absolutely. Everyone at sun was great.