com.miginfocom.calendar.decorators
Class DecoratorSupport

java.lang.Object
  extended by com.miginfocom.calendar.decorators.DecoratorSupport

public class DecoratorSupport
extends java.lang.Object

A class that keeps track of a set of Decorators and gives the possibility to paint them.


Constructor Summary
DecoratorSupport()
          Constructor.
 
Method Summary
 void addDecorator(Decorator decorator)
          Adds a decorator this this grid and set it's grid to this.
 void addDecorators(java.util.Collection decs)
          Adds a number of GridDecorators.
 Decorator getDecorator(java.lang.Class type, boolean inclSubClasses)
          Returnes the first decorator found with the class type type, including sub types id inclSubClasses == true.
 java.util.List getDecorators()
          Returns a cloned list with the decorators currently installed.
 int getSize()
          returns the number of decorators that this class is currently handling.
 void paintDecorations(java.awt.Graphics2D g2, java.awt.Rectangle bounds)
          Paints the decorations for all registered decorators in the order the decorators was added.
 boolean processEvent(java.awt.AWTEvent e)
          Notifies the decorates one after one about the event.
 boolean removeDecorator(java.lang.Class type, boolean inclSubClasses)
          Removes the first decorator found with the class type type, including sub types id inclSubClasses == true.
 boolean removeDecorator(Decorator decorator)
          Removes a decorator and calls the decorator's Decorator.dispose().
 void removeDecorators()
          Calls Decorator.dispose() and then removes all decorators.
 void removeDecorators(java.util.Collection decs)
          Removes the decorators.
 void setDecorators(java.util.Collection decs)
          Set the decorators in this object.
 void sortDecorators()
          Resort the decorators.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DecoratorSupport

public DecoratorSupport()
Constructor.

Method Detail

addDecorator

public void addDecorator(Decorator decorator)
Adds a decorator this this grid and set it's grid to this.

Parameters:
decorator - The decorator. Not null

removeDecorator

public boolean removeDecorator(Decorator decorator)
Removes a decorator and calls the decorator's Decorator.dispose(). Even if the decorator couldn't be found in this list dispose is called.

Parameters:
decorator - The decorator. Not null
Returns:
If a decorator was removed.

removeDecorator

public boolean removeDecorator(java.lang.Class type,
                               boolean inclSubClasses)
Removes the first decorator found with the class type type, including sub types id inclSubClasses == true.

Parameters:
type - The type. Not null.
inclSubClasses - If sub classes of type should be removed as well.
Returns:
If a decorator was removed.

getDecorator

public Decorator getDecorator(java.lang.Class type,
                              boolean inclSubClasses)
Returnes the first decorator found with the class type type, including sub types id inclSubClasses == true.

Parameters:
type - The type. Not null.
inclSubClasses - If sub classes of type should be removed as well.
Returns:
If a decorator was removed.

getDecorators

public java.util.List getDecorators()
Returns a cloned list with the decorators currently installed.

Returns:
The decorators. Not null.

setDecorators

public void setDecorators(java.util.Collection decs)
Set the decorators in this object. Disposes of the old ones.

Parameters:
decs - The decorators. Not null. List is cloned shallow for storage.

addDecorators

public void addDecorators(java.util.Collection decs)
Adds a number of GridDecorators.

Parameters:
decs - The decorators. Not null or elements that are null.

removeDecorators

public void removeDecorators(java.util.Collection decs)
Removes the decorators.

Parameters:
decs - The decorators. Not null.

removeDecorators

public void removeDecorators()
Calls Decorator.dispose() and then removes all decorators.


paintDecorations

public void paintDecorations(java.awt.Graphics2D g2,
                             java.awt.Rectangle bounds)
Paints the decorations for all registered decorators in the order the decorators was added.

Parameters:
g2 - The obejct to draw in
bounds - The bounds to stay within (a must). If width and/or height is 0 that dimension is not scaled to fit.

processEvent

public boolean processEvent(java.awt.AWTEvent e)
Notifies the decorates one after one about the event. Stops if it gets consumed. (only InputEvents can be consumed though. Notifies in reversed order since the last ones will be painted laft and thus appear on top.

Parameters:
e - The event
Returns:
If the event was consumed.
See Also:
Decorator.processEvent(java.awt.AWTEvent)

sortDecorators

public void sortDecorators()
Resort the decorators. This is normally only needed if any of the decorators that is handeled by this support class has changed its layer outside the control of this support class.


getSize

public int getSize()
returns the number of decorators that this class is currently handling.

Returns:
The number of decorators that this class is currently handling.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.