protected void addRange(  
        TextPresentation presentation,  
        int offset,  
        int length,  
        TextAttribute attr) {  
        if (attr != null)  
            presentation.addStyleRange(  
                new StyleRange(  
                    offset,  
                    length,  
                    attr.getForeground(),  
                    attr.getBackground(),  
                    attr.getStyle()));  
    }