com.miginfocom.calendar.decorators
Class DateRangeDecorator

java.lang.Object
  extended by com.miginfocom.calendar.decorators.AbstractGridDecorator
      extended by com.miginfocom.calendar.decorators.AbstractDateGridDecorator
          extended by com.miginfocom.calendar.decorators.DateRangeDecorator
All Implemented Interfaces:
Decorator, GridDecorator, java.lang.Comparable

public class DateRangeDecorator
extends AbstractDateGridDecorator

A decorator that paints the cells in a grid that overlaps a date range.

Since:
6.0

Field Summary
static int TEXT_MODE_SINGLE_LINE
          Writes a single line, much faster than TYPE_WRAP_TEXT and should be used if text wrapping isn't needed.
static int TEXT_MODE_SINGLE_LINE_ROT_CCW
          Writes a single line rotated counter clockwise 90 degrees
static int TEXT_MODE_SINGLE_LINE_ROT_CW
          Writes a single line rotated clockwise 90 degrees
static int TEXT_MODE_WRAP_TEXT
          Wraps text at line/word boundary
 
Constructor Summary
DateRangeDecorator(DateGridContainer container, int layerIndex)
          Constructor.
DateRangeDecorator(DateGridContainer container, int layerIndex, ImmutableDateRange dateRange, java.awt.Paint fillPaint, int cellOutlineMode, int outlineShapeMode)
          Constructor
DateRangeDecorator(DateGridContainer container, int layerIndex, ImmutableDateRange dateRange, java.awt.Paint fillPaint, java.awt.Stroke stroke, java.awt.Paint strokePaint, int cellOutlineMode, int outlineShapeMode)
          Constructor
 
