com.miginfocom.calendar.decorators
Interface Decorator

All Superinterfaces:
java.lang.Comparable
All Known Subinterfaces:
GridDecorator
All Known Implementing Classes:
AbstractDateGridDecorator, AbstractGridDecorator, AShapeDecorator, AShapeGridDecorator, CellLabelDecorator, CompositeDecorator, DateRangeDecorator, DateSeparatorDecorator, DefaultDateArea.ActivityViewDecorator, DefaultDateArea.MultiSelectRectangleDecorator, EvenFieldFillDecorator, GridCellDecorator, GridCellRangeDecorator, GridLineDecorator, HeaderAShapeGridDecorator, ImageDecorator, NoFitShapeDecorator, OccupiedDecorator, OddRowFillDecorator, SelectionGridDecorator, StaticAShapeGridDecorator, SubRowHeaderDecorator, ThemeCellLabelDecorator, ThemeSelectionGridDecorator

public interface Decorator
extends java.lang.Comparable

A generic layered painter interface.
A painter is a class which can take a Graphics2D and paint something within some rectangular bounds.


Method Summary
 int compareTo(java.lang.Object o)
          Sorts according to layer index.
 void dispose()
          Clean up and deregister listeners.
 void doPaint(java.awt.Graphics2D g2, java.awt.Rectangle bounds)
          Paint what should be painted.
 int getLayerIndex()
          Returns a number to indicate the order in which to paint something.
 void processEvent(java.awt.AWTEvent e)
          A callback method that lets this decorator intercept any AWTEvent (such and KeyEvents and MouseEvents).
 void setLayerIndex(int layerIndex)
          Sets a number to indicate the order in which to paint something.
 

Method Detail

doPaint

void doPaint(java.awt.Graphics2D g2,
             java.awt.Rectangle bounds)
Paint what should be painted. Color, paints, fonts, hints and similar should be same as when called.

Parameters:
g2 - The graphics object to paint in
bounds - The bounds to stay within (a must). If width and/or height is 0 that dimension is not scaled to fit and should be ignored.

getLayerIndex

int getLayerIndex()
Returns a number to indicate the order in which to paint something. The number is interpreted by the object that invokes doPaint(java.awt.Graphics2D, java.awt.Rectangle).

Returns:
A number to indicate the order in which to paint something. Lower if painted before. I.e. under.

setLayerIndex

void setLayerIndex(int layerIndex)
Sets a number to indicate the order in which to paint something. The number is interpreted by the object that invokes doPaint(java.awt.Graphics2D, java.awt.Rectangle).

Parameters:
layerIndex - A number to indicate the order in which to paint something. Lower if painted before. I.e. under.

processEvent

void processEvent(java.awt.AWTEvent e)
A callback method that lets this decorator intercept any AWTEvent (such and KeyEvents and MouseEvents). The target that this decorator is installed on will manually have to call this method though, but for instance DefaultDateArea does so.

If only events that aren't consumed should be caught the normaly process of adding the appropriate listener to the target is adviced. This method is for catching the event before it is precessed by the target.

If the event is a InputEvent and the 'consumed' flag is set to true no more decorators are notified, neither is the normal event handling dispatching for the target. A notable amount of events can come this way so processing should be very fast.

Parameters:
e - The event.

dispose

void dispose()
Clean up and deregister listeners. Should be called when a Decorator isn't needed any more.


compareTo

int compareTo(java.lang.Object o)
Sorts according to layer index. Code normally looks like this:
return getLayerIndex() - ((Decorator) o).getLayerIndex();.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Another Decorator
Returns:
getLayerIndex() - ((Decorator) o).getLayerIndex().


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.