2D graphics library for Android

I am working on an Android application that requires a two-dimensional graphical representation with a large set of objects. Here is what I basically need to display:

enter image description here

In my case, there may be hundreds of spatially distributed objects. This view will behave like a map, so the user can scroll horizontally and vertically, zoom in and out. It also requires click event handling, so the user can click on any triangle, and then I have to display some advanced information related to that particular triangle.

I mainly worry about 3 things:

  • If I re-draw all the objects in my onDraw() handler, it will be very slow. In addition, there are cases when I donโ€™t even need to draw all these objects, since some of them are invisible depending on the zoom level and scroll position. This requires the use of quad trees, which I do not want to do manually.
  • All these objects are defined as (x, y, rotation, type), so if the client decides that we need the "show all" button, I will have to implement a function to calculate the bounding fields.
  • I need to be able to handle click events and (possibly) drag and drop for all of these shapes.

Is there a library that can help me with these tasks? I just do not want to spend 3 days on things that, I think, have already been implemented.

+4
source share
1 answer

All methods of the Canvas class of the android.graphics package should be sufficient. Canvas does clipping (which means that drawing commands are discarded if they are not visible), so if the image is static, you can display it in Picture and draw that on onDraw() .

I think drawing methods have methods for calculating borders and returning them. See Path computeBounds(RectF bounds, boolean exact) .

+2
source

Source: https://habr.com/ru/post/1386240/


All Articles