Revision 2229

View differences:

branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/RasterFilterStackManager.java
62 62
 * estos para que la ejecuci?n sea correcta. Un cliente que desee aplicar un 
63 63
 * filtro deber? introducirlo en la pila usando para ello esta clase.
64 64
 */
65
public class RasterFilterStackManager{
65
public class RasterFilterStackManager implements StackManager{
66 66
	
67 67
	protected RasterFilterStack	filterStack = null;
68 68
	private boolean				debug = false;
69 69
	
70 70
	protected Hashtable 		typeFilters = new Hashtable();
71 71
	public	int[]				order = null;
72
	private ArrayList			managers = new ArrayList();
73
	protected ArrayList			filterList = null;
72 74
	
73 75
	public RasterFilterStackManager(RasterFilterStack filterStack){
74 76
		this.filterStack = filterStack;
......
80 82
		this.filterStack.setOrder(order);
81 83
	}
82 84
	
85
	/**
86
	 * Registra un manager del sistema
87
	 * @param manager
88
	 */
89
	protected void register(StackManager manager){
90
		managers.add(manager);
91
	}
92
	
83 93
	protected void init(){
84 94
		order = new int[typeFilters.size()];
85 95
		order[0] = ((Integer)typeFilters.get("computeminmax")).intValue();
......
424 434
		return filterStack.getStats();
425 435
	}
426 436
	
427
	/**
428
	 * Convierte cada filtro o elemento de un filtro de la pila en un String de la forma
429
	 * elemento=valor
430
	 * @return ArrayList donde cada elemento es una cadena 
437

  
438
	/* (non-Javadoc)
439
	 * @see org.cresques.io.raster.StackManager#getStringsFromStack()
431 440
	 */
432 441
	public ArrayList getStringsFromStack(){
433
		ArrayList lista = new ArrayList();
442
		filterList = new ArrayList();
434 443
		for(int i=0;i<filterStack.lenght();i++){
435 444
			RasterFilter rf = filterStack.get(i);
436 445
			if(rf instanceof TransparencyFilter){
437
				lista.add("filter.transparency.active=true");
438
				lista.add("filter.transparency.rangeR="+rangeToString(((TransparencyFilter)rf).getRangeR()));
439
				lista.add("filter.transparency.rangeG="+rangeToString(((TransparencyFilter)rf).getRangeG()));
440
				lista.add("filter.transparency.rangeB="+rangeToString(((TransparencyFilter)rf).getRangeB()));
446
				filterList.add("filter.transparency.active=true");
447
				filterList.add("filter.transparency.rangeR="+rangeToString(((TransparencyFilter)rf).getRangeR()));
448
				filterList.add("filter.transparency.rangeG="+rangeToString(((TransparencyFilter)rf).getRangeG()));
449
				filterList.add("filter.transparency.rangeB="+rangeToString(((TransparencyFilter)rf).getRangeB()));
441 450
				
442 451
			}else if(rf instanceof LinearEnhancementFilter){
443
				lista.add("filter.enhanced.active=true");
444
				lista.add("filter.enhanced.remove="+((LinearEnhancementFilter)rf).getRemoveExtrema().toString());
452
				filterList.add("filter.enhanced.active=true");
453
				filterList.add("filter.enhanced.remove="+((LinearEnhancementFilter)rf).getRemoveExtrema().toString());
445 454
								
446 455
			}else if(rf instanceof ComputeMinMaxFilter){
447
				lista.add("filter.computeminmax.active=true");
456
				filterList.add("filter.computeminmax.active=true");
448 457
												
449 458
			}else if(rf instanceof PercentTailTrimFilter){
450
				lista.add("filter.tail.active=true");
451
				lista.add("filter.tail.value="+this.getStackStats().tailPercent);
452
				lista.add("filter.tail.remove="+((PercentTailTrimFilter)rf).removeMaxValue());
459
				filterList.add("filter.tail.active=true");
460
				filterList.add("filter.tail.value="+this.getStackStats().tailPercent);
461
				filterList.add("filter.tail.remove="+((PercentTailTrimFilter)rf).removeMaxValue());
462
			}else{ //Se recorren todos los managers registrados comprobando si corresponde a la clase del filtro 
463
				for(int j=0;j<managers.size();j++)
464
					((StackManager)managers.get(j)).getStringsFromStack();					
453 465
			}
454 466
		}
455
				
456
		return lista;
467
		return filterList;
457 468
	}
458 469
	
459 470
	/**
......
462 473
	 * @param filters 
463 474
	 */
464 475
	public void createStackFromStrings(ArrayList f){
476
		this.createStackFromStrings(f, new Integer(0));
477
	}
478

  
479
	/* (non-Javadoc)
480
	 * @see org.cresques.io.raster.StackManager#createStackFromStrings(java.util.ArrayList)
481
	 */
482
	public void createStackFromStrings(ArrayList f, Integer pos){
465 483
		ArrayList filters = (ArrayList)f.clone();
466 484
		filterStack.clear();
467
		int filteri = 0;
485
		int filteri = pos.intValue();
468 486
		
469 487
		//Busca un filtro activo y despu?s todas las propiedades que necesita ese filtro para
470 488
		//ser creado. Una vez las tiene a?ade en la pila el tipo de filtro.
......
534 552
				filteri = -1;
535 553
			}
536 554
			
555
			for(int j=0;j<managers.size();j++)
556
				((StackManager)managers.get(j)).createStackFromStrings(filters, new Integer(filteri));
557
			
537 558
			filteri++;
538 559
		}
539 560
	}
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/ComputeMinMaxFilter.java
52 52
			stats.maxBandValue[i] = max[i];
