protected void figureCurrentHistory ( ) { int first = _historyModel . getValue ( ) ; int count = 0 ; Graphics2D gfx = null ; if ( isLaidOut ( ) && ! _history . isEmpty ( ) ) { gfx = getTargetGraphics ( ) ; if ( gfx == null ) { log . warning ( "Can't figure current history, no graphics." ) ; return ; } // start from the bottom.. Rectangle vbounds = _target . getViewBounds ( ) ; int ypos = vbounds . height - _subtitleYSpacing ; for ( int ii = first ; ii >= 0 ; ii -- , count ++ ) { ChatGlyph rec = getHistorySubtitle ( ii , gfx ) ; // see if it will fit Rectangle r = rec . getBounds ( ) ; ypos -= r . height ; if ( ( count != 0 ) && ypos <= ( vbounds . height - _subtitleHeight ) ) { break ; // don't add that one.. } // position it rec . setLocation ( vbounds . x + _subtitleXSpacing , vbounds . y + ypos ) ; // add space for the next ypos -= getHistorySubtitleSpacing ( ii ) ; } } // finally, because we've been adding to the _showingHistory here (via getHistorySubtitle) // and in figureHistoryOffset (possibly called prior to this method) we now need to prune // out the ChatGlyphs that aren't actually needed and make sure the ones that are are // positioned on the screen correctly for ( Iterator < ChatGlyph > itr = _showingHistory . iterator ( ) ; itr . hasNext ( ) ; ) { ChatGlyph cg = itr . next ( ) ; boolean managed = ( _target != null ) && _target . isManaged ( cg ) ; if ( cg . histIndex <= first && cg . histIndex > ( first - count ) ) { // it should be showing if ( ! managed ) { _target . addAnimation ( cg ) ; } } else { // it shouldn't be showing if ( managed ) { _target . abortAnimation ( cg ) ; } itr . remove ( ) ; } } if ( gfx != null ) { gfx . dispose ( ) ; } }
Figure out which ChatMessages in the history should currently appear in the showing history .