public class GridBase extends Object implements Grid, EventTarget
Grid interface.
You can specify some row height in the constructor for some of your rows.
Just give a Map of Integer (the number of the concerned row) and Double (the
height, default is 24.0).
If you want to change the value of a cell, you have to go through the API
with setCellValue(int, int, Object). This method will verify that
the value is corresponding to the SpreadsheetCellType of the cell and
try to convert it if possible. It will also fire a GridChange event
in order to notify all listeners that a value has changed.
If you want to listen to those changes, you can use the
addEventHandler(EventType, EventHandler) and
removeEventHandler(EventType, EventHandler) methods.
A basic listener for implementing a undo/redo in the SpreadsheetView could be
like that:
Grid grid = ...;
Stack<GridChange> undoStack = ...;
grid.addEventHandler(GridChange.GRID_CHANGE_EVENT, new EventHandler<GridChange>() {
public void handle(GridChange change) {
undoStack.push(change);
}
});
Grid,
GridChange| Type | Property and Description |
|---|---|
BooleanProperty |
locked
Return a BooleanProperty associated with the locked grid state.
|
| Modifier and Type | Class and Description |
|---|---|
static class |
GridBase.MapBasedRowHeightFactory
This class serves as a bridge between row height Callback needed by the
GridBase and a Map
|
| Constructor and Description |
|---|
GridBase()
Creates grid with 'unlimited' rows and columns
|
GridBase(int rowCount,
int columnCount)
Creates a grid with a fixed number of rows and columns.
|
| Modifier and Type | Method and Description |
|---|---|
<E extends GridChange> |
addEventHandler(EventType<E> eventType,
EventHandler<E> eventHandler)
Registers an event handler to this Grid.
|
EventDispatchChain |
buildEventDispatchChain(EventDispatchChain tail) |
int |
getColumnCount()
Return how many columns are inside the grid.
|
ObservableList<String> |
getColumnHeaders()
Returns an ObservableList of string to display in the column headers.
|
int |
getRowCount()
Return how many rows are inside the grid.
|
ObservableList<String> |
getRowHeaders()
Returns an ObservableList of string to display in the row headers.
|
double |
getRowHeight(int row)
Return the height of a row.
|
ObservableList<ObservableList<SpreadsheetCell>> |
getRows()
Return an ObservableList of ObservableList of
SpreadsheetCell
instances. |
SpreadsheetView.SpanType |
getSpanType(SpreadsheetView spv,
int row,
int column)
Return the
SpreadsheetView.SpanType for a given cell row/column intersection. |
boolean |
isLocked()
Return whether this Grid id locked or not.
|
BooleanProperty |
lockedProperty()
Return a BooleanProperty associated with the locked grid state.
|
<E extends GridChange> |
removeEventHandler(EventType<E> eventType,
EventHandler<E> eventHandler)
Unregisters a previously registered event handler from this Grid.
|
void |
setCellValue(int row,
int column,
Object value)
Change the value situated at the intersection if possible.
|
void |
setLocked(Boolean lock)
Lock or unlock this Grid.
|
void |
setRowHeightCallback(Callback<Integer,Double> rowHeight)
Set a new
Callback for this grid in order to specify height of
each row. |
void |
setRows(Collection<ObservableList<SpreadsheetCell>> rows)
This method sets the rows used by the grid, and updates the rowCount.
|
void |
spanColumn(int count,
int rowIndex,
int colIndex)
Span in column the cell situated at rowIndex and colIndex by the number
count
|
void |
spanRow(int count,
int rowIndex,
int colIndex)
Span in row the cell situated at rowIndex and colIndex by the number
count
|
public BooleanProperty lockedProperty
SpreadsheetCell.editableProperty().isLocked(),
setLocked(Boolean)public GridBase()
public GridBase(int rowCount,
int columnCount)
rowCount - columnCount - public ObservableList<ObservableList<SpreadsheetCell>> getRows()
SpreadsheetCell
instances. Refer to the Grid class javadoc for more detail.getRows in interface GridSpreadsheetCell
instancespublic void setCellValue(int row,
int column,
Object value)
SpreadsheetCellType.match(Object)
and SpreadsheetCellType.convertValue(Object).setCellValue in interface Gridpublic int getRowCount()
getRowCount in interface Gridpublic int getColumnCount()
getColumnCount in interface Gridpublic SpreadsheetView.SpanType getSpanType(SpreadsheetView spv, int row, int column)
SpreadsheetView.SpanType for a given cell row/column intersection.getSpanType in interface GridSpreadsheetView.SpanType for a given cell row/column intersection.public double getRowHeight(int row)
Callbackprovided at the
initialization. If nothing's found, default height will be taken.getRowHeight in interface Gridpublic void setRowHeightCallback(Callback<Integer,Double> rowHeight)
Callback for this grid in order to specify height of
each row.rowHeight - public ObservableList<String> getRowHeaders()
public ObservableList<String> getColumnHeaders()
public BooleanProperty lockedProperty()
SpreadsheetCell.editableProperty().isLocked(),
setLocked(Boolean)public boolean isLocked()
public void setLocked(Boolean lock)
lock - public void spanRow(int count,
int rowIndex,
int colIndex)
count - rowIndex - colIndex - public void spanColumn(int count,
int rowIndex,
int colIndex)
count - rowIndex - colIndex - public void setRows(Collection<ObservableList<SpreadsheetCell>> rows)
public <E extends GridChange> void addEventHandler(EventType<E> eventType, EventHandler<E> eventHandler)
SpreadsheetCell's value
will change.addEventHandler in interface GrideventType - the type of the events to receive by the handlereventHandler - the handler to registerpublic <E extends GridChange> void removeEventHandler(EventType<E> eventType, EventHandler<E> eventHandler)
removeEventHandler in interface GrideventType - the event type from which to unregistereventHandler - the handler to unregisterpublic EventDispatchChain buildEventDispatchChain(EventDispatchChain tail)
buildEventDispatchChain in interface EventTarget