将 awt 与 android 一起使用 [英] Using awt with android

查看:38
本文介绍了将 awt 与 android 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绘制图表的 Java Swing 应用程序.它使用 Graphics2D 调用和 Rectangle 等 awt 对象.

在某些时候,我可能想将其移植到 Android.我知道我不能在 Android 上使用 Graphics2D,但我仍然可以使用 awt Rectangle、Font、Color(等)类.

我想要做的是通过添加一个仿真层来隔离 Swing 版本和 Android 版本之间的任何代码更改,以便我的 Graphics2D 调用可以转换为 Android 绘图调用.

这可行吗?

澄清一下,我不太担心 Swing UI 方面的事情(UI 很小,可以为 Android 重写),我担心从许多地方调用 Graphics2D 的实际绘图代码.

解决方案

主要问题是您将无法在名为 java.awt 的包中创建类.但除此之外,基本上你可以基于awt API重写一个库.

您还可以查看awt-android-compat 项目.>

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.

解决方案

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.

这篇关于将 awt 与 android 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