Class SpreadsheetView

java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.control.Control
org.controlsfx.control.spreadsheet.SpreadsheetView
All Implemented Interfaces:
javafx.css.Styleable, javafx.event.EventTarget, javafx.scene.control.Skinnable

public class SpreadsheetView extends javafx.scene.control.Control
The SpreadsheetView is a control similar to the JavaFX TableView control but with different functionalities and use cases. The aim is to have a powerful grid where data can be written and retrieved.

Features

  • Cells can span in row and in column.
  • Rows can be frozen to the top of the SpreadsheetView so that they are always visible on screen.
  • Columns can be frozen to the left of the SpreadsheetView so that they are always visible on screen.
  • A row header can be switched on in order to display the row number.
  • Rows can be resized just like columns with click & drag.
  • Both row and column header can be visible or invisible.
  • Selection of several cells can be made with a click and drag.
  • A copy/paste context menu is accessible with a right-click. The usual shortcuts are also working.
  • Picker can be placed above column header or to the side of the row header.
  • Rows and columns can be hidden (like Excel grouping).
  • Zoom in and out in order for the SpreadsheetView to fit on a monitor.
  • Rows can be sorted using a Comparator.

Freezing Rows and Columns


You can freeze some rows and some columns by right-clicking on their header. A context menu will appear if it's possible to freeze them. When frozen, the label header will then be in italic and the background will turn to dark grey.
You have also the possibility to freeze them manually by adding and removing items from getFixedRows() and getFixedColumns(). But you are strongly advised to check if it's possible to do so with SpreadsheetColumn.isColumnFixable() for the frozen columns and with isRowFixable(int) for the frozen rows.
A set of rows cannot be frozen if any cell inside these rows has a row span superior to the number of frozen rows. Likewise, a set of columns cannot be frozen if any cell inside these columns has a column span superior to the number of frozen columns.

If you want to freeze several rows or columns together, and they have a span inside, you can call areRowsFixable(java.util.List) or areSpreadsheetColumnsFixable(java.util.List) to verify if you can freeze them. Be sure to add them all in once otherwise the system will detect that a span is going out of bounds and will throw an exception. Calling those methods prior every move will ensure that no exception will be thrown.

You have also the possibility to deactivate these possibilities. For example, you force some row/column to be frozen and then the user cannot change the settings.

Headers


You can also access and toggle header's visibility by using the methods provided like setShowRowHeader(boolean) or setShowColumnHeader(boolean).
Users can double-click on a column header will resize the column to the best size in order to fully see each cell in it. Same rule apply for row header. Also note that double-clicking on the little space between two row or two columns (when resizable) will also work just like Excel.

Pickers


You can show some little images next to the headers. They will appear on the left of the VerticalHeader and on top on the HorizontalHeader. They are called "picker" because they were used originally for picking a row or a column to insert in the SpreadsheetView.
But you can do anything you want with it. Simply put a row or a column index in getRowPickers() and getColumnPickers() along with an instance of Picker. You can override the Picker.onClick() method in order to react when the user click on the picker.
The pickers will appear on the top of the column's header and on the left of the row's header.
For example, here is a picker displayed for a row that allow to group rows like Excel:
A Picker that can hide some rows.

Once we clicked on the picker (minus sign), the rows are hidden.
A Picker that can sho some rows.

Here is the code related to the images :
 Picker picker = new Picker() {
          @Override
          public void onClick() {
          //If my details are hidden
              if (getHiddenRows().get(3)) {
                  showRow(3);
                  showRow(4);
                  showRow(5);
                  showRow(6);
              } else {
                  hideRow(3);
                  hideRow(4);
                  hideRow(5);
                  hideRow(6);
              }
          }
 };
 getRowPickers().put(2, picker);

 

Copy pasting

You can copy any cell you want and paste it elsewhere. Be aware that only the value inside will be pasted, not the style nor the type. Thus the value you're trying to paste must be compatible with the SpreadsheetCellType of the receiving cell. Pasting a Double into a String will work but the reverse operation will not.
See SpreadsheetCellType Value Verification documentation for more information.
A unique cell or a selection can be copied and pasted.

Hiding rows and columns

Rows and columns can be hidden if you need to. Simply call showRow(int) or hideRow(int) in order to toggle the visibility of a row. Same for the column.
Note that the span of the cell (in row or column) will automatically adapt based on the visible rows or columns. You have nothing to do.
Because toggling visibility have an impact on the Grid, if you have a lot of rows/columns to show or hide, you may consider setting them all directly by using setHiddenRows(java.util.BitSet). The BitSet represent all your rows/columns and the bit associated to it represent its visibility.

Zoom

The SpreadsheetView offers the possibility to zoom in or out. This is useful when you have a second monitor and you want your whole grid to fit in. Or when you want to draw the attention on a particular portion of the grid.
You can modify the zoom factor by playing with setZoomFactor(java.lang.Double). We recommend using value between 2 and 0.1.
Also note that the SpreadsheetView is configured to react when CTRL + and CTRL - are triggered by, respectively, zooming in and zooming out by 10%. Also CTRL 0 will bring the zoom back to default (1).

