com.miginfocom.calendar.grid
Interface Grid

All Known Implementing Classes:
AbstractGrid, DateGrid, DateHeaderGrid, HeaderGrid

public interface Grid

An interface that specifies how a grid should behave and what it always can do.


Field Summary
static int OUTLINE_SHAPE_MODE_EXACT
          The outline will follow from the start cell to the end cell in the time flow dimension and result in a number of rectangles that will oulint the exact cells included.
static int OUTLINE_SHAPE_MODE_EXACT_CLIPPED
          The outline will follow from the start cell to the end cell in the time flow dimension and result in a number of rectangles that will oulint the exact cells included.
static int OUTLINE_SHAPE_MODE_POLYGON
          The outline will follow from the start cell to the end cell in the time flow dimension and result in a polygon that will oulint the exact cells included.
static int OUTLINE_SHAPE_MODE_RECTANGLE
          The start and end cell will be the corner of a rectangle.
static int PRIMARY_DIMENSION
          Constant for denoting the dimension that time will flow primarily and the only dimension it would flow if it never wrapped.
static int SECONDARY_DIMENSION
          Constant for denoting the dimension that time will increased by a wrap of the primery dimension.
static int SIZE_MODE_INSIDE
          The returned rectangle will not draw over the cell's surrounding grid.
static int SIZE_MODE_MIDDLE
          The returned rectangle will draw in the middle of the cell's surrounding grid.
static int SIZE_MODE_OUTSIDE
          The returned rectangle will draw over as much as possible of the cell's surrounding grid.
static int SIZE_MODE_UPPER_LEFT
          The returned rectangle will draw over as much as possible of the cell's upper and left surrounding grid lines but not over the grid lines to the right or below.
 
Method Summary
 java.lang.Integer getAbsolutePreferredHeight()
          Returns the preferred height if it can be specified.
 java.lang.Integer getAbsolutePreferredWidth()
          Returns the preferred width if it can be specified.
 java.awt.Rectangle getBoundingBox(int startRow, int startCol, int endRow, int endCol, int cellSizeMode, boolean forDraw)
          Returns the bounds that contains all cells between the two cells (inclusive).
 java.awt.Rectangle getBoundsOfCell(int row, int col, int cellSizeMode, boolean forDraw)
          Returns a rectangle of the bounds of a cell, or hole, in the grid.
 java.awt.Point getCell(int number)
          Return the cell for a cell number.
 int getCellCount(int dim)
          Returns the number of cells in the specified dimension
 int getCellNumber(java.awt.Point cell)
          Returns the cell number for a cell.
 java.awt.Polygon getCellsOutline(int startRow, int startCol, int endRow, int endCol, int cellSizeMode, boolean forDraw)
          Traces the outline from the start cell to the end cell so that all cells between the start and end cell is inside the polygon, and no other cells.
 int getColumnCount()
          Returns the number of columns (holes) in the grid.
 int getColumnDimIx()
          Returns the column dimension index.
 java.lang.Integer getColumnForX(int x, boolean lenient)
          Returns the column that the x-value is over.
 GridLine[] getColumnGridLines()
          Returns the column grid lines.
 GridRow[] getColumns()
          Returns the grid-rows for the cell columns
 GridLine[] getGridLines(int dimIx)
          Returns the live grid lines for one dimension.
 GridLineSpecification getGridLineSpecification()
          Returns the grid line specification for this grid.
 GridRow[] getGridRows(int dimIx)
          Returns the live rows for the cells for one dimension.
 int getHeight()
          Returns the height
 int getMaximumHeight()
          Returns the maximum height that this grid can have.
 int getMaximumWidth()
          Returns the maximum width that this grid can have.
 int getMinimumHeight()
          Returns the minimum height that this grid can have.
 int getMinimumWidth()
          Returns the minimum width that this grid can have.
 java.lang.Float getPercentInsideColumn(int x, boolean lenient)
          Returns how far into the column that the x-value is over, in percent (0..1)
 java.lang.Float getPercentInsideRow(int y, boolean lenient)
          Returns how far into the row that the y-value is over, in percent (0..1)
 int getPrimaryDimension()
          Returns the primary dimension.
 int getRowCount()
          Returns the number of rows (holes) in the grid.
 int getRowDimIx()
          Returns the row dimension index.
 java.lang.Integer getRowForY(int y, boolean lenient)
          Returns the row that the y-value is over.
 GridLine[] getRowGridLines()
          Returns the row grid lines.
 GridRow[] getRows()
          Returns the grid-rows for the cell rows
 java.awt.Dimension getSize()
          Returns the size of the grid
 int getSize(int dimIx)
          Returns either bounds.width or bounds.height depending on which dimension is the primary
 int getWidth()
          Returns the width
 int getX(float percentage)
          Returns the x-position that is percentage percentange into the grid.
 int getY(float percentage)
          Returns the y-position that is percentage percentange into the grid.
 void layout()
          Calculates all positions for all rows.
 void setGridLines(int dimIx, GridLine[] newGridLines)
          Sets the grid lines.
 void setSize(java.awt.Dimension size)
          Sets the size and set the layout to dirty, but doen't lay it out.
 

