de.matthiasmann.twl.utils
Class ClipStack

java.lang.Object
  extended by de.matthiasmann.twl.utils.ClipStack

public class ClipStack
extends java.lang.Object

A stack for clipping regions


Nested Class Summary
protected static class ClipStack.Entry
           
 
Constructor Summary
ClipStack()
           
 
Method Summary
 void clearStack()
          Clears the clip stack
 boolean getClipRect(Rect rect)
          Retrieves the active clip region from the top of the stack
 int getStackSize()
          Returns the current number of entries in the clip stack
protected  void intersect(Rect tos)
           
 boolean isClipEmpty()
          Checks if the top of stack is an empty region (nothing will be rendered).
 void pop()
          Removes the active clip regions from the stack.
protected  ClipStack.Entry push()
           
 void push(int x, int y, int w, int h)
          Pushes the intersection of the new clip region and the current clip region onto the stack.
 void push(Rect rect)
          Pushes the intersection of the new clip region and the current clip region onto the stack.
 void pushDisable()
          Pushes an "disable clipping" onto the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClipStack

public ClipStack()
Method Detail

push

public void push(int x,
                 int y,
                 int w,
                 int h)
Pushes the intersection of the new clip region and the current clip region onto the stack.

Parameters:
x - the left start
y - the top start
w - the width
h - the height
See Also:
pop()

push

public void push(Rect rect)
Pushes the intersection of the new clip region and the current clip region onto the stack.

Parameters:
rect - the new clip region.
Throws:
java.lang.NullPointerException - if rect is null
See Also:
pop()

pushDisable

public void pushDisable()
Pushes an "disable clipping" onto the stack.

See Also:
pop()

pop

public void pop()
Removes the active clip regions from the stack.

Throws:
java.lang.IllegalStateException - when no clip regions are on the stack

isClipEmpty

public boolean isClipEmpty()
Checks if the top of stack is an empty region (nothing will be rendered). This can be used to speedup rendering by skipping all rendering when the clip region is empty.

Returns:
true if the TOS is an empty region

getClipRect

public boolean getClipRect(Rect rect)
Retrieves the active clip region from the top of the stack

Parameters:
rect - the rect coordinates - may not be updated when clipping is disabled
Returns:
true if clipping is active, false if clipping is disabled

getStackSize

public int getStackSize()
Returns the current number of entries in the clip stack

Returns:
the number of entries

clearStack

public void clearStack()
Clears the clip stack


push

protected ClipStack.Entry push()

intersect

protected void intersect(Rect tos)