FileDocCategorySizeDatePackage
DocumentDescriptorRenderer.javaAPI DocApache Poi 3.0.12999Mon Jan 01 12:39:34 GMT 2007org.apache.poi.contrib.poibrowser

DocumentDescriptorRenderer

public class DocumentDescriptorRenderer extends DefaultTreeCellRenderer

{@link TreeCellRenderer} for a {@link DocumentDescriptor}. The renderer is extremly rudimentary since displays only the document's name, its size and its fist few bytes.

author
Rainer Klute <klute@rainer-klute.de>
version
$Id: DocumentDescriptorRenderer.java 489730 2006-12-22 19:18:16Z bayard $
since
2002-02-05

Fields Summary
Constructors Summary
Methods Summary
public java.awt.ComponentgetTreeCellRendererComponent(javax.swing.JTree tree, java.lang.Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)

        final DocumentDescriptor d = (DocumentDescriptor)
            ((DefaultMutableTreeNode) value).getUserObject();
        final JPanel p = new JPanel();
        final JTextArea text = new JTextArea();
        text.append(renderAsString(d));
        text.setFont(new Font("Monospaced", Font.PLAIN, 10));
        p.add(text);
        if (selected)
            Util.invert(text);
        return p;
    
protected java.lang.StringrenderAsString(DocumentDescriptor d)

Renders {@link DocumentDescriptor} as a string.

        final StringBuffer b = new StringBuffer();
        b.append("Name: ");
        b.append(d.name);
        b.append(" (");
        b.append(Codec.hexEncode(d.name));
        b.append(")  \n");

        b.append("Size: ");
        b.append(d.size);
        b.append(" bytes\n");

        b.append("First bytes: ");
        b.append(Codec.hexEncode(d.bytes));

        return b.toString();