Field Detail

PRIMARY_DIMENSION

static final int PRIMARY_DIMENSION
Constant for denoting the dimension that time will flow primarily and the only dimension it would flow if it never wrapped. For instance normally vertical in a day view and horizontal if a month view.

See Also:
Constant Field Values

SECONDARY_DIMENSION

static final int SECONDARY_DIMENSION
Constant for denoting the dimension that time will increased by a wrap of the primery dimension. For instance normally horizonlal in a day view and vertical if a month view.

See Also:
Constant Field Values

OUTLINE_SHAPE_MODE_POLYGON

static final int OUTLINE_SHAPE_MODE_POLYGON
The outline will follow from the start cell to the end cell in the time flow dimension and result in a polygon that will oulint the exact cells included.

Since:
6.0
See Also:
Constant Field Values

OUTLINE_SHAPE_MODE_RECTANGLE

static final int OUTLINE_SHAPE_MODE_RECTANGLE
The start and end cell will be the corner of a rectangle.

Since:
6.0
See Also:
Constant Field Values

OUTLINE_SHAPE_MODE_EXACT

static final int OUTLINE_SHAPE_MODE_EXACT
The outline will follow from the start cell to the end cell in the time flow dimension and result in a number of rectangles that will oulint the exact cells included.

Since:
6.0
See Also:
Constant Field Values

OUTLINE_SHAPE_MODE_EXACT_CLIPPED

static final int OUTLINE_SHAPE_MODE_EXACT_CLIPPED
The outline will follow from the start cell to the end cell in the time flow dimension and result in a number of rectangles that will oulint the exact cells included. They will be clipped by the grid bounds.

Since:
6.0
See Also:
Constant Field Values

SIZE_MODE_INSIDE

static final int SIZE_MODE_INSIDE
The returned rectangle will not draw over the cell's surrounding grid.

See Also:
Constant Field Values

SIZE_MODE_MIDDLE

static final int SIZE_MODE_MIDDLE
The returned rectangle will draw in the middle of the cell's surrounding grid.

See Also:
Constant Field Values

SIZE_MODE_OUTSIDE

static final int SIZE_MODE_OUTSIDE
The returned rectangle will draw over as much as possible of the cell's surrounding grid.

See Also:
Constant Field Values

SIZE_MODE_UPPER_LEFT

static final int SIZE_MODE_UPPER_LEFT
The returned rectangle will draw over as much as possible of the cell's upper and left surrounding grid lines but not over the grid lines to the right or below.

See Also:
Constant Field Values
Method Detail

getColumnCount

int getColumnCount()
Returns the number of columns (holes) in the grid. Always > 0.

Returns:
The number of columns (holes) in the grid.
See Also:
getCellCount(int)

getRowCount

int getRowCount()
Returns the number of rows (holes) in the grid. Always > 0.

Returns:
The number of rows (holes) in the grid.
See Also:
getCellCount(int)

getCellCount

int getCellCount(int dim)
Returns the number of cells in the specified dimension

Parameters:
dim - Grid.PRIMARY_DIMENSION or Grid.SECONDARY_DIMENSION
Returns:
The number of cells in the specified dimension
See Also:
getColumnCount(), getRowCount()

setSize

void setSize(java.awt.Dimension size)
Sets the size and set the layout to dirty, but doen't lay it out.

Parameters:
size - The new size. Not null.
See Also:
layout()

getSize

java.awt.Dimension getSize()
Returns the size of the grid

Returns:
The size of the grid

getWidth

int getWidth()
Returns the width

Returns:
The width

getHeight

int getHeight()
Returns the height

Returns:
The height

layout

void layout()
Calculates all positions for all rows. If bounds are not set yet, the minimum bounds will be used.

Only does the actual layout if the layout is dirty.


getColumnForX

java.lang.Integer getColumnForX(int x,
                                boolean lenient)
Returns the column that the x-value is over. x-values on the grid line is rounded to the closest column.

Parameters:
x - The x-value
lenient - If true this method never returns null, it returns first or last column of outside grid depending on whether the point is before or after the nearest col
Returns:
The column that x-value is over or null if outside grid.

