com.miginfocom.calendar.decorators
Class ImageDecorator

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

public class ImageDecorator
extends java.lang.Object
implements Decorator

A decorator that paints an image, tiled or single.


Constructor Summary
ImageDecorator()
          Empty constructor.
ImageDecorator(int layerIndex, XtdImage xtdImage, PlaceRect placeRect, boolean tile)
          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.
 int getLayerIndex()
          Returns a number to indicate the order in which to paint something.
 PlaceRect getPlaceRect()
          Property: How the image should be placed relative to the bounds of the date area.
 boolean getTiling()
          Property: If the image should be tiled within the bounds.
 XtdImage getXtdImage()
          Property: The image to draw.
 void processEvent(java.awt.AWTEvent e)
          A callback method that lets this decorator intercept any AWTEvent (such and KeyEvents and MouseEvents).
 void setLayerIndex(int i)
          Sets a number to indicate the order in which to paint something.
 void setPlaceRect(PlaceRect p)
          Property: How the image should be placed relative to the bounds of the date area.
 void setTiling(boolean b)
          Property: If the image should be tiled within the bounds.
 void setXtdImage(XtdImage i)
          Property: The image to draw.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageDecorator

public ImageDecorator()
Empty constructor.


ImageDecorator

public ImageDecorator(int layerIndex,
                      XtdImage xtdImage,
                      PlaceRect placeRect,
                      boolean tile)
Constructor.

Parameters:
layerIndex - A number to indicate the order in which to paint something. Lower if painted before. I.e. under.
xtdImage - The image to draw. null will not paint anything.
placeRect - The positioning of the image in regard to the bounds given by the decorated object.
tile - If the image should be tiled within the bounds. It is stretched/shrinked otherwise, depending on the rectangle returned bu the placeRect.
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 image 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 image 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.

getTiling

public boolean getTiling()
Property: If the image should be tiled within the bounds. It is stretched/shrinked otherwise, depending on the rectangle returned bu the placeRect.

Returns:
The current value.

setTiling

public void setTiling(boolean b)
Property: If the image should be tiled within the bounds. It is stretched/shrinked otherwise, depending on the rectangle returned bu the placeRect.

Parameters:
b - the new value.

getXtdImage

public XtdImage getXtdImage()
Property: The image to draw. null will not paint anything.

Returns:
The current value. May be null.

setXtdImage

public void setXtdImage(XtdImage i)
Property: The image to draw. null will not paint anything.

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

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.