com.miginfocom.calendar.decorators
Class AShapeDecorator

java.lang.Object
  extended by com.miginfocom.calendar.decorators.AShapeDecorator
All Implemented Interfaces:
Decorator, java.lang.Comparable

public class AShapeDecorator
extends java.lang.Object
implements Decorator

A decorator that paints an AShape.

Since:
6.0

Constructor Summary
AShapeDecorator()
          Empty constructor.
AShapeDecorator(int layerIndex, RootAShape aShape, PlaceRect placeRect)
          Constructor.
 
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 g, java.awt.Rectangle bounds)
          Paint what should be painted.
 RootAShape getAShape()
          Property: The root shape to use.
 int getLayerIndex()
          Returns a number to indicate the order in which to paint something.
 PlaceRect getPlaceRect()
          Property: How the ashape should be placed relative to the bounds of the date area.
 void processEvent(java.awt.AWTEvent e)
          A callback method that lets this decorator intercept any AWTEvent (such and KeyEvents and MouseEvents).
 void setAShape(RootAShape aShape)
          Property: The root shape to use.
 void setLayerIndex(int i)
          Sets a number to indicate the order in which to paint something.
 void setPlaceRect(PlaceRect p)
          Property: How the ashape should be placed relative to the bounds of the date area.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AShapeDecorator

public AShapeDecorator()
Empty constructor.


AShapeDecorator

public AShapeDecorator(int layerIndex,
                       RootAShape aShape,
                       PlaceRect placeRect)
Constructor.

Parameters:
layerIndex - A number to indicate the order in which to paint something. Lower if painted before. I.e. under.
aShape - The shape to draw. null will not paint anything.
placeRect - The positioning of the image in regard to the bounds given by the decorated object.
Method Detail

doPaint

public void doPaint(java.awt.Graphics2D g,
                    java.awt.Rectangle bounds)
Description copied from interface: Decorator
Paint what should be painted. Color, paints, fonts, hints and similar should be same as when called.

Specified by:
doPaint in interface Decorator
Parameters:
g - 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.

getPlaceRect

public PlaceRect getPlaceRect()
Property: How the ashape should be placed relative to the bounds of the date area. Note that the placing is very flexible through the use of the rectangle transformation interface PlaceRect.

Returns:
The current value. May be null.

setPlaceRect

public void setPlaceRect(PlaceRect p)
Property: How the ashape should be placed relative to the bounds of the date area. Note that the placing is very flexible through the use of the rectangle transformation interface PlaceRect.

Parameters:
p - the new value. May be null.

getAShape

public RootAShape getAShape()
Property: The root shape to use. It will get the bounds and sub shapes of it can the relate to these bounds and place themselves whenever they like relative to the bounds.

Returns:
The current ashape. May be null.

setAShape

public void setAShape(RootAShape aShape)
Property: The root shape to use. It will get the bounds and sub shapes of it can the relate to these bounds and place themselves whenever they like relative to the bounds.

Parameters:
aShape - The new ashape. If null nothing will be painted.

getLayerIndex

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

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

setLayerIndex

public void setLayerIndex(int i)
Description copied from interface: Decorator
Sets a number to indicate the order in which to paint something. The number is interpreted by the object that invokes Decorator.doPaint(java.awt.Graphics2D, java.awt.Rectangle).

Specified by:
setLayerIndex in interface Decorator
Parameters:
i - A number to indicate the order in which to paint something. Lower if painted before. I.e. under.

compareTo

public int compareTo(java.lang.Object o)
Sorts according to layer index.

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

dispose

public void dispose()
Description copied from interface: Decorator
Clean up and deregister listeners. Should be called when a Decorator isn't needed any more.

Specified by:
dispose in interface Decorator

processEvent

public void processEvent(java.awt.AWTEvent e)
Description copied from interface: Decorator
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.

Specified by:
processEvent in interface Decorator
Parameters:
e - The event.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.