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.

No comments: