APIdia Launch Partner
Top Description Fields Constructors Methods
sun.awt

public Class RepaintArea

extends Object
Class Inheritance
Known Direct Subclasses
sun.awt.X11.XRepaintArea
Imports
java.awt.Component, .Graphics, .Rectangle, java.awt.event.PaintEvent

The RepaintArea is a geometric construct created for the purpose of holding the geometry of several coalesced paint events. This geometry is accessed synchronously, although it is written such that painting may still be executed asynchronously.
Author
Eric Hawkes
Since
1.3

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
MAX_BENEFIT_RATIO

Maximum ratio of bounding rectangle to benefit for which both the vertical and horizontal unions are repainted.

private Rectangle[]
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public
RepaintArea()

Constructs a new RepaintArea

private
RepaintArea(RepaintArea
the RepaintArea from which to copy initial values to a newly constructed RepaintArea
ra
)

Constructs a new RepaintArea initialized to match the values of the specified RepaintArea.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
add(Rectangle
the specified Rectangle
r
,
int
possible values PaintEvent.UPDATE or PaintEvent.PAINT
id
)

Adds a Rectangle to this RepaintArea.

private synchronized RepaintArea

Returns:

ra a new RepaintArea having the same geometry as this RepaintArea.
cloneAndReset
()

Creates a new RepaintArea with the same geometry as this RepaintArea, then removes all of the geometry from this RepaintArea and restores it to an empty RepaintArea.

public synchronized void
constrain(int x, int y, int w, int h)

Constrains the size of the repaint area to the passed in bounds.

public boolean
public void
paint(Object
Component to paint or update
target
,
boolean shouldClearRectBeforePaint)

Invokes paint and update on target Component with optimal rectangular clip region.

protected void
paintComponent(Component comp, Graphics g)

Calls Component.paint(Graphics) with given Graphics.

public synchronized void
subtract(int x, int y, int w, int h)

Marks the passed in region as not needing to be painted.

pack-priv static boolean
subtract(Rectangle rect, Rectangle subtr)

Subtracts subtr from rect.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected void
updateComponent(Component comp, Graphics g)

Calls Component.update(Graphics) with given Graphics.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

HORIZONTALback to summary
private static final int HORIZONTAL
MAX_BENEFIT_RATIOback to summary
private static final int MAX_BENEFIT_RATIO

Maximum ratio of bounding rectangle to benefit for which both the vertical and horizontal unions are repainted. For smaller ratios the whole bounding rectangle is repainted.

See Also
paint
paintRectsback to summary
private Rectangle[] paintRects
RECT_COUNTback to summary
private static final int RECT_COUNT
UPDATEback to summary
private static final int UPDATE
VERTICALback to summary
private static final int VERTICAL

Constructor Detail

RepaintAreaback to summary
public RepaintArea()

Constructs a new RepaintArea

Since
1.3
RepaintAreaback to summary
private RepaintArea(RepaintArea ra)

Constructs a new RepaintArea initialized to match the values of the specified RepaintArea.

Parameters
ra:RepaintArea

the RepaintArea from which to copy initial values to a newly constructed RepaintArea

Since
1.3

Method Detail

addback to summary
public synchronized void add(Rectangle r, int id)

Adds a Rectangle to this RepaintArea. PAINT Rectangles are divided into mostly vertical and mostly horizontal. Each group is unioned together. UPDATE Rectangles are unioned.

Parameters
r:Rectangle

the specified Rectangle

id:int

possible values PaintEvent.UPDATE or PaintEvent.PAINT

Since
1.3
cloneAndResetback to summary
private synchronized RepaintArea cloneAndReset()

Creates a new RepaintArea with the same geometry as this RepaintArea, then removes all of the geometry from this RepaintArea and restores it to an empty RepaintArea.

Returns:RepaintArea

ra a new RepaintArea having the same geometry as this RepaintArea.

Since
1.3
constrainback to summary
public synchronized void constrain(int x, int y, int w, int h)

Constrains the size of the repaint area to the passed in bounds.

isEmptyback to summary
public boolean isEmpty()
paintback to summary
public void paint(Object target, boolean shouldClearRectBeforePaint)

Invokes paint and update on target Component with optimal rectangular clip region. If PAINT bounding rectangle is less than MAX_BENEFIT_RATIO times the benefit, then the vertical and horizontal unions are painted separately. Otherwise the entire bounding rectangle is painted.

Parameters
target:Object

Component to paint or update

Since
1.4
paintComponentback to summary
protected void paintComponent(Component comp, Graphics g)

Calls Component.paint(Graphics) with given Graphics.

subtractback to summary
public synchronized void subtract(int x, int y, int w, int h)

Marks the passed in region as not needing to be painted. It's possible this will do nothing.

subtractback to summary
pack-priv static boolean subtract(Rectangle rect, Rectangle subtr)

Subtracts subtr from rect. If the result is rectangle changes rect and returns true. Otherwise false.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

updateComponentback to summary
protected void updateComponent(Component comp, Graphics g)

Calls Component.update(Graphics) with given Graphics.