类 OrientationHelper.HorizontalHelper

java.lang.Object
io.github.palexdev.virtualizedfx.flow.base.OrientationHelper.HorizontalHelper
所有已实现的接口:
OrientationHelper
封闭接口:
OrientationHelper

public static class OrientationHelper.HorizontalHelper extends Object implements OrientationHelper
Implementation of OrientationHelper for Orientation.HORIZONTAL.

This helper is also responsible for listening to changes to the VirtualFlow's width, because in such cases it's needed to recompute the number of cells needed (to add or remove), and changes to the VirtualFlow.horizontalPositionProperty() to update the container's layoutX property and call SimpleVirtualFlowContainer.update(double) with the new position.

Note that these listeners are added late during VirtualFlow's initialization as adding them already in the constructor would lead to an infinite loop and RAM eating for some reason.
另请参阅:
  • 构造器详细资料

  • 方法详细资料

    • initialize

      public void initialize()
      DO NOT CALL THIS METHOD, it's automatically handled by the VirtualFlow.
    • firstVisible

      public int firstVisible()
      Computes the first visible cell index in the viewport with this formula:

      (int) Math.floor(scrolled / cellWidth)

      The scrolled parameter is the amount of pixels scrolled from the left and cellWidth is the fixed cells' width.

      The result is clamped between 0 and the number of items -1.

      指定者:
      firstVisible 在接口中 OrientationHelper
      返回:
      the index of the first visible cell in the viewport
    • lastVisible

      public int lastVisible()
      Computes the first visible cell index in the viewport with this formula:

      (int) Math.ceil((scrolled + virtualFlowWidth) / cellWidth - 1)

      The scrolled parameter is the amount of pixels scrolled from the left, the virtualFlowWidth well... is self-explanatory, and cellWidth is the fixed cells' width.

      The result is clamped between 0 and the number of items -1.

      指定者:
      lastVisible 在接口中 OrientationHelper
      返回:
      the index of the last visible cell in the viewport
    • computeCellsNumber

      public int computeCellsNumber()
      指定者:
      computeCellsNumber 在接口中 OrientationHelper
      返回:
      the number of cells to show based on the viewport's width and cells' width
    • computeEstimatedHeight

      public double computeEstimatedHeight(double cellHeight)
      从接口复制的说明: OrientationHelper
      Computes the estimated height of the flow.
      指定者:
      computeEstimatedHeight 在接口中 OrientationHelper
      返回:
      the VirtualFlow's height
    • computeEstimatedWidth

      public double computeEstimatedWidth(double cellWidth)
      从接口复制的说明: OrientationHelper
      Computes the estimated width of the flow.
      指定者:
      computeEstimatedWidth 在接口中 OrientationHelper
      返回:
      the given cellWidth multiplied by the number of items
    • getHeight

      public double getHeight(Node node)
      If the Node's maxHeight is set to Double.MAX_VALUE then returns the VirtualFlow's height, otherwise calls OrientationHelper.boundSize(double, double, double).
      指定者:
      getHeight 在接口中 OrientationHelper
      返回:
      the height of the given node
    • getWidth

      public double getWidth(Node node)
      指定者:
      getWidth 在接口中 OrientationHelper
      返回:
      the Node's pref width
    • resizeRelocate

      public void resizeRelocate(Node node, double pos, double w, double h)
      Resizes and relocated the given node with the given parameters, the y offset is always 0.
      指定者:
      resizeRelocate 在接口中 OrientationHelper
      参数:
      node - the Node to resize and relocate
      pos - the x position
      w - the width
      h - the height
    • layout

      public void layout(Node node, int index, double cellW, double cellH)
      Computes the Node's x position and then calls resizeRelocate(Node, double, double, double).
      指定者:
      layout 在接口中 OrientationHelper
    • scrollBy

      public void scrollBy(double pixels)
      Scrolls the flow by the given amount of pixels.

      Gets the current horizontal position and adds the given amount of pixels to it. The result is clamped between 0 and the hBar's max property.
      指定者:
      scrollBy 在接口中 OrientationHelper
    • scrollTo

      public void scrollTo(int index)
      Scrolls the flow to the given cell index.

      Computes the pixel value by multiplying the given index for the fixed cells' width, then calls scrollToPixel(double) with the result.
      指定者:
      scrollTo 在接口中 OrientationHelper
    • scrollToFirst

      public void scrollToFirst()
      Calls scrollTo(int) with 0 as argument.
      指定者:
      scrollToFirst 在接口中 OrientationHelper
    • scrollToLast

      public void scrollToLast()
      Calls scrollTo(int) with items size - 1 as argument.
      指定者:
      scrollToLast 在接口中 OrientationHelper
    • scrollToPixel

      public void scrollToPixel(double pixel)
      Scrolls the flow to the given pixel value.

      The given pixel value is clamped between 0 and the hBar's max property before.
      指定者:
      scrollToPixel 在接口中 OrientationHelper
    • dispose

      public void dispose()
      Removes and clears any listener.

      This must be called every time the OrientationHelper of the VirtualFlow is changed (typically occurs when the orientation changes).

      指定者:
      dispose 在接口中 OrientationHelper