Statistics
| Revision:

gvsig-3d / 2.1 / trunk / org.gvsig.gvsig3d / org.gvsig.gvsig3d.app / org.gvsig.gvsig3d.app.commons / src / main / java / org / gvsig / gvsig3d / app / resources / ResourcesFactory.java @ 385

History | View | Annotate | Download (3.42 KB)

1
/* gvSIG 3D extension for gvSIG
2
 *
3
 * Copyright (C) 2012 Prodevelop.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *   Prodevelop, S.L.
22
 *   Pza. Don Juan de Villarrasa, 14 - 5
23
 *   46001 Valencia
24
 *   Spain
25
 *
26
 *   +34 963 510 612
27
 *   +34 963 510 968
28
 *   prode@prodevelop.es
29
 *   http://www.prodevelop.es
30
 */
31
/*
32
 * AUTHORS:
33
 * 2012 AI2 - Instituto Universitario de Automatica e Informatica Industrial.
34
 * Universitat Politecnica de Valencia (UPV)
35
 * http://www.ai2.upv.es
36
 */
37

    
38

    
39
package org.gvsig.gvsig3d.app.resources;
40

    
41
import java.io.File;
42

    
43
/**
44
 * @author Julio Campos 
45
 * @author Jesus Zarzoso- jzarzoso@ai2.upv.es for gvSIG 2.0
46
 * 
47
 * This class is a factory to find resources in 3D extensions
48
 * 
49
 */
50
public class ResourcesFactory {
51

    
52
        private static String textPath;
53

    
54
        private static String extPath;
55

    
56
        static {
57
                extPath = File.separator+"gvSIG"+File.separator+"extensiones"+File.separator+"org.gvsig.gvsig3d.app.extension"+File.separator+"images"+File.separator;
58

    
59
                textPath = System.getProperty("user.dir") + extPath;
60
        }
61

    
62
        /**
63
         * Method to get Path resources directory
64
         * 
65
         * @return
66
         */
67
        public static String getResourcesPath() {
68
                return textPath;
69
        }
70

    
71
        /**
72
         * Method to get path to specific resource
73
         * 
74
         * @param name
75
         *            Name of resource
76
         * @return All path resource
77
         */
78
        public static String getResourcePath(String name) {
79
                return textPath + name;
80
        }
81

    
82
        /**
83
         * Method to get a list of all resources
84
         * 
85
         * @return String array with all resources
86
         */
87
        public static String[] getResources() {
88
                String[] resourcesList;
89

    
90
                File dir = new File(ResourcesFactory.getResourcesPath());
91

    
92
                resourcesList = dir.list();
93
                if (resourcesList == null) {
94
                        // Either dir does not exist or is not a directory
95
                } else {
96
                        for (int i = 0; i < resourcesList.length; i++) {
97
                                // Get filename of file or directory
98
                                String filename = resourcesList[i];
99
                        }
100
                }
101

    
102
                return resourcesList;
103
        }
104

    
105
        /**
106
         * Method to verify if this resource exits
107
         * 
108
         * @param name
109
         *            Name of resource
110
         * @return True or false
111
         */
112
        public static boolean exitsResouce(String name) {
113
                boolean exit = false;
114
                String[] resourcesList = ResourcesFactory.getResources();
115
                if (resourcesList != null) {
116

    
117
                        for (int i = 0; i < resourcesList.length; i++) {
118
                                // Get filename of file or directory
119
                                String filename = resourcesList[i];
120
                                if (filename.equals(name))
121
                                        return true;
122
                        }
123
                }
124

    
125
                return exit;
126
        }
127

    
128
        /**
129
         * Method to set the extension path
130
         * 
131
         * @param extPath
132
         */
133
        public static void setExtPath(String extPath) {
134
                ResourcesFactory.extPath = extPath;
135
                textPath = System.getProperty("user.dir") + extPath;
136
        }
137

    
138
        /**
139
         * Method to get the extension path
140
         * 
141
         * @param extPath
142
         */
143
        public static String getExtPath() {
144
                return ResourcesFactory.extPath;
145
        }
146
}
147