Top Description Fields Constructors Methods
impl.org.controlsfx.spreadsheet

public Class GridViewSkin

extends TableViewSkinBase<ObservableList<SpreadsheetCell>, ObservableList<SpreadsheetCell>, TableView<ObservableList<SpreadsheetCell>>, TableRow<ObservableList<SpreadsheetCell>>, TableColumn<ObservableList<SpreadsheetCell>, ?>>
Class Inheritance
Imports
java.time.LocalDate, java.util.BitSet, .HashMap, .HashSet, .List, .Map, .Set, javafx.beans.InvalidationListener, .Observable, javafx.beans.property.BooleanProperty, .SimpleBooleanProperty, javafx.collections.FXCollections, .ListChangeListener, .ObservableList, .ObservableMap, .ObservableSet, .SetChangeListener, javafx.event.EventHandler, .Event, javafx.geometry.HPos, .VPos, javafx.scene.Node, javafx.scene.control.IndexedCell, .TableCell, .TableColumn, .TableColumnBase, .TableFocusModel, .TableRow, .TableView, .ScrollBar, javafx.scene.input.MouseEvent, javafx.scene.layout.Region, javafx.stage.Screen, javafx.util.Callback, org.controlsfx.control.spreadsheet.Grid, .SpreadsheetCell, .SpreadsheetColumn, .SpreadsheetView, javafx.application.Platform, javafx.scene.control.skin.TableHeaderRow, .TableViewSkinBase, .VirtualFlow

This skin is actually the skin of the SpreadsheetGridView (tableView) contained within the SpreadsheetView. The skin for the SpreadsheetView itself currently resides inside the SpreadsheetView constructor! We need to extends directly from TableViewSkinBase in order to work-around https://javafx-jira.kenai.com/browse/RT-34753 if we want to set a custom TableViewBehavior.

Field Summary

Modifier and TypeField and Description
private GridViewBehavior
private ObservableSet<Integer>
currentlyFixedRow

The currently fixedRow.

private final SetChangeListener<? super Integer>
currentlyFixedRowListener

We listen on the currentlyFixedRow in order to do the modification in the FixedRowHeight.

private static final double
public static final double
DEFAULT_CELL_HEIGHT

Default height of a row.

pack-priv final Map<GridRow, Set<CellView>>
deportedCells

When we add some tableCell to some topRow in order for them to be on top in term of z-order.

private final ListChangeListener<SpreadsheetColumn>
fixedColumnsListener

We listen on the FixedColumns in order to do the modification in the VirtualFlow.

pack-priv double
fixedColumnWidth

This is the current width used by the currently fixed column on the left.

private double
fixedRowHeight

The total height of the currently fixedRows.

private final ListChangeListener<Integer>
fixedRowsListener

We listen on the FixedRows in order to do the modification in the VirtualFlow

private GridCellEditor
gridCellEditor

The editor.

protected final SpreadsheetHandle
pack-priv BitSet
hBarValue

These variable try to optimize the layout of the rows in order not to layout every time every row.

protected HorizontalPicker
pack-priv BooleanProperty
lastRowLayout

When we try to select cells after a setGrid, we end up with the cell selected but no visual confirmation.

pack-priv RectangleSelection
rectangleSelection

This rectangle will be used for drawing a border around the selection.

pack-priv ObservableMap<Integer, Double>
rowHeightMap

When resizing, we save the height here in order to override default row height.

pack-priv BitSet
private InvalidationListener
private final ObservableList<Integer>
selectedColumns

A list of Integer with the current selected Columns.

private final ObservableList<Integer>
selectedRows

A list of Integer with the current selected Rows.

protected SpreadsheetView
private final InvalidationListener
vbarValueListener

When the vertical moves, we update the verticalHeader

protected VerticalHeader

Constructor Summary

AccessConstructor and Description
public
GridViewSkin(final SpreadsheetHandle handle)

CONSTRUCTOR * *

