PageRenderTime 25ms CodeModel.GetById 18ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/branches/jsdoc_tk_gui/src/org/jsdoctoolkit/image/IconFactory.java

http://jsdoc-toolkit.googlecode.com/
Java | 35 lines | 24 code | 10 blank | 1 comment | 5 complexity | 6f35cd4cbe8cf1267f646f678714710e MD5 | raw file
 1package org.jsdoctoolkit.image;
 2
 3import java.net.URL;
 4
 5import javax.swing.ImageIcon;
 6
 7import org.jsdoctoolkit.model.MyLogger;
 8
 9public class IconFactory {
10
11    public static String GIF = ".gif";
12
13    public static String PNG = ".png";
14
15    public static ImageIcon getImageIcon(String fileName, String fileType) {
16
17        if (!"".equals(fileName)) {
18            
19            URL imageURL = IconFactory.class.getResource(fileName.toLowerCase()
20                    + fileType.toLowerCase());
21            
22            if(imageURL == null){
23                //Gestion des images dans le Jar obfusqué
24                imageURL = IconFactory.class.getResource("img/" 
25                        + fileName.toLowerCase() + fileType.toLowerCase());   
26            }
27            if (imageURL != null) {
28                ImageIcon img = new ImageIcon(imageURL);
29                return img;
30            }
31        }
32        MyLogger.getLogger().info("Image not found !! : " + fileName + fileType);
33        return null;
34    }
35}