protected void trackPathable ( ) { // if we're tracking a pathable, adjust our view coordinates if ( _fpath == null ) { return ; } int width = getWidth ( ) , height = getHeight ( ) ; int nx = _vbounds . x , ny = _vbounds . y ; // figure out where to move switch ( _fmode ) { case TRACK_PATHABLE : nx = _fpath . getX ( ) ; ny = _fpath . getY ( ) ; break ; case CENTER_ON_PATHABLE : nx = _fpath . getX ( ) - width / 2 ; ny = _fpath . getY ( ) - height / 2 ; break ; case ENCLOSE_PATHABLE : Rectangle bounds = _fpath . getBounds ( ) ; if ( nx > bounds . x ) { nx = bounds . x ; } else if ( nx + width < bounds . x + bounds . width ) { nx = bounds . x + bounds . width - width ; } if ( ny > bounds . y ) { ny = bounds . y ; } else if ( ny + height < bounds . y + bounds . height ) { ny = bounds . y + bounds . height - height ; } break ; default : log . warning ( "Eh? Set to invalid pathable mode" , "mode" , _fmode ) ; break ; } // Log.info("Tracking pathable [mode=" + _fmode + // ", pable=" + _fpath + ", nx=" + nx + ", ny=" + ny + "]."); setViewLocation ( nx , ny ) ; }
Implements the standard pathable tracking support . Derived classes may wish to override this if they desire custom tracking functionality .