Method Summary

Modifier and TypeMethod and Description
public void
computeFixedRowHeight()

We compute the total height of the fixedRows so that the selection can use it without performance regression.

public final boolean
containsRow(int index)

Indicate whether or not the row at the specified index is currently being displayed.

private TableRow<ObservableList<SpreadsheetCell>>
protected TableHeaderRow
protected VirtualFlow<TableRow<ObservableList<SpreadsheetCell>>>
createVirtualFlow()

Overrides javafx.scene.control.skin.VirtualContainerBase.createVirtualFlow.

Create the virtualized container that handles the layout and scrolling of all the cells.

pack-priv void
public GridViewBehavior
public int
public ObservableList<TableColumn<ObservableList<SpreadsheetCell>, ?>>
protected final ObservableSet<Integer>
public int
getFirstRow(SpreadsheetCell cell, int index)

This return the first index displaying a cell in case of a rowSpan.

public double
private int
pack-priv GridVirtualFlow<?>
public ScrollBar
public HorizontalHeader
public final int
getItemCount()

Implements abstract javafx.scene.control.skin.VirtualContainerBase.getItemCount.

Returns the total number of items in this container, including those that are currently hidden because they are out of view.

public GridRow
getRow(int index)

This return the row at the specified index in the list.

public double
getRowHeight(int row)

Compute the height of a particular row.

public GridRow
getRowIndexed(int index)

This return the GridRow which has the specified index if found.

public ObservableList<Integer>
public ObservableList<Integer>
getSelectedRows()

Contains the index of the sortedList.

public GridCellEditor
public ScrollBar
protected final void
init()

PRIVATE/PROTECTED METHOD * *

private BitSet
initRowToLayoutBitSet()

Return a BitSet of the rows that needs layout all the time.

protected void
layoutChildren(double x, double y, double w, final double h)

Overrides javafx.scene.control.skin.TableViewSkinBase.layoutChildren.

Called during the layout pass of the scenegraph.

protected void
onFocusAboveCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onFocusAboveCell.

Called when the focus is set on the cell above the current focused cell in order to scroll to it to make it visible.

protected void
onFocusBelowCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onFocusBelowCell.

Called when the focus is set on the cell below the current focused cell in order to scroll to it to make it visible.

protected void
onSelectAboveCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onSelectAboveCell.

Called when the selection is set on the the cell above the current focused cell in order to scroll to it to make it visible.

protected void
onSelectBelowCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onSelectBelowCell.

Called when the selection is set on the cell below the current focused cell in order to scroll to it to make it visible.

public void
resize(TableColumnBase<?, ?> tc, int maxRows)

Used in the HorizontalColumnHeader when we need to resize in double click.

public void
resizeColumnToFitContent(TableColumn<ObservableList<SpreadsheetCell>, ?> tc, int maxRows)

We want to have extra space when displaying LocalDate because they will use an editor that display a little icon on the right.

public void
public void
resizeRowsToFitContent()

Will compute for every row the necessary height and fit the line.

public void
public void
resizeRowToFitContent(int modelRow)

Will compute for the row the necessary height and fit the line.

public void
scrollHorizontally()

Overrides javafx.scene.control.skin.TableViewSkinBase.scrollHorizontally.

Scrolls to the column containing the current focused cell.

protected void
public void
setHbarValue(double value)

If the scene is not yet instantiated, we need to wait otherwise the VirtualFlow will not shift the cells properly.

public void
setHbarValue(double value, int count)

private void
Inherited from javafx.scene.control.skin.TableViewSkinBase:
computePrefHeightcomputePrefWidthdisposegetTableHeaderRowonFocusLeftCellonFocusRightCellonMoveToFirstCellonMoveToLastCellonScrollPageDownonScrollPageUponSelectLeftCellonSelectRightCellqueryAccessibleAttributeupdateItemCount

Field Detail

