Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libRaster / src / org / gvsig / raster / grid / filter / histogramMatching / HistogramMatchingListManager.java @ 26873

History | View | Annotate | Download (5.52 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Instituto de Desarrollo Regional 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
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Iba?ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
34
 *   Campus Universitario s/n
35
 *   02071 Alabacete
36
 *   Spain
37
 *
38
 *   +34 967 599 200
39
 */
40

    
41
package org.gvsig.raster.grid.filter.histogramMatching;
42

    
43
import java.util.ArrayList;
44

    
45
import org.gvsig.raster.dataset.IRasterDataSource;
46
import org.gvsig.raster.dataset.Params;
47
import org.gvsig.raster.datastruct.Histogram;
48
import org.gvsig.raster.grid.filter.FilterTypeException;
49
import org.gvsig.raster.grid.filter.IRasterFilterListManager;
50
import org.gvsig.raster.grid.filter.RasterFilter;
51
import org.gvsig.raster.grid.filter.RasterFilterList;
52
import org.gvsig.raster.grid.filter.RasterFilterListManager;
53
import org.gvsig.tools.ToolsLocator;
54
import org.gvsig.tools.extensionpoint.ExtensionPoint;
55
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
56

    
57
/**
58
 * Gestion  de la lista de filtros para el filtro de tipo HistogramMatchig
59
 *
60
 * @author aMu?oz (alejandro.munoz@uclm.es)
61
 * @version 27-05-2008
62
 *
63
 * */
64
public class HistogramMatchingListManager implements IRasterFilterListManager{
65

    
66
        protected RasterFilterList                        filterList                                = null;
67

    
68
        // Constructor
69
        public HistogramMatchingListManager(RasterFilterListManager filterListManager){
70
                this.filterList = filterListManager.getFilterList();
71
        }
72

    
73
        /** Metodo de registro del filtro */
74
        public static void register() {
75
                ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager();
76
                ExtensionPoint point=extensionPoints.get("RasterFilter");
77
                point.append("Matching", "", HistogramMatchingListManager.class);
78
        }
79

    
80

    
81
        public void addFilter(Class classFilter, Params params) throws FilterTypeException {
82
                if (classFilter.equals(HistogramMatchingFilter.class)) {
83
                        String fileNameOutput=null;
84
                        IRasterDataSource raster=null;
85
                        int numbands=0;
86
                        Histogram histogramReference                = null;
87
                        for (int i = 0; i < params.getNumParams(); i++) {
88
                                if (params.getParam(i).id.equals("raster"))
89
                                        raster = (IRasterDataSource)(params.getParam(i).defaultValue);
90
                                if (params.getParam(i).id.equals("numbands"))
91
                                        numbands = ((Integer)(params.getParam(i).defaultValue)).intValue();
92
                                if (params.getParam(i).id.equals("histogramReference"))
93
                                        histogramReference = (Histogram)(params.getParam(i).defaultValue);
94
                                if (params.getParam(i).id.equals("fileNameOutput"))
95
                                        fileNameOutput= new String((String) params.getParam(i).defaultValue);
96
                        }
97
                        addHistogramMatchingFilter(raster,numbands,histogramReference,fileNameOutput);
98
                }
99
        }
100

    
101
        /**
102
         * A?ade un filtro HistogramMatching a la pila de filtros.
103
         * @param histogramReference Histograma de referencia al que ajustar el raster
104
         * @param fileNameOutput fichero de salida
105
         * @throws FilterTypeException
106
         */
107
        public void addHistogramMatchingFilter(IRasterDataSource raster,int numbands,Histogram histogramReference,String fileNameOutput) throws FilterTypeException {
108
                RasterFilter filter = new HistogramMatchingByteFilter();
109
                if (filter != null){
110
                        filter.addParam("raster", raster);
111
                        filter.addParam("histogramReference", histogramReference);
112
                        filter.addParam("numbands",new Integer(numbands));
113
                        filter.addParam("fileNameOutput",fileNameOutput);
114
                        filterList.add(filter);
115
                }
116
        }
117

    
118

    
119
        public int createFilterListFromStrings(ArrayList filters, String fil, int filteri) {
120
                return filteri;
121
        }
122

    
123

    
124
        /**
125
         * Obtiene un Array de Strings a partir de una pila de filtros. Cada elemento
126
         * del array tendr? la forma de elemento=valor.
127
         */
128
        public ArrayList getStringsFromFilterList(ArrayList filterList, RasterFilter rf) {
129

    
130
                if (rf instanceof HistogramMatchingFilter) {
131
                        HistogramMatchingFilter histogramMatchingFilter = (HistogramMatchingFilter) rf;
132
                        filterList.add("filter.histogramMatch.active=true");
133
                        filterList.add("filter.histogramMatch.histogramReference="+histogramMatchingFilter.histogramReference);
134
                        filterList.add("filter.histogramMatch.numbands="+histogramMatchingFilter.numbands);
135
                        filterList.add("filter.histogramMatch.filenameOutput="+histogramMatchingFilter.fileNameOutput);
136
                        filterList.add("filter.histogramMatch.filterName=" + histogramMatchingFilter.getName());
137
                }
138

    
139
                return filterList;
140
        }
141

    
142
        /*
143
         * (non-Javadoc)
144
         * @see org.gvsig.raster.grid.filter.IRasterFilterListManager#getRasterFilterList()
145
         */
146
        public ArrayList getRasterFilterList() {
147
                ArrayList filters = new ArrayList();
148
                filters.add(HistogramMatchingFilter.class);
149
                return filters;
150
        }
151

    
152
        public static RasterFilter createHistogramMatchFilter() {
153
                RasterFilter filter = new HistogramMatchingFilter();
154
                return filter;
155
        }
156
}