Module MaterialFX

Class MFXPagination

All Implemented Interfaces:
Styleable, EventTarget, Skinnable

public class MFXPagination extends Control
This is the implementation of a smart, material pagination control in JavaFX.

There are three main properties:

- the current page property that specifies the current selected page

- the max page property that specifies the number of pages

- the pages to show property that specifies how many pages can be shown at a time by the control

MFXPagination is highly customizable.

The indexesSupplierProperty() allows you to specify how to build the page indexes. The default algorithm, set by defaultIndexesSupplier(), is a digg-style pagination.

The pageCellFactoryProperty() allows you to specify how to build the pages' button.

The ellipseStringProperty() allows you to specify the string shown on the truncated pages.

The showPopupForTruncatedPagesProperty() allows you to decide whether to show a little popup when clicking ona truncated page, which contains a list of the pages in between, for faster navigation. The popup in created and handled by the default cells, MFXPage.

The orientationProperty() allows you to specify the pagination orientation.

  • Property Details

  • Constructor Details

    • MFXPagination

      public MFXPagination()
    • MFXPagination

      public MFXPagination(int maxPage)
    • MFXPagination

      public MFXPagination(int maxPage, int toShow)
  • Method Details

    • defaultIndexesSupplier

      public void defaultIndexesSupplier()
      Sets the default indexing algorithm.
    • computePagesIndex

      protected List<Integer> computePagesIndex()
      This is the default algorithm used to build the pages.

      This is a digg-style pagination algorithm.

      There are some exception that won't make this work as expected. If the number of pages is lesser than the specified number of pages to show, or the specified number of pages to show is lesser than 5, all the indexes will be shown.
    • computeMiddleIndexes

      protected List<Integer> computeMiddleIndexes(int current, int toShow)
      Helper method to computePagesIndex() to properly compute the page indexes when the current page is in the middle.
    • createDefaultSkin

      protected Skin<?> createDefaultSkin()
      Overrides:
      createDefaultSkin in class Control
    • getUserAgentStylesheet

      public String getUserAgentStylesheet()
      Overrides:
      getUserAgentStylesheet in class Region
    • getCurrentPage

      public int getCurrentPage()
      Gets the value of the property currentPage.
      Property description:
      Specifies the current selected page.
    • currentPageProperty

      public IntegerProperty currentPageProperty()
      Specifies the current selected page.
      See Also:
    • setCurrentPage

      public void setCurrentPage(int currentPage)
      Sets the value of the property currentPage.
      Property description:
      Specifies the current selected page.
    • getMaxPage

      public int getMaxPage()
      Gets the value of the property maxPage.
      Property description:
      Specifies the max number of pages.
    • maxPageProperty

      public IntegerProperty maxPageProperty()
      Specifies the max number of pages.
      See Also:
    • setMaxPage

      public void setMaxPage(int maxPage)
      Sets the value of the property maxPage.
      Property description:
      Specifies the max number of pages.
    • getPagesToShow

      public int getPagesToShow()
      Gets the value of the property pagesToShow.
      Property description:
      Specifies the max number of pages to show at a time.
    • pagesToShowProperty

      public IntegerProperty pagesToShowProperty()
      Specifies the max number of pages to show at a time.
      See Also:
    • setPagesToShow

      public void setPagesToShow(int pagesToShow)
      Sets the value of the property pagesToShow.
      Property description:
      Specifies the max number of pages to show at a time.
    • getIndexesSupplier

      public Supplier<List<Integer>> getIndexesSupplier()
      Gets the value of the property indexesSupplier.
      Property description:
      This supplier specifies the algorithm used to build the pages.
    • indexesSupplierProperty

      public SupplierProperty<List<Integer>> indexesSupplierProperty()
      This supplier specifies the algorithm used to build the pages.
      See Also:
    • setIndexesSupplier

      public void setIndexesSupplier(Supplier<List<Integer>> indexesSupplier)
      Sets the value of the property indexesSupplier.
      Property description:
      This supplier specifies the algorithm used to build the pages.
    • getPageCellFactory

      public Function<Integer,MFXPage> getPageCellFactory()
      Gets the value of the property pageCellFactory.
      Property description:
      This function specifies how to convert an index to a page.
    • pageCellFactoryProperty

      public FunctionProperty<Integer,MFXPage> pageCellFactoryProperty()
      This function specifies how to convert an index to a page.
      See Also:
    • setPageCellFactory

      public void setPageCellFactory(Function<Integer,MFXPage> pageCellFactory)
      Sets the value of the property pageCellFactory.
      Property description:
      This function specifies how to convert an index to a page.
    • getEllipseString

      public String getEllipseString()
      Gets the value of the property ellipseString.
      Property description:
      Specifies the string to show for truncated pages.
    • ellipseStringProperty

      public StringProperty ellipseStringProperty()
      Specifies the string to show for truncated pages.
      See Also:
    • setEllipseString

      public void setEllipseString(String ellipseString)
      Sets the value of the property ellipseString.
      Property description:
      Specifies the string to show for truncated pages.
    • getOrientation

      public Orientation getOrientation()
      Gets the value of the property orientation.
      Property description:
      Specifies the control's orientation.
    • orientationProperty

      public ObjectProperty<Orientation> orientationProperty()
      Specifies the control's orientation.
      See Also:
    • setOrientation

      public void setOrientation(Orientation orientation)
      Sets the value of the property orientation.
      Property description:
      Specifies the control's orientation.
    • isShowPopupForTruncatedPages

      public boolean isShowPopupForTruncatedPages()
      Gets the value of the property showPopupForTruncatedPages.
      Property description:
      Specifies whether truncated pages should show a popup containing the pages in between, on click.
    • showPopupForTruncatedPagesProperty

      public BooleanProperty showPopupForTruncatedPagesProperty()
      Specifies whether truncated pages should show a popup containing the pages in between, on click.
      See Also:
    • setShowPopupForTruncatedPages

      public void setShowPopupForTruncatedPages(boolean showPopupForTruncatedPages)
      Sets the value of the property showPopupForTruncatedPages.
      Property description:
      Specifies whether truncated pages should show a popup containing the pages in between, on click.