root / trunk / libraries / libRaster / src / org / gvsig / raster / dataset / Params.java @ 12122
History | View | Annotate | Download (4.58 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
|
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 |
package org.gvsig.raster.dataset; |
20 |
|
21 |
import java.util.ArrayList; |
22 |
import java.util.Iterator; |
23 |
|
24 |
|
25 |
/**
|
26 |
* Par?metros para los drivers de escritura. Las variables estaticas contenidas representan
|
27 |
* los tipos de par?metro posibles.
|
28 |
*
|
29 |
* @version 17/04/2007
|
30 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
31 |
*/
|
32 |
public class Params implements Cloneable { |
33 |
public static final int CHECK = 1; |
34 |
public static final int CHOICE = 2; |
35 |
public static final int SLIDER = 3; |
36 |
public static final int MULTI_CHECK = 4; |
37 |
|
38 |
/**
|
39 |
* Clase que representa un par?metro. Los atributos principales son:
|
40 |
* <UL>
|
41 |
* <LI>type: tipo de par?metro que tendr? un valor correspondiente a las variables estaticas de
|
42 |
* Params.</LI>
|
43 |
* <LI>id: que contiene el identificador del par?metro en cadena de texto</LI>
|
44 |
* <LI>defaultValue: que ser? el valor por defecto asignado al par?metro</LI>
|
45 |
* <LI>list: que contiene una lista de valores con datos asociados al par?metro en concreto</LI>
|
46 |
* </UL>
|
47 |
* . Por ejemplo, para una selecci?n por lista de valores tendr? la lista de valores a
|
48 |
* seleccionar. Para un slider tendr? el valor m?ximo, el m?nimo, el intervalo menor
|
49 |
* y el mayor. Para una selecci?n por check esta lista puede ser vacia.
|
50 |
*
|
51 |
* @version 17/04/2007
|
52 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
53 |
*
|
54 |
*/
|
55 |
public class Param { |
56 |
public int type = -1; |
57 |
public String id = null; |
58 |
public String defaultValue = null; |
59 |
public String[] list = null; |
60 |
} |
61 |
|
62 |
private ArrayList params = new ArrayList(); |
63 |
|
64 |
/**
|
65 |
* Obtiene el par?metro de la posici?n definida por param
|
66 |
* @param param Posici?n del par?metro
|
67 |
* @return Objeto Param
|
68 |
*/
|
69 |
public Param getParam(int param) { |
70 |
return (Param)params.get(param);
|
71 |
} |
72 |
|
73 |
/**
|
74 |
* Asigna el par?metro pasado a la lista de par?metros necesitados por el driver
|
75 |
* @param param
|
76 |
*/
|
77 |
public void setParam(Param param) { |
78 |
params.add(param); |
79 |
} |
80 |
|
81 |
/**
|
82 |
* Inicializa la lista de par?metros
|
83 |
*/
|
84 |
public void clear() { |
85 |
params.clear(); |
86 |
} |
87 |
|
88 |
/**
|
89 |
* Obtiene un par?metro de la lista a partir de su identificador
|
90 |
* @param id Identificador del par?metro
|
91 |
* @return Par?metro o null si no existe
|
92 |
*/
|
93 |
public Param getParamById(String id) { |
94 |
for (Iterator iter = params.iterator(); iter.hasNext();) { |
95 |
Param p = (Param) iter.next(); |
96 |
if (p.id.equals(id))
|
97 |
return p;
|
98 |
} |
99 |
return null; |
100 |
} |
101 |
|
102 |
/**
|
103 |
* Asigna un par?metro. Si existe este lo reemplaza.
|
104 |
* @param id Identificador
|
105 |
* @param value Valor
|
106 |
* @param type Tipo
|
107 |
* @param list Lista de valores
|
108 |
*/
|
109 |
public void setParam(String id, String value, int type, String[] list) { |
110 |
Param p = getParamById(id); |
111 |
if (p == null) |
112 |
p = new Param();
|
113 |
|
114 |
p.id = id; |
115 |
p.defaultValue = value; |
116 |
p.type = type; |
117 |
p.list = list; |
118 |
params.add(p); |
119 |
} |
120 |
|
121 |
/**
|
122 |
* Borra los parametros asociados a ese id
|
123 |
* @param id
|
124 |
*/
|
125 |
public void removeParam(String id) { |
126 |
for (int i = 0; i < params.size(); i++) { |
127 |
Param p = (Param) params.get(i); |
128 |
if (p.id.equals(id)) {
|
129 |
params.remove(i); |
130 |
i--; |
131 |
} |
132 |
} |
133 |
} |
134 |
|
135 |
/**
|
136 |
* Asigna un valor para un par?metro existens. Si no existe no hace nada.
|
137 |
*
|
138 |
* @param id Identificador del par?metro
|
139 |
* @param value Valor a asignar
|
140 |
*/
|
141 |
public void changeParamValue(String id, String value) { |
142 |
for (Iterator iter = params.iterator(); iter.hasNext();) { |
143 |
Param p = (Param) iter.next(); |
144 |
if(p.id.equals(id))
|
145 |
p.defaultValue = value; |
146 |
} |
147 |
} |
148 |
|
149 |
/**
|
150 |
* Obtiene el n?mero de par?metros.
|
151 |
* @return N?mero de par?metros.
|
152 |
*/
|
153 |
public int getNumParams() { |
154 |
return params.size();
|
155 |
} |
156 |
|
157 |
/**
|
158 |
* Devuelve el array de los Params
|
159 |
* @return
|
160 |
*/
|
161 |
public ArrayList getParams() { |
162 |
return params;
|
163 |
} |
164 |
|
165 |
/* (non-Javadoc)
|
166 |
* @see java.lang.Object#clone()
|
167 |
*/
|
168 |
public Object clone() throws CloneNotSupportedException { |
169 |
Object aux = super.clone(); |
170 |
((Params) aux).params = (ArrayList) this.params.clone(); |
171 |
return aux;
|
172 |
} |
173 |
} |