svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libRaster / src / org / gvsig / raster / grid / filter / bands / ColorBalanceCMYManager.java @ 26873
History | View | Annotate | Download (5.07 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.grid.filter.bands; |
20 |
|
21 |
import java.util.ArrayList; |
22 |
|
23 |
import org.gvsig.raster.dataset.Params; |
24 |
import org.gvsig.raster.grid.filter.FilterTypeException; |
25 |
import org.gvsig.raster.grid.filter.IRasterFilterListManager; |
26 |
import org.gvsig.raster.grid.filter.RasterFilter; |
27 |
import org.gvsig.raster.grid.filter.RasterFilterList; |
28 |
import org.gvsig.raster.grid.filter.RasterFilterListManager; |
29 |
import org.gvsig.tools.ToolsLocator; |
30 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
31 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
32 |
/**
|
33 |
* Gestor del filtro de balance de color
|
34 |
*
|
35 |
* @version 30/11/2007
|
36 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
37 |
*/
|
38 |
public class ColorBalanceCMYManager implements IRasterFilterListManager { |
39 |
protected RasterFilterList filterList = null; |
40 |
|
41 |
/**
|
42 |
* Registra ColorBalanceCMYManager en los puntos de extension de RasterFilter
|
43 |
*/
|
44 |
public static void register() { |
45 |
ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager(); |
46 |
ExtensionPoint point=extensionPoints.get("RasterFilter");
|
47 |
point.append("ColorBalanceCMY", "", ColorBalanceCMYManager.class); |
48 |
} |
49 |
|
50 |
/**
|
51 |
* Constructor.
|
52 |
* Asigna la lista de filtros y el managener global.
|
53 |
*
|
54 |
* @param filterListManager
|
55 |
*/
|
56 |
public ColorBalanceCMYManager(RasterFilterListManager filterListManager) {
|
57 |
this.filterList = filterListManager.getFilterList();
|
58 |
} |
59 |
|
60 |
/**
|
61 |
* A?ade un filtro de conversi?n de RGB a CMYK a la pila de filtros.
|
62 |
* @throws FilterTypeException
|
63 |
*/
|
64 |
public void addColorBalanceFilter(double cyan, double magenta, double yellow, boolean luminosity, int[] renderBands) throws FilterTypeException { |
65 |
RasterFilter filter = new ColorBalanceCMYByteFilter();
|
66 |
|
67 |
//Cuando el filtro esta creado, tomamos los valores y lo a?adimos a la pila
|
68 |
|
69 |
if (filter != null) { |
70 |
filter.addParam("cyan", new Double(cyan)); |
71 |
filter.addParam("magenta", new Double(magenta)); |
72 |
filter.addParam("yellow", new Double(yellow)); |
73 |
filter.addParam("luminosity", new Boolean(luminosity)); |
74 |
filter.addParam("renderBands", renderBands);
|
75 |
filterList.add(filter); |
76 |
} |
77 |
|
78 |
} |
79 |
|
80 |
/*
|
81 |
* (non-Javadoc)
|
82 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#getRasterFilterList()
|
83 |
*/
|
84 |
public ArrayList getRasterFilterList() { |
85 |
ArrayList filters = new ArrayList(); |
86 |
filters.add(ColorBalanceCMYFilter.class); |
87 |
return filters;
|
88 |
} |
89 |
|
90 |
/*
|
91 |
* (non-Javadoc)
|
92 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#addFilter(java.lang.Class, org.gvsig.raster.dataset.Params)
|
93 |
*/
|
94 |
public void addFilter(Class classFilter, Params params) throws FilterTypeException { |
95 |
if (classFilter.equals(ColorBalanceCMYFilter.class)) {
|
96 |
double cyan = 0, magenta = 0, yellow = 0; |
97 |
boolean luminosity = false; |
98 |
int[] renderBands = { 0, 1, 2 }; |
99 |
|
100 |
for (int i = 0; i < params.getNumParams(); i++) { |
101 |
if (params.getParam(i).id.equals("RenderBands") && |
102 |
params.getParam(i).defaultValue instanceof String) { |
103 |
String[] bands = new String((String) params.getParam(i).defaultValue).split(" "); |
104 |
renderBands[0] = new Integer(bands[0]).intValue(); |
105 |
renderBands[1] = new Integer(bands[1]).intValue(); |
106 |
renderBands[2] = new Integer(bands[2]).intValue(); |
107 |
continue;
|
108 |
} |
109 |
if (params.getParam(i).id.equals("cyan")) |
110 |
cyan = ((Double) params.getParam(i).defaultValue).doubleValue();
|
111 |
if (params.getParam(i).id.equals("magenta")) |
112 |
magenta = ((Double) params.getParam(i).defaultValue).doubleValue();
|
113 |
if (params.getParam(i).id.equals("yellow")) |
114 |
yellow = ((Double) params.getParam(i).defaultValue).doubleValue();
|
115 |
if (params.getParam(i).id.equals("luminosity")) |
116 |
luminosity = ((Boolean) params.getParam(i).defaultValue).booleanValue();
|
117 |
|
118 |
} |
119 |
addColorBalanceFilter(cyan, magenta, yellow, luminosity, renderBands); |
120 |
} |
121 |
} |
122 |
|
123 |
/*
|
124 |
* (non-Javadoc)
|
125 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#createFilterListFromStrings(java.util.ArrayList, java.lang.String, int)
|
126 |
*/
|
127 |
public int createFilterListFromStrings(ArrayList filters, String fil, int filteri) { |
128 |
return filteri;
|
129 |
} |
130 |
|
131 |
/*
|
132 |
* (non-Javadoc)
|
133 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#getStringsFromFilterList(java.util.ArrayList, org.gvsig.raster.grid.filter.RasterFilter)
|
134 |
*/
|
135 |
public ArrayList getStringsFromFilterList(ArrayList filterList, RasterFilter rf) { |
136 |
return filterList;
|
137 |
} |
138 |
} |