com.miginfocom.calendar.grid
Class AbstractGrid

java.lang.Object
  extended by com.miginfocom.calendar.grid.AbstractGrid
All Implemented Interfaces:
Grid, java.beans.PropertyChangeListener, java.util.EventListener
Direct Known Subclasses:
DateGrid, HeaderGrid

public abstract class AbstractGrid
extends java.lang.Object
implements Grid, java.beans.PropertyChangeListener

Implements most of the basic geometry work for a Grid. It doesn't have any rows or gridlines created, that will be done by calling createGridLinesAndCellRows() the first time setSize(java.awt.Dimension) is called sice the rows/cells can't be created without the bounds set.

This grid only supports one level of sub-grid lines. This means that every row in the secondary dimension can consist of a number of sub rows. Those however can not (even though the GridRow API can support an arbitrary depth) contain sub grid rows. Also, currently all rows have to have an equal amount of grid rows.

This class is immutable once created and should be recreated if data on which it is build changes.

Note! Subclasses should call createGridLinesAndCellRows() at the end of the constructor to create the grid rows/lines or at least create them in some other way. Use setCellRows(int, GridRow[]) and setGridLines(int, GridLine[]) to set the rows. Listeners will be attached to them and removed if new rows are installed.


Field Summary
 
Fields inherited from interface com.miginfocom.calendar.grid.Grid
OUTLINE_SHAPE_MODE_EXACT, OUTLINE_SHAPE_MODE_EXACT_CLIPPED, OUTLINE_SHAPE_MODE_POLYGON, OUTLINE_SHAPE_MODE_RECTANGLE, PRIMARY_DIMENSION, SECONDARY_DIMENSION, SIZE_MODE_INSIDE, SIZE_MODE_MIDDLE, SIZE_MODE_OUTSIDE, SIZE_MODE_UPPER_LEFT
 
Constructor Summary
protected AbstractGrid(int primDim, int primDimCellCount, int secDimCellCount, GridLineSpecification gridLineSpec)
          Constructor.
 
Method Summary
 void addPropertyListener(java.beans.PropertyChangeListener l)
          Transfer to addPropertyListener(java.beans.PropertyChangeListener, boolean) with false for as>WeakRef.
 void addPropertyListener(java.beans.PropertyChangeListener l, boolean asWeakRef)
          Add a listener that listens for any changes in the properties for this grid, as well as the GridRows it contains.
protected  void assertSize(int row, int col)
          Throws a IndexOutOfBoundsException if cell doesn't exist
protected abstract  void createGridLinesAndCellRows()
          Implement this to create the cell rows and grid lines.
protected  void firePropertyChangeEvent(java.lang.String propName, java.lang.Object oldValue, java.lang.Object newValue)
          Notifies listeners of property changes, but only if there actually was a change.
 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 r, int c, 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.
protected  int getOrientationForDimIx(int dimIx)
          Returns the dimension for dimIx.
 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.
 GridDimensionLayout getPrimaryDimensionLayout()
           
protected  int getRelPos(int dimIx, float perc)
          Returns an absolute pixel position perc percent into the grid's cells.
 GridRow getRowAt(int dimIx, java.awt.Point p, int maxDepth)
          Recursively call getRowIndexForPos(int, int, boolean) to get the deepest grid row that pos hits.
 GridRow getRowAt(int dimIx, java.awt.Point p, int maxDepth, boolean lenientBounds)
          Deprecated. Since rows may not be layed out neck-to-neck from v5.5 the lenient argument can not be used. Use getRowAt(int, java.awt.Point, int) instead.
 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.
protected  java.lang.Integer getRowIndexForPos(int dimIx, int pos, boolean lenientBounds)
          Returns the cell for a position
 GridRow[] getRows()
          Returns the grid-rows for the cell rows
 GridDimensionLayout getSecondaryDimensionLayout()
           
 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 perc)
          Returns the x-position that is percentage percentange into the grid.
 int getY(float perc)
          Returns the y-position that is percentage percentange into the grid.
 boolean isIgnorePropertyEvents()
          Returns if events are currently ignored.
 void layout()
          Calculates all positions for all rows.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Just dispatch it to the listeners for this class.
 void removePropertyListener(java.beans.PropertyChangeListener l)
          Removes the listener, if it is in the list.