behaviorback to summary
private GridViewBehavior behavior
currentlyFixedRowback to summary
private ObservableSet<Integer> currentlyFixedRow

The currently fixedRow. This handles an Integer's set of rows being fixed. NOT Fixable but truly fixed.

currentlyFixedRowListenerback to summary
private final SetChangeListener<? super Integer> currentlyFixedRowListener

We listen on the currentlyFixedRow in order to do the modification in the FixedRowHeight.

DATE_CELL_MIN_WIDTHback to summary
private static final double DATE_CELL_MIN_WIDTH
DEFAULT_CELL_HEIGHTback to summary
public static final double DEFAULT_CELL_HEIGHT

Default height of a row.

deportedCellsback to summary
pack-priv final Map<GridRow, Set<CellView>> deportedCells

When we add some tableCell to some topRow in order for them to be on top in term of z-order. We may end up with the situation where the row that put the cell is not in the ViewPort anymore. For example when a fixedRow has taken over the real row when scrolling down. Then, the tableCell added is still hanging out in the topRow. That tableCell has no clue that its "creator" has been destroyed or re-used since that tableCell was not technically belonging to its "creator". Therefore, we need to track those cells in order to remove them each time.

fixedColumnsListenerback to summary
private final ListChangeListener<SpreadsheetColumn> fixedColumnsListener

We listen on the FixedColumns in order to do the modification in the VirtualFlow.

fixedColumnWidthback to summary
pack-priv double fixedColumnWidth

This is the current width used by the currently fixed column on the left.

fixedRowHeightback to summary
private double fixedRowHeight

The total height of the currently fixedRows.

fixedRowsListenerback to summary
private final ListChangeListener<Integer> fixedRowsListener

We listen on the FixedRows in order to do the modification in the VirtualFlow

gridCellEditorback to summary
private GridCellEditor gridCellEditor

The editor.

handleback to summary
protected final SpreadsheetHandle handle
hBarValueback to summary
pack-priv BitSet hBarValue

These variable try to optimize the layout of the rows in order not to layout every time every row. So rowToLayout contains the rows that really needs layout(contain span or fixed). And hBarValue is an indicator for the VirtualFlow. When the Hbar is touched, this BitSet is set to false. And when a row is drawing, it flips its value in this BitSet. So that we know when scrolling up or down whether a row has taken into account that the HBar was moved (otherwise, blank area may appear).

horizontalPickersback to summary
protected HorizontalPicker horizontalPickers
lastRowLayoutback to summary
pack-priv BooleanProperty lastRowLayout

When we try to select cells after a setGrid, we end up with the cell selected but no visual confirmation. In order to prevent that, we need to warn the selectionModel when the layout is starting and then the selectionModel will do the appropriate actions in order to force the visual to come.

rectangleSelectionback to summary
pack-priv RectangleSelection rectangleSelection

This rectangle will be used for drawing a border around the selection.

rowHeightMapback to summary
pack-priv ObservableMap<Integer, Double> rowHeightMap

When resizing, we save the height here in order to override default row height. package protected.

rowToLayoutback to summary
pack-priv BitSet rowToLayout
rowToLayoutListenerback to summary
private InvalidationListener rowToLayoutListener
selectedColumnsback to summary
private final ObservableList<Integer> selectedColumns

A list of Integer with the current selected Columns. This is useful for HorizontalHeader and VerticalHeader because they need to highlight when a selection is made.

selectedRowsback to summary
private final ObservableList<Integer> selectedRows

A list of Integer with the current selected Rows. This is useful for HorizontalHeader and VerticalHeader because they need to highlight when a selection is made.

spreadsheetViewback to summary
protected SpreadsheetView spreadsheetView
vbarValueListenerback to summary
private final InvalidationListener vbarValueListener

When the vertical moves, we update the verticalHeader

verticalHeaderback to summary
protected VerticalHeader verticalHeader

Constructor Detail

