com.miginfocom.calendar.decorators
Class GridCellRangeDecorator

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

public class GridCellRangeDecorator
extends AbstractGridDecorator

A decorator that paints cells in a grid with an optional paint and optional outline/stroke.

Also see DateRangeDecorator, it has more functionality in general but is using dates and is thus a bit more complex to use in some situations. It also have support for text, even text that are formatted by the decorated date.

Since:
6.0

Constructor Summary
GridCellRangeDecorator(GridContainer container, int layerIndex)
          Constructor.
GridCellRangeDecorator(GridContainer container, int layerIndex, PlaceRect cellRange, java.awt.Paint fillPaint, int cellOutlineMode, boolean flowMode)
          Constructor.
GridCellRangeDecorator(GridContainer container, int layerIndex, PlaceRect cellRange, java.awt.Paint fillPaint, java.awt.Stroke stroke, java.awt.Paint strokePaint, int cellOutlineMode, boolean flowMode)
          Constructor.
 
Method Summary
 void doPaint(java.awt.Graphics2D g, java.awt.Rectangle bounds)
          Paint what should be painted.
 PlaceRect getBoundsCorrection()
          Property: Correction to the painted and drawn bounds in non-flow mode.
 int getCellOutlineMode()
          Property: The mode to use for caclulating the bounds of what to draw.
 PlaceRect getCellRange()
          Property: The cells that should be painted.
 java.awt.Paint getFillPaint()
          Property: The paint, if any, to use for filling the cells.
 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.
 void gridChanged(java.beans.PropertyChangeEvent e)
          Called when the grid changes.
 boolean isFlowMode()
          Property: If the cells painted should flow in time, making possible a non-rectangular cell range outline, from the start coordidinate to the end coordinate.
 void setBoundsCorrection(PlaceRect r)
          Property: Correction to the painted and drawn bounds in non-flow mode.
 void setCellOutlineMode(int mode)
          Property: The mode to use for caclulating the bounds of what to draw.
 void setCellRange(PlaceRect r)
          Property: The cells that should be painted.
 void setFillPaint(java.awt.Paint p)
          Property: The paint, if any, to use for filling the cells.
 void setFlowMode(boolean b)
          Property: If the cells painted should flow in time, making possible a non-rectangular cell range outline, from the start coordidinate to the end coordinate.
 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.
 
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
 

Constructor Detail

GridCellRangeDecorator

public GridCellRangeDecorator(GridContainer 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".

GridCellRangeDecorator

public GridCellRangeDecorator(GridContainer container,
                              int layerIndex,
                              PlaceRect cellRange,
                              java.awt.Paint fillPaint,
                              int cellOutlineMode,
                              boolean flowMode)
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".
cellRange - The cells that should be painted. See AbsRect. It is a very flexbile way to express which cells are covered. E.g. new AbsRect(new AtStart(1), new AtStart(1), new AtEnd(-1), new AtEnd(-1)) to paint all cells except the border cells.
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
flowMode - If the cells painted should flow in time, making possible a non-rectangular cell range outline, from the start coordidinate to the end coordinate. Setting this value to false will make the cell range outline always rectangular.

GridCellRangeDecorator

public GridCellRangeDecorator(GridContainer container,
                              int layerIndex,
                              PlaceRect cellRange,
                              java.awt.Paint fillPaint,
                              java.awt.Stroke stroke,
                              java.awt.Paint strokePaint,
                              int cellOutlineMode,
                              boolean flowMode)
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".
cellRange - The cells that should be painted. See AbsRect. It is a very flexbile way to express which cells are covered. E.g. new AbsRect(new AtStart(1), new AtStart(1), new AtEnd(-1), new AtEnd(-1)) to paint all cells except the border cells.
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
flowMode - If the cells painted should flow in time, making possible a non-rectangular cell range outline, from the start coordidinate to the end coordinate. Setting this value to false will make the cell range outline always rectangular.
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.

getBoundsCorrection

public PlaceRect getBoundsCorrection()
Property: Correction to the painted and drawn bounds in non-flow mode.

Returns:
The current value. May be null (default) which means no correction.

setBoundsCorrection

public void setBoundsCorrection(PlaceRect r)
Property: Correction to the painted and drawn bounds in non-flow mode.


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

isFlowMode

public boolean isFlowMode()
Property: If the cells painted should flow in time, making possible a non-rectangular cell range outline, from the start coordidinate to the end coordinate. Setting this value to false will make the cell range outline always rectangular.

Returns:
If in flow mode. false is default.

setFlowMode

public void setFlowMode(boolean b)
Property: If the cells painted should flow in time, making possible a non-rectangular cell range outline, from the start coordidinate to the end coordinate. Setting this value to false will make the cell range outline always rectangular.

Parameters:
b - If flow mode. false is default.

getCellRange

public PlaceRect getCellRange()
Property: The cells that should be painted. See AbsRect. It is a very flexbile way to express which cells are covered. E.g. new AbsRect(new AtStart(1), new AtStart(1), new AtEnd(-1), new AtEnd(-1)) to paint all cells except the border cells.

Returns:
The current cell range. Never null.

setCellRange

public void setCellRange(PlaceRect r)
Property: The cells that should be painted. See AbsRect. It is a very flexbile way to express which cells are covered. E.g. new AbsRect(new AtStart(1), new AtStart(1), new AtEnd(-1), new AtEnd(-1)) to paint all cells except the border cells.

Parameters:
r - The current cell range. If null it will be replaced by AbsRect.FILL.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.