com.miginfocom.util.gfx
Class RepaintRegion

java.lang.Object
  extended by com.miginfocom.util.gfx.RepaintRegion

public class RepaintRegion
extends java.lang.Object

A special Rectangle that can have an area that are null. It handles adding of (or rather disregarding) null rects and helps with repainting. It doesn't have do any special rectangle calculations, it mostly reduces a lot of null handling.


Constructor Summary
RepaintRegion()
           
RepaintRegion(java.awt.Rectangle r)
          Constructor
 
Method Summary
 void add(java.awt.Point p)
          Adds a point so that the current repaint region includes the point.
 void add(java.awt.Rectangle rect)
          Add a rectangle by "unioning" it with the current rectangle.
 void add(java.awt.Shape shape)
          Adds the bounds of the shape to the repaing region
 void clear()
          Clears the dirty region
 boolean contains(int x, int y)
          Returns if the repaint region contains the point
 java.awt.Rectangle getBounds()
          Return the current bounds of this region.
 java.awt.Rectangle getClonedBounds()
          Return the current bounds of this region as a clone, free to use
 boolean hasBounds()
          Returns if there is any bounds.
 void repaint(javax.swing.JComponent comp)
          Repaint the current region of this in the component, if this region is not null in which case the method does nothing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepaintRegion

public RepaintRegion()

RepaintRegion

public RepaintRegion(java.awt.Rectangle r)
Constructor

Parameters:
r - The initial rect, can be null. Overtaken, not cloned!
Method Detail

add

public void add(java.awt.Rectangle rect)
Add a rectangle by "unioning" it with the current rectangle. Handles null.

Parameters:
rect - The rect to add. If null nothing happens. Not changed or kept. Cloned locally.

add

public void add(java.awt.Point p)
Adds a point so that the current repaint region includes the point.

Parameters:
p - The point to add. If null nothing happens. Not changed or kept. Cloned locally.

add

public void add(java.awt.Shape shape)
Adds the bounds of the shape to the repaing region

Parameters:
shape - The shape. Can be null in which case nothing is added.

clear

public void clear()
Clears the dirty region


hasBounds

public boolean hasBounds()
Returns if there is any bounds.

Returns:
If there is any bounds.

getBounds

public java.awt.Rectangle getBounds()
Return the current bounds of this region.

Returns:
The bounds as a reference. Can be null. Not Cloned so do not change!

getClonedBounds

public java.awt.Rectangle getClonedBounds()
Return the current bounds of this region as a clone, free to use

Returns:
The bounds as a clone. Can be null.

repaint

public void repaint(javax.swing.JComponent comp)
Repaint the current region of this in the component, if this region is not null in which case the method does nothing.

Parameters:
comp - The component to repaint. Not null.

contains

public boolean contains(int x,
                        int y)
Returns if the repaint region contains the point

Parameters:
x - X
y - Y
Returns:
If the repaint region contains the point. Always false if the repaint region is empty


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.