If the clip would be constructed once and then reused a lot, then the Area 
operations that Dmitri posted are the most general and safest way (but not the 
fastest) to construct it.

On the other hand, if all of the foreground rectangles are *known* to be 
non-overlapping, and if the background rectangle is *known* to encompass them 
all, and you need to reconstruct it pretty quickly fairly often, then a faster, 
though not as general, way to construct it would be to append all of the 
rectangles into a GeneralPath with an EvenOdd winding rule which will contain 
only those areas that are inside the big outer rectangle, but not inside the 
smaller inner rectangles (which must not overlap).

With either method, you might still find that clipped rendering is slower than 
painting a lot of rectangles as it involves less optimized loops (for one thing 
complex clips aren't as easily accelerated as simple rectangles drawn inside of 
rectangular clips).

How many smaller inner rectangles are we talking about?
Are some of them off the screen?
Have you tried skipping the rendering calls for the ones that are known to be 
off the visible part of the window?
Which calls are you using to render the rectangles?  drawRect() will be *much, 
much* faster than draw(rectangleObject) for example.
[Message sent by forum member 'flar' (flar)]

http://forums.java.net/jive/thread.jspa?messageID=246656

===========================================================================
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".

Reply via email to