Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_898 / libraries / libIverUtiles / src / com / iver / utiles / Utils.java @ 10513

History | View | Annotate | Download (2.49 KB)

1
/*
2
 * Created on 19-oct-2004
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Generation - Code and Comments
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
package com.iver.utiles;
48

    
49
/**
50
 * @author FJP
51
 *
52
 * TODO To change the template for this generated type comment go to
53
 * Window - Preferences - Java - Code Generation - Code and Comments
54
 */
55
import java.io.File;
56

    
57
import javax.swing.ImageIcon;
58
/* Utils.java is a 1.4
59
example used by FileChooserDemo2.java. */
60
public class Utils
61
{
62
        public final static String jpeg = "jpeg";
63
        public final static String jpg = "jpg";
64
        public final static String gif = "gif";
65
        public final static String tiff = "tiff";
66
        public final static String tif = "tif";
67
        public final static String png = "png";
68
/* * Get the extension of a file. */
69
        public static String getExtension(File f)
70
        {
71
                String ext = null;
72
                String s = f.getName();
73
                int i = s.lastIndexOf('.');
74
                if (i > 0 && i < s.length() - 1)
75
                {
76
                        ext = s.substring(i+1).toLowerCase();
77
                }
78
                return ext;
79
        }
80
/** Returns an ImageIcon, or null if the path was invalid. */
81
        protected static ImageIcon createImageIcon(String path)
82
        {
83
                java.net.URL imgURL = Utils.class.getResource(path);
84
                if (imgURL != null) {
85
                        return new ImageIcon(imgURL);
86
                } else {
87
                        System.err.println("Couldn't find file: " + path);
88
                        return null;
89
                }
90
        }
91

    
92

    
93
}