Skip to content

BaseScrollbarNode

abstract class BaseScrollbarNode
Extends: Node
Known subtypes: ScrollbarNode
Package: dev.joid.lib.ui.node.impl.control.scrollbar · Module: core · Source: BaseScrollbarNode.java

The behavior of a scrollbar without its look: it reads the scroll of the node it serves and scrolls it when the user drags along the bar.

Give a scrollbar to a node with Node.scrollbar, never with attach: the node becomes its parent and the bar serves it. The bar is horizontal when it is wider than high, and vertical otherwise. A left press on the thumb grabs it where it was pressed; a press elsewhere on the bar centers the thumb on the pointer; a drag then scrolls the node. Use ScrollbarNode for a look made of a track and a thumb.

ReturnsSignatureSummary
BaseScrollbarNode(double x, double y, double width, double height) protectedCreates the bar at x, y with a width and a height in design pixels, relative to the node it serves, from the constructor of a skin.

PropertyTypeDefaultSummary
scrollNodeNodenullThe node that the bar scrolls; Node.scrollbar sets it.
minThumb signaldouble0DThe smallest length of the thumb, in design pixels, so that a long content keeps a thumb large enough to grab.
Inherited from Node (24)

x · y · width · height · position · anchor · anchorX · anchorY · aspectRatio · zindex · zlevel · skeleton · visible · enabled · interactive · cursor · hoverDuration · hoverEquation · hover · overflow · scrollSpeed · scrollbar · label · draggable

ReturnsSignatureSummary
booleanisHorizontal()If true, the bar is wider than high: it then scrolls the node horizontally.
booleanisOverflowing()If true, the content of the node goes beyond it on the axis of the bar.
doublegetRatio()Returns the part of the content that the node shows on the axis of the bar, from 0D to 1D; 1D while the content fits.
doublegetProgress()Returns how far the node scrolled on the axis of the bar, from 0D at the start to 1D at the end; during a drag, the offset that the node glides to, so the thumb stays in place when a beforeScroll listener refuses the scroll.
doublegetThumbLength()Returns the length of the thumb, in design pixels: the length of the bar times getRatio(), at least minThumb and at most the bar.
booleanisDragging()If true, the user drags the bar.
ReturnsSignatureSummary
voiddrawSkeleton(double mouseX, double mouseY) hookDraws the bar as usual while its content waits, instead of a skeleton.
voidmousePressed(NodeMouseEvent<?> event) hookOn a left press over the bar that no one consumed, starts the drag, scrolls the node to the pointer and consumes the press.
voidmouseReleased(NodeMouseEvent<?> event) hookEnds the drag on the release of the left button.
voidmouseDragged(NodeMouseEvent<?> event) hookScrolls the node so that the thumb follows the pointer during the drag.
voiddetach() hookEnds a drag in progress when the bar leaves the tree.
Inherited from Node (127)

load · render · renderHover · updateScroll · updateScrollX · updateScrollY · append · attach · body · clearChildren · getChild · getChildren · getNodeListAt · getParent · isAttached · getAbsoluteX · getAbsoluteY · getAbsoluteDefaultX · getAbsoluteDefaultY · toDrawX · toDrawY · w · h · dw · dh · mw · mh · aw · ah · ax · ay · getDefaultWidth · getDefaultHeight · removeHover · clearHover · refreshHover · getResolvedCursor · hoverValue · getHoverAnimator · isHovered · handleMousePressed · handleMouseReleased · handleMouseDragged · handleMouseScroll · handleCharTyped · handleKeyPressed · handleKeyReleased · getLastClickTime · getLastClickButton · getLastKey · getLastKeyTime · scrollX · scrollY · scrollTo · beforeScroll · hasOverflowX · hasOverflowY · getOverflowArea · getScrollX · getScrollY · getTargetScrollX · getTargetScrollY · getMaxScrollX · getMaxScrollY · isScrollEndX · isScrollEndY · startDragging · stopDragging · beforeDragStart · beforeDragDrop · getDragX · getDragY · isDragged · getDragSource · getDraggedNode · getStartDragX · getStartDragY · getTargetDragX · getTargetDragY · effect · removeEffect · clearEffects · hasEffect · getEffect · layer · clearLayers · animate · removeAnimator · wait · watch · hasListener · isVisibleProperty · isMounted · getIndex · getUi · getHierarchy · getMappedIndex · getTaskList · getShortcutList · toJson · toString · getEventBus · getBodyConsumer · getDefaultX · getDefaultY · getLayoutX · getLayoutY · getShiftX · getShiftY · isStepping · getLastCodepoint · getLoadCount · getRenderTime · remove · self · copy · useStore · addTask · removeTask · addShortcut · removeShortcut · layoutPosition · layoutSize · fit · move · beforeMove · hoverColor

Inherited from Node (21)

onUpdate · onDetach · onInit · onRender · onDraw · onMount · onHoverStart · onHover · onHoverEnd · onScroll · onScrollToEnd · onScrollEndReached · onDragStart · onDrag · onDragDrop · onDragSnap · onMove · onChildAppend · onClick · onAnimate · onWatch

BaseScrollbarNode(double x, double y, double width, double height) protected

Creates the bar at x, y with a width and a height in design pixels, relative to the node it serves, from the constructor of a skin.

  • this scrollNode(Node scrollNode) fluent
  • Node getScrollNode()

Default: null

The node that the bar scrolls; Node.scrollbar sets it. A bar attached without one throws an IllegalStateException.

  • this minThumb(double minThumb) fluent
  • this minThumb(Supplier<Double> minThumb) fluent signal
  • double getMinThumb()

Default: 0D

The smallest length of the thumb, in design pixels, so that a long content keeps a thumb large enough to grab.

boolean isHorizontal()

If true, the bar is wider than high: it then scrolls the node horizontally.

boolean isOverflowing()

If true, the content of the node goes beyond it on the axis of the bar.

double getRatio()

Returns the part of the content that the node shows on the axis of the bar, from 0D to 1D; 1D while the content fits.

double getProgress()

Returns how far the node scrolled on the axis of the bar, from 0D at the start to 1D at the end; during a drag, the offset that the node glides to, so the thumb stays in place when a beforeScroll listener refuses the scroll.

double getThumbLength()

Returns the length of the thumb, in design pixels: the length of the bar times getRatio(), at least minThumb and at most the bar.

boolean isDragging()

If true, the user drags the bar.

void drawSkeleton(double mouseX, double mouseY) hook

Draws the bar as usual while its content waits, instead of a skeleton.

void mousePressed(NodeMouseEvent<?> event) hook

On a left press over the bar that no one consumed, starts the drag, scrolls the node to the pointer and consumes the press.

void mouseReleased(NodeMouseEvent<?> event) hook

Ends the drag on the release of the left button.

void mouseDragged(NodeMouseEvent<?> event) hook

Scrolls the node so that the thumb follows the pointer during the drag.

void detach() hook

Ends a drag in progress when the bar leaves the tree.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page