A weird Java2D bug under OSX

Last week I was playing with my toy line drawing editor again, and I noticed a very strange bug in the Java 2D graphics support under MacOS X. I wrote a tool to draw ovals, and it worked great. Then I wrote a tool to draw circles; it was just a subclass of the oval tool that constrained the vertical and horizontal axes to be the same dimension. It worked great, too, but I noticed that all my ovals (and other shapes, for that matter) were nicely antialiased, and all of the circles were jaggy.

Java2D circle bug

At first I thought I’d done something wrong, but the circle tool doesn’t change any of the drawing code from the oval tool.

It turns out that if you draw a circle using Java2D under MacOS X (at least using Java 1.3.1 under Jaguar) it does not do antialiasing at all. If you choose the oval tool and start sweeping out the bounding box, you can see it suddenly switch to jaggy pixels as the dimensions become completely circular, and then back to antialiased mode as you keep going. In the picture, both shapes were drawn with the oval tool; the only difference is that the one on the left has a square bounding box.

It doesn’t happen with Java on other platforms, or with Cocoa. My theory: there’s an optimization path in the Carbon port of Java2D. When it notices that it’s drawing a true circle, that optimization path kicks in, and there’s a bug so that it loses the quality hints.

Flouting user interface conventions

I remember the first time I tried a web browser with this behavior: you click once in the URL field, and the entire contents of the field is selected, ready to be replaced with a single keystroke. I don’t know for sure whether IE or Netscape for Windows was the first to do that, but I was definitely annoyed: “That’s not the way text fields are supposed to work!”

It still annoys me. But I am used to it. I know I’m used to it because Chimera doesn’t have that behavior, and it really throws me. Click … click … click click … drag … oh yeah, gotta remember, it’s easier if I use Command-L.

I’m glad the Chimera folks have decided to stick to UI conventions. (Of course, Chimera’s in beta, so perhaps they just haven’t added that “feature” yet.) It’s not as though the right way is really difficult. There are three easy ways to select the whole URL field: drag across it, triple-click, or Command-L. But it’s annoying that I’ve had several years of training in the wrong way.

Crashes …

I’ve had my PowerBook for over 3 months now. Saturday, for the first time, it crashed. (Early on, I had a few instances where it would power down instead of going to sleep, but I found out what was causing that.) Saturday was the first time it crashed on me while I was using it. I’ve got to hand it to those Apple guys: crashing on a Mac has a much better user interface than the Blue Screen O’ Death.

This morning, it happened again. Two crashes in four days. *sigh*. How disappointing.

Update: Again tonight. Time to figure out how to turn on crash dumps.

What is it about me?

I seem to have this knack: I pick up a new technology, and the very first thing I try to do with it goes beyond what the technology is capable of. It happens time and time again.

I’m using XSLT today. (It’s not the first time I used XSLT, but it’s the first time in a while, and I recall something similar happening the first time, too.) And I spent over an hour thinking, “There’s got to be a way to do this.

I finally went to the XSLT 2.0 Requirements document, and sure enough, what I want to do is in there … as an option that the working group may want to consider. *sigh*.

Google and fairness

I’ve seen a lot of people worrying lately about how fair, equitable, accurate, or helpful Google’s page rankings are. Dave is puzzled that he has an unreasonably high ranking when you search for “Dave”, and likewise an unreasonably low ranking when you search for “weblog”.

Come on, people. Google’s ranking system is based on heuristics, and sometimes those heuristics will give good results, sometimes bad. Google is a huge improvement on what went before, but the difference is just that their heuristics are better (and, incidentally, much more expensive to calculate).

Furthermore: it has to be that way. Given the weak semantics of HTML, the different ways of writing and structuring web pages, and the very different things that different people think are important, there’s no “one true way”; heuristic ranking is the only thing that makes sense.

subscribe via RSS or JSON Feed