27 |
27 |
protected int sizePanelY = 210;
|
28 |
28 |
private RasterTransparencyPanel pTrans = null;
|
29 |
29 |
private BandSetupPanel pSetup = null;
|
|
30 |
private int[][] rangeTransparency;
|
30 |
31 |
|
31 |
32 |
public FilterRasterDialogPanel() {
|
32 |
33 |
|
... | ... | |
163 |
164 |
|
164 |
165 |
for(int i=0;i<values.length();i++){
|
165 |
166 |
char c = values.charAt(i);
|
166 |
|
if( c!='0' && c!='1' && c!='2' && c!='3' && c!='4' &&
|
167 |
|
c!='5' && c!='6' && c!='7' && c!='8' && c!='9' &&
|
168 |
|
c!='.' && c!=':' && c!=','){
|
|
167 |
|
|
168 |
//Control de caracter valido
|
|
169 |
if( c != '0' && c != '1' && c != '2' && c != '3' && c != '4' &&
|
|
170 |
c != '5' && c != '6' && c != '7' && c != '8' && c != '9' &&
|
|
171 |
c != ':' && c != ','){
|
169 |
172 |
System.err.println("Caracteres incorrectos en la cadena.");
|
170 |
173 |
throw new IOException("Caracteres incorrectos en la cadena.");
|
171 |
174 |
}
|
172 |
175 |
|
173 |
|
if( values.startsWith(".") || values.startsWith(",") || values.startsWith(":") ||
|
174 |
|
values.endsWith(".") || values.endsWith(",") || values.endsWith(":")){
|
|
176 |
//Control de comienzo por un simbolo
|
|
177 |
if( values.startsWith(",") || values.startsWith(":") ||
|
|
178 |
values.endsWith(",") || values.endsWith(":")){
|
175 |
179 |
System.err.println("La cadena empieza o acaba con simbolos incorrectos");
|
176 |
180 |
throw new IOException();
|
177 |
181 |
}
|
|
182 |
|
|
183 |
//Control de signos consecutivos
|
178 |
184 |
if(i<values.length()-1){
|
|
185 |
|
179 |
186 |
char cmas = values.charAt(i+1);
|
180 |
|
if((c==',' || c=='.' || c==':') && (cmas==',' || cmas=='.' || cmas==':')){
|
181 |
|
System.err.println("Signos de puntuaci?n consecutivos");
|
|
187 |
if((c == ',' || c == ':') && (cmas == ',' || cmas == ':')){
|
|
188 |
System.err.println("Signos consecutivos");
|
182 |
189 |
throw new IOException();
|
183 |
190 |
}
|
|
191 |
|
|
192 |
}
|
184 |
193 |
|
|
194 |
//Control de dos : seguidos con un n?mero en el medio
|
|
195 |
if(i<values.length()-3 && c==':'){
|
|
196 |
int n=i+1;
|
|
197 |
while(n<values.length()-1 && values.charAt(n) != ',' && values.charAt(n) != ':')
|
|
198 |
n++;
|
|
199 |
|
|
200 |
char signoSgte = values.charAt(n);
|
|
201 |
if(signoSgte == ':'){
|
|
202 |
System.err.println("Dos separadores de rango consecutivos");
|
|
203 |
throw new IOException();
|
|
204 |
}
|
185 |
205 |
}
|
186 |
206 |
|
187 |
207 |
}
|
188 |
208 |
|
189 |
|
/*String [] temp = null;
|
190 |
|
temp = values.split("\\,");
|
191 |
|
for(int i=0;i<temp.length;i++){
|
192 |
|
if(temp[i].indexOf(":")==-1){
|
193 |
|
|
194 |
|
}
|
195 |
|
}*/
|
|
209 |
//Obtenemos los valores de los intervalos
|
|
210 |
|
|
211 |
if(!values.equals("")){
|
|
212 |
String[] t1 = null;
|
|
213 |
t1 = values.split("\\,");
|
|
214 |
rangeTransparency = new int[t1.length][2];
|
|
215 |
for(int i=0;i<t1.length;i++){
|
|
216 |
if(t1[i].indexOf(":")==-1){
|
|
217 |
rangeTransparency[i][0] = rangeTransparency[i][1] = Integer.parseInt(t1[i]);
|
|
218 |
}else{
|
|
219 |
String[] t2 = null;
|
|
220 |
t2 = t1[i].split("\\:");
|
|
221 |
if(Integer.parseInt(t2[1])>Integer.parseInt(t2[0])){
|
|
222 |
rangeTransparency[i][0] = Integer.parseInt(t2[0]);
|
|
223 |
rangeTransparency[i][1] = Integer.parseInt(t2[1]);
|
|
224 |
}else{
|
|
225 |
rangeTransparency[i][0] = Integer.parseInt(t2[1]);
|
|
226 |
rangeTransparency[i][1] = Integer.parseInt(t2[0]);
|
|
227 |
}
|
|
228 |
}
|
|
229 |
if( rangeTransparency[i][0]<0 || rangeTransparency[i][0]>255 ||
|
|
230 |
rangeTransparency[i][1]<0 || rangeTransparency[i][1]>255){
|
|
231 |
System.err.println("Valores fuera de rango (0-255)");
|
|
232 |
throw new IOException();
|
|
233 |
}
|
|
234 |
}
|
|
235 |
|
|
236 |
for(int i=0;i<rangeTransparency.length;i++)
|
|
237 |
System.out.println("("+rangeTransparency[i][0]+":"+rangeTransparency[i][1]+")");
|
|
238 |
}
|
196 |
239 |
}
|
|
240 |
|
|
241 |
|
|
242 |
|
197 |
243 |
/**
|
198 |
244 |
* Controla que si el formato introducido en el textfield
|
199 |
245 |
* de opacidad es numerico se actualiza la posici?n del
|