On Wed, 12 Jun 2002, Adrian Barnett wrote: > David Eisner wrote > > > > >This isn't a real-world program, but I'm wondering how one > >would improve the performance -- with the hope that any such > >improvements might be applicable elsewhere. > > > >Thanks. > > > One thing that might help is to use a BSP (binary space partition) tree > to store the positions of all the rectangles. Then, instead of comparing > each rectangle to the clip box, ask the BSP tree to return a list of > all rectangles within the clip box and draw them. That way you're not > comparing every single rectangle to the box for each update. It can > dramatically decrease the time taken to decide what to draw. The > downside is that you have to rebuild the BSP tree if rectangles are moved.
First, thanks for everybody's suggestions. I'd like to code them up and maybe make a web page with multiple versions of the app for comparison. We'll see if I get a chance. I tried out the XOR solution (which I knew about from programming Motif apps), but I don't like the appearance during dragging. This may be something you have to live with. It does solve the drag/lag problem. My impression is that the slowdown is in the multiple calls to render the rectangles, and not in running through the list. The reason I believe this is that if you drag one of the interior rectangles, it moves around very quickly, even though each redraw runs through the Vector. But when you drag the line across the rectangles, it increases the number that actually get redrawn, and that's when the slowdown occurs. -David ------------------------+--------------------------+ David Eisner | E-mail: [EMAIL PROTECTED] | CALCE EPSC | Phone: 301-405-5341 | University of Maryland | Fax: 301-314-9269 | ------------------------+--------------------------+ =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
