Revision 18362
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/regionalpha/filter/RegionAlphaDoubleFilter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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.regionalpha.filter; |
|
20 |
|
|
21 |
import java.awt.image.DataBuffer; |
|
22 |
/** |
|
23 |
* Clase vacia para que sepa que se puede instanciar este tipo de datos |
|
24 |
* @version 17/01/2008 |
|
25 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class RegionAlphaDoubleFilter extends RegionAlphaFilter { |
|
28 |
public int getInRasterDataType() {return DataBuffer.TYPE_DOUBLE;} |
|
29 |
public int getOutRasterDataType() { return DataBuffer.TYPE_DOUBLE;} |
|
30 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/regionalpha/filter/RegionAlphaIntegerFilter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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.regionalpha.filter; |
|
20 |
|
|
21 |
import java.awt.image.DataBuffer; |
|
22 |
/** |
|
23 |
* Clase vacia para que sepa que se puede instanciar este tipo de datos |
|
24 |
* @version 17/01/2008 |
|
25 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class RegionAlphaIntegerFilter extends RegionAlphaFilter { |
|
28 |
public int getInRasterDataType() {return DataBuffer.TYPE_INT;} |
|
29 |
public int getOutRasterDataType() { return DataBuffer.TYPE_INT;} |
|
30 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/regionalpha/filter/RegionAlphaFilter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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.regionalpha.filter; |
|
20 |
|
|
21 |
import java.awt.geom.Point2D; |
|
22 |
import java.util.ArrayList; |
|
23 |
|
|
24 |
import org.gvsig.raster.buffer.RasterBuffer; |
|
25 |
import org.gvsig.raster.dataset.IBuffer; |
|
26 |
import org.gvsig.raster.dataset.MultiRasterDataset; |
|
27 |
import org.gvsig.raster.dataset.Params; |
|
28 |
import org.gvsig.raster.grid.GridExtent; |
|
29 |
import org.gvsig.raster.grid.filter.RasterFilter; |
|
30 |
import org.gvsig.raster.grid.roi.ROI; |
|
31 |
import org.gvsig.raster.regionalpha.panel.RegionAlphaUI; |
|
32 |
|
|
33 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
34 |
/** |
|
35 |
* |
|
36 |
* @version 15/01/2008 |
|
37 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
38 |
*/ |
|
39 |
public class RegionAlphaFilter extends RasterFilter { |
|
40 |
public static String[] names = new String[] { "regionalpha" }; |
|
41 |
private RegionAlphaUI regionAlphaUI = null; |
|
42 |
private ArrayList rois = null; |
|
43 |
private IBuffer rasterAlpha = null; |
|
44 |
private int alpha = 255; |
|
45 |
|
|
46 |
/* Variables que hacen falta en el process */ |
|
47 |
private GridExtent gridExtent; |
|
48 |
private GridExtent windowExtent; |
|
49 |
private MultiRasterDataset dataset; |
|
50 |
|
|
51 |
/** |
|
52 |
* Constructor |
|
53 |
*/ |
|
54 |
public RegionAlphaFilter() { |
|
55 |
super(); |
|
56 |
setName(names[0]); |
|
57 |
} |
|
58 |
|
|
59 |
/* |
|
60 |
* (non-Javadoc) |
|
61 |
* @see org.gvsig.raster.grid.filter.RasterFilter#getGroup() |
|
62 |
*/ |
|
63 |
public String getGroup() { |
|
64 |
return "radiometricos"; |
|
65 |
} |
|
66 |
|
|
67 |
/* |
|
68 |
* (non-Javadoc) |
|
69 |
* @see org.gvsig.raster.grid.filter.RasterFilter#getNames() |
|
70 |
*/ |
|
71 |
public String[] getNames() { |
|
72 |
return names; |
|
73 |
} |
|
74 |
|
|
75 |
/* |
|
76 |
* (non-Javadoc) |
|
77 |
* @see org.gvsig.raster.grid.filter.RasterFilter#getResult(java.lang.String) |
|
78 |
*/ |
|
79 |
public Object getResult(String name) { |
|
80 |
if (!name.equals("raster")) |
|
81 |
return null; |
|
82 |
|
|
83 |
if (!exec) |
|
84 |
return (Object) this.raster; |
|
85 |
|
|
86 |
return (Object) this.rasterResult; |
|
87 |
} |
|
88 |
|
|
89 |
/* |
|
90 |
* (non-Javadoc) |
|
91 |
* @see org.gvsig.raster.grid.filter.RasterFilter#getUIParams(java.lang.String) |
|
92 |
*/ |
|
93 |
public Params getUIParams(String nameFilter) { |
|
94 |
Params params = new Params(); |
|
95 |
params.setParam("Panel", getRegionAlphaUI(), -1, null); |
|
96 |
params.setParam("FilterName", nameFilter, -1, null); |
|
97 |
params.setParam("Alpha", |
|
98 |
new Integer(alpha), |
|
99 |
Params.SLIDER, |
|
100 |
new String[]{ "0", "255", "0", "1", "25" }); //min, max, valor defecto, intervalo peque?o, intervalo grande; |
|
101 |
|
|
102 |
return params; |
|
103 |
} |
|
104 |
|
|
105 |
private RegionAlphaUI getRegionAlphaUI() { |
|
106 |
if (regionAlphaUI == null) { |
|
107 |
regionAlphaUI = new RegionAlphaUI(); |
|
108 |
FLayer raster = (FLayer) getEnv().get("initRaster"); |
|
109 |
regionAlphaUI.setLayer(raster); |
|
110 |
} |
|
111 |
return regionAlphaUI; |
|
112 |
} |
|
113 |
|
|
114 |
/* |
|
115 |
* (non-Javadoc) |
|
116 |
* @see org.gvsig.raster.grid.filter.RasterFilter#pre() |
|
117 |
*/ |
|
118 |
public void pre() { |
|
119 |
exec = true; |
|
120 |
raster = rasterResult; |
|
121 |
raster = (RasterBuffer) params.get("raster"); |
|
122 |
|
|
123 |
rois = (ArrayList) params.get("rois"); |
|
124 |
if (rois == null) |
|
125 |
rois = new ArrayList(); |
|
126 |
height = raster.getHeight(); |
|
127 |
width = raster.getWidth(); |
|
128 |
|
|
129 |
alpha = ((Integer) params.get("alpha")).intValue(); |
|
130 |
|
|
131 |
gridExtent = (GridExtent) environment.get("GridExtent"); |
|
132 |
windowExtent = (GridExtent) environment.get("WindowExtent"); |
|
133 |
dataset = (MultiRasterDataset) environment.get("MultiRasterDataset"); |
|
134 |
|
|
135 |
rasterAlpha = RasterBuffer.getBuffer(IBuffer.TYPE_BYTE, raster.getWidth(), raster.getHeight(), 1, true); |
|
136 |
} |
|
137 |
|
|
138 |
/* |
|
139 |
* (non-Javadoc) |
|
140 |
* @see org.gvsig.raster.grid.filter.RasterFilter#post() |
|
141 |
*/ |
|
142 |
public void post() { |
|
143 |
// En caso de que nadie apunte a raster, se liberara su memoria. |
|
144 |
mergeBufferTransparency(rasterAlpha); |
|
145 |
raster = null; |
|
146 |
} |
|
147 |
|
|
148 |
/* |
|
149 |
* (non-Javadoc) |
|
150 |
* @see org.gvsig.raster.grid.filter.RasterFilter#process(int, int) |
|
151 |
*/ |
|
152 |
public void process(int x, int y) { |
|
153 |
if ((windowExtent == null) || (gridExtent == null)) |
|
154 |
return; |
|
155 |
double newX = windowExtent.minX() + ((((double) x) * windowExtent.width()) / ((double) raster.getWidth())); |
|
156 |
double newY = windowExtent.minY() + ((( (double) (raster.getHeight() - (y + 1))) * windowExtent.height()) / ((double) raster.getHeight())); |
|
157 |
|
|
158 |
Point2D point2D = dataset.worldToRaster(new Point2D.Double(newX, newY)); |
|
159 |
newX = point2D.getX(); |
|
160 |
newY = point2D.getY(); |
|
161 |
|
|
162 |
for (int i = 0; i < rois.size(); i++) { |
|
163 |
if (((ROI) rois.get(i)).isInGrid((int) Math.floor(newX), (int) Math.floor(newY))) { |
|
164 |
rasterAlpha.setElem(y, x, 0, (byte) (255 - alpha)); |
|
165 |
return; |
|
166 |
} |
|
167 |
} |
|
168 |
rasterAlpha.setElem(y, x, 0, (byte) 255); |
|
169 |
} |
|
170 |
|
|
171 |
public int getInRasterDataType() {return 0;} |
|
172 |
public int getOutRasterDataType() {return 0;} |
|
173 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/regionalpha/filter/RegionAlphaShortFilter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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.regionalpha.filter; |
|
20 |
|
|
21 |
import java.awt.image.DataBuffer; |
|
22 |
/** |
|
23 |
* Clase vacia para que sepa que se puede instanciar este tipo de datos |
|
24 |
* @version 17/01/2008 |
|
25 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class RegionAlphaShortFilter extends RegionAlphaFilter { |
|
28 |
public int getInRasterDataType() {return DataBuffer.TYPE_SHORT;} |
|
29 |
public int getOutRasterDataType() { return DataBuffer.TYPE_SHORT;} |
|
30 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/regionalpha/filter/RegionAlphaListManager.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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.regionalpha.filter; |
|
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.raster.grid.filter.RegistrableFilterListener; |
|
30 |
import org.gvsig.raster.util.extensionPoints.ExtensionPoints; |
|
31 |
import org.gvsig.raster.util.extensionPoints.ExtensionPointsSingleton; |
|
32 |
|
|
33 |
public class RegionAlphaListManager implements IRasterFilterListManager { |
|
34 |
protected RasterFilterList filterList = null; |
|
35 |
|
|
36 |
/** |
|
37 |
* Constructor. Asigna la lista de filtros y el manager. |
|
38 |
* @param filterListManager |
|
39 |
*/ |
|
40 |
public RegionAlphaListManager(RasterFilterListManager filterListManager) { |
|
41 |
this.filterList = filterListManager.getFilterList(); |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* Registrar los manager en los puntos de extension |
|
46 |
*/ |
|
47 |
public static void register() { |
|
48 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
49 |
extensionPoints.add("RasterFilter", "RegionAlpha", RegionAlphaListManager.class); |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
public void addRegionAlphaFilter(ArrayList rois, int alpha) throws FilterTypeException { |
|
54 |
RasterFilter filter = new RegionAlphaByteFilter(); |
|
55 |
|
|
56 |
//Cuando el filtro esta creado, tomamos los valores y lo a?adimos a la pila |
|
57 |
if (filter != null) { |
|
58 |
filter.addParam("rois", rois); |
|
59 |
filter.addParam("alpha", Integer.valueOf(alpha)); |
|
60 |
filterList.add(filter); |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
/* |
|
65 |
* (non-Javadoc) |
|
66 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#getRasterFilterList() |
|
67 |
*/ |
|
68 |
public ArrayList getRasterFilterList() { |
|
69 |
ArrayList filters = new ArrayList(); |
|
70 |
filters.add(RegionAlphaFilter.class); |
|
71 |
return filters; |
|
72 |
} |
|
73 |
|
|
74 |
/* |
|
75 |
* (non-Javadoc) |
|
76 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#addFilter(java.lang.Class, org.gvsig.raster.dataset.Params) |
|
77 |
*/ |
|
78 |
public void addFilter(Class classFilter, Params params) throws FilterTypeException { |
|
79 |
if (classFilter.equals(RegionAlphaFilter.class)) { |
|
80 |
ArrayList rois = new ArrayList(); |
|
81 |
int alpha = 255; |
|
82 |
|
|
83 |
Params paramsUI = null; |
|
84 |
for (int i = 0; i < params.getNumParams(); i++) { |
|
85 |
if (params.getParam(i).id.equals("Panel") && |
|
86 |
params.getParam(i).defaultValue instanceof RegistrableFilterListener) { |
|
87 |
paramsUI = ((RegistrableFilterListener) params.getParam(i).defaultValue).getParams(); |
|
88 |
} |
|
89 |
if (params.getParam(i).id.equals("Alpha") && params.getParam(i).defaultValue instanceof Integer) { |
|
90 |
alpha = ((Integer) params.getParam(i).defaultValue).intValue(); |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
if (paramsUI != null) { |
|
95 |
for (int i = 0; i < paramsUI.getNumParams(); i++) { |
|
96 |
if (paramsUI.getParam(i).id.equals("rois")) |
|
97 |
rois = (ArrayList) paramsUI.getParam(i).defaultValue; |
|
98 |
} |
|
99 |
} |
|
100 |
addRegionAlphaFilter(rois, alpha); |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
/* |
|
105 |
* (non-Javadoc) |
|
106 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#createFilterListFromStrings(java.util.ArrayList, java.lang.String, int) |
|
107 |
*/ |
|
108 |
public int createFilterListFromStrings(ArrayList filters, String fil, int filteri) throws FilterTypeException { |
|
109 |
return filteri; |
|
110 |
} |
|
111 |
|
|
112 |
/* |
|
113 |
* (non-Javadoc) |
|
114 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#getStringsFromFilterList(java.util.ArrayList, org.gvsig.raster.grid.filter.RasterFilter) |
|
115 |
*/ |
|
116 |
public ArrayList getStringsFromFilterList(ArrayList filterList, RasterFilter rf) { |
|
117 |
return filterList; |
|
118 |
} |
|
119 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/regionalpha/filter/RegionAlphaByteFilter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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.regionalpha.filter; |
|
20 |
|
|
21 |
import java.awt.image.DataBuffer; |
|
22 |
/** |
|
23 |
* Clase vacia para que sepa que se puede instanciar este tipo de datos |
|
24 |
* @version 17/01/2008 |
|
25 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class RegionAlphaByteFilter extends RegionAlphaFilter { |
|
28 |
public int getInRasterDataType() {return DataBuffer.TYPE_BYTE;} |
|
29 |
public int getOutRasterDataType() { return DataBuffer.TYPE_BYTE;} |
|
30 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/regionalpha/filter/RegionAlphaFloatFilter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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.regionalpha.filter; |
|
20 |
|
|
21 |
import java.awt.image.DataBuffer; |
|
22 |
/** |
|
23 |
* Clase vacia para que sepa que se puede instanciar este tipo de datos |
|
24 |
* @version 17/01/2008 |
|
25 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class RegionAlphaFloatFilter extends RegionAlphaFilter { |
|
28 |
public int getInRasterDataType() {return DataBuffer.TYPE_FLOAT;} |
|
29 |
public int getOutRasterDataType() { return DataBuffer.TYPE_FLOAT;} |
|
30 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/regionalpha/panel/RegionAlphaUI.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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.regionalpha.panel; |
|
20 |
|
|
21 |
import java.awt.BorderLayout; |
|
22 |
import java.util.ArrayList; |
|
23 |
|
|
24 |
import javax.swing.event.TableModelEvent; |
|
25 |
import javax.swing.event.TableModelListener; |
|
26 |
|
|
27 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
|
28 |
import org.gvsig.gui.beans.table.TableContainer; |
|
29 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
30 |
import org.gvsig.raster.dataset.Params; |
|
31 |
import org.gvsig.raster.grid.filter.RegistrableFilterListener; |
|
32 |
import org.gvsig.raster.grid.roi.ROI; |
|
33 |
|
|
34 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
35 |
/** |
|
36 |
* |
|
37 |
* @version 17/01/2008 |
|
38 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
39 |
*/ |
|
40 |
public class RegionAlphaUI extends RegistrableFilterListener implements TableModelListener { |
|
41 |
private TableContainer tableContainer = null; |
|
42 |
private FLayer layer = null; |
|
43 |
|
|
44 |
public RegionAlphaUI() { |
|
45 |
initialize(); |
|
46 |
} |
|
47 |
|
|
48 |
private void initialize() { |
|
49 |
setLayout(new BorderLayout()); |
|
50 |
add(getTableContainer(), BorderLayout.CENTER); |
|
51 |
} |
|
52 |
|
|
53 |
private TableContainer getTableContainer() { |
|
54 |
if (tableContainer == null) { |
|
55 |
String[] columnNames = {" ", "Nombre", ""}; |
|
56 |
int[] columnWidths = {22, 334, 0}; |
|
57 |
tableContainer = new TableContainer(columnNames, columnWidths); |
|
58 |
tableContainer.setModel("CheckBoxModel"); |
|
59 |
tableContainer.initialize(); |
|
60 |
tableContainer.setControlVisible(false); |
|
61 |
tableContainer.setMoveRowsButtonsVisible(false); |
|
62 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(0).setMinWidth(22); |
|
63 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(0).setMaxWidth(22); |
|
64 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(2).setMinWidth(0); |
|
65 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(2).setMaxWidth(0); |
|
66 |
tableContainer.getModel().addTableModelListener(this); |
|
67 |
} |
|
68 |
return tableContainer; |
|
69 |
} |
|
70 |
|
|
71 |
public void setLayer(FLayer layer) { |
|
72 |
this.layer = layer; |
|
73 |
if (layer == null) |
|
74 |
return; |
|
75 |
ArrayList roisArray = ((FLyrRasterSE) layer).getRois(); |
|
76 |
if (roisArray != null) { |
|
77 |
for (int i = 0; i < roisArray.size(); i++) { |
|
78 |
ROI roi = (ROI) roisArray.get(i); |
|
79 |
|
|
80 |
Object row[] = {"", "", ""}; |
|
81 |
row[0] = new Boolean(false); |
|
82 |
row[1] = roi.getName(); |
|
83 |
row[2] = new Integer(i); |
|
84 |
try { |
|
85 |
getTableContainer().addRow(row); |
|
86 |
} catch (NotInitializeException e) { |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
private ArrayList getSelectedROIs() { |
|
93 |
if (layer == null) |
|
94 |
return null; |
|
95 |
|
|
96 |
ArrayList roisArray = ((FLyrRasterSE) layer).getRois(); |
|
97 |
ArrayList selected = new ArrayList(); |
|
98 |
if (roisArray != null) { |
|
99 |
for (int i = 0; i < roisArray.size(); i++) { |
|
100 |
if (((Boolean) tableContainer.getModel().getValueAt(i, 0)).booleanValue()) { |
|
101 |
selected.add(roisArray.get(i)); |
|
102 |
} |
|
103 |
} |
|
104 |
} |
|
105 |
return selected; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* Sobrecargamos el m?todo getParams para que siempre devuelva |
|
110 |
* algo. |
|
111 |
*/ |
|
112 |
public Params getParams() { |
|
113 |
params = new Params(); |
|
114 |
params.setParam("rois", |
|
115 |
getSelectedROIs(), |
|
116 |
-1, |
|
117 |
null); |
|
118 |
return params; |
|
119 |
} |
|
120 |
|
|
121 |
/* |
|
122 |
* (non-Javadoc) |
|
123 |
* @see javax.swing.event.TableModelListener#tableChanged(javax.swing.event.TableModelEvent) |
|
124 |
*/ |
|
125 |
public void tableChanged(TableModelEvent e) { |
|
126 |
callStateChanged(); |
|
127 |
} |
|
128 |
} |
Also available in: Unified diff