GridViewSkinback to summary
public GridViewSkin(final SpreadsheetHandle handle)

CONSTRUCTOR * *

Method Detail

computeFixedRowHeightback to summary
public void computeFixedRowHeight()

We compute the total height of the fixedRows so that the selection can use it without performance regression.

containsRowback to summary
public final boolean containsRow(int index)

Indicate whether or not the row at the specified index is currently being displayed.

createCellback to summary
private TableRow<ObservableList<SpreadsheetCell>> createCell()
createTableHeaderRowback to summary
protected TableHeaderRow createTableHeaderRow()

Overrides javafx.scene.control.skin.TableViewSkinBase.createTableHeaderRow.

Doc from javafx.scene.control.skin.TableViewSkinBase.createTableHeaderRow.

Creates a new TableHeaderRow instance. By default this method should not be overridden, but in some circumstances it makes sense (e.g. testing, or when extreme customization is desired).

Annotations
@Override
createVirtualFlowback to summary
protected VirtualFlow<TableRow<ObservableList<SpreadsheetCell>>> createVirtualFlow()

Overrides javafx.scene.control.skin.VirtualContainerBase.createVirtualFlow.

Doc from javafx.scene.control.skin.VirtualContainerBase.createVirtualFlow.

Create the virtualized container that handles the layout and scrolling of all the cells. This enables skin subclasses to provide a custom VirtualFlow implementation. If not overridden, this method instantiates a default VirtualFlow instance.

Annotations
@Override
focusScrollback to summary
pack-priv void focusScroll()
getBehaviorback to summary
public GridViewBehavior getBehavior()
getCellsSizeback to summary
public int getCellsSize()
getColumnsback to summary
public ObservableList<TableColumn<ObservableList<SpreadsheetCell>, ?>> getColumns()
getCurrentlyFixedRowback to summary
protected final ObservableSet<Integer> getCurrentlyFixedRow()
getFirstRowback to summary
public int getFirstRow(SpreadsheetCell cell, int index)

This return the first index displaying a cell in case of a rowSpan. If the returned index is the same as given, it means the current cell is the one showing. Otherwise, it means another cell above will be the one drawn.

getFixedRowHeightback to summary
public double getFixedRowHeight()
getFixedRowSizeback to summary
private int getFixedRowSize()
getFlowback to summary
pack-priv GridVirtualFlow<?> getFlow()
getHBarback to summary
public ScrollBar getHBar()
getHorizontalHeaderback to summary
public HorizontalHeader getHorizontalHeader()
getItemCountback to summary
public final int getItemCount()

Implements abstract javafx.scene.control.skin.VirtualContainerBase.getItemCount.

Doc from javafx.scene.control.skin.VirtualContainerBase.getItemCount.

Returns the total number of items in this container, including those that are currently hidden because they are out of view.

Annotations
@Override
getRowback to summary
public GridRow getRow(int index)

This return the row at the specified index in the list. The index specified HAS NOTHING to do with the index of the row.