getRowForY

java.lang.Integer getRowForY(int y,
                             boolean lenient)
Returns the row that the y-value is over. y-values on the grid line is rounded to the closest row.

Parameters:
y - The y-value in the coordinate system that grid's bounds is in.
lenient - If true this method never returns null, it returns first or last row of outside grid depending on whether the point is before or after the nearest col
Returns:
The row that y-value is over or null if outside grid.

getPercentInsideColumn

java.lang.Float getPercentInsideColumn(int x,
                                       boolean lenient)
Returns how far into the column that the x-value is over, in percent (0..1)

Parameters:
x - The x-value in the coordinate system that grid's bounds is in.
lenient - If true this method never returns null, it returns 0 or 1 depending on whether the point is before or after the nearest col
Returns:
How far into the column that the x-value is over, in percent (0..1) or null if over no column.

getPercentInsideRow

java.lang.Float getPercentInsideRow(int y,
                                    boolean lenient)
Returns how far into the row that the y-value is over, in percent (0..1)

Parameters:
y - The y-value in the coordinate system that grid's bounds is in.
lenient - If true this method never returns null, it returns 0 or 1 depending on whether the point is before or after the nearest col
Returns:
How far into the row that the y-value is over, in percent (0..1) or null if over no row.

getBoundsOfCell

java.awt.Rectangle getBoundsOfCell(int row,
                                   int col,
                                   int cellSizeMode,
                                   boolean forDraw)
Returns a rectangle of the bounds of a cell, or hole, in the grid.

Parameters:
row - The row, zero based
col - The column, zero based
cellSizeMode - The size and placement of the returned rectangle. Eg. SIZE_MODE_INSIDE
forDraw - If true the returned size is for draw-commands. If false it's sized for fill-commands (one pixel bigger) see class doc for more info.
Returns:
A rectangle of the bounds of the cell.

getBoundingBox

java.awt.Rectangle getBoundingBox(int startRow,
                                  int startCol,
                                  int endRow,
                                  int endCol,
                                  int cellSizeMode,
                                  boolean forDraw)
Returns the bounds that contains all cells between the two cells (inclusive). Note that all cells between the two cells are included in the normaly "flow" of the grid. This will thus NOT cut out a "box" with the cells. It will be like getting the boundary outline of a text when you know the first and last letter.

Parameters:
startCol - The start column. Must exist in the grid
startRow - The start row. Must exist in the grid
endCol - The end column. Must exist in the grid
endRow - The end row. Must exist in the grid
cellSizeMode - The size and placement of the returned outline. Eg. SIZE_MODE_INSIDE
forDraw - If true the returned size is for draw-commands. If false it's sized for fill-commands (one pixel bigger normally) see class doc for more info.
Returns:
The bounds, not null.

getCellsOutline

java.awt.Polygon getCellsOutline(int startRow,
                                 int startCol,
                                 int endRow,
                                 int endCol,
                                 int cellSizeMode,
                                 boolean forDraw)
Traces the outline from the start cell to the end cell so that all cells between the start and end cell is inside the polygon, and no other cells.

Parameters:
startCol - The start column. Must exist in the grid
startRow - The start row. Must exist in the grid
endCol - The end column. Must exist in the grid
endRow - The end row. Must exist in the grid
cellSizeMode - The size and placement of the returned outline. Eg. SIZE_MODE_INSIDE
forDraw - If true the returned size is for draw-commands. If false it's sized for fill-commands (one pixel bigger normally) see class doc for more info.
Returns:
The outline from the start cell to the end cell. Never null.

getX

int getX(float percentage)
Returns the x-position that is percentage percentange into the grid. For a normal grid the is a simple operation (linear), but for a segmented grid with segments of different scales this could non-trivial to calculate.

Parameters:
percentage - (normally 0.0 - 1.0) The percentage into the grid. Can be < 0.0 or > 1.0, the grid should extrapolate the absolute position is those cases.
Returns:
The x-position that is percentage percentange into the grid.

getY

int getY(float percentage)
Returns the y-position that is percentage percentange into the grid.

Parameters:
percentage - (normally 0.0 - 1.0) The percentage into the grid. Can be < 0.0 or > 1.0, the grid should extrapolate the absolute position is those cases.
Returns:
The y-position that is percentage percentange into the grid.

getMinimumWidth

int getMinimumWidth()
Returns the minimum width that this grid can have. 0 if not explicitly set.

Returns:
The minimum width that this grid can have. 0 if not explicitly set.

getMinimumHeight

int getMinimumHeight()
Returns the minimum height that this grid can have. 0 if not explicitly set.

