java - Good data structure to represent a 2D map/grid that you can zoom in and out of? -


I have created a 2D grid in Java, where each cell can have a certain attribute, the color is called . At every frequency of the main loop, that color may possibly change

What I want to be able to do is:
- When zoomed in, this small subset of the grid and the grid of each grid Will show the actual color.
- As you zoom out and look at more cells at a time, seeing the cells individually will start to become very small, so I will be able to use that area (a collection of single cells) as a color I want to be able to present (say that one of the most frequent occurrences in that collection)

I thought to do that one thing would be to use hierarchical tree / pyramid structure, Where on the leaves you have each room. Each parent is given information of each child in its node, so to draw a map at a high zoom level, instead of seeing each room individually, only a few levels will go down, however, changing the parents from the leaves And later, the changes occurring at every high level are propagated, as if it would take some time for a large grid to run each loop.

Is there a better way to do this? This problem seems like it should have been handled by people of the graphics / gaming world before, but I am having trouble finding Google as well as finding the right keywords, so any help or direction is appreciated. Thank you.

Perhaps quadtree will be a useful search term.



Comments