See Also
{@link #getRowIndexed(int)} for a getting a row with its real index.
getRowHeightback to summary
public double getRowHeight(int row)

Compute the height of a particular row. If the row is in Grid#AUTOFIT, DEFAULT_CELL_HEIGHT is returned.

getRowIndexedback to summary
public GridRow getRowIndexed(int index)

This return the GridRow which has the specified index if found. Otherwise null is returned.

getSelectedColumnsback to summary
public ObservableList<Integer> getSelectedColumns()
getSelectedRowsback to summary
public ObservableList<Integer> getSelectedRows()

Contains the index of the sortedList.

getSpreadsheetCellEditorImplback to summary
public GridCellEditor getSpreadsheetCellEditorImpl()
getVBarback to summary
public ScrollBar getVBar()
initback to summary
protected final void init()

PRIVATE/PROTECTED METHOD * *

initRowToLayoutBitSetback to summary
private BitSet initRowToLayoutBitSet()

Return a BitSet of the rows that needs layout all the time. This includes any row containing a span, or a fixed row.

layoutChildrenback to summary
protected void layoutChildren(double x, double y, double w, final double h)

Overrides javafx.scene.control.skin.TableViewSkinBase.layoutChildren.

Doc from javafx.scene.control.skin.TableViewSkinBase.layoutChildren.

Called during the layout pass of the scenegraph.

Annotations
@Override
onFocusAboveCellback to summary
protected void onFocusAboveCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onFocusAboveCell.

Doc from javafx.scene.control.skin.TableViewSkinBase.onFocusAboveCell.

Called when the focus is set on the cell above the current focused cell in order to scroll to it to make it visible.

Annotations
@Override
onFocusBelowCellback to summary
protected void onFocusBelowCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onFocusBelowCell.

Doc from javafx.scene.control.skin.TableViewSkinBase.onFocusBelowCell.

Called when the focus is set on the cell below the current focused cell in order to scroll to it to make it visible.

Annotations
@Override
onSelectAboveCellback to summary
protected void onSelectAboveCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onSelectAboveCell.

Doc from javafx.scene.control.skin.TableViewSkinBase.onSelectAboveCell.

Called when the selection is set on the the cell above the current focused cell in order to scroll to it to make it visible.

Annotations
@Override
onSelectBelowCellback to summary
protected void onSelectBelowCell()

Overrides javafx.scene.control.skin.TableViewSkinBase.onSelectBelowCell.

Doc from javafx.scene.control.skin.TableViewSkinBase.onSelectBelowCell.

Called when the selection is set on the cell below the current focused cell in order to scroll to it to make it visible.

Annotations
@Override
resizeback to summary
public void resize(TableColumnBase<?, ?> tc, int maxRows)

Used in the HorizontalColumnHeader when we need to resize in double click.

resizeColumnToFitContentback to summary
public void resizeColumnToFitContent(TableColumn<ObservableList<SpreadsheetCell>, ?> tc, int maxRows)

We want to have extra space when displaying LocalDate because they will use an editor that display a little icon on the right. Thus, that icon is reducing the visibility of the date string.

resizeRowsToDefaultback to summary
public void resizeRowsToDefault()
resizeRowsToFitContentback to summary
public void resizeRowsToFitContent()

Will compute for every row the necessary height and fit the line. This can degrade performance a lot so need to use it wisely. But I don't see other solutions right now.

resizeRowsToMaximumback to summary
public void resizeRowsToMaximum()
resizeRowToFitContentback to summary
public void resizeRowToFitContent(int modelRow)

Will compute for the row the necessary height and fit the line. This can degrade performance a lot so need to use it wisely. But I don't see other solutions right now.

scrollHorizontallyback to summary
public void scrollHorizontally()

Overrides javafx.scene.control.skin.TableViewSkinBase.scrollHorizontally.

Doc from javafx.scene.control.skin.TableViewSkinBase.scrollHorizontally.

Scrolls to the column containing the current focused cell.

Handles the horizontal scrolling when the selection mode is cell-based and the newly selected cell belongs to a column which is not completely visible.

Annotations
@Override
scrollHorizontallyback to summary
protected void scrollHorizontally(TableColumn<ObservableList<SpreadsheetCell>, ?> col)

Overrides javafx.scene.control.skin.TableViewSkinBase.scrollHorizontally.

Doc from javafx.scene.control.skin.TableViewSkinBase.scrollHorizontally.

Programmatically scrolls to the given column. This call will ensure that the column is aligned on the left edge of the TableView and also that the columns don't become detached from the right edge of the table.

Annotations
@Override
setHbarValueback to summary
public void setHbarValue(double value)

If the scene is not yet instantiated, we need to wait otherwise the VirtualFlow will not shift the cells properly.

setHbarValueback to summary
public void setHbarValue(double value, int count)
verticalScrollback to summary
private void verticalScroll()