Class StatsPageChooser

java.lang.Object
com.thecsdev.common.scene.Node<com.thecsdev.commonmc.api.client.gui.TElement>
com.thecsdev.commonmc.api.client.gui.TElement
com.thecsdev.commonmc.api.client.gui.misc.TFillColorElement
com.thecsdev.commonmc.api.client.gui.misc.TFillColorElement.Flat
com.thecsdev.betterstats.client.gui.panel.StatsPageChooser
All Implemented Interfaces:
com.thecsdev.common.scene.INode<com.thecsdev.commonmc.api.client.gui.TElement>, com.thecsdev.common.scene.INodeBounded<com.thecsdev.commonmc.api.client.gui.TElement, com.thecsdev.common.math.Bounds2i>, com.thecsdev.common.scene.INodeRenderable<com.thecsdev.commonmc.api.client.gui.TElement, com.thecsdev.commonmc.api.client.gui.render.TGuiGraphics>, Iterable<com.thecsdev.commonmc.api.client.gui.TElement>, Collection<com.thecsdev.commonmc.api.client.gui.TElement>

@Internal @Environment(CLIENT) public final class StatsPageChooser extends com.thecsdev.commonmc.api.client.gui.misc.TFillColorElement.Flat
A simple page chooser element for paginating statistics that are displayed on StatsViews.
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.thecsdev.commonmc.api.client.gui.misc.TFillColorElement

    com.thecsdev.commonmc.api.client.gui.misc.TFillColorElement.Flat
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final com.thecsdev.common.event.Event<Consumer<Integer>>
    Deprecated.

    Fields inherited from class com.thecsdev.commonmc.api.client.gui.TElement

    eInitialized
  • Constructor Summary

    Constructors
    Constructor
    Description
    StatsPageChooser(int pageCount, StatsView.Filters filters, @NotNull net.minecraft.resources.Identifier filterId)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final <SS extends com.thecsdev.commonmc.api.stats.util.SubjectStats<?>>
    Collection<SS>
    applyFilter(@NotNull Collection<SS> stats, StatsView.Filters filters, int itemsPerPage)
    Applies pagination to a Collection of SubjectStats.
    final int
    Returns the currently selected page value (zero-indexed).
    protected final void
     
    static final @Nullable StatsPageChooser
    initPanel(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement target, StatsView.Filters filters, int itemsPerPage, int itemsTotal)
    Initializes a StatsPageChooser on the provided target TPanelElement.
    final void
    setPageValue(int page)
    Sets the currently selected page value (zero-indexed).

    Methods inherited from class com.thecsdev.commonmc.api.client.gui.misc.TFillColorElement.Flat

    postRenderCallback, renderCallback

    Methods inherited from class com.thecsdev.commonmc.api.client.gui.misc.TFillColorElement

    fillColorProperty, outlineColorProperty

    Methods inherited from class com.thecsdev.commonmc.api.client.gui.TElement

    addRel, boundsProperty, clearAndInit, clipsDescendantsProperty, contextMenuProperty, dragEndCallback, dragStartCallback, findElementAt, focusableProperty, focusGainedCallback, focusLostCallback, forEachVisible, getBaseType, getBounds, getClient, getContentBounds, getCursor, getSelf, getTooltip, hoverableProperty, hoverGainedCallback, hoverLostCallback, inputCallback, invalidateTooltipCache, isFocusable, isFocused, isHoverable, isHovered, isHoveredOrFocused, isVisible, move, moveChildren, moveTo, removeRel, screenProperty, setBounds, setBounds, setBounds, showContextMenu, tickCallback, tooltipProperty, toString, visibleProperty

    Methods inherited from class com.thecsdev.common.scene.Node

    add, addAll, childAddedCallback, childRemovedCallback, clear, contains, containsAll, equals, findChild, findParent, findSibling, forEach, get, getFirst, getLast, getParent, hashCode, indexOf, isEmpty, iterator, parentProperty, remove, remove, remove, removeAll, retainAll, rootProperty, size, toArray, toArray

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface Iterable

    forEach
  • Field Details

    • ePageChanged

      @Deprecated public final com.thecsdev.common.event.Event<Consumer<Integer>> ePageChanged
      Deprecated.
      An event that is fired whenever the page is changed. The Consumer parameter provides the new page value (zero-indexed).
  • Constructor Details

  • Method Details

    • initCallback

      protected final void initCallback()
      Overrides:
      initCallback in class com.thecsdev.commonmc.api.client.gui.TElement
    • getPageValue

      public final int getPageValue()
      Returns the currently selected page value (zero-indexed).
    • setPageValue

      public final void setPageValue(int page)
      Sets the currently selected page value (zero-indexed).
      Parameters:
      page - The page to set (zero-indexed).
    • initPanel

      @Nullable public static final @Nullable StatsPageChooser initPanel(@NotNull @NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement target, @NotNull StatsView.Filters filters, int itemsPerPage, int itemsTotal) throws NullPointerException, IllegalArgumentException
      Initializes a StatsPageChooser on the provided target TPanelElement.
      Parameters:
      target - The target TPanelElement where the StatsPageChooser is to initialize.
      filters - The StatsView.Filters where the "current page" value is stored.
      itemsPerPage - The number of items to show per page.
      itemsTotal - The total number of items to paginate.
      Returns:
      The initialized StatsPageChooser, or null if there are no items to paginate.
      Throws:
      NullPointerException - If a NotNull argument is null.
      IllegalArgumentException - If "items per page" is less than 1.
    • applyFilter

      @CallerSensitive public static final <SS extends com.thecsdev.commonmc.api.stats.util.SubjectStats<?>> Collection<SS> applyFilter(@NotNull @NotNull Collection<SS> stats, @NotNull StatsView.Filters filters, int itemsPerPage) throws NullPointerException, IllegalArgumentException
      Applies pagination to a Collection of SubjectStats.
      Type Parameters:
      SS - The type of SubjectStats contained in the Collection.
      Parameters:
      stats - The full Collection of all SubjectStats to paginate.
      filters - The StatsView.Filters that holds the current page value.
      itemsPerPage - The number of items to show per page.
      Returns:
      A paginated Collection of SubjectStats.
      Throws:
      NullPointerException - If a NotNull argument is null.
      IllegalArgumentException - If itemsPerPage is less than 1.