移植AWT图形code到Android [英] Porting AWT graphics code to Android

查看:150
本文介绍了移植AWT图形code到Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们愿用我们的一些现有的Java AWT图形code在Android平台上。据我所知,Android不包括任何AWT类的 - 没有的Graphics2D Path2D中的FontMetrics 等。

We would like to use some of our existing Java AWT graphics code on the Android platform. As far as I can tell, Android does not include any of the AWT classes -- no Graphics2D, Path2D, FontMetrics, etc.

什么是口最好的办法我们的绘图code到Android?理想情况下,我们要修改我们的code基地为目标的两个的Andr​​oid和通用的Java。

What is the best approach to port our drawing code to Android? Ideally, we would like to modify our code base to target both Android and generic Java.

推荐答案

Android平台支持AWT的一小部分。小,我的意思是它支持AWT的字体。从Java秋千去(你真的只使用AWT作为一个独立的用户界面?)到Android将是一个震动系统。一个限定机器人的UI中的XML资源文件,并且这些资源被装载到哪个重新presents应用程序的一个逻辑单元的活动类。画布'取代的Graphics2D对象,并且它们具有稍微不同functionality.The机器人UI系统力求避免绝对定位,这是在Java的UI的常见。而且有这么多考虑为Android一样,不同的屏幕尺寸和不同的分辨率。这两者都不是太大的问题,对Java SE的。要回答你的问题:你有你的工作等着你,你将不得不开始多从零开始的编码。

The android platform supports a small subset of awt. By small, I mean it supports awt fonts. Going from java swing (are you really just using awt as a standalone UI?) to Android is going to be a shock to the system. One defines Android's UI in XML resource files, and those resources are loaded into Activity classes which represents a logical unit of the application. Canvas' replace Graphics2D objects, and they have somewhat different functionality.The Android UI system seeks to avoid absolute positioning, which is common in java UI's. And there is so much more to consider for Android, like varying screen sizes and differences in resolution. Neither of which were much of a issue for Java SE. To answer your question: you have your work cut out for you and you will have to start much of your coding from scratch.

我不知道有什么借鉴code'的意思,但对我来说,我有一个通过AWT的形状显示了大量的动漫code。这是可再现的Andr​​oid作为有graphics.drawable.shapes对象,可以通过执行类似canvas.drawCircle(X,Y,Z,H)显示原始形状(提醒的东西吗?)。但是,当我将它移植,这是困难的,感觉就像我是cortorting Android的做一些事情真的不想,并没有打算这样做。这是很难回答你的问题正是鉴于它​​的模糊性。

I'm not sure what 'drawing code' means, but in my case, I have a large amount of animation code that is displayed via awt shapes. This is reproducable on android as there are graphics.drawable.shapes objects, and one can display primitive shapes by doing something like canvas.drawCircle(x,y,z,h) (remind you of something?). But when I ported it, it was difficulty and felt like I was cortorting the android to do something it really didn't want to, and wasn't intended to do. It's hard to answer your question exactly given the vagueness of it.

这篇关于移植AWT图形code到Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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