Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libUI / src / org / gvsig / gui / beans / swing / jComboBoxWithImageIconItems / ImageIconItemInfoUtils.java @ 10137

History | View | Annotate | Download (2.25 KB)

1
package org.gvsig.gui.beans.swing.jComboBoxWithImageIconItems;
2

    
3
import javax.swing.ImageIcon;
4

    
5
import org.apache.log4j.Logger;
6

    
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47

    
48
/**
49
 * This class has an static method that is an utility to load an image icon 
50
 * 
51
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
52
 */
53
public class ImageIconItemInfoUtils {
54
        // TRACE - DEBUG
55
        private static Logger logger = Logger.getLogger(ImageIconItemInfoUtils.class.getClass());
56
        // END TRACE - DEBUG
57
        
58
    /**
59
     * Returns an ImageIcon, or null if the path from class reference was invalid.
60
     * 
61
     * @param class_Reference A reference to a class which path will be the base to find the resource of the 'path' param
62
     * @param path Path to the image to load
63
     * @return javax.swing.ImageIcon
64
     */
65
    public static ImageIcon createImageIcon(Class class_Reference, String path) {
66
            java.net.URL imgURL = class_Reference.getResource(path);
67
        if (imgURL != null) {
68
            return new ImageIcon(imgURL);
69
        } else {
70
                logger.debug("Couldn't find file: " + path);
71
            return null;
72
        }
73
    }
74
}