protected  void setCellRows(int dimIx, GridRow[] newCellRows)
          Sets the cell rows.
 void setGridLines(int dimIx, GridLine[] newGridLines)
          Sets the grid lines.
 boolean setIgnorePropertyEvents(boolean b)
          Sets if events should be ignored, and thus not fired.
 void setPrimaryDimensionLayout(GridDimensionLayout layout)
           
 void setSecondaryDimensionLayout(GridDimensionLayout layout)
           
 void setSize(java.awt.Dimension size)
          Sets the size and set the layout to dirty, but doen't lay it out.
 int toPos(int dimIx, java.awt.Point p)
          Return either p.x or p.y depending in the indicated dimension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractGrid

protected AbstractGrid(int primDim,
                       int primDimCellCount,
                       int secDimCellCount,
                       GridLineSpecification gridLineSpec)
Constructor. Note that the grid still don't have a valid bounds after creation. This constructor creates a grid which contains all possible dates/times within dateRange.

Parameters:
primDim - The dimensions the cells should be laid out if they where sequental. e.g. code>SwingConstants.HORIZONTAL means that the "next" cell if normally to the right, if not reached the last column, where it wraps to next row.
primDimCellCount - The number of cells in the primary dimension. & gt 0.
secDimCellCount - The number of cells in the secondary dimension. & gt 0.
gridLineSpec - The specification for the grid lines in the primary, secondary and for all sub dimensins. Not null.
See Also:
setSize(java.awt.Dimension)
Method Detail

getSecondaryDimensionLayout

public GridDimensionLayout getSecondaryDimensionLayout()

setSecondaryDimensionLayout

public void setSecondaryDimensionLayout(GridDimensionLayout layout)

getPrimaryDimensionLayout

public GridDimensionLayout getPrimaryDimensionLayout()

setPrimaryDimensionLayout

public void setPrimaryDimensionLayout(GridDimensionLayout layout)

getColumnCount

public int getColumnCount()
Description copied from interface: Grid
Returns the number of columns (holes) in the grid. Always > 0.

Specified by:
getColumnCount in interface Grid
Returns:
The number of columns (holes) in the grid.
See Also:
Grid.getCellCount(int)

getRowCount

public int getRowCount()
Description copied from interface: Grid
Returns the number of rows (holes) in the grid. Always > 0.

Specified by:
getRowCount in interface Grid
Returns:
The number of rows (holes) in the grid.
See Also:
Grid.getCellCount(int)

getCellCount

public int getCellCount(int dim)
Description copied from interface: Grid
Returns the number of cells in the specified dimension

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

getSize

public java.awt.Dimension getSize()
Description copied from interface: Grid
Returns the size of the grid

Specified by:
getSize in interface Grid
Returns:
The size of the grid

getSize

public int getSize(int dimIx)
Description copied from interface: Grid
Returns either bounds.width or bounds.height depending on which dimension is the primary

Specified by:
getSize in interface Grid
Parameters:
dimIx - Either Grid.PRIMARY_DIMENSION or Grid.SECONDARY_DIMENSION
Returns:
The size of the bounds

getHeight

public int getHeight()
Description copied from interface: Grid
Returns the height

Specified by:
getHeight in interface Grid
Returns:
The height

getWidth

public int getWidth()
Description copied from interface: Grid
Returns the width

Specified by:
getWidth in interface Grid
Returns:
The width

setSize

public void setSize(java.awt.Dimension size)
Description copied from interface: Grid
Sets the size and set the layout to dirty, but doen't lay it out.

Specified by:
setSize in interface Grid
Parameters:
size - The new size. Not null.
See Also:
Grid.layout()

getMinimumWidth

public int getMinimumWidth()
Description copied from interface: Grid
Returns the minimum width that this grid can have. 0 if not explicitly set.

Specified by:
getMinimumWidth in interface Grid
Returns:
The minimum width that this grid can have. 0 if not explicitly set.

getMaximumWidth

public int getMaximumWidth()
Description copied from interface: Grid
Returns the maximum width that this grid can have. MigUtil.BIG_INT if not explicitly set.

Specified by:
getMaximumWidth in interface Grid
Returns:
The maximum width that this grid can have. MigUtil.BIG_INT if not explicitly set.

getMinimumHeight

public int getMinimumHeight()
Description copied from interface: Grid
Returns the minimum height that this grid can have. 0 if not explicitly set.

Specified by:
getMinimumHeight in interface Grid
Returns:
The minimum height that this grid can have. 0 if not explicitly set.

