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
FieldsModifier and TypeFieldDescriptionDeprecated.Fields inherited from class com.thecsdev.commonmc.api.client.gui.TElement
eInitialized -
Constructor Summary
ConstructorsConstructorDescriptionStatsPageChooser(int pageCount, StatsView.Filters filters, @NotNull net.minecraft.resources.Identifier filterId) -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 aCollectionofSubjectStats.final intReturns the currently selected page value (zero-indexed).protected final voidstatic final @Nullable StatsPageChooserinitPanel(@NotNull com.thecsdev.commonmc.api.client.gui.panel.TPanelElement target, StatsView.Filters filters, int itemsPerPage, int itemsTotal) Initializes aStatsPageChooseron the provided targetTPanelElement.final voidsetPageValue(int page) Sets the currently selected page value (zero-indexed).Methods inherited from class com.thecsdev.commonmc.api.client.gui.misc.TFillColorElement.Flat
postRenderCallback, renderCallbackMethods inherited from class com.thecsdev.commonmc.api.client.gui.misc.TFillColorElement
fillColorProperty, outlineColorPropertyMethods 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, visiblePropertyMethods 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
-
Field Details
-
ePageChanged
Deprecated.An event that is fired whenever the page is changed. TheConsumerparameter provides the new page value (zero-indexed).
-
-
Constructor Details
-
StatsPageChooser
public StatsPageChooser(int pageCount, @NotNull StatsView.Filters filters, @NotNull @NotNull net.minecraft.resources.Identifier filterId) throws NullPointerException, IllegalArgumentException - Parameters:
pageCount- The total number of pages available.filters- TheStatsView.Filterswhere the "current page" value is stored.filterId- The unique ID of the "current page" filter.- Throws:
NullPointerException- If aNotNullargument isnull.IllegalArgumentException- If "page count" is less than1.
-
-
Method Details
-
initCallback
protected final void initCallback()- Overrides:
initCallbackin classcom.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 aStatsPageChooseron the provided targetTPanelElement.- Parameters:
target- The targetTPanelElementwhere theStatsPageChooseris to initialize.filters- TheStatsView.Filterswhere 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, ornullif there are no items to paginate. - Throws:
NullPointerException- If aNotNullargument isnull.IllegalArgumentException- If "items per page" is less than1.
-
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 aCollectionofSubjectStats.- Type Parameters:
SS- The type ofSubjectStatscontained in theCollection.- Parameters:
stats- The fullCollectionof allSubjectStatsto paginate.filters- TheStatsView.Filtersthat holds the current page value.itemsPerPage- The number of items to show per page.- Returns:
- A paginated
CollectionofSubjectStats. - Throws:
NullPointerException- If aNotNullargument isnull.IllegalArgumentException- IfitemsPerPageis less than1.
-