javax.swing

Class RepaintManager

public class RepaintManager extends Object

The repaint manager holds a set of dirty regions, invalid components, and a double buffer surface. The dirty regions and invalid components are used to coalesce multiple revalidate() and repaint() calls in the component tree into larger groups to be refreshed "all at once"; the double buffer surface is used by root components to paint themselves.

See this document for more details.

document for more details.

Constructor Summary
RepaintManager()
Create a new RepaintManager object.
Method Summary
voidaddDirtyRegion(JComponent component, int x, int y, int w, int h)
Add a region to the set of dirty regions for a specified component.
voidaddInvalidComponent(JComponent component)
Add a component to the {@link #invalidComponents} vector.
static RepaintManagercurrentManager(Component component)
Returns the RepaintManager for the current thread's thread group.
static RepaintManagercurrentManager(JComponent component)
Returns the RepaintManager for the current thread's thread group.
RectanglegetDirtyRegion(JComponent component)
Get the dirty region associated with a component, or null if the component has no dirty region.
DimensiongetDoubleBufferMaximumSize()
Get the value of the {@link #doubleBufferMaximumSize} property.
ImagegetOffscreenBuffer(Component component, int proposedWidth, int proposedHeight)
Get an offscreen buffer for painting a component's image.
ImagegetVolatileOffscreenBuffer(Component comp, int proposedWidth, int proposedHeight)
Creates and returns a volatile offscreen buffer for the specified component that can be used as a double buffer.
booleanisCompletelyDirty(JComponent component)
Return true if the specified component is completely contained within its dirty region, otherwise false
booleanisDoubleBufferingEnabled()
Get the value of the {@link #doubleBufferingEnabled} property.
voidmarkCompletelyClean(JComponent component)
Remove all dirty regions for a specified component
voidmarkCompletelyDirty(JComponent component)
Mark a component as dirty over its entire bounds.
voidpaintDirtyRegions()
Repaint all regions of all components which have been marked dirty in the {@link #dirtyComponents} table.
voidremoveInvalidComponent(JComponent component)
Remove a component from the {@link #invalidComponents} vector.
static voidsetCurrentManager(RepaintManager manager)
Sets the repaint manager for the calling thread's thread group.
voidsetDoubleBufferingEnabled(boolean buffer)
Set the value of the {@link #doubleBufferingEnabled} property.
voidsetDoubleBufferMaximumSize(Dimension size)
Set the value of the {@link #doubleBufferMaximumSize} property.
StringtoString()
voidvalidateInvalidComponents()
Validate all components which have been marked invalid in the {@link #invalidComponents} vector.

Constructor Detail

RepaintManager

public RepaintManager()
Create a new RepaintManager object.

Method Detail

addDirtyRegion

public void addDirtyRegion(JComponent component, int x, int y, int w, int h)
Add a region to the set of dirty regions for a specified component. This involves union'ing the new region with any existing dirty region associated with the component. If the {@link #repaintWorker} class is not active, insert it in the system event queue.

Parameters: component The component to add a dirty region for x The left x coordinate of the new dirty region y The top y coordinate of the new dirty region w The width of the new dirty region h The height of the new dirty region

See Also: RepaintManager RepaintManager RepaintManager RepaintManager RepaintManager

addInvalidComponent

public void addInvalidComponent(JComponent component)
Add a component to the {@link #invalidComponents} vector. If the {@link #repaintWorker} class is not active, insert it in the system event queue.

Parameters: component The component to add

See Also: RepaintManager

currentManager

public static RepaintManager currentManager(Component component)
Returns the RepaintManager for the current thread's thread group. The default implementation ignores the component parameter and returns the same repaint manager for all components.

Parameters: component a component to look up the manager of

Returns: the current repaint manager for the calling thread's thread group and the specified component

See Also: RepaintManager

currentManager

public static RepaintManager currentManager(JComponent component)
Returns the RepaintManager for the current thread's thread group. The default implementation ignores the component parameter and returns the same repaint manager for all components. This method is only here for backwards compatibility with older versions of Swing and simply forwards to {@link #currentManager(Component)}.

Parameters: component a component to look up the manager of

Returns: the current repaint manager for the calling thread's thread group and the specified component

See Also: RepaintManager

getDirtyRegion

public Rectangle getDirtyRegion(JComponent component)
Get the dirty region associated with a component, or null if the component has no dirty region.

Parameters: component The component to get the dirty region of

Returns: The dirty region of the component

See Also: dirtyComponents RepaintManager RepaintManager RepaintManager RepaintManager

getDoubleBufferMaximumSize

public Dimension getDoubleBufferMaximumSize()
Get the value of the {@link #doubleBufferMaximumSize} property.

Returns: The current value of the property

See Also: RepaintManager

getOffscreenBuffer

public Image getOffscreenBuffer(Component component, int proposedWidth, int proposedHeight)
Get an offscreen buffer for painting a component's image. This image may be smaller than the proposed dimensions, depending on the value of the {@link #doubleBufferMaximumSize} property.

Parameters: component The component to return an offscreen buffer for proposedWidth The proposed width of the offscreen buffer proposedHeight The proposed height of the offscreen buffer

Returns: A shared offscreen buffer for painting

getVolatileOffscreenBuffer

public Image getVolatileOffscreenBuffer(Component comp, int proposedWidth, int proposedHeight)
Creates and returns a volatile offscreen buffer for the specified component that can be used as a double buffer. The returned image is a {@link VolatileImage}. Its size will be (proposedWidth, proposedHeight) except when the maximum double buffer size has been set in this RepaintManager.

Parameters: comp the Component for which to create a volatile buffer proposedWidth the proposed width of the buffer proposedHeight the proposed height of the buffer

Since: 1.4

See Also: VolatileImage

isCompletelyDirty

public boolean isCompletelyDirty(JComponent component)
Return true if the specified component is completely contained within its dirty region, otherwise false

Parameters: component The component to check for complete dirtyness

Returns: Whether the component is completely dirty

See Also: dirtyComponents RepaintManager RepaintManager RepaintManager RepaintManager

isDoubleBufferingEnabled

public boolean isDoubleBufferingEnabled()
Get the value of the {@link #doubleBufferingEnabled} property.

Returns: The current value of the property

See Also: RepaintManager

markCompletelyClean

public void markCompletelyClean(JComponent component)
Remove all dirty regions for a specified component

Parameters: component The component to mark as clean

See Also: dirtyComponents RepaintManager RepaintManager RepaintManager RepaintManager

markCompletelyDirty

public void markCompletelyDirty(JComponent component)
Mark a component as dirty over its entire bounds.

Parameters: component The component to mark as dirty

See Also: dirtyComponents RepaintManager RepaintManager RepaintManager RepaintManager

paintDirtyRegions

public void paintDirtyRegions()
Repaint all regions of all components which have been marked dirty in the {@link #dirtyComponents} table.

removeInvalidComponent

public void removeInvalidComponent(JComponent component)
Remove a component from the {@link #invalidComponents} vector.

Parameters: component The component to remove

See Also: RepaintManager

setCurrentManager

public static void setCurrentManager(RepaintManager manager)
Sets the repaint manager for the calling thread's thread group.

Parameters: manager the repaint manager to set for the current thread's thread group

See Also: currentManager

setDoubleBufferingEnabled

public void setDoubleBufferingEnabled(boolean buffer)
Set the value of the {@link #doubleBufferingEnabled} property.

Parameters: buffer The new value of the property

See Also: RepaintManager

setDoubleBufferMaximumSize

public void setDoubleBufferMaximumSize(Dimension size)
Set the value of the {@link #doubleBufferMaximumSize} property.

Parameters: size The new value of the property

See Also: RepaintManager

toString

public String toString()

validateInvalidComponents

public void validateInvalidComponents()
Validate all components which have been marked invalid in the {@link #invalidComponents} vector.