Method Summary
 void doPaint(java.awt.Graphics2D g, java.awt.Rectangle bounds)
          Paint what should be painted.
 int getCellOutlineMode()
          Property: The mode to use for caclulating the bounds of what to draw.
 boolean getClipText()
          Property: IF text that end up outside the rectangle should be clipped.
 ImmutableDateRange getDateRange()
          Property: The base date range to decorate.
 DateRangeRounder getDateRangeRounder()
          Property: The date range rounder that will round the set date range (or now-date if date range is not set).
 DateStringProvider getDateStringProvider()
          Property: A date string provider that will convert the date range to a string.
 java.awt.Paint getFillPaint()
          Property: The paint, if any, to use for filling the cells.
 java.awt.Font getFont()
          Property: The font for the text.
 int getOutlineShapeMode()
          Property: How the shape around the date range will be calculated.
 PlaceRect getPlaceRect()
          Property: A place rect that can be used to relatively reposition (or absolutely position) the final paint rectangle(s).
 Recurrence getRecurrence()
          Property: A Recurrence that can be used to repeat the date range (setDateRange(com.miginfocom.util.dates.ImmutableDateRange).
 java.awt.Stroke getStroke()
          Property: The stroke to use for drawing the outline of the cells.
 java.awt.Paint getStrokePaint()
          Property: The paint, if any, to use for drawing the outline of the cells.
 int getTextAntiAliasHint()
          Property: The hint for what type of anti aliasing should be used.
 int getTextDrawMode()
          Property: How to draw and interpres the text.
 AtRefRangeNumber getTextHorizontalAlignment()
          Property: The alignment in the horizontal dimension for the text within the bounds that the date range(s) outline.
 java.awt.Paint getTextPaint()
          Property: The paint for the text.
 PlaceRect getTextPlaceRect()
          Property: A place rect that can be used to relatively reposition (or absolutely position) the final text within the painted rectangle(s).
 int getTextRowSpacingAdjustment()
          Property: Adjustment in pixels for the inter-row spacing.
 java.awt.Color getTextShadowColor()
          Property: The color of the shadow (if any shadow).
 java.awt.Point getTextShadowOffset()
          Property: If there should be a shadow for the text (!= null) and how it should be offset.
 int getTextUnderlineWidth()
          Property: The width of the underline.
 AtRefRangeNumber getTextVerticalAlignment()
          Property: The alignment in the vertical dimension for the text within the bounds that the date range(s) outline.
 void gridChanged(java.beans.PropertyChangeEvent e)
          Called when the grid changes.
 void setCellOutlineMode(int mode)
          Property: The mode to use for caclulating the bounds of what to draw.
 void setClipText(boolean clipText)
          Property: IF text that end up outside the rectangle should be clipped.
 void setDateRange(ImmutableDateRange dateRange)
          Property: The base date range to decorate.
 void setDateRangeRounder(DateRangeRounder rounder)
          Property: The date range rounder that will round the set date range (or now-date if date range is not set).
 void setDateStringProvider(DateStringProvider p)
          Property: A date string provider that will convert the date range to a string.
 void setFillPaint(java.awt.Paint p)
          Property: The paint, if any, to use for filling the cells.
 void setFont(java.awt.Font f)
           
 void setOutlineShapeMode(int mode)
          Property: How the shape around the date range will be calculated.
 void setPlaceRect(PlaceRect placeRect)
          Property: A place rect that can be used to relatively reposition (or absolutely position) the final paint rectangle(s).
 void setRecurrence(Recurrence r)
          Property: A Recurrence that can be used to repeat the date range (setDateRange(com.miginfocom.util.dates.ImmutableDateRange).
 void setStroke(java.awt.Stroke s)
          Property: The stroke to use for drawing the outline of the cells.
 void setStrokePaint(java.awt.Paint p)
          Property: The paint, if any, to use for drawing the outline of the cells.
 void setTextAntiAliasHint(int hint)
          Property: The hint for what type of anti aliasing should be used.
 void setTextDrawMode(int mode)
          Property: How to draw and interpres the text.
 void setTextHorizontalAlignment(AtRefRangeNumber align)
          Property: The alignment in the horizontal dimension for the text within the bounds that the date range(s) outline.
 void setTextPaint(java.awt.Paint p)
          Property: The paint for the text.
 void setTextPlaceRect(PlaceRect placeRect)
          Property: A place rect that can be used to relatively reposition (or absolutely position) the final text within the painted rectangle(s).
 void setTextRowSpacingAdjustment(int pixels)
          Property: Adjustment in pixels for the inter-row spacing.
 void setTextShadowColor(java.awt.Color p)
          Property: The color of the shadow (if any shadow).
 void setTextShadowOffset(java.awt.Point offset)
          Property: If there should be a shadow for the text (!= null) and how it should be offset.
 void setTextUnderlineWidth(int width)
          Property: The width of the underline.
 void setTextVerticalAlignment(AtRefRangeNumber align)
          Property: The alignment in the vertical dimension for the text within the bounds that the date range(s) outline.
 
Methods inherited from class com.miginfocom.calendar.decorators.AbstractDateGridDecorator
getDateGrid, getDateGridContainer
 
Methods inherited from class com.miginfocom.calendar.decorators.AbstractGridDecorator
compareTo, dispose, 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

TEXT_MODE_WRAP_TEXT

public static final int TEXT_MODE_WRAP_TEXT
Wraps text at line/word boundary

See Also:
TEXT_MODE_SINGLE_LINE, Constant Field Values

TEXT_MODE_SINGLE_LINE

public static final int TEXT_MODE_SINGLE_LINE
Writes a single line, much faster than TYPE_WRAP_TEXT and should be used if text wrapping isn't needed.

See Also:
Constant Field Values

TEXT_MODE_SINGLE_LINE_ROT_CW

public static final int TEXT_MODE_SINGLE_LINE_ROT_CW
Writes a single line rotated clockwise 90 degrees

See Also:
Constant Field Values

TEXT_MODE_SINGLE_LINE_ROT_CCW

public static final int TEXT_MODE_SINGLE_LINE_ROT_CCW
Writes a single line rotated counter clockwise 90 degrees

See Also:
Constant Field Values
Constructor Detail

DateRangeDecorator

public DateRangeDecorator(DateGridContainer container,
                          int layerIndex)
Constructor.

Parameters:
container - The date grid container that holds the which DateGrid to decorate. Stored in a WeakReference. Can for instance be a DateArea.
layerIndex - The index at which to paint this "layer". Higer layer numbers will be painted on top of lower layers.

DateRangeDecorator

public DateRangeDecorator(DateGridContainer container,
                          int layerIndex,
                          ImmutableDateRange dateRange,
                          java.awt.Paint fillPaint,
                          int cellOutlineMode,
                          int outlineShapeMode)
Constructor

Parameters:
container - The date grid container that holds the which DateGrid to decorate. Stored in a WeakReference. Can for instance be a DateArea.
layerIndex - The index at which to paint this "layer". Higer layer numbers will be painted on top of lower layers.
dateRange - The base date range to decorate. If there is no recurrence then this is the only date. If there is a recurrence then the base range will act at the "base date range" from which the recurrence start.
fillPaint - The paint to paint in the background of the corresponding date range.
cellOutlineMode - How the area (polygon) around the date range to be painted should be positioned. One of:
Grid.SIZE_MODE_INSIDE - Will not draw over the cell's surrounding grid.
Grid.SIZE_MODE_MIDDLE - Will draw in the middle of the cell's surrounding grid.
Grid.SIZE_MODE_OUTSIDE - Will draw over as much as possible of the cell's surrounding grid.
Grid.SIZE_MODE_UPPER_LEFT - Will draw over as much as possible of the cell's upper and left
outlineShapeMode - How the shape around the date range will be calculated. E.g:
Grid.OUTLINE_SHAPE_MODE_EXACT
Grid.OUTLINE_SHAPE_MODE_EXACT_CLIPPED
Grid.OUTLINE_SHAPE_MODE_POLYGON
Grid.OUTLINE_SHAPE_MODE_RECTANGLE

DateRangeDecorator

public DateRangeDecorator(DateGridContainer container,
                          int layerIndex,
                          ImmutableDateRange dateRange,
                          java.awt.Paint fillPaint,
                          java.awt.Stroke stroke,
                          java.awt.Paint strokePaint,
                          int cellOutlineMode,
                          int outlineShapeMode)
Constructor

Parameters:
container - The date grid container that holds the which DateGrid to decorate. Stored in a WeakReference. Can for instance be a DateArea.
layerIndex - The index at which to paint this "layer". Higer layer numbers will be painted on top of lower layers.
dateRange - The base date range to decorate. If there is no recurrence then this is the only date. If there is a recurrence then the base range will act at the "base date range" from which the recurrence start.
fillPaint - The paint to paint in the background of the corresponding date range.
stroke - The stroke to draw around the corresponding date range.
strokePaint - The paint of the stroke to draw around the corresponding date range.
cellOutlineMode - How the area (polygon) around the date range to be painted should be positioned. One of:
Grid.SIZE_MODE_INSIDE - Will not draw over the cell's surrounding grid.
Grid.SIZE_MODE_MIDDLE - Will draw in the middle of the cell's surrounding grid.
Grid.SIZE_MODE_OUTSIDE - Will draw over as much as possible of the cell's surrounding grid.
Grid.SIZE_MODE_UPPER_LEFT - Will draw over as much as possible of the cell's upper and left
outlineShapeMode - How the shape around the date range will be calculated. E.g:
Grid.OUTLINE_SHAPE_MODE_EXACT
Grid.OUTLINE_SHAPE_MODE_EXACT_CLIPPED
Grid.OUTLINE_SHAPE_MODE_POLYGON
Grid.OUTLINE_SHAPE_MODE_RECTANGLE
Method Detail

doPaint

public final 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.

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.

gridChanged

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

Specified by:
gridChanged in class AbstractGridDecorator
Parameters:
e - The event.

getDateRange

public ImmutableDateRange getDateRange()
Property: The base date range to decorate. If there is no recurrence then this is the only date. If there is a recurrence then the base range will act at the "base date range" from which the recurrence start.

Returns:
The current date range. May be null which should be interpreted as "now".

setDateRange

public void setDateRange(ImmutableDateRange dateRange)
Property: The base date range to decorate. If there is no recurrence then this is the only date. If there is a recurrence then the base range will act at the "base date range" from which the recurrence start.

Parameters:
dateRange - The new date range. May be null which should be interpreted as "now".

getFillPaint

public java.awt.Paint getFillPaint()
Property: The paint, if any, to use for filling the cells.

Returns:
The current value. May be null.

setFillPaint

public void setFillPaint(java.awt.Paint p)
Property: The paint, if any, to use for filling the cells.

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

getStroke

public java.awt.Stroke getStroke()
Property: The stroke to use for drawing the outline of the cells.

Returns:
The current value. Nver null.

setStroke

public void setStroke(java.awt.Stroke s)
Property: The stroke to use for drawing the outline of the cells.

Parameters:
s - The new value. May be null.

getStrokePaint

public java.awt.Paint getStrokePaint()
Property: The paint, if any, to use for drawing the outline of the cells.

Returns:
The current value. May be null.

setStrokePaint

public void setStrokePaint(java.awt.Paint p)
Property: The paint, if any, to use for drawing the outline of the cells.

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

getCellOutlineMode

public int getCellOutlineMode()
Property: The mode to use for caclulating the bounds of what to draw. Especially if the cell lines is != 1 pixel.

Returns:
The current mode.
See Also:
Grid.SIZE_MODE_INSIDE, Grid.SIZE_MODE_MIDDLE, Grid.SIZE_MODE_OUTSIDE, Grid.SIZE_MODE_UPPER_LEFT

setCellOutlineMode

public void setCellOutlineMode(int mode)
Property: The mode to use for caclulating the bounds of what to draw. Especially if the cell lines is != 1 pixel.

Parameters:
mode - The new mode.
See Also:
Grid.SIZE_MODE_INSIDE, Grid.SIZE_MODE_MIDDLE, Grid.SIZE_MODE_OUTSIDE, Grid.SIZE_MODE_UPPER_LEFT

getOutlineShapeMode

public int getOutlineShapeMode()
Property: How the shape around the date range will be calculated. E.g:
Grid.OUTLINE_SHAPE_MODE_EXACT
Grid.OUTLINE_SHAPE_MODE_EXACT_CLIPPED
Grid.OUTLINE_SHAPE_MODE_POLYGON
Grid.OUTLINE_SHAPE_MODE_RECTANGLE

Returns:
The current value.

setOutlineShapeMode

public void setOutlineShapeMode(int mode)
Property: How the shape around the date range will be calculated. E.g:
Grid.OUTLINE_SHAPE_MODE_EXACT
Grid.OUTLINE_SHAPE_MODE_EXACT_CLIPPED
Grid.OUTLINE_SHAPE_MODE_POLYGON
Grid.OUTLINE_SHAPE_MODE_RECTANGLE

Parameters:
mode - The new value.

getDateRangeRounder

public DateRangeRounder getDateRangeRounder()
Property: The date range rounder that will round the set date range (or now-date if date range is not set).

Returns:
The current rounder. May be null.

setDateRangeRounder

public void setDateRangeRounder(DateRangeRounder rounder)
Property: The date range rounder that will round the set date range (or now-date if date range is not set).

Parameters:
rounder - The new rounder. May be null.

getPlaceRect

public PlaceRect getPlaceRect()
Property: A place rect that can be used to relatively reposition (or absolutely position) the final paint rectangle(s).

Returns:
The current value. May be null.

setPlaceRect

public void setPlaceRect(PlaceRect placeRect)
Property: A place rect that can be used to relatively reposition (or absolutely position) the final paint rectangle(s).

Parameters:
placeRect - The new value. May be null.

getDateStringProvider

public DateStringProvider getDateStringProvider()
Property: A date string provider that will convert the date range to a string.

Returns:
The current value. May be null.

setDateStringProvider

public void setDateStringProvider(DateStringProvider p)
Property: A date string provider that will convert the date range to a string.

Parameters:
p - The current value. May be null.

getRecurrence

public Recurrence getRecurrence()
Property: A Recurrence that can be used to repeat the date range (setDateRange(com.miginfocom.util.dates.ImmutableDateRange).

Returns:
The current value. May be null.

setRecurrence

public void setRecurrence(Recurrence r)
Property: A Recurrence that can be used to repeat the date range (setDateRange(com.miginfocom.util.dates.ImmutableDateRange).

Parameters:
r - The current value. May be null.

getTextPaint

public java.awt.Paint getTextPaint()
Property: The paint for the text.

Returns:
The current value. Never null.

setTextPaint

public void setTextPaint(java.awt.Paint p)
Property: The paint for the text.

Parameters:
p - The new value. May be null in which case black is used.

getFont

public java.awt.Font getFont()
Property: The font for the text.

Returns:
The current value. Never null.

setFont

public void setFont(java.awt.Font f)

getTextAntiAliasHint

public int getTextAntiAliasHint()
Property: The hint for what type of anti aliasing should be used.

Returns:
The current value. May be null.
See Also:
GfxUtil.confAntiAliasingHint(java.awt.Graphics2D, boolean, int)

setTextAntiAliasHint

public void setTextAntiAliasHint(int hint)
Property: The hint for what type of anti aliasing should be used.

Parameters:
hint - The new value. E.g. GfxUtil.AA_HINT_PLATFORM.
See Also:
GfxUtil.confAntiAliasingHint(java.awt.Graphics2D, boolean, int)

getTextUnderlineWidth

public int getTextUnderlineWidth()
Property: The width of the underline.

Returns:
The current value. Default is 0.

setTextUnderlineWidth

public void setTextUnderlineWidth(int width)
Property: The width of the underline.

Parameters:
width - The new value. Default is 0.

getTextHorizontalAlignment

public AtRefRangeNumber getTextHorizontalAlignment()
Property: The alignment in the horizontal dimension for the text within the bounds that the date range(s) outline.

Returns:
The current value. Not null. Defaults to AtFraction.CENTER.

setTextHorizontalAlignment

public void setTextHorizontalAlignment(AtRefRangeNumber align)
Property: The alignment in the horizontal dimension for the text within the bounds that the date range(s) outline.

Parameters:
align - The new value. May be null which means center alignment.

getTextVerticalAlignment

public AtRefRangeNumber getTextVerticalAlignment()
Property: The alignment in the vertical dimension for the text within the bounds that the date range(s) outline.

Returns:
The current value. Not null. Defaults to AtFraction.CENTER.

setTextVerticalAlignment

public void setTextVerticalAlignment(AtRefRangeNumber align)
Property: The alignment in the vertical dimension for the text within the bounds that the date range(s) outline.

Parameters:
align - The new value. May be null which means center alignment.

getClipText

public boolean getClipText()
Property: IF text that end up outside the rectangle should be clipped.

Returns:
The current value. Default is false.

setClipText

public void setClipText(boolean clipText)
Property: IF text that end up outside the rectangle should be clipped.

Parameters:
clipText - The new value. Default is false.

getTextRowSpacingAdjustment

public int getTextRowSpacingAdjustment()
Property: Adjustment in pixels for the inter-row spacing.

Returns:
The current value. Default is 0.

setTextRowSpacingAdjustment

public void setTextRowSpacingAdjustment(int pixels)
Property: Adjustment in pixels for the inter-row spacing.

Parameters:
pixels - The new value. Default is 0.

getTextDrawMode

public int getTextDrawMode()
Property: How to draw and interpres the text.

TEXT_MODE_SINGLE_LINE, TEXT_MODE_SINGLE_LINE_ROT_CCW, TEXT_MODE_SINGLE_LINE_ROT_CW or TEXT_MODE_WRAP_TEXT.

Returns:
The current value. Default is TEXT_MODE_SINGLE_LINE.

setTextDrawMode

public void setTextDrawMode(int mode)
Property: How to draw and interpres the text.

TEXT_MODE_SINGLE_LINE, TEXT_MODE_SINGLE_LINE_ROT_CCW, TEXT_MODE_SINGLE_LINE_ROT_CW or TEXT_MODE_WRAP_TEXT.

Parameters:
mode - The new value. Default is TEXT_MODE_SINGLE_LINE.

getTextShadowOffset

public java.awt.Point getTextShadowOffset()
Property: If there should be a shadow for the text (!= null) and how it should be offset.

Returns:
The current value. May be null.

setTextShadowOffset

public void setTextShadowOffset(java.awt.Point offset)
Property: If there should be a shadow for the text (!= null) and how it should be offset.

Parameters:
offset - The new value. May be null.

getTextShadowColor

public java.awt.Color getTextShadowColor()
Property: The color of the shadow (if any shadow).

Returns:
The current value. Never null. Default is Color.GRAY.

setTextShadowColor

public void setTextShadowColor(java.awt.Color p)
Property: The color of the shadow (if any shadow).

Parameters:
p - The new value. null resets the default Color.GRAY.

getTextPlaceRect

public PlaceRect getTextPlaceRect()
Property: A place rect that can be used to relatively reposition (or absolutely position) the final text within the painted rectangle(s).

Returns:
The current value. May be null.

setTextPlaceRect

public void setTextPlaceRect(PlaceRect placeRect)
Property: A place rect that can be used to relatively reposition (or absolutely position) the final text within the painted rectangle(s).

Parameters:
placeRect - The current value. May be null.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.