Efficient Z-Order Calculation
This isn't specifically a Java2D question, though the context is a
Java2D-based application. Hopefully I'm not too far out of line.
I have an application which displays a large number (~10-1000) of opaque
2D shapes. The user can add, delete, and move the shapes with the
mouse. Operations can be performed on single shapes or on user-selected
sets of them.
The problem involves generating the z-ordering of the shapes. If shape
A is inside shape B, and I draw shape A first, then shape B will
completely hide it. I need an efficient algorithm and data structure to
maintain an ordering on the shapes so that, at worst, a shape is only
partially obscured by another. Generating the data structure should be
relatively fast, and once it is generated, add, delete, and move
operations should be fast.
The approach that comes to mind is some sort of tree structure based on
a nesting hierarchy of the bounding boxes of the shapes. I've done a
little research. Would some variation on R-trees be appropriate? This
seems like a problem others would have encountered, but I can't seem to
find anything that specifically addresses this issue. Any help would be
greatly appreciated. Thanks!
To unsubscribe, send email to email@example.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
firstname.lastname@example.org and include in the body of the message "help".