Enum Class ScrollUnits

java.lang.Object
java.lang.Enum<ScrollUnits>
io.github.palexdev.virtualizedfx.enums.ScrollUnits
All Implemented Interfaces:
Serializable, Comparable<ScrollUnits>, Constable

public enum ScrollUnits extends Enum<ScrollUnits>
Defines the unit of measurement used when setting the scroll increment for a VFXScrollPane.

Scroll units are used to convert a logical amount (e.g., 3 cells, 100 pixels) into a percentage value in the range [0.0, 1.0], which is then applied to the scroll pane.

See Also:
  • Enum Constant Details

    • CELL

      public static final ScrollUnits CELL
      Scrolls by a number of cells/rows/columns, depending on the orientation.

      This unit is only valid when the scroll pane's content is an instance of VFXContainer. The pixel size of each cell/row/column is multiplied by the specified amount and then converted into a percentage relative to the container's max scroll value (VFXContainer.maxVScrollProperty() or VFXContainer.maxHScrollProperty()).

      Binding dependencies include the container's scroll bounds and its cell size property.
    • PERCENTAGE

      public static final ScrollUnits PERCENTAGE
      Scrolls by a percentage of the total scrollable area.

      This is the simplest unit, no conversion is performed. Because of that, bindings for this unit are ignored and fallback to a standard apply.

      Use this when you want to directly specify the exact scroll delta in percentage terms.

    • PIXELS

      public static final ScrollUnits PIXELS
      Scrolls by a fixed number of pixels.

      The specified pixel amount is converted into a percentage based on the scrollable content's size and the scroll pane's viewport size. If the content is a VFXContainer, its virtualized scroll bounds are used. Otherwise, the scrollable extent is derived from the layout bounds.

      Binding dependencies include either virtual scroll bounds or layout bounds, depending on content type.
  • Method Details

    • values

      public static ScrollUnits[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ScrollUnits valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • calc

      public abstract Supplier<Double> calc(VFXScrollPane vsp, double amount, Orientation orientation)
      Calculates the scroll amount as a percentage value in [0.0, 1.0], based on the given unit type.

      The orientation parameters specifies the axis on which select the properties. E.g: VERTICAL -> height, HORIZONTAL -> width
    • deps

      public abstract ObservableValue<?>[] deps(VFXScrollPane vsp, Orientation orientation)
      Lists observable properties that should be watched when using this unit in a binding context.

      An empty array indicates that the binding is not necessary and should be ignored. This is the case of PERCENTAGE.