javax.swing
Class RepaintManager

java.lang.Object
  |
  +--javax.swing.RepaintManager

public class RepaintManager
extends Object

Unsafe: This class manages repaint requests, allowing the number of repaints to be minimized, for example by collapsing multiple requests into a single repaint for members of a component tree.

Version:
1.51 04/18/02
Author:
Arnaud Weber

Field Summary
(package private)  Hashtable dirtyComponents
           
(package private)  boolean doubleBufferingEnabled
           
private  Dimension doubleBufferMaxSize
           
(package private)  Vector invalidComponents
           
private static Object repaintManagerKey
           
(package private)  javax.swing.RepaintManager.DoubleBufferInfo standardDoubleBuffer
           
(package private)  Rectangle tmp
           
(package private)  Hashtable tmpDirtyComponents
           
(package private) static int VOLATILE_LOOP_MAX
           
(package private)  javax.swing.RepaintManager.DoubleBufferInfo volatileDoubleBuffer
           
(package private) static boolean volatileImageBufferEnabled
           
 
Constructor Summary
RepaintManager()
          Suppressed: Create a new RepaintManager instance.
 
Method Summary
private  Image _getOffscreenBuffer(Component c, int proposedWidth, int proposedHeight, boolean useVolatileImage)
           
 void addDirtyRegion(JComponent c, int x, int y, int w, int h)
          Suppressed: Add a component in the list of components that should be refreshed.
 void addInvalidComponent(JComponent invalidComponent)
          Suppressed: Mark the component as in need of layout and queue a runnable for the event dispatching thread that will validate the components first isValidateRoot() ancestor.
(package private)  void collectDirtyComponents(Hashtable dirtyComponents, JComponent dirtyComponent, Vector roots)
           
static RepaintManager currentManager(Component c)
          Suppressed: Return the RepaintManager for the calling thread given a Component.
static RepaintManager currentManager(JComponent c)
          Suppressed: Return the RepaintManager for the calling thread given a JComponent.
 Rectangle getDirtyRegion(JComponent aComponent)
          Suppressed: Return the current dirty region for a component.
 Dimension getDoubleBufferMaximumSize()
          Suppressed: Returns the maximum double buffer size.
 Image getOffscreenBuffer(Component c, int proposedWidth, int proposedHeight)
          Suppressed: Return the offscreen buffer that should be used as a double buffer with the component c.
 Image getVolatileOffscreenBuffer(Component c, int proposedWidth, int proposedHeight)
          Suppressed: Return a volatile offscreen buffer that should be used as a double buffer with the specified component c.
 boolean isCompletelyDirty(JComponent aComponent)
          Suppressed: Convenience method that returns true if aComponent will be completely painted during the next paintDirtyRegions().
 boolean isDoubleBufferingEnabled()
          Suppressed: Returns true if this RepaintManager is double buffered.
 void markCompletelyClean(JComponent aComponent)
          Suppressed: Mark a component completely clean.
 void markCompletelyDirty(JComponent aComponent)
          Suppressed: Mark a component completely dirty.
 void paintDirtyRegions()
          Suppressed: Paint all of the components that have been marked dirty.
 void removeInvalidComponent(JComponent component)
          Suppressed: Remove a component from the list of invalid components.
(package private)  void resetDoubleBuffer()
          This resets the double buffer.
(package private)  void resetVolatileDoubleBuffer()
          This resets the volatile double buffer.
static void setCurrentManager(RepaintManager aRepaintManager)
          Suppressed: Set the RepaintManager that should be used for the calling thread.
 void setDoubleBufferingEnabled(boolean aFlag)
          Suppressed: Enables or disables double buffering in this RepaintManager.
 void setDoubleBufferMaximumSize(Dimension d)
          Suppressed: Set the maximum double buffer size.
 String toString()
          Suppressed: Returns a string that displays and identifies this object's properties.
(package private)  boolean useVolatileDoubleBuffer()
          Returns true if we should use the Image returned from getVolatileOffscreenBuffer to do double buffering.
 void validateInvalidComponents()
          Suppressed: Validate all of the components that have been marked invalid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dirtyComponents

Hashtable dirtyComponents

tmpDirtyComponents

Hashtable tmpDirtyComponents

invalidComponents

Vector invalidComponents

doubleBufferingEnabled

boolean doubleBufferingEnabled

doubleBufferMaxSize

private Dimension doubleBufferMaxSize

standardDoubleBuffer

javax.swing.RepaintManager.DoubleBufferInfo standardDoubleBuffer

volatileDoubleBuffer

javax.swing.RepaintManager.DoubleBufferInfo volatileDoubleBuffer

repaintManagerKey

private static final Object repaintManagerKey

volatileImageBufferEnabled

static boolean volatileImageBufferEnabled

VOLATILE_LOOP_MAX

static final int VOLATILE_LOOP_MAX

tmp

Rectangle tmp
Constructor Detail

RepaintManager

public RepaintManager()
Suppressed: Create a new RepaintManager instance. You rarely call this constructor. directly. To get the default RepaintManager, use RepaintManager.currentManager(JComponent) (normally "this").

Method Detail

currentManager

public static RepaintManager currentManager(Component c)
Suppressed: Return the RepaintManager for the calling thread given a Component.

Parameters:
c - a Component -- unused in the default implementation, but could be used by an overridden version to return a different RepaintManager depending on the Component
Returns:
the RepaintManager object

currentManager

public static RepaintManager currentManager(JComponent c)
Suppressed: Return the RepaintManager for the calling thread given a JComponent.

