public class PSwingRepaintManager extends RepaintManager
This is an internal class used by Piccolo to support Swing components in Piccolo. This should not be instantiated, though all the public methods of javax.swing.RepaintManager may still be called and perform in the expected manner.
PBasicRepaint Manager is an extension of RepaintManager that traps those repaints called by the Swing components that have been added to the PCanvas and passes these repaints to the PSwing rather than up the component hierarchy as usually happens.
Also traps invalidate calls made by the Swing components added to the PCanvas to reshape the corresponding PSwing.
Also keeps a list of PSwings that are painting. This disables repaint until the component has finished painting. This is to address a problem introduced by Swing's CellRendererPane which is itself a work-around. The problem is that JTable's, JTree's, and JList's cell renderers need to be validated before repaint. Since we have to repaint the entire Swing component hierarchy (in the case of a PSwing), this causes an infinite loop. So we introduce the restriction that no repaints can be triggered by a call to paint.
Constructor and Description |
---|
PSwingRepaintManager() |
Modifier and Type | Method and Description |
---|---|
void |
addDirtyRegion(JComponent component,
int x,
int y,
int width,
int height)
This is the method "repaint" now calls in the Swing components.
|
void |
addInvalidComponent(JComponent invalidComponent)
This is the method "invalidate" calls in the Swing components.
|
boolean |
isPainting(JComponent c)
Returns true if repaint is currently locked for a component and false
otherwise.
|
void |
lockRepaint(JComponent c)
Locks repaint for a particular (Swing) component displayed by PCanvas.
|
void |
unlockRepaint(JComponent c)
Unlocks repaint for a particular (Swing) component displayed by PCanvas.
|
addDirtyRegion, addDirtyRegion, currentManager, currentManager, getDirtyRegion, getDoubleBufferMaximumSize, getOffscreenBuffer, getVolatileOffscreenBuffer, isCompletelyDirty, isDoubleBufferingEnabled, markCompletelyClean, markCompletelyDirty, paintDirtyRegions, removeInvalidComponent, setCurrentManager, setDoubleBufferingEnabled, setDoubleBufferMaximumSize, toString, validateInvalidComponents
public void lockRepaint(JComponent c)
c
- The component for which the repaint is to be lockedpublic void unlockRepaint(JComponent c)
c
- The component for which the repaint is to be unlockedpublic boolean isPainting(JComponent c)
c
- The component for which the repaint status is desiredpublic void addDirtyRegion(JComponent component, int x, int y, int width, int height)
addDirtyRegion
in class RepaintManager
component
- Component to be repaintedx
- X coordinate of the dirty region in the componenty
- Y coordinate of the dirty region in the componentwidth
- Width of the dirty region in the componentheight
- Height of the dirty region in the componentpublic void addInvalidComponent(JComponent invalidComponent)
addInvalidComponent
in class RepaintManager
invalidComponent
- The Swing component that needs validationCopyright © 1995-2012 Piccolo2D. All Rights Reserved.