public interface Grid
SpreadsheetCell in order
to be used by the SpreadsheetView.
A Grid is used by SpreadsheetView to represent the data to show on
screen. A default implementation is provided by GridBase, but for
more custom purposes (e.g. loading data on demand), this Grid interface may
prove useful.
A Grid at its essence consists of rows and columns. Critical to the
SpreadsheetView is that the row count and
column count are accurately returned when requested
(even if the data returned by getRows() is not all fully loaded into
memory).
Whilst the getRows() return type may appear confusing, it is
actually quite logical when you think about it: getRows() returns an
ObservableList of ObservableList of SpreadsheetCell instances. In other
words, this is your classic 2D collection, where the outer ObservableList
can be thought of as the rows, and the inner ObservableList as the columns
within each row. Therefore, if you are wanting to iterate through all columns
in every row of the grid, you would do something like this:
Grid grid = ...
for (int row = 0; row < grid.getRowCount(); row++) {
for (int column = 0; column < grid.getColumnCount(); column++) {
SpreadsheetCell<?> cell = getRows().get(row).get(column);
doStuff(cell);
}
}
SpreadsheetView,
GridBase,
SpreadsheetCell| Type | Property and Description |
|---|---|
javafx.beans.property.BooleanProperty |
displaySelection
Returns the Boolean property associated with the displayed selection of the
Grid. |
| Modifier and Type | Field and Description |
|---|---|
static double |
AUTOFIT
This value may be returned from
getRowHeight(int) in order to
let the system compute the best row height. |
| Modifier and Type | Method and Description |
|---|---|
<E extends GridChange> |
addEventHandler(javafx.event.EventType<E> eventType,
javafx.event.EventHandler<E> eventHandler)
Registers an event handler to this Grid.
|
javafx.beans.property.BooleanProperty |
displaySelectionProperty()
Returns the Boolean property associated with the displayed selection of the
Grid. |
int |
getColumnCount()
Returns how many columns are inside the
Grid. |
javafx.collections.ObservableList<java.lang.String> |
getColumnHeaders()
Returns an
ObservableList of String to display in the
column headers. |
int |
getRowCount()
Returns how many rows are inside the
Grid. |
javafx.collections.ObservableList<java.lang.String> |
getRowHeaders()
Returns an
ObservableList of String to display in the row
headers. |
double |
getRowHeight(int row)
Returns the height of a row.
|
javafx.collections.ObservableList<javafx.collections.ObservableList<SpreadsheetCell>> |
getRows()
|
boolean |
isCellDisplaySelection(int row,
int column)
Returns true if the given cell will display a selection rectangle when
selected.
|
boolean |
isDisplaySelection()
Return
true if the selection (black rectangle) is displayed on
the Grid. |
boolean |
isRowResizable(int row)
Returns true if the specified row is resizable.
|
<E extends GridChange> |
removeEventHandler(javafx.event.EventType<E> eventType,
javafx.event.EventHandler<E> eventHandler)
Unregisters a previously registered event handler from this Grid.
|
void |
setCellDisplaySelection(int row,
int column,
boolean displaySelection)
Overrides the value defined by
isDisplaySelection()
so that no matter what is defined on the grid, the given cell will always
have its selection set to the displaySelection parameter. |
void |
setCellValue(int row,
int column,
java.lang.Object value)
Changes the value situated at the intersection if possible.
|
void |
setDisplaySelection(boolean value)
If set to true, the selection (black rectangle) will be displayed on the
Grid. |
void |
setRows(java.util.Collection<javafx.collections.ObservableList<SpreadsheetCell>> rows)
Sets the rows used by the grid, and updates the rowCount.
|
void |
spanColumn(int count,
int rowIndex,
int colIndex)
Spans in column the cell situated at rowIndex and colIndex by the number
count.
|
void |
spanRow(int count,
int rowIndex,
int colIndex)
Spans in row the cell situated at rowIndex and colIndex by the number
count.
|
javafx.beans.property.BooleanProperty displaySelectionProperty
Grid.isDisplaySelection(),
setDisplaySelection(boolean)static final double AUTOFIT
getRowHeight(int) in order to
let the system compute the best row height.int getRowCount()
Grid.Grid.int getColumnCount()
Grid.Grid.javafx.collections.ObservableList<javafx.collections.ObservableList<SpreadsheetCell>> getRows()
ObservableList of ObservableList of
SpreadsheetCell instances. Refer to the Grid class
javadoc for more detail.ObservableList of ObservableList of
SpreadsheetCell instancesvoid setCellValue(int row,
int column,
java.lang.Object value)
SpreadsheetCellType.match(Object) and
SpreadsheetCellType.convertValue(Object).row - the row index issued from the SpreadsheetCellcolumn - the column index issued from the SpreadsheetCellvalue - the value to set to the SpreadsheetCelldouble getRowHeight(int row)
AUTOFIT can be returned in order
to let the system compute the best row height.row - the row indexboolean isRowResizable(int row)
row - the row indextrue if the specified row is resizablejavafx.collections.ObservableList<java.lang.String> getRowHeaders()
ObservableList of String to display in the row
headers.ObservableList of String to display in the row
headersjavafx.collections.ObservableList<java.lang.String> getColumnHeaders()
ObservableList of String to display in the
column headers.ObservableList of String to display in the
column headersvoid spanRow(int count,
int rowIndex,
int colIndex)
count - the span rangerowIndex - the row indexcolIndex - the column indexvoid spanColumn(int count,
int rowIndex,
int colIndex)
count - the span rangerowIndex - the row indexcolIndex - the column indexvoid setRows(java.util.Collection<javafx.collections.ObservableList<SpreadsheetCell>> rows)
Grid is actually given to a
SpreadsheetView. If this method is called after, you should give
the Grid again to the SpreadsheetView by using SpreadsheetView.setGrid(org.controlsfx.control.spreadsheet.Grid).rows - the rows to set for this Gridboolean isDisplaySelection()
true if the selection (black rectangle) is displayed on
the Grid. Cells may override this property with setCellDisplaySelection(int, int, boolean).true if the selection (black rectangle) is displayed on
the Gridvoid setDisplaySelection(boolean value)
Grid. Cells may override this property with setCellDisplaySelection(int, int, boolean).value - true if the selection should be displayedjavafx.beans.property.BooleanProperty displaySelectionProperty()
Grid.isDisplaySelection(),
setDisplaySelection(boolean)void setCellDisplaySelection(int row,
int column,
boolean displaySelection)
isDisplaySelection()
so that no matter what is defined on the grid, the given cell will always
have its selection set to the displaySelection parameter.row - the row indexcolumn - the column indexdisplaySelection - true is the selection should always be
displayed on this cellboolean isCellDisplaySelection(int row,
int column)
isDisplaySelection() is returned.row - the row indexcolumn - the column indextrue if the given cell will display a selection rectangle<E extends GridChange> void addEventHandler(javafx.event.EventType<E> eventType, javafx.event.EventHandler<E> eventHandler)
SpreadsheetCell's value
will change.E - eventType - the type of the events to receive by the handlereventHandler - the handler to registerjava.lang.NullPointerException - if the event type or handler is null<E extends GridChange> void removeEventHandler(javafx.event.EventType<E> eventType, javafx.event.EventHandler<E> eventHandler)
E - eventType - the event type from which to unregistereventHandler - the handler to unregisterjava.lang.NullPointerException - if the event type or handler is null