Hi
I have implemented a map with a sparse matrix of cells using label views; approx 1000 of them. I did it this way as the map is of arbitrary shaped vegetable gardens with different crops . Hence sparse rather than rectangular matrix. Each cell can represent an arbitrary area and they don't have to be square. This makes it very versatile for different types of crop arrangements, Although within any single map all cells must be there same dimensions. But you can have multiple maps.
It works very well and is quite fast. The attributes of each cell are recovered from a data base with and ID and the xy co'ords of the cells. Each cell has an attribute such as path, soil, compost bins etc and soil cells are set to cultivatable so that a crop ID can be assigned to the cell. To speed things up I store the attributes in a B4XMap. I store the ID of each cells label in its Tag as an integer. I use this to key into the database and B4XMaps.
All good. To change a cell click on it and set the pars. That's fast, because I can recover the cell ID from the Senders Tag.
However if i want to do a bulk update or programmatically change a particular cell based on its ID I have to iterate over all of the cell labels to find the one I want to change. This is OK, but it seems highly inefficient as you have to search the entire panel to find the label view you want. Is there any way for finding or "addressing" a view such as a label without having to search for it.
Question 1: Is it possible to set up a table at run-time that keeps the "address" of each of the graphics objects so you don't have to search?
Question 2: Is their a better way of finding the cell's label that I want without searching over and over again every time I want to make a change?
I used labels on a 2D scrollable panel rather than an image because I was too lazy to learn how to use images. I know the correct answer is to use an image as you can recover the xy value, but that is complicated as when you zoom an image you have to be careful to adjust the coordinates to recover the correct cell attributes from the DB. You don't have this trouble with labels representing cells as the label xy values are stored against the cell ID. Now I understand that an image can have very big pixels so that each pixel could represent a cell, but then you have the problem of not having a border around each cell. Of course you could then overlay coarse image with a high res image with transparent pixels and opaque grid lines and it you kept your ratios as integers you could probably keep them registered when zooming.
Any comments or ideas would be appreciated.
Best regards
Rob
I have implemented a map with a sparse matrix of cells using label views; approx 1000 of them. I did it this way as the map is of arbitrary shaped vegetable gardens with different crops . Hence sparse rather than rectangular matrix. Each cell can represent an arbitrary area and they don't have to be square. This makes it very versatile for different types of crop arrangements, Although within any single map all cells must be there same dimensions. But you can have multiple maps.
It works very well and is quite fast. The attributes of each cell are recovered from a data base with and ID and the xy co'ords of the cells. Each cell has an attribute such as path, soil, compost bins etc and soil cells are set to cultivatable so that a crop ID can be assigned to the cell. To speed things up I store the attributes in a B4XMap. I store the ID of each cells label in its Tag as an integer. I use this to key into the database and B4XMaps.
All good. To change a cell click on it and set the pars. That's fast, because I can recover the cell ID from the Senders Tag.
However if i want to do a bulk update or programmatically change a particular cell based on its ID I have to iterate over all of the cell labels to find the one I want to change. This is OK, but it seems highly inefficient as you have to search the entire panel to find the label view you want. Is there any way for finding or "addressing" a view such as a label without having to search for it.
Question 1: Is it possible to set up a table at run-time that keeps the "address" of each of the graphics objects so you don't have to search?
Question 2: Is their a better way of finding the cell's label that I want without searching over and over again every time I want to make a change?
I used labels on a 2D scrollable panel rather than an image because I was too lazy to learn how to use images. I know the correct answer is to use an image as you can recover the xy value, but that is complicated as when you zoom an image you have to be careful to adjust the coordinates to recover the correct cell attributes from the DB. You don't have this trouble with labels representing cells as the label xy values are stored against the cell ID. Now I understand that an image can have very big pixels so that each pixel could represent a cell, but then you have the problem of not having a border around each cell. Of course you could then overlay coarse image with a high res image with transparent pixels and opaque grid lines and it you kept your ratios as integers you could probably keep them registered when zooming.
Any comments or ideas would be appreciated.
Best regards
Rob