Using awt with android

六月ゝ 毕业季﹏ 提交于 2019-11-26 09:50:38

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/3897775/using-awt-with-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!