Reputation: 7694
I'm working on an Android application that requires 2D graphical view with a large set of objects. Here's what I basically need to display:
In my case, there could be hundreds of spatially distributed objects. This view is going to behave like a map, so the user is able to scroll in horizontally and vertically, zoom in and zoom out. It also requires click event handling, so the user is able to click any triangle and I then should display some extended information related with that particular triangle.
I'm mostly concerned about 3 things:
onDraw()
handler, that would be really slow. Also, there I cases when I don't even need to draw all these objects since some of them are invisible depending on zoom level and scroll position. These requires using quad trees which I don't want to implement manually.Is there any library that can help me with these tasks? Just don't want to spend 3 days on stuff that I believe must already have been implemented.
Upvotes: 4
Views: 3799
Reputation: 2088
All the methods in the Canvas
class of the android.graphics
package should suffice. The Canvas
does clipping (meaning drawing commands get discarded if it's not visible) so if the image is static you could render it into a Picture
and draw that on onDraw()
.
I think the drawing methods have methods to calculate bounds and return them. See Path
's computeBounds(RectF bounds, boolean exact)
.
Upvotes: 2