com.miginfocom.calendar.decorators
Class ThemeCellLabelDecorator

java.lang.Object
  extended by com.miginfocom.calendar.decorators.AbstractGridDecorator
      extended by com.miginfocom.calendar.decorators.GridCellDecorator
          extended by com.miginfocom.calendar.decorators.CellLabelDecorator
              extended by com.miginfocom.calendar.decorators.ThemeCellLabelDecorator
All Implemented Interfaces:
Decorator, GridDecorator, DateChangeListener, java.beans.PropertyChangeListener, java.lang.Comparable, java.util.EventListener

public class ThemeCellLabelDecorator
extends CellLabelDecorator
implements DateChangeListener, java.beans.PropertyChangeListener

Extends CellLabelDecorator by getting all properties from a CalendarTheme. Also listens to the tracked dateArea for mouseOver/press and changes the properties accoring to what is specified in the com.miginfocom.theme.
The deccorator wil NOT register itself for updates to the com.miginfocom.theme as this easily can lead to memory leaks. Call reloadFromTheme() to make it update from the com.miginfocom.theme.


Field Summary
static java.lang.String[] MAIN_KEYS
           
 
Fields inherited from class com.miginfocom.calendar.decorators.GridCellDecorator
placeRect
 
Constructor Summary
ThemeCellLabelDecorator(DateArea dateArea, int layerIndex, java.lang.String themeContext)
          Constructor.
 
Method Summary
 void dateRangeChanged(DateChangeEvent e)
          Called when a date range changed.
 void dispose()
          Clean up and deregister listeners.
 DateArea getDateArea()
          Might return null since the date area is kept in a WeakReference
 void gridChanged(java.beans.PropertyChangeEvent e)
          Called when the grid changes.
protected  void paintCell(java.awt.Graphics2D g2, int r, int c, java.awt.Rectangle b)
          Paints the cell, or part thereof.
protected  boolean prePaint()
          Called before the first cell is painted.
 void propertyChange(java.beans.PropertyChangeEvent e)
           
 void reloadFromTheme()
          Reloads all properties from the com.miginfocom.theme
protected  void repaint(java.awt.Rectangle bounds)
          Repaint the date area if not null.
 void setThemeContext(java.lang.String context)
          Set a new com.miginfocom.theme context.
protected  void updateTypeArray()
          Setup a cache for all objects and repaint the part that got changed.
 
Methods inherited from class com.miginfocom.calendar.decorators.CellLabelDecorator
cleanStringLabelCache, getAlignX, getAlignY, getBackground, getBorder, getCellModulo, getDateFormat, getDateGrid, getDateGridContainer, getFirstDateFormat, getFirstInField, getFont, getForeground, getLabelString, getMinimumCellSize, getNowBackground, getNowBorder, getNowDateFormat, getNowFont, getNowForeground, getNowPlaceRect, getNowRangeType, getNowShadowForeground, getNowShadowOffset, getShadowForeground, getShadowOffset, getTextAntiAlias, getUlWidth, invalidateDateRange, isAntiAlias, postPaint, setAlignX, setAlignY, setAntiAlias, setBackground, setBorder, setCellModulo, setDateFormat, setFirstDateFormat, setFirstInField, setFont, setForeground, setMinimumCellSize, setNowBackground, setNowBorder, setNowDateFormat, setNowFont, setNowForeground, setNowPlaceRect, setNowRangeType, setNowShadowForeground, setNowShadowOffset, setShadowForeground, setShadowOffset, setTextAntiAlias, setUlWidth, useStringLabelCache
 
Methods inherited from class com.miginfocom.calendar.decorators.GridCellDecorator
createCellRects, doPaint, getPlaceRect, getSizeMode, setPlaceRect, setSizeMode
 
Methods inherited from class com.miginfocom.calendar.decorators.AbstractGridDecorator
compareTo, getGrid, getGridContainer, getInvalidEnd, getInvalidStart, getLayerIndex, hasInvalidCells, invalidateCells, processEvent, setCellsValid, setLayerIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAIN_KEYS

public static final java.lang.String[] MAIN_KEYS
Constructor Detail

ThemeCellLabelDecorator

public ThemeCellLabelDecorator(DateArea dateArea,
                               int layerIndex,
                               java.lang.String themeContext)
Constructor.

Parameters:
dateArea - The date area to decorate. Not null.
layerIndex - A number to indicate the order in which to paint something. Lower if painted before. I.e. under.
themeContext - The com.miginfocom.theme context used for getting a com.miginfocom.theme.
See Also:
Themes.getTheme(String)
Method Detail

paintCell

protected void paintCell(java.awt.Graphics2D g2,
                         int r,
                         int c,
                         java.awt.Rectangle b)
Description copied from class: GridCellDecorator
Paints the cell, or part thereof.

Overrides:
paintCell in class CellLabelDecorator
Parameters:
g2 - The object to paint in. Paint may be changed and not restored for every call.
r - The row beeing painted.
c - The column beeing painted
b - The bounds of the cell, or part there of, to be painted.

prePaint

protected boolean prePaint()
Description copied from class: GridCellDecorator
Called before the first cell is painted. Possible to do setup.

Overrides:
prePaint in class CellLabelDecorator
Returns:
If the paint should continue. If false GridCellDecorator.paintCell(java.awt.Graphics2D, int, int, java.awt.Rectangle) will not be called this round. GridCellDecorator.postPaint() will be called though.

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
Overrides:
dispose in class AbstractGridDecorator

reloadFromTheme

public void reloadFromTheme()
Reloads all properties from the com.miginfocom.theme


updateTypeArray

protected void updateTypeArray()
Setup a cache for all objects and repaint the part that got changed.


gridChanged

public void gridChanged(java.beans.PropertyChangeEvent e)
Description copied from class: AbstractGridDecorator
Called when the grid changes.

Overrides:
gridChanged in class CellLabelDecorator
Parameters:
e - The event.

dateRangeChanged

public void dateRangeChanged(DateChangeEvent e)
Description copied from interface: DateChangeListener
Called when a date range changed.

Specified by:
dateRangeChanged in interface DateChangeListener
Parameters:
e - The event that explains what happened

setThemeContext

public void setThemeContext(java.lang.String context)
Set a new com.miginfocom.theme context.

Parameters:
context - The com.miginfocom.theme context used for getting a com.miginfocom.theme.

getDateArea

public DateArea getDateArea()
Might return null since the date area is kept in a WeakReference

Returns:
The datearea or null.

repaint

protected void repaint(java.awt.Rectangle bounds)
Repaint the date area if not null.

Parameters:
bounds - The bounds. Not null.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.