// Create a transaction which will be used for persisten object operations
        // during painting (to avoid creating several short-livin transactions)
        ODMGXAWrapper txw = new ODMGXAWrapper();
        
        Thumbnail thumbnail = null;
        log.debug( "finding thumb" );
        boolean hasThumbnail = photo.hasThumbnail();
        log.debug( "asked if has thumb" );
        if ( hasThumbnail ) {
            log.debug( "Photo " + photo.getUid() + " has thumbnail" );
            thumbnail = photo.getThumbnail();
            log.debug( "got thumbnail" );
        } else {
            /*
             Check if the thumbnail has been just invalidated. If so, use the 
             old one until we get the new thumbnail created.
             */
            thumbnail = photo.getOldThumbnail();
            if ( thumbnail != null ) {
                useOldThumbnail = true;
            } else {
                // No success, use default thumnail.
                thumbnail = Thumbnail.getDefaultThumbnail();
            }
            // The photo does not have a thumbnail, so request one to be created
            if ( !thumbCreatorThread.isBusy() ) {
                log.debug( "Create thumbnail for " + photo.getUid() );
                thumbCreatorThread.createThumbnail( photo );
                log.debug( "Thumbnail request submitted" );
            }            
        }
        thumbReadyTime = System.currentTimeMillis();
        
        log.debug( "starting to draw" );
        // Find the position for the thumbnail
        BufferedImage img = thumbnail.getImage();
        if ( img.getWidth() > columnWidth || img.getHeight() > rowHeight ) {
            /*
             If the image is too large for the space reserved for thumbnail, crop
             (yes, this should not be possible but many kinds of miracles do 
             happen. Also this has happened in some weird test cases!!!