getMaximumHeight

public int getMaximumHeight()
Description copied from interface: Grid
Returns the maximum height that this grid can have. MigUtil.BIG_INT if not explicitly set.

Specified by:
getMaximumHeight in interface Grid
Returns:
The maximum height that this grid can have. MigUtil.BIG_INT if not explicitly set.

getAbsolutePreferredWidth

public java.lang.Integer getAbsolutePreferredWidth()
Description copied from interface: Grid
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.

Specified by:
getAbsolutePreferredWidth in interface Grid
Returns:
The height or null if dynamic, i.e. unspecified.

getAbsolutePreferredHeight

public java.lang.Integer getAbsolutePreferredHeight()
Description copied from interface: Grid
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.

Specified by:
getAbsolutePreferredHeight in interface Grid
Returns:
The width or null if dynamic, i.e. unspecified.

getX

public int getX(float perc)
Description copied from interface: Grid
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.

Specified by:
getX in interface Grid
Parameters:
perc - (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

public int getY(float perc)
Description copied from interface: Grid
Returns the y-position that is percentage percentange into the grid.

Specified by:
getY in interface Grid
Parameters:
perc - (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.

getRelPos

protected int getRelPos(int dimIx,
                        float perc)
Returns an absolute pixel position perc percent into the grid's cells.

Parameters:
dimIx - The dimension. E.g. Grid.PRIMARY_DIMENSION or Grid.SECONDARY_DIMENSION
perc - (normally 0.0 - 1.0) The percentage into the grid. Can be < 0.0 or > 1.0, the grid will extrapolate the absolute position is those cases.
Returns:
n absolute pixel position perc percent into the grid's cells.

toPos

public int toPos(int dimIx,
                 java.awt.Point p)
Return either p.x or p.y depending in the indicated dimension. Just a convenience method for getOrientationForDimIx(dimIx) == VER ? p.y : p.x;.

Parameters:
dimIx - The dimension. E.g. Grid.PRIMARY_DIMENSION
p - The point
Returns:
Either p.x or p.y depending in the indicated dimension.

getColumnForX

public java.lang.Integer getColumnForX(int x,
                                       boolean lenient)
Description copied from interface: Grid
Returns the column that the x-value is over. x-values on the grid line is rounded to the closest column.

Specified by:
getColumnForX in interface Grid
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

public java.lang.Integer getRowForY(int y,
                                    boolean lenient)
Description copied from interface: Grid
Returns the row that the y-value is over. y-values on the grid line is rounded to the closest row.

Specified by:
getRowForY in interface Grid
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.

getColumns

public GridRow[] getColumns()
Description copied from interface: Grid
Returns the grid-rows for the cell columns

Specified by:
getColumns in interface Grid
Returns:
The grid rows for the cell columns. Not null
See Also:
GridRow

getRows

public GridRow[] getRows()
Description copied from interface: Grid
Returns the grid-rows for the cell rows

Specified by:
getRows in interface Grid
Returns:
The grid rows for the cell rows. Not null
See Also:
GridRow

getGridRows

public GridRow[] getGridRows(int dimIx)
Description copied from interface: Grid
Returns the live rows for the cells for one dimension.

Specified by:
getGridRows in interface Grid
Parameters:
dimIx - The dimension. E.g. Grid.PRIMARY_DIMENSION.
Returns:
The live rows for the cells for one dimension.

getColumnGridLines

public GridLine[] getColumnGridLines()
Description copied from interface: Grid
Returns the column grid lines.

Specified by:
getColumnGridLines in interface Grid
Returns:
The column grid lines. Not null.

getRowGridLines

public GridLine[] getRowGridLines()
Description copied from interface: Grid
Returns the row grid lines.

Specified by:
getRowGridLines in interface Grid
Returns:
The row grid lines. Not null.

setCellRows

protected void setCellRows(int dimIx,
                           GridRow[] newCellRows)
Sets the cell rows. Unregister old property change listeners and add listeners to newCellRows.

Parameters:
dimIx - The dimension. E.g. PRIMARY_DIMENSION
newCellRows - The new cell rows to set

getGridLines

public GridLine[] getGridLines(int dimIx)
Description copied from interface: Grid
Returns the live grid lines for one dimension.

Specified by:
getGridLines in interface Grid
Parameters:
dimIx - The dimension. E.g. Grid.PRIMARY_DIMENSION.
Returns:
The live grid lines for one dimension.

setGridLines

public void setGridLines(int dimIx,
                         GridLine[] newGridLines)
Description copied from interface: Grid
Sets the grid lines. Unregister old property change listeners and add listeners to newGridLines.

Specified by:
setGridLines in interface Grid
Parameters:
dimIx - The dimension. E.g. PRIMARY_DIMENSION
newGridLines - The new grid lines to set

getGridLineSpecification

public GridLineSpecification getGridLineSpecification()
Description copied from interface: Grid
Returns the grid line specification for this grid.

Specified by:
getGridLineSpecification in interface Grid
Returns:
The grid line specification for this grid. Never null.

getColumnDimIx

public final int getColumnDimIx()
Description copied from interface: Grid
Returns the column dimension index.

Specified by:
getColumnDimIx in interface Grid
Returns:
The column dimension index. (i.e. SECONDARY_DIMENSION or PRIMARY_DIMENSION)
See Also:
Grid.SECONDARY_DIMENSION, Grid.PRIMARY_DIMENSION

getRowDimIx

public final int getRowDimIx()
Description copied from interface: Grid
Returns the row dimension index.

Specified by:
getRowDimIx in interface Grid
Returns:
The row dimension index. (i.e. SECONDARY_DIMENSION or PRIMARY_DIMENSION)
See Also:
Grid.SECONDARY_DIMENSION, Grid.PRIMARY_DIMENSION

getOrientationForDimIx

protected final int getOrientationForDimIx(int dimIx)
Returns the dimension for dimIx.

Parameters:
dimIx - the dimension index. E.g. PRIMARY_DIMENSION.
Returns:
The dimension for dimIx. E.g. SwingUtilities.VERTICAL
See Also:
Grid.SECONDARY_DIMENSION, Grid.PRIMARY_DIMENSION

getRowIndexForPos

protected java.lang.Integer getRowIndexForPos(int dimIx,
                                              int pos,
                                              boolean lenientBounds)
Returns the cell for a position

Parameters:
dimIx - The dimension. E.g. Grid.SECONDARY_DIMENSION
pos - The pixel position.
lenientBounds - If true this method never returns null, it returns first or last cell of outside grid depending on whether the point is before or after the nearest cell.
Returns:
The corresponding cell or null.

getRowAt

public GridRow getRowAt(int dimIx,
                        java.awt.Point p,
                        int maxDepth)
Recursively call getRowIndexForPos(int, int, boolean) to get the deepest grid row that pos hits. Follows the same rules but for a hitted row that row's potential sub rows are then asked.

Parameters:
dimIx - The dimension. E.g. Grid.SECONDARY_DIMENSION
p - The pixel position. Only x OR y will be interesting (depending on dimIx).
maxDepth - The maximum depth to recursively check for sub rows. If 0 then one of the top level rows will be returned.
Returns:
The row that was hit or null if none.

getRowAt

public GridRow getRowAt(int dimIx,
                        java.awt.Point p,
                        int maxDepth,
                        boolean lenientBounds)
Deprecated. Since rows may not be layed out neck-to-neck from v5.5 the lenient argument can not be used. Use getRowAt(int, java.awt.Point, int) instead.

Recursively call getRowIndexForPos(int, int, boolean) to get the grid row that pos hits. Follows the same rules but for a hitted row that row's potential sub rows are then asked.

Parameters:
dimIx - The dimension. E.g. Grid.SECONDARY_DIMENSION
p - The pixel position. Only x OR y will be interesting (depending on dimIx).
maxDepth - The maximum depth to recursively check for sub rows. If 0 then one of the top level rows will be returned.
lenientBounds - NOT USED
Returns:
The row that was hit or null if none.

getPercentInsideColumn

public java.lang.Float getPercentInsideColumn(int x,
                                              boolean lenient)
Description copied from interface: Grid
Returns how far into the column that the x-value is over, in percent (0..1)

Specified by:
getPercentInsideColumn in interface Grid
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

public java.lang.Float getPercentInsideRow(int y,
                                           boolean lenient)
Description copied from interface: Grid
Returns how far into the row that the y-value is over, in percent (0..1)

Specified by:
getPercentInsideRow in interface Grid
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.

getPrimaryDimension

public int getPrimaryDimension()
Description copied from interface: Grid
Returns the primary dimension.

Specified by:
getPrimaryDimension in interface Grid
Returns:
SwingUtilities.HORIZONTAL or SwingUtilities.VERTICAL

getBoundsOfCell

public java.awt.Rectangle getBoundsOfCell(int r,
                                          int c,
                                          int cellSizeMode,
                                          boolean forDraw)
Description copied from interface: Grid
Returns a rectangle of the bounds of a cell, or hole, in the grid.

Specified by:
getBoundsOfCell in interface Grid
Parameters:
r - The row, zero based
c - The column, zero based
cellSizeMode - The size and placement of the returned rectangle. Eg. Grid.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

public java.awt.Rectangle getBoundingBox(int startRow,
                                         int startCol,
                                         int endRow,
                                         int endCol,
                                         int cellSizeMode,
                                         boolean forDraw)
Description copied from interface: Grid
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.

Specified by:
getBoundingBox in interface Grid
Parameters:
startRow - The start row. Must exist in the grid
startCol - The start column. Must exist in the grid
endRow - The end row. Must exist in the grid
endCol - The end column. 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

public java.awt.Polygon getCellsOutline(int startRow,
                                        int startCol,
                                        int endRow,
                                        int endCol,
                                        int cellSizeMode,
                                        boolean forDraw)
Description copied from interface: Grid
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.

Specified by:
getCellsOutline in interface Grid
Parameters:
startRow - The start row. Must exist in the grid
startCol - The start column. Must exist in the grid
endRow - The end row. Must exist in the grid
endCol - The end column. 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.

getCellNumber

public int getCellNumber(java.awt.Point cell)
Description copied from interface: Grid
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)

Specified by:
getCellNumber in interface Grid
Parameters:
cell - The cell. Row, column.
Returns:
The cell number for a cell.

getCell

public java.awt.Point getCell(int number)
Description copied from interface: Grid
Return the cell for a cell number.

Specified by:
getCell in interface Grid
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:
Grid.getCellNumber(java.awt.Point)

layout

public void layout()
Description copied from interface: Grid
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.

Specified by:
layout in interface Grid

assertSize

protected final void assertSize(int row,
                                int col)
Throws a IndexOutOfBoundsException if cell doesn't exist


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Just dispatch it to the listeners for this class. Don't change the source.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - The event, originating from a GridRow.

createGridLinesAndCellRows

protected abstract void createGridLinesAndCellRows()
Implement this to create the cell rows and grid lines. This method will be called the first time setBounds is called and MUST initialize cells and gridRows to the correct sizes.

Set cellRows and gridLines with setCellRows(int, GridRow[]) and setGridLines(int, GridLine[]).


addPropertyListener

public void addPropertyListener(java.beans.PropertyChangeListener l)
Transfer to addPropertyListener(java.beans.PropertyChangeListener, boolean) with false for as>WeakRef.

Parameters:
l - The listener.

addPropertyListener

public void addPropertyListener(java.beans.PropertyChangeListener l,
                                boolean asWeakRef)
Add a listener that listens for any changes in the properties for this grid, as well as the GridRows it contains. The source can be checked to see if the property is from the grid or from a grid row.

Parameters:
l - The listener.
asWeakRef - If the listener should be added wrapped in a WeakReference. This defers memory leak problems since the garbage collector can collect the listener if it is only referenced from this list.
Note! This (weak reference) can not be used with listeners that doesn't have another real (a.k.a Strong) reference to it, as for instance an annonymous inner class. If one such listener is added it will be removed almost immediately by the garbage collector.

removePropertyListener

public void removePropertyListener(java.beans.PropertyChangeListener l)
Removes the listener, if it is in the list.

Parameters:
l - The listener to remove, not null.

isIgnorePropertyEvents

public boolean isIgnorePropertyEvents()
Returns if events are currently ignored.

Returns:
If events are currently ignored.
See Also:
setIgnorePropertyEvents(boolean)

setIgnorePropertyEvents

public boolean setIgnorePropertyEvents(boolean b)
Sets if events should be ignored, and thus not fired.

Parameters:
b - true turns off events
Returns:
The old state of this flag.

firePropertyChangeEvent

protected void firePropertyChangeEvent(java.lang.String propName,
                                       java.lang.Object oldValue,
                                       java.lang.Object newValue)
Notifies listeners of property changes, but only if there actually was a change. If old and new equals nothing will be fired.

Parameters:
propName - The property that has been changed
oldValue - The old value if that is known. May be null.
newValue - The new value if known. May be null.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.