Record Class ScrollParams

java.lang.Object
java.lang.Record
io.github.palexdev.virtualizedfx.utils.ScrollParams
Record Components:
amount - the base scroll value, interpreted based on the unit
trackMultiplier - a multiplier applied to the unit increment to compute the track increment the default value is: DEFAULT_TRACK_MULTIPLIER
unit - the unit of measurement that determines how the amount is interpreted

public record ScrollParams(double amount, double trackMultiplier, ScrollUnits unit) extends Record
Encapsulates the configuration for scrolling behavior in a VFXScrollPane, including the scroll amount, track multiplier, and unit of measurement.

Provides a consistent way to apply or bind scrolling increments to a scroll pane, using either fixed values or dynamically computed ones.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Default multiplier applied to compute the track increment from the unit increment.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ScrollParams(double amount, double trackMultiplier, ScrollUnits unit)
    Creates an instance of a ScrollParams record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the value of the amount record component.
    void
    apply(VFXScrollPane vsp, javafx.geometry.Orientation orientation)
    Applies the scroll parameters to the given scroll pane in the specified orientation.
    void
    bind(VFXScrollPane vsp, javafx.geometry.Orientation orientation)
    Binds the scroll parameters to the given scroll pane in the specified orientation.
    cells(double count)
    Shortcut for new ScrollParams(count, DEFAULT_TRACK_MULTIPLIER, ScrollUnits.CELL).
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    percentage(double frac)
    Shortcut for new ScrollParams(count, DEFAULT_TRACK_MULTIPLIER, ScrollUnits.PERCENTAGE).
    pixels(double px)
    Shortcut for new ScrollParams(count, DEFAULT_TRACK_MULTIPLIER, ScrollUnits.PIXELS).
    final String
    Returns a string representation of this record class.
    double
    Returns the value of the trackMultiplier record component.
    Returns the value of the unit record component.
    withTrackMultiplier(double trackMultiplier)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_TRACK_MULTIPLIER

      public static final double DEFAULT_TRACK_MULTIPLIER
      Default multiplier applied to compute the track increment from the unit increment.

      Used by all factory methods unless a custom multiplier is provided manually or set afterward using withTrackMultiplier(double).

      See Also:
  • Constructor Details

    • ScrollParams

      public ScrollParams(double amount, double trackMultiplier, ScrollUnits unit)
      Creates an instance of a ScrollParams record class.
      Parameters:
      amount - the value for the amount record component
      trackMultiplier - the value for the trackMultiplier record component
      unit - the value for the unit record component
  • Method Details

    • cells

      public static ScrollParams cells(double count)
      Shortcut for new ScrollParams(count, DEFAULT_TRACK_MULTIPLIER, ScrollUnits.CELL).
    • percentage

      public static ScrollParams percentage(double frac)
      Shortcut for new ScrollParams(count, DEFAULT_TRACK_MULTIPLIER, ScrollUnits.PERCENTAGE).
    • pixels

      public static ScrollParams pixels(double px)
      Shortcut for new ScrollParams(count, DEFAULT_TRACK_MULTIPLIER, ScrollUnits.PIXELS).
    • apply

      public void apply(VFXScrollPane vsp, javafx.geometry.Orientation orientation)
      Applies the scroll parameters to the given scroll pane in the specified orientation.

      Sets the unit and track increment as raw values, based on the calculated scroll percentage. No bindings are used — values are evaluated once and applied directly.

      The track increment is obtained by multiplying the found unit increment by the trackMultiplier value.
    • bind

      public void bind(VFXScrollPane vsp, javafx.geometry.Orientation orientation)
      Binds the scroll parameters to the given scroll pane in the specified orientation.

      Creates bindings that automatically update the unit and track increments when any relevant dependencies change (e.g., content bounds, cell size).

      The dependencies are determined by the chosen scroll unit, see ScrollUnits.deps(VFXScrollPane, Orientation).

      If the scroll unit declares no dependencies, this method falls back to apply(io.github.palexdev.virtualizedfx.controls.VFXScrollPane, javafx.geometry.Orientation).

      The track increment properties are bound to the relative unit increment property and multiplied by the trackMultiplier value.
    • withTrackMultiplier

      public ScrollParams withTrackMultiplier(double trackMultiplier)
      Returns:
      a new ScrollParams instance with the same amount and unit, but with the specified trackMultiplier
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • amount

      public double amount()
      Returns the value of the amount record component.
      Returns:
      the value of the amount record component
    • trackMultiplier

      public double trackMultiplier()
      Returns the value of the trackMultiplier record component.
      Returns:
      the value of the trackMultiplier record component
    • unit

      public ScrollUnits unit()
      Returns the value of the unit record component.
      Returns:
      the value of the unit record component