* @param shape Shape to be applied to the component
*/
void applyCompoundShape(Region shape) {
checkTreeLock();
if (!isLightweight()) {
ComponentPeer peer = getPeer();
if (peer != null) {
// The Region class has some optimizations. That's why
// we should manually check whether it's empty and
// substitute the object ourselves. Otherwise we end up
// with some incorrect Region object with loX being
// greater than the hiX for instance.
if (shape.isEmpty()) {
shape = Region.getInstanceXYWH(0, 0, 0, 0);
}
// Note: the shape is not really copied/cloned. We create
// the Region object ourselves, so there's no any possibility
// to modify the object outside of the mixing code.
this.compoundShape = shape;
if (areBoundsValid()) {
Point compAbsolute = getLocationOnWindow();
if (mixingLog.isLoggable(Level.FINER)) {
mixingLog.fine("this = " + this +
"; compAbsolute=" + compAbsolute + "; shape=" + shape);
}
peer.applyShape(shape.getTranslatedRegion(-compAbsolute.x, -compAbsolute.y));
}
}
}
}