53 53
			stats.secondMinBandValue[i] = secondMin[i];
54 54
			stats.secondMaxBandValue[i] = secondMax[i];
55
			System.out.println("L60 ComputeMinMaxFilter "+min[i]+" "+secondMin[i]);
56
			System.out.println("L61 ComputeMinMaxFilter "+max[i]+" "+secondMax[i]);
57 55
		}
58 56
	}
59 57
		
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/StackManager.java
1
/*
2
 * Created on 21-jun-2005
3
 *
4
 * To change the template for this generated file go to
5
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;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 org.cresques.io.raster;
48

  
49
import java.util.ArrayList;
50

  
51
public interface StackManager{
52
	
53
	/**
54
	 * Convierte cada filtro o elemento de un filtro de la pila en un String de la forma
55
	 * elemento=valor
56
	 * @return ArrayList donde cada elemento es una cadena 
57
	 */
58
	public ArrayList getStringsFromStack();
59
	
60
	/**
61
	 * Crea una pila de filtros a partir de un Array de Strings. Cada elemento del array debe
62
	 * tener la forma elemento=valor. 
63
	 * @param filters 
64
	 */
65
	public void createStackFromStrings(ArrayList f, Integer pos);
66
	
67
}
0 68

  
branches/CqCMSDvp/libraries/libCq CMS for java.old/src-test/org/cresques/io/raster/PruebaStackManager.java
1 1
package org.cresques.io.raster;
2 2

  
3
public class PruebaStackManager extends RasterFilterStackManager{
3
import java.util.ArrayList;
4

  
5
import org.cresques.io.raster.PercentTailTrimFilter;
6

  
7
public class PruebaStackManager extends RasterFilterStackManager implements StackManager{
4 8
	
5 9
	public final static int		prueba = 4;
6 10
	
7 11
	public PruebaStackManager(RasterFilterStack filterStack){
8 12
		super(filterStack);
9 13
		addTypeFilter("prueba", PruebaStackManager.prueba, 3);
14
		super.register(this);
10 15
	}
11 16
	 
12 17
	/**
......
31 36
		return super.getType(rasterFilter);
32 37
	}
33 38
	
39
	public ArrayList getStringsFromStack(){
40
		if(rf instanceof PruebaFilter){
41
			filterList.add("filter.prueba.active=true");
42
		}
43
	}
44
	
45
	public void createStackFromStrings(ArrayList f, Integer pos){
46
		if(fil.startsWith("filter.prueba.active") && getValue(fil).equals("true")){
47
			filters.remove(pos.intValue());
48
			this.addPruebaFilter();
49
			filteri = -1;
50
		}
51
	}
52
	
34 53
}

Also available in: Unified diff