Returns:
The minimum height that this grid can have. 0 if not explicitly set.

getMaximumWidth

int getMaximumWidth()
Returns the maximum width that this grid can have. MigUtil.BIG_INT if not explicitly set.

Returns:
The maximum width that this grid can have. MigUtil.BIG_INT if not explicitly set.

getMaximumHeight

int getMaximumHeight()
Returns the maximum height that this grid can have. MigUtil.BIG_INT if not explicitly set.

Returns:
The maximum height that this grid can have. MigUtil.BIG_INT if not explicitly set.

getPrimaryDimension

int getPrimaryDimension()
Returns the primary dimension.

Returns:
SwingUtilities.HORIZONTAL or SwingUtilities.VERTICAL

getColumns

GridRow[] getColumns()
Returns the grid-rows for the cell columns

Returns:
The grid rows for the cell columns. Not null
See Also:
GridRow

getRows

GridRow[] getRows()
Returns the grid-rows for the cell rows

Returns:
The grid rows for the cell rows. Not null
See Also:
GridRow

getSize

int getSize(int dimIx)
Returns either bounds.width or bounds.height depending on which dimension is the primary

Parameters:
dimIx - Either PRIMARY_DIMENSION or SECONDARY_DIMENSION
Returns:
The size of the bounds

getAbsolutePreferredWidth

java.lang.Integer getAbsolutePreferredWidth()
Returns the preferred width if it can be specified. Asks the contained GridSegmentSpec if it has a preferred width and if so, returns it. If the GridSegmentSpec has a relative preferred width (Float), it is considered dynamic and null is returned.
Note that the grid may still be sized. True static width is only guaranteed if minimumWidth == maximumWidth == preferredWidth.

Returns:
The height or null if dynamic, i.e. unspecified.

getAbsolutePreferredHeight

java.lang.Integer getAbsolutePreferredHeight()
Returns the preferred height if it can be specified. Asks the contained GridSegmentSpec if it has a preferred height and if so, returns it. If the GridSegmentSpec has a relative preferred height (Float), it is considered dynamic and null is returned.
Note that the grid may still be sized. True static width is only guaranteed if minimumWidth == maximumWidth == preferredWidth.

Returns:
The width or null if dynamic, i.e. unspecified.

getGridRows

GridRow[] getGridRows(int dimIx)
Returns the live rows for the cells for one dimension.

Parameters:
dimIx - The dimension. E.g. PRIMARY_DIMENSION.
Returns:
The live rows for the cells for one dimension.

getGridLines

GridLine[] getGridLines(int dimIx)
Returns the live grid lines for one dimension.

Parameters:
dimIx - The dimension. E.g. PRIMARY_DIMENSION.
Returns:
The live grid lines for one dimension.

getColumnGridLines

GridLine[] getColumnGridLines()
Returns the column grid lines.

Returns:
The column grid lines. Not null.

getRowGridLines

GridLine[] getRowGridLines()
Returns the row grid lines.

Returns:
The row grid lines. Not null.

setGridLines

void setGridLines(int dimIx,
                  GridLine[] newGridLines)
Sets the grid lines. Unregister old property change listeners and add listeners to newGridLines.

Parameters:
dimIx - The dimension. E.g. PRIMARY_DIMENSION
newGridLines - The new grid lines to set

getGridLineSpecification

GridLineSpecification getGridLineSpecification()
Returns the grid line specification for this grid.

Returns:
The grid line specification for this grid. Never null.

getCellNumber

int getCellNumber(java.awt.Point cell)
Returns the cell number for a cell. Cells are numbered from top-left and then down or right depending on which dimension is the primary. E.g. Cell(0, 0) is number 0 and Cell(maxRows - 1, maxCols - 1) is number (maxCols * maxRows)

Parameters:
cell - The cell. Row, column.
Returns:
The cell number for a cell.

getCell

java.awt.Point getCell(int number)
Return the cell for a cell number.

Parameters:
number - The cell number (as in if they was laied out in one line and not wrapped).
Returns:
The corresponding cell, never null. New object free to use.
See Also:
getCellNumber(java.awt.Point)

getColumnDimIx

int getColumnDimIx()
Returns the column dimension index.

Returns:
The column dimension index. (i.e. SECONDARY_DIMENSION or PRIMARY_DIMENSION)
See Also:
SECONDARY_DIMENSION, PRIMARY_DIMENSION

getRowDimIx

int getRowDimIx()
Returns the row dimension index.

Returns:
The row dimension index. (i.e. SECONDARY_DIMENSION or PRIMARY_DIMENSION)
See Also:
SECONDARY_DIMENSION, PRIMARY_DIMENSION


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.