Code Samples

Just like the TableView, you instantiate the underlying model, a Grid. You will create some rows filled with SpreadsheetCell.

 int rowCount = 15;
     int columnCount = 10;
     GridBase grid = new GridBase(rowCount, columnCount);
     
     ObservableList<ObservableList<SpreadsheetCell>> rows = FXCollections.observableArrayList();
     for (int row = 0; row < grid.getRowCount(); ++row) {
         final ObservableList<SpreadsheetCell> list = FXCollections.observableArrayList();
         for (int column = 0; column < grid.getColumnCount(); ++column) {
             list.add(SpreadsheetCellType.STRING.createCell(row, column, 1, 1,"value"));
         }
         rows.add(list);
     }
     grid.setRows(rows);

     SpreadsheetView spv = new SpreadsheetView(grid);
     
 
At that moment you can span some of the cells with the convenient method provided by the grid. Then you just need to instantiate the SpreadsheetView.

Visual:

Screenshot of SpreadsheetView
See Also:
  • Property Summary

    Properties
    Type
    Property
    Description
    javafx.beans.property.ObjectProperty<Comparator<? super javafx.collections.ObservableList<SpreadsheetCell>>>
    Return an ObjectProperty wrapping the comparator used in the SpreadsheetView.
    final javafx.beans.property.BooleanProperty
    Specifies whether this SpreadsheetView is editable - only if the SpreadsheetView, and the SpreadsheetCell within it are both editable will a SpreadsheetCell be able to go into its editing state.
    javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.control.TablePosition<javafx.collections.ObservableList<SpreadsheetCell>,?>>
    Represents the current cell being edited, or null if there is no cell being edited.
    javafx.beans.property.ReadOnlyBooleanProperty
    Return the Boolean property associated with the allowance of freezing or unfreezing some columns.
    javafx.beans.property.ReadOnlyBooleanProperty
    Return the Boolean property associated with the allowance of freezing or unfreezing some rows.
    final javafx.beans.property.ReadOnlyObjectProperty<Grid>
    Return a ReadOnlyObjectProperty containing the current Grid used in the SpreadsheetView.
    final javafx.beans.property.ObjectProperty<BitSet>
    Return the Objectproperty wrapping the hidden columns.
    final javafx.beans.property.ObjectProperty<BitSet>
    Return the Objectproperty wrapping the hidden rows..
    final javafx.beans.property.ObjectProperty<javafx.scene.Node>
    This Node is shown to the user when the SpreadsheetView has no content to show.
    final javafx.beans.property.DoubleProperty
    This DoubleProperty represents the width of the rowHeader.
    final javafx.beans.property.BooleanProperty
    BooleanProperty associated with the column Header.
    final javafx.beans.property.BooleanProperty
    BooleanProperty associated with the row Header.
    final javafx.beans.property.DoubleProperty
    Return the zoomFactor used for the SpreadsheetView.

    Properties inherited from class javafx.scene.control.Control

    contextMenu, skin, tooltip

    Properties inherited from class javafx.scene.layout.Region

    background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width

    Properties inherited from class javafx.scene.Parent

    needsLayout

    Properties inherited from class javafx.scene.Node

    accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    This event is thrown on the SpreadsheetView when the user resize a column with its mouse.
    static class 
    This event is thrown on the SpreadsheetView when the user resize a row with its mouse.
    static enum 
    The SpanType describes in which state each cell can be.
  • Field Summary

    Fields inherited from class javafx.scene.layout.Region

    USE_COMPUTED_SIZE, USE_PREF_SIZE

    Fields inherited from class javafx.scene.Node

    BASELINE_OFFSET_SAME_AS_HEIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    This constructor will generate sample Grid with 100 rows and 15 columns.
    Creates a SpreadsheetView control with the Grid specified.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    areColumnsFixable(List<? extends Integer> list)
    This method is the same as areSpreadsheetColumnsFixable(java.util.List) but is using a List of SpreadsheetColumn indexes.
    boolean
    areRowsFixable(List<? extends Integer> list)
    Indicates whether a List of rows can be frozen or not.
    boolean
    Indicates whether a List of SpreadsheetColumn can be fixed or not.
    javafx.beans.property.ObjectProperty<Comparator<? super javafx.collections.ObservableList<SpreadsheetCell>>>
    Return an ObjectProperty wrapping the comparator used in the SpreadsheetView.
    void
    Put the current selection into the ClipBoard.
    void
    Decrement the level of zoom by 0.10.
    void
    This method is called when pressing the "delete" key on the SpreadsheetView.
    void
    edit(int row, SpreadsheetColumn column)
    Causes the cell at the given row/column view indexes to switch into its editing state, if it is not already in it, and assuming that the SpreadsheetView and column are also editable.
    final javafx.beans.property.BooleanProperty
    Specifies whether this SpreadsheetView is editable - only if the SpreadsheetView, and the SpreadsheetCell within it are both editable will a SpreadsheetCell be able to go into its editing state.
    javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.control.TablePosition<javafx.collections.ObservableList<SpreadsheetCell>,?>>
    Represents the current cell being edited, or null if there is no cell being edited.
    javafx.beans.property.ReadOnlyBooleanProperty
    Return the Boolean property associated with the allowance of freezing or unfreezing some columns.
    javafx.beans.property.ReadOnlyBooleanProperty
    Return the Boolean property associated with the allowance of freezing or unfreezing some rows.
    Returns the CellGraphicFactory if set that provide implementation for browser in SpreadsheetCell.
    javafx.collections.ObservableMap<Integer,Picker>
     
    final javafx.collections.ObservableList<SpreadsheetColumn>
    Return an ObservableList of the SpreadsheetColumn used.
    int
    Return the current column span of a Cell considering all hidden columns.
    Return the comparator used in the SortedList for the SpreadsheetView.
    javafx.scene.control.TablePosition<javafx.collections.ObservableList<SpreadsheetCell>,?>
    Return a TablePosition of cell being currently edited.
    Return the editor associated with the CellType.
    int
    Return the row where the Filter will be shown.
    int
    getFilteredRow(int modelRow)
    Given a row index base on the Grid, return the index used in the SpreadsheetView.
    int
    Given an index on the SpreadsheetView, it will return the model row by simply considering the hidden rows (and not the actual sort if any).
    javafx.collections.ObservableList<SpreadsheetColumn>
    You can freeze or unfreeze a column by modifying this list.
    javafx.collections.ObservableList<Integer>
    You can freeze or unfreeze a row by modifying this list.
    final Grid
    Return the model Grid used by the SpreadsheetView
    double
    Return the value of the horizontal scrollbar.
    Return a BitSet of the Hidden columns, where true means the column is hidden.
    Return a BitSet of the Hidden rows, where true means the row is hidden.
    javafx.collections.ObservableList<javafx.collections.ObservableList<SpreadsheetCell>>
    Return the current list of rows set in the SpreadsheetView as they appear on the screen.
    int
    getModelColumn(int viewColumn)
    Given a column index based on the visible column list, for example when dealing with TablePosition.getColumn().
    int
    getModelRow(int viewRow)
    Given an index on the SpreadsheetView, return a Grid index it is related to.
    final javafx.scene.Node
    Gets the value of the placeholder property.
    int
    final double
     
    double
    getRowHeight(int row)
     
    javafx.collections.ObservableMap<Integer,Picker>
     
    int
    getRowSpan(SpreadsheetCell cell, int index)
    Return the current row span for the given cell at the given position in the Table.
    int
    Return the row span for the given cell without considering the actual sort.
    Return the selectionModel used by the SpreadsheetView.
    getSpanType(int rowIndex, int modelColumn)
    Return the SpreadsheetView.SpanType of a cell.
    javafx.scene.control.ContextMenu
    Create a menu on rightClick with two options: Copy/Paste This can be overridden by developers for custom behavior.
     
    double
    Return the value of the vertical scrollbar.
    int
    getViewColumn(int modelColumn)
    Given a column index based on the getColumns() list, return an index based on the visible columns in the SpreadsheetView.
    int
    getViewRow(int modelRow)
    Given the row of a SpreadsheetCell, returns the actual row as displayed in the SpreadsheetView.
    final Double
    Return the zoomFactor used for the SpreadsheetView.
    final javafx.beans.property.ReadOnlyObjectProperty<Grid>
    Return a ReadOnlyObjectProperty containing the current Grid used in the SpreadsheetView.
    final javafx.beans.property.ObjectProperty<BitSet>
    Return the Objectproperty wrapping the hidden columns.
    final javafx.beans.property.ObjectProperty<BitSet>
    Return the Objectproperty wrapping the hidden rows..
    void
    Hide the specified SpreadsheetColumn.
    void
    hideRow(int row)
    Hide the specified row.
    void
    Increment the level of zoom by 0.10.
    boolean
    isColumnFixable(int columnIndex)
    Indicate whether this column can be frozen or not.
    boolean
    isColumnHidden(int column)
    Return true if this column index (regarding to getColumns() is hidden.
    final boolean
    Gets the value of the property editable.
    boolean
    Return whether change to frozen columns are allowed.
    boolean
    Return whether change to frozen rows are allowed.
    boolean
    isRowFixable(int row)
    Indicate whether a row can be frozen or not.
    boolean
    isRowHidden(int row)
    Return true is this row is hidden.
    final boolean
    Return if the Column Header is showing.
    final boolean
    Return if the row Header is showing.
    protected void
    * Public Methods * *
    void
    Try to paste the clipBoard to the specified position.
    final javafx.beans.property.ObjectProperty<javafx.scene.Node>
    This Node is shown to the user when the SpreadsheetView has no content to show.
    void
    This method will wipe all changes made to the row's height and set all row's height back to their default height defined in the model Grid.
    void
    This method will compute the best height for each line.
    void
    This method will first apply resizeRowsToFitContent() and then take the highest height and apply it to every row.
    final javafx.beans.property.DoubleProperty
    This DoubleProperty represents the width of the rowHeader.
    void
    Scrolls the SpreadsheetView so that the given SpreadsheetColumn is visible.
    void
    scrollToColumnIndex(int modelColumn)
    Scrolls the SpreadsheetView so that the given column index is visible.
    void
    scrollToRow(int row)
    Scrolls the SpreadsheetView so that the given row is visible.
    void
    Sets the CellGraphicFactory that will provide an implementation for cell that have SpreadsheetCell.isCellGraphic() set to true.
    void
    setComparator(Comparator<javafx.collections.ObservableList<SpreadsheetCell>> comparator)
    Sets a new Comparator for the SpreadsheetView in order to sort the rows.
    final void
    setEditable(boolean b)
    Sets the value of the property editable.
    void
    Set the row (based of Grid indexes) where the Filter will appear.
    void
    If set to true, user will be allowed to freeze and unfreeze the columns.
    void
    If set to true, user will be allowed to freeze and unfreeze the rows.
    final void
    setGrid(Grid grid)
    Set a new Grid for the SpreadsheetView.
    void
    setHBarValue(double value)
    Same method as ScrollBar.setValue(double) on the verticalBar.
    void
    setHiddenColumns(BitSet hiddenColumns)
    Give a complete new BitSet of the hidden columns.
    void
    setHiddenRows(BitSet hiddenRows)
    Give a complete new BitSet of the hidden rows.
    final void
    setPlaceholder(javafx.scene.Node placeholder)
    Sets the value of the placeholder property
    final void
    setRowHeaderWidth(double value)
    Specify a new width for the row header.
    final void
    Activate and deactivate the Column Header
    final void
    setShowRowHeader(boolean b)
    Activate and deactivate the Row Header.
    void
    setVBarValue(double value)
    Same method as ScrollBar.setValue(double) on the verticalBar.
    final void
    setZoomFactor(Double zoomFactor)
    Set a new zoomFactor for the SpreadsheetView.
    void
    Show the specified SpreadsheetColumn.
    final javafx.beans.property.BooleanProperty
    BooleanProperty associated with the column Header.
    void
    showRow(int row)
    Show the specified row.
    final javafx.beans.property.BooleanProperty
    BooleanProperty associated with the row Header.
    final javafx.beans.property.DoubleProperty
    Return the zoomFactor used for the SpreadsheetView.

    Methods inherited from class javafx.scene.control.Control

    computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, createDefaultSkin, executeAccessibleAction, getBaselineOffset, getClassCssMetaData, getContextMenu, getControlCssMetaData, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinProperty, tooltipProperty

    Methods inherited from class javafx.scene.layout.Region

    backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty

    Methods inherited from class javafx.scene.Parent

    getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBounds

    Methods inherited from class javafx.scene.Node

    accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface javafx.css.Styleable

    getStyleableNode
  • Property Details

  • Constructor Details

    • SpreadsheetView

      public SpreadsheetView()
      This constructor will generate sample Grid with 100 rows and 15 columns. All cells are typed as String (see SpreadsheetCellType.STRING).
    • SpreadsheetView

      public SpreadsheetView(Grid grid)
      Creates a SpreadsheetView control with the Grid specified.
      Parameters:
      grid - The Grid that contains the items to be rendered
  • Method Details

    • getUserAgentStylesheet

      public String getUserAgentStylesheet()
      Overrides:
      getUserAgentStylesheet in class javafx.scene.layout.Region
    • setCellGraphicFactory

      public void setCellGraphicFactory(CellGraphicFactory cellGraphicFactory)
      Sets the CellGraphicFactory that will provide an implementation for cell that have SpreadsheetCell.isCellGraphic() set to true.
      Parameters:
      cellGraphicFactory - the CellGraphicFactory
    • getCellGraphicFactory

      public CellGraphicFactory getCellGraphicFactory()
      Returns the CellGraphicFactory if set that provide implementation for browser in SpreadsheetCell.
      Returns:
      the CellGraphicFactory
    • layoutChildren

      protected void layoutChildren()
      * Public Methods * *
      Overrides:
      layoutChildren in class javafx.scene.control.Control
    • isRowHidden

      public boolean isRowHidden(int row)
      Return true is this row is hidden.
      Parameters:
      row -
      Returns:
      true is this row is hidden.
    • getHiddenRows

      public BitSet getHiddenRows()
      Return a BitSet of the Hidden rows, where true means the row is hidden.
      Returns:
      a BitSet of the Hidden rows, where true means the row is hidden.
    • hiddenRowsProperty

      public final javafx.beans.property.ObjectProperty<BitSet> hiddenRowsProperty()
      Return the Objectproperty wrapping the hidden rows..
      Returns:
      the Objectproperty wrapping the hidden rows..
      See Also:
    • setHiddenRows

      public void setHiddenRows(BitSet hiddenRows)
      Give a complete new BitSet of the hidden rows. The BitSet MUST have the size of Grid.getRowCount().
      Parameters:
      hiddenRows -
    • setHiddenColumns

      public void setHiddenColumns(BitSet hiddenColumns)
      Give a complete new BitSet of the hidden columns. The BitSet MUST have the size of () .
      Parameters:
      hiddenColumns -
    • isColumnHidden

      public boolean isColumnHidden(int column)
      Return true if this column index (regarding to getColumns() is hidden.
      Parameters:
      column -
      Returns:
      true if this column index (regarding to getColumns() is hidden.
    • getHiddenColumns

      public BitSet getHiddenColumns()
      Return a BitSet of the Hidden columns, where true means the column is hidden.
      Returns:
      a BitSet of the Hidden columns, where true means the column is hidden.
    • hiddenColumnsProperty

      public final javafx.beans.property.ObjectProperty<BitSet> hiddenColumnsProperty()
      Return the Objectproperty wrapping the hidden columns.
      Returns:
      the Objectproperty wrapping the hidden columns.
      See Also:
    • getFilteredRow

      public int getFilteredRow()
      Return the row where the Filter will be shown. The row is based on the Grid indexes. Return -1 if no row is set for the filters.
      Returns:
      the row where the Filter will be shown.
    • setFilteredRow

      public void setFilteredRow(Integer row)
      Set the row (based of Grid indexes) where the Filter will appear.
      Parameters:
      row -
    • hideRow

      public void hideRow(int row)
      Hide the specified row.
      Parameters:
      row -
    • hideColumn

      public void hideColumn(SpreadsheetColumn column)
      Hide the specified SpreadsheetColumn.
      Parameters:
      column -
    • showRow

      public void showRow(int row)
      Show the specified row.
      Parameters:
      row -
    • showColumn

      public void showColumn(SpreadsheetColumn column)
      Show the specified SpreadsheetColumn.
      Parameters:
      column -
    • getFilteredRow

      public int getFilteredRow(int modelRow)
      Given a row index base on the Grid, return the index used in the SpreadsheetView. Beware ,if the row is hidden, the returned index is not relevant because no row is assigned to it.
      Parameters:
      modelRow -
      Returns:
      the index used in the SpreadsheetView.
    • getViewColumn

      public int getViewColumn(int modelColumn)
      Given a column index based on the getColumns() list, return an index based on the visible columns in the SpreadsheetView.
      Parameters:
      modelColumn -
      Returns:
      an index based on the visible columns in the SpreadsheetView.
    • getModelColumn

      public int getModelColumn(int viewColumn)
      Given a column index based on the visible column list, for example when dealing with TablePosition.getColumn(). It returns an index based on the getColumns() list of the SpreadsheetView.
      Parameters:
      viewColumn -
      Returns:
      an index based on the getColumns() list of the SpreadsheetView.
    • getViewRow

      public int getViewRow(int modelRow)
      Given the row of a SpreadsheetCell, returns the actual row as displayed in the SpreadsheetView. Beware as it can be a time-consuming operation. Also, calling this method on a row that it hidden will return incoherent information.
      Parameters:
      modelRow - the row retrieved in SpreadsheetCell.getRow()
      Returns:
      the ViewRow if possible, -1 or another row if the row is hidden.
    • getModelRow

      public int getModelRow(int viewRow)
      Given an index on the SpreadsheetView, return a Grid index it is related to.
      Parameters:
      viewRow - a row index based on the SpreadsheetView
      Returns:
      a Grid index it is related to.
    • getFilteredSourceIndex

      public int getFilteredSourceIndex(int viewRow)
      Given an index on the SpreadsheetView, it will return the model row by simply considering the hidden rows (and not the actual sort if any). If you hide the row 2, it means the row 2 in the SpreadsheetView will actually display the row 3 in the model Grid. Thus calling this method with the number 2 will give you the number 3.
      Parameters:
      viewRow -
      Returns:
      the model row
    • getRowSpan

      public int getRowSpan(SpreadsheetCell cell, int index)
      Return the current row span for the given cell at the given position in the Table. If a sort is applied to the SpreadsheetView, some spanned cells may be splitted thus explaining why this method can give a different value than SpreadsheetCell.getRowSpan().
      Parameters:
      cell - the considered SpreadsheetCell
      index - the current row position of this cell
      Returns:
      the current row span for the given cell
    • getReverseRowSpan

      public int getReverseRowSpan(SpreadsheetCell cell, int index)
      Return the exact opposite of getRowSpan(org.controlsfx.control.spreadsheet.SpreadsheetCell, int). If a cell is spanned on rows, and the index given is the last one of the spanned zone, it's rowSpan will be 1 and its reverse rowspan will be SpreadsheetCell.getRowSpan().
      Parameters:
      cell - the considered SpreadsheetCell
      index - the current row position of this cell
      Returns:
      the current reverse row span for the given cell
    • getRowSpanFilter

      public int getRowSpanFilter(SpreadsheetCell cell)
      Return the row span for the given cell without considering the actual sort. Only the hidden rows are considered.
      Parameters:
      cell -
      Returns:
      the row span for the given cell.
    • getItems

      public javafx.collections.ObservableList<javafx.collections.ObservableList<SpreadsheetCell>> getItems()
      Return the current list of rows set in the SpreadsheetView as they appear on the screen.
      Returns:
      the current list of rows.
    • getColumnSpan

      public int getColumnSpan(SpreadsheetCell cell)
      Return the current column span of a Cell considering all hidden columns.
      Parameters:
      cell -
      Returns:
      the current column span of a Cell.
    • getZoomFactor

      public final Double getZoomFactor()
      Return the zoomFactor used for the SpreadsheetView.
      Returns:
      the zoomFactor used for the SpreadsheetView.
    • setZoomFactor

      public final void setZoomFactor(Double zoomFactor)
      Set a new zoomFactor for the SpreadsheetView. Advice is not to go beyond 2 and below 0.1.
      Parameters:
      zoomFactor -
    • zoomFactorProperty

      public final javafx.beans.property.DoubleProperty zoomFactorProperty()
      Return the zoomFactor used for the SpreadsheetView.
      Returns:
      the zoomFactor used for the SpreadsheetView.
      See Also:
    • incrementZoom

      public void incrementZoom()
      Increment the level of zoom by 0.10. The base is 1 so we will try to stay of the intervals.
    • decrementZoom

      public void decrementZoom()
      Decrement the level of zoom by 0.10. It will block at 0.20. The base is 1 so we will try to stay of the intervals.
    • edit

      public void edit(int row, SpreadsheetColumn column)
      Causes the cell at the given row/column view indexes to switch into its editing state, if it is not already in it, and assuming that the SpreadsheetView and column are also editable.

      Note: This method will cancel editing if the given row value is less than zero and the given column is null.

      Parameters:
      row -
      column -
    • getComparator

      public Comparator getComparator()
      Return the comparator used in the SortedList for the SpreadsheetView.
      Returns:
      the comparator used in the SortedList for the SpreadsheetView.
    • comparatorProperty

      public javafx.beans.property.ObjectProperty<Comparator<? super javafx.collections.ObservableList<SpreadsheetCell>>> comparatorProperty()
      Return an ObjectProperty wrapping the comparator used in the SpreadsheetView.
      Returns:
      an ObjectProperty wrapping the comparator used in the SpreadsheetView.
      See Also:
    • setComparator

      public void setComparator(Comparator<javafx.collections.ObservableList<SpreadsheetCell>> comparator)
      Sets a new Comparator for the SpreadsheetView in order to sort the rows.
      Parameters:
      comparator - the comparator that will sort the rows.
    • setGrid

      public final void setGrid(Grid grid)
      Set a new Grid for the SpreadsheetView. This will be called by default by SpreadsheetView(Grid). So this is useful when you want to refresh your SpreadsheetView with a new model. This will keep the state of your SpreadsheetView (position of the bar, number of frozen rows etc).
      Parameters:
      grid - the new Grid
    • getEditingCell

      public javafx.scene.control.TablePosition<javafx.collections.ObservableList<SpreadsheetCell>,?> getEditingCell()
      Return a TablePosition of cell being currently edited.
      Returns:
      a TablePosition of cell being currently edited.
    • editingCellProperty

      public javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.control.TablePosition<javafx.collections.ObservableList<SpreadsheetCell>,?>> editingCellProperty()
      Represents the current cell being edited, or null if there is no cell being edited.
      Returns:
      the current cell being edited, or null if there is no cell being edited.
      See Also:
    • getColumns

      public final javafx.collections.ObservableList<SpreadsheetColumn> getColumns()
      Return an ObservableList of the SpreadsheetColumn used. This list is filled automatically by the SpreadsheetView. Adding and removing columns should be done in the model Grid.
      Returns:
      An ObservableList of the SpreadsheetColumn
    • getGrid

      public final Grid getGrid()
      Return the model Grid used by the SpreadsheetView
      Returns:
      the model Grid used by the SpreadsheetView
    • gridProperty

      public final javafx.beans.property.ReadOnlyObjectProperty<Grid> gridProperty()
      Return a ReadOnlyObjectProperty containing the current Grid used in the SpreadsheetView.
      Returns:
      a ReadOnlyObjectProperty.
      See Also:
    • getFixedRows

      public javafx.collections.ObservableList<Integer> getFixedRows()
      You can freeze or unfreeze a row by modifying this list. Call isRowFixable(int) before trying to freeze a row. See SpreadsheetView description for information.
      Returns:
      an ObservableList of integer representing the frozen rows.
    • isRowFixable

      public boolean isRowFixable(int row)
      Indicate whether a row can be frozen or not. Call that method before adding an item with getFixedRows() . A row cannot be frozen alone if any cell inside the row has a row span superior to one.
      Parameters:
      row -
      Returns:
      true if the row can be frozen.
    • areRowsFixable

      public boolean areRowsFixable(List<? extends Integer> list)
      Indicates whether a List of rows can be frozen or not. A set of rows cannot be frozen if any cell inside these rows has a row span superior to the number of frozen rows.
      Parameters:
      list -
      Returns:
      true if the List of row can be frozen together.
    • isFixingRowsAllowed

      public boolean isFixingRowsAllowed()
      Return whether change to frozen rows are allowed.
      Returns:
      whether change to frozen rows are allowed.
    • setFixingRowsAllowed

      public void setFixingRowsAllowed(boolean b)
      If set to true, user will be allowed to freeze and unfreeze the rows.
      Parameters:
      b -
    • fixingRowsAllowedProperty

      public javafx.beans.property.ReadOnlyBooleanProperty fixingRowsAllowedProperty()
      Return the Boolean property associated with the allowance of freezing or unfreezing some rows.
      Returns:
      the Boolean property associated with the allowance of freezing or unfreezing some rows.
      See Also:
    • getFixedColumns

      public javafx.collections.ObservableList<SpreadsheetColumn> getFixedColumns()
      You can freeze or unfreeze a column by modifying this list. Call SpreadsheetColumn.isColumnFixable() on the column before adding an item.
      Returns:
      an ObservableList of the frozen columns.
    • isColumnFixable

      public boolean isColumnFixable(int columnIndex)
      Indicate whether this column can be frozen or not. If you have a SpreadsheetColumn, call SpreadsheetColumn.isColumnFixable() on it directly. Call that method before adding an item with getFixedColumns() .
      Parameters:
      columnIndex -
      Returns:
      true if the column if freezable
    • areSpreadsheetColumnsFixable

      public boolean areSpreadsheetColumnsFixable(List<? extends SpreadsheetColumn> list)
      Indicates whether a List of SpreadsheetColumn can be fixed or not. A set of columns cannot be frozen if any cell inside these columns has a column span superior to the number of frozen columns.
      Parameters:
      list -
      Returns:
      true if the List of columns can be frozen together.
    • areColumnsFixable

      public boolean areColumnsFixable(List<? extends Integer> list)
      This method is the same as areSpreadsheetColumnsFixable(java.util.List) but is using a List of SpreadsheetColumn indexes. A set of columns cannot be frozen if any cell inside these columns has a column span superior to the number of frozen columns.
      Parameters:
      list -
      Returns:
      true if the List of columns can be frozen together.
    • isFixingColumnsAllowed

      public boolean isFixingColumnsAllowed()
      Return whether change to frozen columns are allowed.
      Returns:
      whether change to frozen columns are allowed.
    • setFixingColumnsAllowed

      public void setFixingColumnsAllowed(boolean b)
      If set to true, user will be allowed to freeze and unfreeze the columns.
      Parameters:
      b -
    • fixingColumnsAllowedProperty

      public javafx.beans.property.ReadOnlyBooleanProperty fixingColumnsAllowedProperty()
      Return the Boolean property associated with the allowance of freezing or unfreezing some columns.
      Returns:
      the Boolean property associated with the allowance of freezing or unfreezing some columns.
      See Also:
    • setShowColumnHeader

      public final void setShowColumnHeader(boolean b)
      Activate and deactivate the Column Header
      Parameters:
      b -
    • isShowColumnHeader

      public final boolean isShowColumnHeader()
      Return if the Column Header is showing.
      Returns:
      a boolean telling whether the column Header is shown
    • showColumnHeaderProperty

      public final javafx.beans.property.BooleanProperty showColumnHeaderProperty()
      BooleanProperty associated with the column Header.
      Returns:
      the BooleanProperty associated with the column Header.
      See Also:
    • setShowRowHeader

      public final void setShowRowHeader(boolean b)
      Activate and deactivate the Row Header.
      Parameters:
      b -
    • isShowRowHeader

      public final boolean isShowRowHeader()
      Return if the row Header is showing.
      Returns:
      a boolean telling if the row Header is being shown
    • showRowHeaderProperty

      public final javafx.beans.property.BooleanProperty showRowHeaderProperty()
      BooleanProperty associated with the row Header.
      Returns:
      the BooleanProperty associated with the row Header.
      See Also:
    • rowHeaderWidthProperty

      public final javafx.beans.property.DoubleProperty rowHeaderWidthProperty()
      This DoubleProperty represents the width of the rowHeader. This is just representing the width of the Labels, not the pickers.
      Returns:
      A DoubleProperty.
    • setRowHeaderWidth

      public final void setRowHeaderWidth(double value)
      Specify a new width for the row header.
      Parameters:
      value -
    • getRowHeaderWidth

      public final double getRowHeaderWidth()
      Returns:
      the current width of the row header.
    • getRowPickers

      public javafx.collections.ObservableMap<Integer,Picker> getRowPickers()
      Returns:
      An ObservableMap with the row index as key and the Picker as a value.
    • getColumnPickers

      public javafx.collections.ObservableMap<Integer,Picker> getColumnPickers()
      Returns:
      An ObservableMap with the column index as key and the Picker as a value.
    • resizeRowsToFitContent

      public void resizeRowsToFitContent()
      This method will compute the best height for each line. That is to say a height where each content of each cell could be fully visible.\n Use this method wisely because it can degrade performance on great grid.
    • resizeRowsToMaximum

      public void resizeRowsToMaximum()
      This method will first apply resizeRowsToFitContent() and then take the highest height and apply it to every row.\n Just as resizeRowsToFitContent(), this method can be degrading your performance on great grid.
    • resizeRowsToDefault

      public void resizeRowsToDefault()
      This method will wipe all changes made to the row's height and set all row's height back to their default height defined in the model Grid.
    • getRowHeight

      public double getRowHeight(int row)
      Parameters:
      row -
      Returns:
      the height of a particular row of the SpreadsheetView.
    • getSelectionModel

      public SpreadsheetViewSelectionModel getSelectionModel()
      Return the selectionModel used by the SpreadsheetView.
      Returns:
      SpreadsheetViewSelectionModel
    • scrollToRow

      public void scrollToRow(int row)
      Scrolls the SpreadsheetView so that the given row is visible. Beware, you must call getViewRow(int) before if you are using SpreadsheetCell.getRow() and the grid is sorted/filtered.
      Parameters:
      row - the row to scroll to
    • setVBarValue

      public void setVBarValue(double value)
      Same method as ScrollBar.setValue(double) on the verticalBar.
      Parameters:
      value -
    • setHBarValue

      public void setHBarValue(double value)
      Same method as ScrollBar.setValue(double) on the verticalBar.
      Parameters:
      value -
    • getVBarValue

      public double getVBarValue()
      Return the value of the vertical scrollbar. See ScrollBar.getValue()
      Returns:
      the value of the vertical scrollbar.
    • getHBarValue

      public double getHBarValue()
      Return the value of the horizontal scrollbar. See ScrollBar.getValue()
      Returns:
      the value of the horizontal scrollbar.
    • scrollToColumn

      public void scrollToColumn(SpreadsheetColumn column)
      Scrolls the SpreadsheetView so that the given SpreadsheetColumn is visible.
      Parameters:
      column -
    • scrollToColumnIndex

      public void scrollToColumnIndex(int modelColumn)
      Scrolls the SpreadsheetView so that the given column index is visible.
      Parameters:
      modelColumn -
    • getEditor

      public final Optional<SpreadsheetCellEditor> getEditor(SpreadsheetCellType<?> cellType)
      Return the editor associated with the CellType. (defined in SpreadsheetCellType.createEditor(SpreadsheetView). FIXME Maybe keep the editor references inside the SpreadsheetCellType
      Parameters:
      cellType -
      Returns:
      the editor associated with the CellType.
    • setEditable

      public final void setEditable(boolean b)
      Sets the value of the property editable.
      Parameters:
      b -
    • isEditable

      public final boolean isEditable()
      Gets the value of the property editable.
      Returns:
      a boolean telling if the SpreadsheetView is editable.
    • editableProperty

      public final javafx.beans.property.BooleanProperty editableProperty()
      Specifies whether this SpreadsheetView is editable - only if the SpreadsheetView, and the SpreadsheetCell within it are both editable will a SpreadsheetCell be able to go into its editing state.
      Returns:
      the BooleanProperty associated with the editableProperty.
      See Also:
    • placeholderProperty

      public final javafx.beans.property.ObjectProperty<javafx.scene.Node> placeholderProperty()
      This Node is shown to the user when the SpreadsheetView has no content to show.
      Returns:
      the placeholder property
      See Also:
    • setPlaceholder

      public final void setPlaceholder(javafx.scene.Node placeholder)
      Sets the value of the placeholder property
      Parameters:
      placeholder - the node to show when the SpreadsheetView has no content to show.
    • getPlaceholder

      public final javafx.scene.Node getPlaceholder()
      Gets the value of the placeholder property.
      Returns:
      the Node used as a placeholder that is shown when the SpreadsheetView has no content to show.
    • copyClipboard

      public void copyClipboard()
      Put the current selection into the ClipBoard. This can be overridden by developers for custom behavior.
    • pasteClipboard

      public void pasteClipboard()
      Try to paste the clipBoard to the specified position. Try to paste the current selection into the Grid. If the two contents are not matchable, then it's not pasted. This can be overridden by developers for custom behavior.
    • getSpreadsheetViewContextMenu

      public javafx.scene.control.ContextMenu getSpreadsheetViewContextMenu()
      Create a menu on rightClick with two options: Copy/Paste This can be overridden by developers for custom behavior.
      Returns:
      the ContextMenu to use.
    • deleteSelectedCells

      public void deleteSelectedCells()
      This method is called when pressing the "delete" key on the SpreadsheetView. This will erase the values of selected cells. This can be overridden by developers for custom behavior.
    • getSpanType

      public SpreadsheetView.SpanType getSpanType(int rowIndex, int modelColumn)
      Return the SpreadsheetView.SpanType of a cell. This is used internally by the SpreadsheetView but some users may find it useful.
      Parameters:
      rowIndex -
      modelColumn -
      Returns:
      The SpreadsheetView.SpanType of a cell