Odd shaped circles revisited
Date: Mon, 8 Nov 1999 10:19:50 GMT
Reply-To: Ron Yorston <rmy@TIGRESS.CO.UK>
Sender: Discussion list for Java 2D API <JAVA2D-INTEREST@JAVA.SUN.COM>
From: Ron Yorston <rmy@TIGRESS.CO.UK>
Subject: Odd shaped circles revisited
A couple of weeks ago I asked about bug id 4151279 (Filled ellipses are
often not as smooth as calling fillOval in JDK 1.1), and whether anything
was going to happen about fixing it for the final release of JDK 1.3.
My applet, which draws a large number of small circle as markers on a map,
works fine under JDK 1.0 and 1.1 but less well under JDK 1.2:
1) Drawing the map is slower.
2) The circles look ugly, and non-circular.
3) Circles drawn to an offscreen image have a different shape to those
drawn directly to a window.
The only suggestion from the list (thanks to John Caron) was to set the
Graphics2D rendering hint to turn on anti-aliasing. This improved the
appearance of the circles but slowed down the drawing to an unacceptable
I've now worked around the problem by drawing the circles as polygons.
Since I only want circles with 3 to 10 pixel diameter I've just hardcoded
the necessary polygons to provide the same appearance as under JDK 1.0/1.1.
Mostly these are octagons. When I detect that the applet is running under
JDK 1.2 (because the Graphics object for the offscreen image is a subclass
of java.awt.Graphics2D) I use the polygons instead of drawOval/fillOval.
Here are timings for one of my animations. (All times in min:sec; Blackdown
Linux ports of JDK; 1.0.2 with no JIT, 1.1.7 with TYA, 1.2.0 with sunwjit.)
JDK 1.0.2 0:34
JDK 1.1.7 0:32
JDK 1.2.0 4:50
JDK 1.2.0+anti-alias 13:56
JDK 1.2.0+polygons 1:34
So, using the polygons, JDK 1.2 is only three times slower than 1.0/1.1, and
the appearance of the circles is identical in all cases.
I can't say I'm very happy to have this performance penalty in 1.2, nor with
having to bloat my code with special cases to achieve even this level of
performance. Nor, come to that, with Sun's dismissive attitude to this
issue in the bug database where an evaluator wrote (over a year ago) that
the circles 'look good enough for the first release'. This is only the
case if you don't want circles that look circular.
Bring back sun.awt.motif.X11OffScreenImage, I say.