2
* $Id: RepaintManagerX.java,v 1.9 2006/08/22 21:57:17 rbair Exp $
4
* Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5
* Santa Clara, California 95054, U.S.A. All rights reserved.
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
package org.jdesktop.swingx;
24
import java.awt.Container;
25
import java.awt.Rectangle;
27
import javax.swing.JComponent;
28
import javax.swing.RepaintManager;
31
* <p>An implementation of {@link RepaintManager} which adds support for transparency
32
* in {@link JXPanel}s. <code>JXPanel</code> (which supports translucency) will
33
* replace the current RepaintManager with an instance of RepaintManagerX
34
* <em>unless</em> the current RepaintManager is tagged by the {@link TranslucentRepaintManager}
40
@TranslucentRepaintManager
41
public class RepaintManagerX extends RepaintManager {
42
public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
43
Rectangle dirtyRegion = getDirtyRegion(c);
44
if (dirtyRegion.width == 0 && dirtyRegion.height == 0) {
45
int lastDeltaX = c.getX();
46
int lastDeltaY = c.getY();
47
Container parent = c.getParent();
48
while (parent instanceof JComponent) {
49
if (!parent.isVisible() || (parent.getPeer() == null)) {
52
if (parent instanceof JXPanel && (((JXPanel)parent).getAlpha() < 1f ||
53
!parent.isOpaque())) {
56
lastDeltaX = lastDeltaY = 0;
57
c = (JComponent)parent;
59
lastDeltaX += parent.getX();
60
lastDeltaY += parent.getY();
61
parent = parent.getParent();
64
super.addDirtyRegion(c, x, y, w, h);
b'\\ No newline at end of file'