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


  • final class CellPositioner<T,​C extends Cell<T,​?>>
    extends java.lang.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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cropTo​(int from, int to)  
      java.util.OptionalInt firstVisibleAfter​(int position)  
      java.util.Optional<C> getCellIfVisible​(int itemIndex)  
      java.util.OptionalInt getFirstVisibleIndex()  
      java.util.OptionalInt getLastVisibleIndex()  
      (package private) C getSizedCell​(int itemIndex)
      Returns properly sized, but not properly positioned cell for the given index.
      C getVisibleCell​(int itemIndex)  
      java.util.OptionalInt lastVisibleBefore​(int position)  
      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.
      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.
      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.
      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.
      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 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.
      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
    • Method Detail

      • cropTo

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

        public C getVisibleCell​(int itemIndex)
      • getCellIfVisible

        public java.util.Optional<C> getCellIfVisible​(int itemIndex)
      • lastVisibleBefore

        public java.util.OptionalInt lastVisibleBefore​(int position)
      • firstVisibleAfter

        public java.util.OptionalInt firstVisibleAfter​(int position)
      • getLastVisibleIndex

        public java.util.OptionalInt getLastVisibleIndex()
      • getFirstVisibleIndex

        public java.util.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)