I seem to have started down a possibly foolish path and I wanted to
get some feedback. I have started porting Piccolo to the new HTML5
Canvas API. Mind you I am only a few hours into this, but here are my
thoughts up to this point.

After reviewing the Canvas API I noticed that it is rather similar to
Graphics2D, which makes sense since it is solving a similar problem;
writing raster graphics. I have not had the chance to do a feature by
feature comparison, so there is probably something missing which will
bit me down the road.

After looking at the implementation of a number of the PNode
subclasses, it looked to me like a number of them could use Canvas to
accomplish at least a similar visual effect. Things like PImage and
PPath looks like they should work and hopefully PText will work as
well. I suspect PHtmlView will never work, but maybe that's ok.

Basically I am using GWT to take as much of the Java Code from
Piccolo2D  and use the project gwt-canvas to provide the Graphics2D
type functionality. Since Piccolo depends so heavily on java.awt and
java.awt.geom and the awt packages are not supported in GWT I am
including a copy of those source files in the GWT project. For
example, Piccolo depends on java.awt.Rectangle, so I copy the existing
Rectangle class to a java.gwt.Rectangle and simply change the import
statement in the Piccolo code.

Copying the awt classes looks like it is going to work in general but
there are few problems which have shown themselves. First, most of the
geometry type classes (Rectangle2D, Point2D, etc) only depend on them
selves and java.lang.Math, so this makes them viable classes to be
used with GWT, but some of them depends on internal sun.java.bla.bla.*
classes, which I don't currently have the source code for. The second
problem as I have not had a chance to review the legal issue in
reusing Oracle's code in this way. I has occurred to me I might have
better luck taking the code from Apache's project harmony, but again I
have not gotten that far. For that matter I am not sure about altering
the Piccolo2D code either.

It is my intention to make all of the work I am going here as free as
possible, so if someone has some experience with this, helping me make
sure that everyone's licenses are being properly honored, please let
me know.

Another concern of mine is that Piccolo does a lot more than just draw
a scene, it also provides node picking and other input events, I am
not sure how well that is going to work. A HTML5 Canvas element is
able to receive mouse and keyboard events, I just don't know if those
will be descriptive enough work with the existing Piccolo APIs.

Another issue is that JavaScript (which GWT code ultimately becomes)
does not support a double precision floating point values. GWT allows
you to use Java doubles in your code, but behind the scene they are
actually using two single precision float values to store the data and
they do some magic to manage those values for you. It is stated in the
GWT docs that this includes some overhead. So, since I am basically
copying all of the awt classes, I could just turn every double into a
float and then do the same to the piccolo code.... I have not started
doing this, but this is another topic I would like some feedback on.

So those are basically my technical concerns up to this point. But you
might be asking, "why are you doing this?" and basically it comes down
creating a cross platform scene graph API. I have worked with Piccolo
in the past and know that it is a solid scene graph API. I have also
worked a lot with JavaFX and know that that brings an excellent scene
graph API as well, plus it has properties and value binding, it is a
real pleasure to work with. But both of these APIs are dependent on
the presence of a modern JVM and frankly I don't see a real JVM
showing up on the devices I want to develop for. But on all of the
devices I want to developer for there is HTML5 compliant browser, this
includes, all desktop computers, Apple's i products, set top boxes,
Android and any other future google device, and many more.

I considered SVG, which also has pretty good cross platform support,
but there are limitations, especially coming from the Microsoft side
of things which claim they will not be including the animation
features.

Anyway, thanks for reading all this, I would love to get a reality
check here :)

-Lucas

Resources:
http://www.piccolo2d.org/
http://code.google.com/webtoolkit/
http://code.google.com/p/gwt-canvas/
http://harmony.apache.org/



-- 
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en

Reply via email to