使用AWT采用AndroidAWT、Android

2023-09-12 02:22:01 作者:拿稳我心你称王

我有一个Java Swing应用程序而绘制的图表。它使用的Graphics2D电话和AWT的对象,如矩形等。

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

在某一点上,我可能想将这个到Android。我明白,我不能在Android上使用的Graphics2D,但我还可以使用AWT的矩形,字体,颜色(等)的类。

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.

我想要做的就是通过增加一个模拟层,所以我的Graphics2D电话可以转换到Android绘图调用隔离摆动版本和Android版本之间的任何code的变化。

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.

这是可行的?

只是要清楚,我不是太担心的事情了Swing UI端(用户界面是最小的,可以改写为Android),我关心实际的绘图code从许多地方调用的Graphics2D

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.

推荐答案

主要的问题是,你不能做在一个名为包创建类 java.awt中的 。但除了这一点,基本上可以基于AWT API重写的库。

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.

您还可以查看 AWT,Android为COMPAT 的项目。