List all objects

Hi,

I’d like to be able to list all JGoObjects in a JGoView and return all the objects in, say, a Vector.

eg

public Vector getAllObjects(JGoView view)
{

}

How do I recurse into the view (or document) so as to get all the objects irrespective of whether they are nested within JGoAreas etc. In other words I’d like to ‘flatten’ the whole thing and get each and every JGoObject contained within.

Thanks

Mike

I haven’t tried this to make sure, but something like this:

[code]ArrayList arraylist = new ArrayList();
JGoListPosition pos = document.getFirstObjectPos();
while (pos != null) {
JGoObject obj = document.getObjectAtPos(pos);
pos = document.getNextObjectPos(pos); // recurse
arraylist.add(obj);
}[/code]
The normal iteration over the top-level objects would be the same, but calling getNextObjectPosAtTop instead of getNextObjectPos.

[QUOTE=walter]I haven’t tried this to make sure, but something like this:

ArrayList arraylist = new ArrayList(); JGoListPosition pos = document.getFirstObjectPos(); while (pos != null) { JGoObject obj = document.getObjectAtPos(pos); pos = document.getNextObjectPos(pos); // recurse arraylist.add(obj); }

The normal iteration over the top-level objects would be the same, but calling getNextObjectPosAtTop instead of getNextObjectPos.[/quote]

Thanks Walter. My code was identical except that I had getNextObjectPosAtTop rather than getNextObjectPos. Duh!!!