com.miginfocom.calendar.grid
Class DefaultGridLineProvider

java.lang.Object
  extended by com.miginfocom.util.repetition.DefaultRepetitionSpec
      extended by com.miginfocom.calendar.grid.DefaultGridLineProvider
All Implemented Interfaces:
GridLineProvider, RepetitionSpec, java.io.Serializable

public class DefaultGridLineProvider
extends DefaultRepetitionSpec
implements GridLineProvider

A class that holds sizes (widths) and other properties of grid lines in one dimension in a very flexible way. The class is immutable and does some caching of the values.

See Also:
Serialized Form

Constructor Summary
DefaultGridLineProvider(GridLineRepetition[] lines)
          Constructor.
DefaultGridLineProvider(GridLineRepetition[] lines, GridLineException[] exceptions)
          Constructor.
DefaultGridLineProvider(int firstSize, int betweenEvenSize, int betweenOddSize, int lastSize, java.awt.Paint evenPaint, java.awt.Paint oddPaint)
          Constructor for a special size for the first and last line compared to the ones in between.
DefaultGridLineProvider(int firstSize, int betweenEvenSize, int betweenOddSize, int lastSize, java.awt.Paint evenPaint, java.awt.Paint oddPaint, GridLineException[] exceptions)
          Constructor for a special size for the first and last line compared to the ones in between.
DefaultGridLineProvider(int firstSize, int betweenSize, int lastSize, java.awt.Paint paint)
          Constructor for a special size for the first and last line compared to the ones in between.
DefaultGridLineProvider(int size, java.awt.Paint paint)
          Constructor for a uni-size with paint and special treatment of first and last line.
 
Method Summary
 int configureGridLines(GridRow[] rows, GridLine[] gridLines)
          Configures the grid lines.
 GridLine[] createGridLines(GridRow[] rows)
          Returns the grid lines between and around the rows.
 GridLineException[] getExceptions()
          Returns the exceptions to this grid line provider.
 int getGridLinesSize(GridRow[] rows)
          Returns the total size of the grid lines for the given rows.
 
Methods inherited from class com.miginfocom.util.repetition.DefaultRepetitionSpec
getRepetition, getRepetitions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGridLineProvider

public DefaultGridLineProvider(int size,
                               java.awt.Paint paint)
Constructor for a uni-size with paint and special treatment of first and last line.

Parameters:
size - The size of all grid lines.
paint - The paint to use for all grid lines.

DefaultGridLineProvider

public DefaultGridLineProvider(int firstSize,
                               int betweenSize,
                               int lastSize,
                               java.awt.Paint paint)
Constructor for a special size for the first and last line compared to the ones in between.

Parameters:
firstSize - Size of the first line
betweenSize - Size of all lines between first and last.
lastSize - Size of the lst line
paint - The paint to use for all grid lines.

DefaultGridLineProvider

public DefaultGridLineProvider(int firstSize,
                               int betweenEvenSize,
                               int betweenOddSize,
                               int lastSize,
                               java.awt.Paint evenPaint,
                               java.awt.Paint oddPaint)
Constructor for a special size for the first and last line compared to the ones in between.

Parameters:
firstSize - Size of the first line
betweenEvenSize - Size of all lines between first and last, that are even.
betweenOddSize - Size of all lines between first and last, that are odd.
lastSize - Size of the lst line
evenPaint - The paint to use for all grid lines, that are even.
oddPaint - The paint to use for all grid lines, that are odd.

DefaultGridLineProvider

public DefaultGridLineProvider(int firstSize,
                               int betweenEvenSize,
                               int betweenOddSize,
                               int lastSize,
                               java.awt.Paint evenPaint,
                               java.awt.Paint oddPaint,
                               GridLineException[] exceptions)
Constructor for a special size for the first and last line compared to the ones in between.

Parameters:
firstSize - Size of the first line
betweenEvenSize - Size of all lines between first and last, that are even.
betweenOddSize - Size of all lines between first and last, that are odd.
lastSize - Size of the lst line
evenPaint - The paint to use for all grid lines, that are even.
oddPaint - The paint to use for all grid lines, that are odd.

DefaultGridLineProvider

public DefaultGridLineProvider(GridLineRepetition[] lines)
Constructor.

Parameters:
lines - The grid lines. Object is overtaken without defensive copy so don't keep a reference to it.

DefaultGridLineProvider

public DefaultGridLineProvider(GridLineRepetition[] lines,
                               GridLineException[] exceptions)
Constructor.

Parameters:
lines - The grid lines. Object is overtaken without defensive copy so don't keep a reference to it.
Method Detail

createGridLines

public GridLine[] createGridLines(GridRow[] rows)
Description copied from interface: GridLineProvider
Returns the grid lines between and around the rows.

Specified by:
createGridLines in interface GridLineProvider
Parameters:
rows - The rows to have the grid lines around.
Returns:
The grid lines for decorating around the grid rows. Always one more that the row count.

configureGridLines

public int configureGridLines(GridRow[] rows,
                              GridLine[] gridLines)
Description copied from interface: GridLineProvider
Configures the grid lines.

Specified by:
configureGridLines in interface GridLineProvider
Parameters:
rows - Some rows for which grid lines has previously been created with this provider.
gridLines - The grid lines to configure.
Returns:
The size of the grid lines.

getGridLinesSize

public int getGridLinesSize(GridRow[] rows)
Description copied from interface: GridLineProvider
Returns the total size of the grid lines for the given rows.

If the same rows are passed into GridLineProvider.createGridLines(GridRow[]) those's size must be the same as the returned size from this method.

Specified by:
getGridLinesSize in interface GridLineProvider
Parameters:
rows - The rows.
Returns:
The total size of the grid lines.

getExceptions

public GridLineException[] getExceptions()
Returns the exceptions to this grid line provider.

Returns:
The exceptions to this grid line provider. May be null.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.