ComponentOrientation and Right To Left Languages

March 16th, 2008

For some time, we've had an Arabic translation in EditLive! and the editor pane itself fully supports bidirectional text, but we've never updated the UI to flip over to a mirror image when a right to left language is in use. Java actually has pretty reasonable support for this via the ComponentOrientation property in AWT (and inherited through to Swing) but there are a couple of annoying limitations:

  1. It applies on a per component basis, so there isn't a single place you can apply the orientation and be done with it.
  2. Various components still don't flip, eg JSplitPane.
  3. The Aqua L&F on OS X has some annoying bugs when in right to left mode.

For the first issue, you can use applyComponentOrientation which will automatically traverse the component hierarchy and make the changes but it still misses things like combo box renderers, dialogs or components that are generated later. For an application that loads its UI incrementally instead of blocking the swing thread while it loads in one go this is a significant annoyance. Even beyond that, all the dialogs need to be updated as well. While it is good that you can override the orientation on a per-component basis, it seems more intelligent to have a simple way to change the default value in one place without all the work.

The second issue really just means more special case code to deal with which is a shame. In some cases you just need to change the way you use the classes like using LINE_START and LINE_END instead of EAST and WEST with BorderLayout, in others you really need special case code.

The bugs in the Aqua L&F are annoying - editable JComboBoxes are probably the worst, the text field winds up aligned right but the combo drop down button stays on the right so they overlap. The new capsule button styles that are applied by client properties don't handle right to left either so you have to manually track the component orientation and flip the "first" to "last" and visa versa.

All that said, supporting right to left languages is never just a flick of the switch and I'm yet to really get into the details of how it all should work (this was just an afternoon's investigation) so Java's done a pretty good job at supporting it and getting things this far. It will be interesting to hear from people who actually speak Arabic and get their feedback about how it should work and where all the little details we need to take care of are. If you happen to be an Arabic EditLive! user, please get in touch, it would be great to get some individual feedback before we roll out an update to everyone.

Kudos To Landon Fuller

November 6th, 2007

With all the complaining about Apple not having shipped JDK 6 with Leopard it's nice that someone has actually stopped whining and started coding. So kudos to Landon Fuller for actually doing something useful. Of course, he hasn't really gotten anywhere because porting Java is an awful lot of work, but if nothing else he'll understand why it takes Apple so long.

It also means we can start the timer to see if the open source model can actually bring Java 6 to OS X faster than Apple can.

Java 5 on Leopard

October 31st, 2007

The rumors of Java 5 being horribly broken beyond all usability on Leopard are, quite frankly, bullshit. It's faster, has better integration with the OS, the Aqua L&F is significantly improved, it has full support for 64 bit and a huge raft of bug fixes and miscellaneous improvements. Everyone's pointing to an uninformed rant on JavaLobby which as it's key example actually highlights a major improvement to the Aqua L&F - the JOptionPane icons should use the application icon, not some obscure artwork that's not used anywhere else in the system. The new dialogs actually allow you to look more like native app, not less. It's even explained in the release notes - heck, the old implementation was probably reported as a bug against Tiger.

Radar #4858198

JOptionPanes did not match the native Mac OS X dialog appearance

Description:

Default info JOptionPanes now use the application's icon, as per the Aqua User Interface Guidelines instead of a message bubble icon. Warning and error JOptionPanes now show the application's icon badged onto the warning or error icon as per the Aqua User Interface Guidelines.

Resolution:

This problem is now fixed in Mac OS X 10.5.

The graphics pipeline has changed in Leopard which means that if you've optimized for the Quartz renderer, you should specifically request it or you may find that suddenly things start going much slower. In most cases the Sun 2D pipeline is faster than the Quartz pipeline - particularly if the code makes Windows specific performance assumptions (most Java 2D code does whether the author knows it or not). So while some applications may run slower by default, most applications run much faster and those that do run slow can switch back to the Quartz pipeline. Change isn't always easy but it happens - stop whining and start coding.

You can complain that there's no Java 6 yet (though all those people complaining aren't getting anywhere with porting their own and there's no excuses now), and you can complain about the lack of information but Java 5 on Leopard is a significant improvement and the engineers at Apple deserve to be congratulated for that - not insulted.

Java On Leopard

October 28th, 2007

I was silly enough to open my work email this morning, only to discover that the Apple Java-Dev list had broken out into the age old Java on OS X argument. First up here's what people have reported1:

  • Java 6 is not included with Leopard.
  • The previous Java 6 DP which was pulled from ADC a while back does not run on Leopard.
  • Upgrading to Leopard from a system with the Java 6 DP installed can cause some frustrating issues with switching Java versions.
  • Apparently Java 5 is much faster on Leopard.
  • Java 5 looks different with quite a few tweaks to the Aqua L&F.
  • Some fonts don't look right in Java 5 on Leopard because it uses the Sun 2D graphics pipeline instead of the Quartz pipeline. The Sun 2D pipeline doesn't support sub-pixel antialiasing. You can override the default and there's a few other conditions that trigger the Quartz pipeline to be used by default.
  • Java 5 supports 64bit on Intel Core 2s (but not PPC). There seemed to be some problem with it when using the Java tools in /usr/bin though - can't say I followed that discussion too carefully.
  • Lots of documentation is coming, but not much is available yet.

Pretty sure that's the Java on Leopard wrap up, the other 150 emails to the list were just the usual gnashing of teeth about Apple abandoning Java and how Apple will lose so much business if they don't get Java 6 out yesterday etc etc etc. Of course, Apple's doing better than it ever has before and JavaOne was full of people using Macs - without Java 6 - so it would seem it's all just talk and insignificant numbers of people are actually leaving OS X. As a fresh twist, this time round people are talking of porting OpenJDK to OS X themselves and finally freeing themselves from the evil clutches of Apple! Apparently no one has told them that Java 6 isn't available from OpenJDK either - it will become Java 7 and is quite some way from that yet. I think it's a safe bet that Apple will have Java 6 out long before even a reasonable uncertified port of OpenJDK is available for OS X.

Oh well, time to put my flame proof underwear on - nothing gets people going like Java on OS X posts, for those who subscribe to the comments feed, this one's likely to drown out the Back to the 80s nonsense for a fair while….

Tomcat Startup Issues

August 21st, 2007

I was so close to having everything working… EC2, S3, automatically pulling down the latest build and deploying it, Tomcat 5.5 with the native APR libraries, SSL support and using iptables to forward ports 80 and 443 directly over to Tomcat. Everything ready to go. Except Tomcat isn't so keen on starting.

It usually starts, though it can take over half an hour to do so and on a couple of occasions it's just flat out sat there and done nothing for multiple hours on end. At startup it outputs the log message:

Aug 20, 2007 3:08:56 PM org.apache.coyote.http11.Http11AprProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080

and then nothing until all of a sudden 5-45 minutes later it suddenly comes back to life, finishes starting up and works perfectly. There's no CPU usage while it's out, it's just sitting there waiting for something to happen (network lookup??).

Sigh. I'm sure the world is out to get me….