Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using awt with android

Tags:

I have a Java Swing application which draws diagrams. It uses Graphics2D calls and awt objects such as Rectangle etc.

At some point I might want to port this to Android. I understand that I can't use Graphics2D on Android, but can I still use the awt Rectangle, Font, Color (etc) classes.

What I want to do is to isolate any code changes between the swing version and the Android version by adding an emulation layer so my Graphics2D calls can be converted to Android drawing calls.

Is this feasible?

Just to be clear, I am not too worried about the Swing UI side of things (the UI is minimal and can be rewritten for Android), I am concerned about the actual drawing code which calls Graphics2D from many places.

like image 439
tomd Avatar asked Oct 09 '10 20:10

tomd


2 Answers

The main problem is that you won't be able do create classes in packages named java.awt. But except that point, basically you can rewrite a library based on awt API.

You can also check awt-android-compat project.

like image 92
Colin Hebert Avatar answered Oct 01 '22 06:10

Colin Hebert


http://www.apogee.com/ has commercial products which will allow you to run Swing programs on Android. Note that I've never used this product so I can't comment on how good it is.

like image 29
Noel Grandin Avatar answered Oct 01 '22 04:10

Noel Grandin