private void fillViewportFrom ( int itemIndex ) { // cell for itemIndex is assumed to be placed correctly // fill up to the ground int ground = fillTowardsGroundFrom0 ( itemIndex ) ; // if ground not reached, shift cells to the ground double gapBefore = distanceFromGround ( ground ) ; if ( gapBefore > 0 ) { shiftCellsTowardsGround ( ground , itemIndex , gapBefore ) ; } // fill up to the sky int sky = fillTowardsSkyFrom0 ( itemIndex ) ; // if sky not reached, add more cells under the ground and then shift double gapAfter = distanceFromSky ( sky ) ; if ( gapAfter > 0 ) { ground = fillTowardsGroundFrom0 ( ground , - gapAfter ) ; double extraBefore = - distanceFromGround ( ground ) ; double shift = Math . min ( gapAfter , extraBefore ) ; shiftCellsTowardsGround ( ground , sky , - shift ) ; } // crop to the visible cells int first = Math . min ( ground , sky ) ; int last = Math . max ( ground , sky ) ; while ( first < last && orientation . maxY ( positioner . getVisibleCell ( first ) ) <= 0.0 ) { ++ first ; } while ( last > first && orientation . minY ( positioner . getVisibleCell ( last ) ) >= sizeTracker . getViewportLength ( ) ) { -- last ; } firstVisibleIndex = first ; lastVisibleIndex = last ; positioner . cropTo ( first , last + 1 ) ; }
Starting from the anchor cell s node fills the viewport from the anchor to the ground and then from the anchor to the sky .