001    /*
002     * $Id: IconValue.java 3298 2009-03-11 13:51:25Z kleopatra $
003     *
004     * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle,
005     * Santa Clara, California 95054, U.S.A. All rights reserved.
006     *
007     * This library is free software; you can redistribute it and/or
008     * modify it under the terms of the GNU Lesser General Public
009     * License as published by the Free Software Foundation; either
010     * version 2.1 of the License, or (at your option) any later version.
011     * 
012     * This library is distributed in the hope that it will be useful,
013     * but WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015     * Lesser General Public License for more details.
016     * 
017     * You should have received a copy of the GNU Lesser General Public
018     * License along with this library; if not, write to the Free Software
019     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
020     */
021    package org.jdesktop.swingx.renderer;
022    
023    import java.io.Serializable;
024    
025    import javax.swing.Icon;
026    
027    import org.jdesktop.swingx.icon.EmptyIcon;
028    
029    /**
030     * A simple converter to return a Icon representation of an Object.
031     * <p>
032     * 
033     * This class is intended to be the "small coin" to configure/format icon cell
034     * content of concrete subclasses of <code>ComponentProvider</code>.
035     * <p>
036     * 
037     * 
038     * NOTE: this is experimental, most probably will change. A (near) future
039     * version with change the signature of the getIcon method to
040     * 
041     * <pre><code>
042     * Icon getIcon(Object value, IconType type);
043     * </code></pre>
044     * 
045     * That will allow a more fine-grained control of custom icons in tree rendering.
046     * 
047     * @author Jeanette Winzenburg
048     */
049    public interface IconValue extends Serializable {
050        
051        /**
052         * The cell type the icon is used for.
053         */
054        public enum IconType {
055            
056            LEAF,
057            
058            OPEN_FOLDER,
059            
060            CLOSED_FOLDER
061            
062        }
063        
064        /**
065         * A marker icon used to indicate a null. 
066         * 
067         */
068        public final static Icon NULL_ICON = new EmptyIcon();
069        
070        
071        /**
072         * Returns a icon representation of the given value.
073         * 
074         * @param value the object to present as Icon
075         * @return a Icon representation of the given value, 
076         *  may be null if none available.
077         *  
078         */
079        Icon getIcon(Object value);
080    
081    }