As long as said abstraction layer doesn't take away from what's possible
with Java2D, it doesn't matter to me. Maybe offer a "lower-level"
toolkit-specific API in addition to the "higher-level" drawing abstraction
layer.
Cheers,
Michael
On Mon, 29 Mar 2010, Greg Brown wrote:
Hi Michael,
These are some great points. FWIW, what we have been discussing more
recently is providing an abstraction layer that would allow Pivot apps
to run on top of Java2D or SWT (i.e. an "org.apache.pivot.wtk.Graphics"
class). Pivot's component skins would be refactored to draw to this
rather than Graphics2D directly. This will allow us to run apps natively
in whatever graphics context is most appropriate. Later, we may add
additional support for other drawing contexts, such as JOGL, Android, or
the HTML 5 canvas tag.
Greg
On Mar 28, 2010, at 8:35 PM, Michael Allman wrote:
Hi,
I found a thread on the eclipse developers' list
http://dev.eclipse.org/mhonarc/lists/eclipse-dev/msg08814.html
where Greg talks about switching Pivot from Java2D to SWT. As someone with
experience with Java2D and SWT from building Swing and Eclipse apps,
respectively, I think this is a bad idea. Here's why.
First, Java2D is built-in to the JRE. SWT adds another dependency, and it's a
biggie. On my installation of Eclipse, the Cocoa SWT jar file is 1.9 megabytes.
Second, can SWT applets be built? I don't know...
Third, Java2D drawing can be transparently accelerated with Direct3D or OpenGL
(to the best of my knowledge, this is not enabled by default to maintain
pixel-accurate backwards and cross-platform compatibility).
Fourth, Java2D offers the VolatileImage, which is an image buffer that can be
backed by video RAM.
Fifth, Java2D offers subpixel drawing. All of the drawing operations and
graphics primitives of the SWT GC class are defined with int parameters. Java2D
offers subpixel float and double specifications for drawing and rectangles, etc.
Finally, a migration means that any custom component skins or anything that
uses Graphics2D will need to be ported, and if the SWT drawing API doesn't
support a Java2D feature that Joe User used, he's not going to be a happy
camper.
I'm curious to hear other views on this matter. Who wants to stick with
Java2D? Who wants to switch to SWT? Who wants ice cream?
Cheers,
Michael