edu.umd.cs.piccolox.pswing
Class PSwingRepaintManager

java.lang.Object
  extended by javax.swing.RepaintManager
      extended by edu.umd.cs.piccolox.pswing.PSwingRepaintManager

public class PSwingRepaintManager
extends javax.swing.RepaintManager

This RepaintManager replaces the default Swing implementation, and is used to intercept and repaint dirty regions of PSwing components.

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 SwingVisualComponent rather than up the component hierarchy as usually happens.

Also traps revalidate calls made by the Swing components added to the PCanvas to reshape the applicable Visual Component.

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 Swing component group used as a Piccolo visual component). This causes an infinite loop. So we introduce the restriction that no repaints can be triggered by a call to paint.

Author:
Benjamin B. Bederson, Lance E. Good, Sam R. Reid

Constructor Summary
PSwingRepaintManager()
           
 
Method Summary
 void addDirtyRegion(javax.swing.JComponent c, int x, int y, int w, int h)
          This is the method "repaint" now calls in the Swing components.
 void addInvalidComponent(javax.swing.JComponent invalidComponent)
          This is the method "revalidate" calls in the Swing components.
 boolean isPainting(javax.swing.JComponent c)
          Returns true if repaint is currently locked for a component and false otherwise
 void lockRepaint(javax.swing.JComponent c)
          Locks repaint for a particular (Swing) component displayed by PCanvas
 void unlockRepaint(javax.swing.JComponent c)
          Unlocks repaint for a particular (Swing) component displayed by PCanvas
 
Methods inherited from class javax.swing.RepaintManager
addDirtyRegion, addDirtyRegion, currentManager, currentManager, getDirtyRegion, getDoubleBufferMaximumSize, getOffscreenBuffer, getVolatileOffscreenBuffer, isCompletelyDirty, isDoubleBufferingEnabled, markCompletelyClean, markCompletelyDirty, paintDirtyRegions, removeInvalidComponent, setCurrentManager, setDoubleBufferingEnabled, setDoubleBufferMaximumSize, toString, validateInvalidComponents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PSwingRepaintManager

public PSwingRepaintManager()
Method Detail

lockRepaint

public void lockRepaint(javax.swing.JComponent c)
Locks repaint for a particular (Swing) component displayed by PCanvas

Parameters:
c - The component for which the repaint is to be locked

unlockRepaint

public void unlockRepaint(javax.swing.JComponent c)
Unlocks repaint for a particular (Swing) component displayed by PCanvas

Parameters:
c - The component for which the repaint is to be unlocked

isPainting

public boolean isPainting(javax.swing.JComponent c)
Returns true if repaint is currently locked for a component and false otherwise

Parameters:
c - The component for which the repaint status is desired
Returns:
Whether the component is currently painting

addDirtyRegion

public void addDirtyRegion(javax.swing.JComponent c,
                           int x,
                           int y,
                           int w,
                           int h)
This is the method "repaint" now calls in the Swing components. Overridden to capture repaint calls from those Swing components which are being used as Piccolo visual components and to call the Piccolo repaint mechanism rather than the traditional Component hierarchy repaint mechanism. Otherwise, behaves like the superclass.

Overrides:
addDirtyRegion in class javax.swing.RepaintManager
Parameters:
c - Component to be repainted
x - X coordinate of the dirty region in the component
y - Y coordinate of the dirty region in the component
w - Width of the dirty region in the component
h - Height of the dirty region in the component

addInvalidComponent

public void addInvalidComponent(javax.swing.JComponent invalidComponent)
This is the method "revalidate" calls in the Swing components. Overridden to capture revalidate calls from those Swing components being used as Piccolo visual components and to update Piccolo's visual component wrapper bounds (these are stored separately from the Swing component). Otherwise, behaves like the superclass.

Overrides:
addInvalidComponent in class javax.swing.RepaintManager
Parameters:
invalidComponent - The Swing component that needs validation


Copyright © 2008 by University of Maryland, College Park, MD 20742, USA All rights reserved.