root / trunk / libraries / libRaster / src / org / gvsig / raster / dataset / WriterParams.java @ 11343
History | View | Annotate | Download (4.01 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 WriterParams { |
33 |
|
34 |
public static final int CHECK = 1; |
35 |
public static final int CHOICE = 2; |
36 |
public static final int SLIDER = 3; |
37 |
public static final int MULTI_CHECK = 4; |
38 |
|
39 |
/**
|
40 |
* Clase que representa un par?metro. Los atributos principales son:
|
41 |
* <UL>
|
42 |
* <LI>type: tipo de par?metro que tendr? un valor correspondiente a las variables estaticas de
|
43 |
* WriterParams.</LI>
|
44 |
* <LI>id: que contiene el identificador del par?metro en cadena de texto</LI>
|
45 |
* <LI>defaultValue: que ser? el valor por defecto asignado al par?metro</LI>
|
46 |
* <LI>list: que contiene una lista de valores con datos asociados al par?metro en concreto</LI>
|
47 |
* </UL>
|
48 |
* . Por ejemplo, para una selecci?n por lista de valores tendr? la lista de valores a
|
49 |
* seleccionar. Para un slider tendr? el valor m?ximo, el m?nimo, el intervalo menor
|
50 |
* y el mayor. Para una selecci?n por check esta lista puede ser vacia.
|
51 |
*
|
52 |
* @version 17/04/2007
|
53 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
54 |
*
|
55 |
*/
|
56 |
public class Param { |
57 |
public int type = -1; |
58 |
public String id = null; |
59 |
public String defaultValue = null; |
60 |
public String[] list = null; |
61 |
} |
62 |
|
63 |
private ArrayList params = new ArrayList(); |
64 |
|
65 |
/**
|
66 |
* Obtiene el par?metro de la posici?n definida por param
|
67 |
* @param param Posici?n del par?metro
|
68 |
* @return Objeto Param
|
69 |
*/
|
70 |
public Param getParam(int param) { |
71 |
return (Param)params.get(param);
|
72 |
} |
73 |
|
74 |
/**
|
75 |
* Asigna el par?metro pasado a la lista de par?metros necesitados por el driver
|
76 |
* @param param
|
77 |
*/
|
78 |
public void setParam(Param param) { |
79 |
params.add(param); |
80 |
} |
81 |
|
82 |
/**
|
83 |
* Inicializa la lista de par?metros
|
84 |
*/
|
85 |
public void clear() { |
86 |
params.clear(); |
87 |
} |
88 |
|
89 |
/**
|
90 |
* Obtiene un par?metro de la lista a partir de su identificador
|
91 |
* @param id Identificador del par?metro
|
92 |
* @return Par?metro o null si no existe
|
93 |
*/
|
94 |
public Param getParamById(String id) { |
95 |
for (Iterator iter = params.iterator(); iter.hasNext();) { |
96 |
Param p = (Param) iter.next(); |
97 |
if(p.id.equals(id))
|
98 |
return p;
|
99 |
} |
100 |
return null; |
101 |
} |
102 |
|
103 |
/**
|
104 |
* ASigna un par?metro. Si existe este lo reemplaza.
|
105 |
* @param id Identificador
|
106 |
* @param value Valor
|
107 |
* @param type Tipo
|
108 |
* @param list Lista de valores
|
109 |
*/
|
110 |
public void setParam(String id, String value, int type, String[] list) { |
111 |
Param p = getParamById(id); |
112 |
if(p == null) |
113 |
p = new Param();
|
114 |
|
115 |
p.id = id; |
116 |
p.defaultValue = value; |
117 |
p.type = type; |
118 |
p.list = list; |
119 |
params.add(p); |
120 |
} |
121 |
|
122 |
/**
|
123 |
* Asigna un valor para un par?metro existens. Si no existe no hace nada.
|
124 |
* @param id Identificador del par?metro
|
125 |
* @param value Valor a asignar
|
126 |
*/
|
127 |
public void changeParamValue(String id, String value) { |
128 |
for (Iterator iter = params.iterator(); iter.hasNext();) { |
129 |
Param p = (Param) iter.next(); |
130 |
if(p.id.equals(id))
|
131 |
p.defaultValue = value; |
132 |
} |
133 |
} |
134 |
|
135 |
/**
|
136 |
* Obtiene el n?mero de par?metros.
|
137 |
* @return N?mero de par?metros.
|
138 |
*/
|
139 |
public int getNumParams() { |
140 |
return params.size();
|
141 |
} |
142 |
} |