Android Question RegionIterator

Liquidkourage

Member
Licensed User
Longtime User
Hello,

I have a project that uses the ABExtDrawing library to generate graphic regions on a google map. The regions end up being somewhat complex, intersecting rectangles, circles, etc. I would like to write a function that can return the area of the region, and I found a few methods online that rely on the Android RegionIterator object (http://developer.android.com/reference/android/graphics/RegionIterator.html). I would like to know if there's a way that I can use the reflection library to construct a RegionIterator object by passing my region to it. The code I've tried so far fails though because I'm passing an ABRegion object.

Is there a way I'm not realizing to somehow turn my ABRegion into a native Android region?

Thanks in advance.
 

Liquidkourage

Member
Licensed User
Longtime User
Here is the current code I have written, which fails due to the object types not being the same:

B4X:
Dim reflector As Reflector
Dim tempregion As JavaObject=masterregion
reflector.Target=reflector.CreateObject2("android.graphics.RegionIterator",Array As JavaObject(tempregion),Array As String("android.graphics.Region"))
Dim numrects As Int = 0
Dim rectarea As Float=0
Dim tmpRect As Rect
Do While reflector.RunMethod4("next", Array As Rect(tmpRect),Array As String("android.graphics.Rect"))
    numrects=numrects+1
    rectarea=rectarea+((tmpRect.Right-tmpRect.Left)*(tmpRect.Bottom-tmpRect.top))
Loop
Log("region area is "&rectarea)
 
Upvote 0
Top