Note: This method exists for backward binary compatibility with earlier versions of the Swing library. It simply returns the result returned by currentManager(Component).

Parameters:
c - a JComponent -- unused
Returns:
the RepaintManager object

setCurrentManager

public static void setCurrentManager(RepaintManager aRepaintManager)
Suppressed: Set the RepaintManager that should be used for the calling thread. aRepaintManager will become the current RepaintManager for the calling thread's thread group.

Parameters:
aRepaintManager - the RepaintManager object to use

addInvalidComponent

public void addInvalidComponent(JComponent invalidComponent)
Suppressed: Mark the component as in need of layout and queue a runnable for the event dispatching thread that will validate the components first isValidateRoot() ancestor.

See Also:
JComponent.isValidateRoot(), removeInvalidComponent(javax.swing.JComponent)

removeInvalidComponent

public void removeInvalidComponent(JComponent component)
Suppressed: Remove a component from the list of invalid components.

See Also:
addInvalidComponent(javax.swing.JComponent)

addDirtyRegion

public void addDirtyRegion(JComponent c,
                           int x,
                           int y,
                           int w,
                           int h)
Suppressed: Add a component in the list of components that should be refreshed. If c already has a dirty region, the rectangle (x,y,w,h) will be unioned with the region that should be redrawn.

See Also:
JComponent.repaint(long, int, int, int, int)

getDirtyRegion

public Rectangle getDirtyRegion(JComponent aComponent)
Suppressed: Return the current dirty region for a component. Return an empty rectangle if the component is not dirty.


markCompletelyDirty

public void markCompletelyDirty(JComponent aComponent)
Suppressed: Mark a component completely dirty. aComponent will be completely painted during the next paintDirtyRegions() call.


markCompletelyClean

public void markCompletelyClean(JComponent aComponent)
Suppressed: Mark a component completely clean. aComponent will not get painted during the next paintDirtyRegions() call.


isCompletelyDirty

public boolean isCompletelyDirty(JComponent aComponent)
Suppressed: Convenience method that returns true if aComponent will be completely painted during the next paintDirtyRegions(). If computing dirty regions is expensive for your component, use this method and avoid computing dirty region if it return true.


validateInvalidComponents

public void validateInvalidComponents()
Suppressed: Validate all of the components that have been marked invalid.

See Also:
addInvalidComponent(javax.swing.JComponent)

paintDirtyRegions

public void paintDirtyRegions()
Suppressed: Paint all of the components that have been marked dirty.

See Also:
addDirtyRegion(javax.swing.JComponent, int, int, int, int)

collectDirtyComponents

void collectDirtyComponents(Hashtable dirtyComponents,
                            JComponent dirtyComponent,
                            Vector roots)

toString

public String toString()
Suppressed: Returns a string that displays and identifies this object's properties.

Overrides:
toString in class Object
Returns:
a String representation of this object

getOffscreenBuffer

public Image getOffscreenBuffer(Component c,
                                int proposedWidth,
                                int proposedHeight)
Suppressed: Return the offscreen buffer that should be used as a double buffer with the component c. By default there is a double buffer per RepaintManager. The buffer might be smaller than (proposedWidth,proposedHeight) This happens when the maximum double buffer size as been set for the receiving repaint manager.


getVolatileOffscreenBuffer

public Image getVolatileOffscreenBuffer(Component c,
                                        int proposedWidth,
                                        int proposedHeight)
Suppressed: Return a volatile offscreen buffer that should be used as a double buffer with the specified component c. The image returned will be an instance of VolatileImage, or null if a VolatileImage object could not be instantiated. This buffer might be smaller than (proposedWidth,proposedHeight). This happens when the maximum double buffer size has been set for this repaint manager.

Since:
1.4
See Also:
java.awt.image.VolatileImage

_getOffscreenBuffer

private Image _getOffscreenBuffer(Component c,
                                  int proposedWidth,
                                  int proposedHeight,
                                  boolean useVolatileImage)

setDoubleBufferMaximumSize

public void setDoubleBufferMaximumSize(Dimension d)
Suppressed: Set the maximum double buffer size.


getDoubleBufferMaximumSize

public Dimension getDoubleBufferMaximumSize()
Suppressed: Returns the maximum double buffer size.

Returns:
a Dimension object representing the maximum size

setDoubleBufferingEnabled

public void setDoubleBufferingEnabled(boolean aFlag)
Suppressed: Enables or disables double buffering in this RepaintManager. CAUTION: The default value for this property is set for optimal paint performance on the given platform and it is not recommended that programs modify this property directly.

Parameters:
aFlag - true to activate double buffering
See Also:
isDoubleBufferingEnabled()

isDoubleBufferingEnabled

public boolean isDoubleBufferingEnabled()
Suppressed: Returns true if this RepaintManager is double buffered. The default value for this property may vary from platform to platform. On platforms where native double buffering is supported in the AWT, the default value will be false to avoid unnecessary buffering in Swing. On platforms where native double buffering is not supported, the default value will be true.

Returns:
true if this object is double buffered

resetDoubleBuffer

void resetDoubleBuffer()
This resets the double buffer. Actually, it marks the double buffer as invalid, the double buffer will then be recreated on the next invocation of getOffscreenBuffer.


resetVolatileDoubleBuffer

void resetVolatileDoubleBuffer()
This resets the volatile double buffer.


useVolatileDoubleBuffer

boolean useVolatileDoubleBuffer()
Returns true if we should use the Image returned from getVolatileOffscreenBuffer to do double buffering.



comments?