ActionScript 3 unlike earlier versions of ActionScript (JavaScript) is very similar in syntax to Java. Both languages are strongly type and object oriented. Unlike strange prototype notation in earlier ActionScript AS 3 code have normal class declaration with fields and methods.
Porting code from java:
1) Use automatic converter to change syntax (mainly moving variable type definition to beginning)
2) Check types used. Numerical libraries probally will only use classes from Java Collection Framework other libraries may contains IO classes. Make your custom ActionScript version of these classes
3) Convert JUnit tests into FlexUnit
4)Run tests
And voila, your library is ported. In reality it is not so easy and you will need a lot of time to tweak your ported library.
niedziela, 14 lutego 2010
GPCAS 3 - ActionScript 3 geometrical library
Few months ago I has to project in Flex in which I had to manipulate geometrical data. In short words it was about merging and splitting geometrical areas. Splitting polygon with section line is rather simply alghoritm, merging is little bit taughet but it is possible to write it in few hours. But problems appears when you have to split and merge polygon with "holes"
What is hole?
For example - take a look on map of South Africa. You see country of Lesotho which is bordered from every side by South Africa. So there is polygon "South Africa" and polygon "Lesotho" inside. Algorithm thats correctly merge and split polygons with holes is not easy to implement.

After some quick research I discovered that are no good library in ActionScript to handle this issue. I found some open source libraries in C++ and Java but I was not convinced to move this code to server side. After all I decided to port one of best geometrical libraries GPCAS to ActionScript. Because it was easier I ported already existing java version of library. Finally feature rich GPC library is available nativele in ActionScript 3 as SWC library. Anyone who wants may use it in his product.
http://code.google.com/p/gpcas/
What is hole?
For example - take a look on map of South Africa. You see country of Lesotho which is bordered from every side by South Africa. So there is polygon "South Africa" and polygon "Lesotho" inside. Algorithm thats correctly merge and split polygons with holes is not easy to implement.
After some quick research I discovered that are no good library in ActionScript to handle this issue. I found some open source libraries in C++ and Java but I was not convinced to move this code to server side. After all I decided to port one of best geometrical libraries GPCAS to ActionScript. Because it was easier I ported already existing java version of library. Finally feature rich GPC library is available nativele in ActionScript 3 as SWC library. Anyone who wants may use it in his product.
http://code.google.com/p/gpcas/
Subskrybuj:
Posty (Atom)