org.jdesktop.swingx
Class ForwardingRepaintManager

java.lang.Object
  extended by javax.swing.RepaintManager
      extended by org.jdesktop.swingx.ForwardingRepaintManager
Direct Known Subclasses:
RepaintManagerX

public class ForwardingRepaintManager
extends RepaintManager

A RepaintManager that is designed to forward all calls to a contained delegate. This class is designed for extension, such that subclasses should override method as appropriate and allow the original repaint manager to handle the rest of the work.

Install a forwarding repaint manager:

 RepaintManager manager = RepaintManager.currentManager(this);
 RepaintManager frm = new ForwardingRepaintManager(manager);
 RepaintManager.setCurrentManager(frm);
 


Constructor Summary
ForwardingRepaintManager(RepaintManager delegate)
          Creates a new forwarding manager that forwards all calls to the delegate.
 
Method Summary
 void addDirtyRegion(JComponent c, int x, int y, int w, int h)
          Add a component in the list of components that should be refreshed.
 void addInvalidComponent(JComponent invalidComponent)
          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.
 RepaintManager getDelegateManager()
          Gets the delegate repaint manager backing this forwarding repaint manager.
 Rectangle getDirtyRegion(JComponent component)
          Return the current dirty region for a component.
 Dimension getDoubleBufferMaximumSize()
          Returns the maximum double buffer size.
 Image getOffscreenBuffer(Component c, int proposedWidth, int proposedHeight)
          Return the offscreen buffer that should be used as a double buffer with the component c.
 Image getVolatileOffscreenBuffer(Component c, int proposedWidth, int proposedHeight)
          Return a volatile offscreen buffer that should be used as a double buffer with the specified component c.
 boolean isCompletelyDirty(JComponent component)
          Convenience method that returns true if aComponent will be completely painted during the next paintDirtyRegions().
 boolean isDoubleBufferingEnabled()
          Returns true if this RepaintManager is double buffered.
 void markCompletelyClean(JComponent component)
          Mark a component completely clean.
 void markCompletelyDirty(JComponent component)
          Mark a component completely dirty.
 void paintDirtyRegions()
          Paint all of the components that have been marked dirty.
 void removeInvalidComponent(JComponent component)
          Remove a component from the list of invalid components.
 void setDoubleBufferingEnabled(boolean flag)
          Enables or disables double buffering in this RepaintManager.
 void setDoubleBufferMaximumSize(Dimension d)
          Set the maximum double buffer size.
 String toString()
          Returns a string that displays and identifies this object's properties.
 void validateInvalidComponents()
          Validate all of the components that have been marked invalid.
 
Methods inherited from class javax.swing.RepaintManager
currentManager, currentManager, setCurrentManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ForwardingRepaintManager

public ForwardingRepaintManager(RepaintManager delegate)
Creates a new forwarding manager that forwards all calls to the delegate.

Parameters:
delegate - the manager backing this ForwardingRepaintManager
Throws:
NullPointerException - if delegate is null
Method Detail

addDirtyRegion

public void addDirtyRegion(JComponent c,
                           int x,
                           int y,
                           int w,
                           int h)
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.

Overrides:
addDirtyRegion in class RepaintManager
See Also:
JComponent.repaint(long, int, int, int, int)

addInvalidComponent

public void addInvalidComponent(JComponent invalidComponent)
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.

Overrides:
addInvalidComponent in class RepaintManager
See Also:
JComponent.isValidateRoot(), RepaintManager.removeInvalidComponent(javax.swing.JComponent)

getDirtyRegion

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

Overrides:
getDirtyRegion in class RepaintManager

getDoubleBufferMaximumSize

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

Overrides:
getDoubleBufferMaximumSize in class RepaintManager
Returns:
a Dimension object representing the maximum size

getOffscreenBuffer

public Image getOffscreenBuffer(Component c,
                                int proposedWidth,
                                int proposedHeight)
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.

Overrides:
getOffscreenBuffer in class RepaintManager

getVolatileOffscreenBuffer

public Image getVolatileOffscreenBuffer(Component c,
                                        int proposedWidth,
                                        int proposedHeight)
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.

Overrides:
getVolatileOffscreenBuffer in class RepaintManager
See Also:
VolatileImage

isCompletelyDirty

public boolean isCompletelyDirty(JComponent component)
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.

Overrides:
isCompletelyDirty in class RepaintManager

isDoubleBufferingEnabled

public boolean isDoubleBufferingEnabled()
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.

Overrides:
isDoubleBufferingEnabled in class RepaintManager
Returns:
true if this object is double buffered

markCompletelyClean

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

Overrides:
markCompletelyClean in class RepaintManager

markCompletelyDirty

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

Overrides:
markCompletelyDirty in class RepaintManager

paintDirtyRegions

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

Overrides:
paintDirtyRegions in class RepaintManager
See Also:
RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)

removeInvalidComponent

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

Overrides:
removeInvalidComponent in class RepaintManager
See Also:
RepaintManager.addInvalidComponent(javax.swing.JComponent)

setDoubleBufferingEnabled

public void setDoubleBufferingEnabled(boolean flag)
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.

Overrides:
setDoubleBufferingEnabled in class RepaintManager
Parameters:
flag - true to activate double buffering
See Also:
RepaintManager.isDoubleBufferingEnabled()

setDoubleBufferMaximumSize

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

Overrides:
setDoubleBufferMaximumSize in class RepaintManager

toString

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

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

validateInvalidComponents

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

Overrides:
validateInvalidComponents in class RepaintManager
See Also:
RepaintManager.addInvalidComponent(javax.swing.JComponent)

getDelegateManager

public final RepaintManager getDelegateManager()
Gets the delegate repaint manager backing this forwarding repaint manager.

Returns:
the delegate for this forwarding manager