2

I'm currently working on a cross-platform application (actually a game using libgdx), and I need a constructive area geometry implementation for some algorithms.

The problem is that the Android API does not contain the java.awt.geom.Area implementation. It does contain the android.graphics.Region class 'though, which seems to be able to perform the same thing, meaning in this context defining polygons and then performing basic logical operation on their areas.

The solution seems to be to develop an adapter interface, and have each distribution (Java SE/Android) set the appropriate implementation at startup.

This is simple enough, but after some searching I'm baffled that I haven't yet encountered an implementation of the aforementioned solution.

My question is: is there, after all, a library that actually does already this, or, alternatively, another, easier solution to the problem, e.g. buried somewhere in the "common" Java API?

mikołak
  • 9,605
  • 1
  • 48
  • 70

1 Answers1

1

You might be able to use the code from the (now defunct?) Apache Harmony project's implementation of the java.awt.geom package: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/awt/src/main/java/common/java/awt/geom/

I have no experience with this code, so I can't say if its complete or any good. Its also not clear how much additional code you would have to bring in to make this work ...

P.T.
  • 24,557
  • 7
  • 64
  • 95
  • Hah, funnily enough, I've used the exact same solution [to answer another question](http://stackoverflow.com/questions/7529522/messagepack-in-android/#7624106) :). Thanks for the suggestion, I'll wait a bit for alternative answers and in the event there aren't any, I'll accept yours. – mikołak Jul 17 '12 at 16:53