Class CellPositioner<T,C extends Cell<T,?>>

java.lang.Object
org.fxmisc.flowless.CellPositioner<T,C>

final class CellPositioner<T,C extends Cell<T,?>> extends Object
Helper class for properly resizing and relocating a Cell's Node as well as handling calls related to whether a cell's node is visible (displayed in the viewport) or not.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final CellListManager<T,C>
     
    private final OrientationHelper
     
    private final SizeTracker
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    CellPositioner(CellListManager<T,C> cellManager, OrientationHelper orientation, SizeTracker sizeTracker)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cropTo(int from, int to)
     
    firstVisibleAfter(int position)
     
    getCellIfVisible(int itemIndex)
     
     
     
    (package private) C
    getSizedCell(int itemIndex)
    Returns properly sized, but not properly positioned cell for the given index.
    getVisibleCell(int itemIndex)
     
    lastVisibleBefore(int position)
     
    placeEndFromEnd(int itemIndex, double endOffEnd)
    Properly resizes the cell's node, and sets its "layoutY" value, so that is the last visible node in the viewport, and further offsets this value by endOffStart, so that the node's bottom edge appears (if negative) "above," (if 0) "at," or (if negative) "below" the viewport's "bottom" edge.
    placeEndFromStart(int itemIndex, double endOffStart)
    Properly resizes the cell's node, and sets its "layoutY" value, so that is the last visible node in the viewport, and further offsets this value by endOffStart, so that the node's top edge appears (if negative) "above," (if 0) "at," or (if negative) "below" the viewport's "bottom" edge.
    placeStartAt(int itemIndex, double startOffStart)
    Properly resizes the cell's node, and sets its "layoutY" value, so that is the first visible node in the viewport, and further offsets this value by startOffStart, so that the node's top edge appears (if negative) "above," (if 0) "at," or (if negative) "below" the viewport's "top" edge.
    placeStartFromEnd(int itemIndex, double startOffEnd)
    Properly resizes the cell's node, and sets its "layoutY" value, so that is the last visible node in the viewport, and further offsets this value by endOffStart, so that the node's bottom edge appears (if negative) "above," (if 0) "at," or (if negative) "below" the viewport's "top" edge.
    private void
    relocate(C cell, double breadth0, double length0)
     
    void
    shiftCellBy(C cell, double delta)
    Moves the given cell's node's "layoutY" value by delta.
    double
    Gets the shortest delta amount by which to scroll the viewport's length in order to fully display a partially-displayed cell's node.
    double
    shortestDeltaToViewport(C cell, double fromY, double toY)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • cropTo

      public void cropTo(int from, int to)
    • getVisibleCell

      public C getVisibleCell(int itemIndex)
    • getCellIfVisible

      public Optional<C> getCellIfVisible(int itemIndex)
    • lastVisibleBefore

      public OptionalInt lastVisibleBefore(int position)
    • firstVisibleAfter

      public OptionalInt firstVisibleAfter(int position)
    • getLastVisibleIndex

      public OptionalInt getLastVisibleIndex()
    • getFirstVisibleIndex

      public OptionalInt getFirstVisibleIndex()
    • shortestDeltaToViewport

      public double shortestDeltaToViewport(C cell)
      Gets the shortest delta amount by which to scroll the viewport's length in order to fully display a partially-displayed cell's node.
    • shortestDeltaToViewport

      public double shortestDeltaToViewport(C cell, double fromY, double toY)
    • shiftCellBy

      public void shiftCellBy(C cell, double delta)
      Moves the given cell's node's "layoutY" value by delta. See OrientationHelper's javadoc for more explanation on what quoted terms mean.
    • placeStartAt

      public C placeStartAt(int itemIndex, double startOffStart)
      Properly resizes the cell's node, and sets its "layoutY" value, so that is the first visible node in the viewport, and further offsets this value by startOffStart, so that the node's top edge appears (if negative) "above," (if 0) "at," or (if negative) "below" the viewport's "top" edge. See OrientationHelper's javadoc for more explanation on what quoted terms mean.
      
            --------- top of cell's node if startOffStart is negative
      
           __________ "top edge" of viewport / top of cell's node if startOffStart = 0
           |
           |
           |--------- top of cell's node if startOffStart is positive
           |
       
      Parameters:
      itemIndex - the index of the item in the list of all (not currently visible) cells
      startOffStart - the amount by which to offset the "layoutY" value of the cell's node
    • placeEndFromStart

      public C placeEndFromStart(int itemIndex, double endOffStart)
      Properly resizes the cell's node, and sets its "layoutY" value, so that is the last visible node in the viewport, and further offsets this value by endOffStart, so that the node's top edge appears (if negative) "above," (if 0) "at," or (if negative) "below" the viewport's "bottom" edge. See OrientationHelper's javadoc for more explanation on what quoted terms mean.
      
           |--------- top of cell's node if endOffStart is negative
           |
           |
           |_________ "bottom edge" of viewport / top of cell's node if endOffStart = 0
      
      
            --------- top of cell's node if endOffStart is positive
       
      Parameters:
      itemIndex - the index of the item in the list of all (not currently visible) cells
      endOffStart - the amount by which to offset the "layoutY" value of the cell's node
    • placeEndFromEnd

      public C placeEndFromEnd(int itemIndex, double endOffEnd)
      Properly resizes the cell's node, and sets its "layoutY" value, so that is the last visible node in the viewport, and further offsets this value by endOffStart, so that the node's bottom edge appears (if negative) "above," (if 0) "at," or (if negative) "below" the viewport's "bottom" edge. See OrientationHelper's javadoc for more explanation on what quoted terms mean.
      
           |--------- bottom of cell's node if endOffEnd is negative
           |
           |_________ "bottom edge" of viewport / bottom of cell's node if endOffEnd = 0
      
      
            --------- bottom of cell's node if endOffEnd is positive
       
      Parameters:
      itemIndex - the index of the item in the list of all (not currently visible) cells
      endOffEnd - the amount by which to offset the "layoutY" value of the cell's node
    • placeStartFromEnd

      public C placeStartFromEnd(int itemIndex, double startOffEnd)
      Properly resizes the cell's node, and sets its "layoutY" value, so that is the last visible node in the viewport, and further offsets this value by endOffStart, so that the node's bottom edge appears (if negative) "above," (if 0) "at," or (if negative) "below" the viewport's "top" edge. See OrientationHelper's javadoc for more explanation on what quoted terms mean.
      
            --------- bottom of cell's node if startOffStart is negative
      
           __________ "top edge" of viewport / bottom of cell's node if startOffStart = 0
           |
           |
           |--------- bottom of cell's node if startOffStart is positive
           |
       
      Parameters:
      itemIndex - the index of the item in the list of all (not currently visible) cells
      startOffEnd - the amount by which to offset the "layoutY" value of the cell's node
    • getSizedCell

      C getSizedCell(int itemIndex)
      Returns properly sized, but not properly positioned cell for the given index.
    • relocate

      private void relocate(C cell, double breadth0, double length0)