Revision 30184
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/util/process/ClippingProcess.java | ||
---|---|---|
19 | 19 |
package org.gvsig.raster.util.process; |
20 | 20 |
|
21 | 21 |
import java.awt.geom.AffineTransform; |
22 |
import java.awt.geom.Point2D; |
|
22 | 23 |
import java.io.File; |
23 | 24 |
import java.io.IOException; |
25 |
import java.util.ArrayList; |
|
24 | 26 |
|
27 |
import org.gvsig.fmap.raster.grid.roi.VectorialROI; |
|
25 | 28 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
26 | 29 |
import org.gvsig.raster.Configuration; |
27 | 30 |
import org.gvsig.raster.RasterProcess; |
... | ... | |
70 | 73 |
private String viewName = ""; |
71 | 74 |
private Params params = null; |
72 | 75 |
private DatasetColorInterpretation colorInterp = null; |
76 |
private ArrayList selectedRois = null; |
|
73 | 77 |
|
74 | 78 |
private double[] wcValues = null; |
75 | 79 |
|
... | ... | |
110 | 114 |
interpolationMethod = getIntParam("interpolationmethod"); |
111 | 115 |
affineTransform = (AffineTransform)getParam("affinetransform"); |
112 | 116 |
colorInterp = (DatasetColorInterpretation)getParam("colorInterpretation"); |
117 |
selectedRois = (ArrayList)getParam("selectedrois"); |
|
113 | 118 |
if(getIntArrayParam("resolution") != null) { |
114 | 119 |
resolutionWidth = getIntArrayParam("resolution")[0]; |
115 | 120 |
resolutionHeight = getIntArrayParam("resolution")[1]; |
... | ... | |
225 | 230 |
} |
226 | 231 |
//TODO: FUNCIONALIDAD: Poner los getWriter con la proyecci?n del fichero fuente |
227 | 232 |
|
233 |
|
|
234 |
if ((selectedRois != null) && (!bufferFactory.isReadOnly())){ |
|
235 |
int despX = 0; |
|
236 |
int despY = 0; |
|
237 |
if (pValues != null){ |
|
238 |
despX = pValues[0]; |
|
239 |
despY = pValues[1]; |
|
240 |
} else if (wcValues != null){ |
|
241 |
despX = (int)dsetCopy.worldToRaster(new Point2D.Double(wcValues[0], wcValues[1])).getX(); |
|
242 |
despY = (int)dsetCopy.worldToRaster(new Point2D.Double(wcValues[0], wcValues[1])).getY(); |
|
243 |
} |
|
244 |
drawOnlyROIs(buffer, selectedRois, despX, despY); |
|
245 |
} |
|
246 |
|
|
228 | 247 |
insertLineLog(RasterToolsUtil.getText(this, "salvando_imagen")); |
229 | 248 |
|
230 | 249 |
String finalFileName = ""; |
... | ... | |
317 | 336 |
} |
318 | 337 |
|
319 | 338 |
/** |
339 |
* Acciones para poner a NoData los pixels que est?n fuera de las |
|
340 |
* regiones de inter?s seleccionadas. |
|
341 |
* @param buffer |
|
342 |
*/ |
|
343 |
private void drawOnlyROIs(IBuffer buffer, ArrayList rois, int despX, int despY){ |
|
344 |
for (int i = 0 ; i<buffer.getWidth() ; i++){ |
|
345 |
for (int j = 0 ; j<buffer.getHeight() ; j++){ |
|
346 |
boolean inside = false; |
|
347 |
for (int k = 0 ; k<rois.size() ; k++){ |
|
348 |
VectorialROI roi = (VectorialROI)rois.get(k); |
|
349 |
//TODO: Hacer la comprobacion por coordenadas del mundo en lugar de coordenadas pixel. |
|
350 |
if (roi.isInGrid(i + despX, j + despY)){ |
|
351 |
inside = true; |
|
352 |
} |
|
353 |
} |
|
354 |
if (!inside){ |
|
355 |
for (int l = 0 ; l<buffer.getBandCount() ; l++){ |
|
356 |
try{ |
|
357 |
if (buffer.getDataType() == RasterBuffer.TYPE_BYTE){ |
|
358 |
buffer.setElem(j, i, l, buffer.getByteNoDataValue()); |
|
359 |
} else if (buffer.getDataType() == RasterBuffer.TYPE_DOUBLE){ |
|
360 |
buffer.setElem(j, i, l, buffer.getFloatNoDataValue()); |
|
361 |
} else if (buffer.getDataType() == RasterBuffer.TYPE_FLOAT){ |
|
362 |
buffer.setElem(j, i, l, buffer.getFloatNoDataValue()); |
|
363 |
} else if (buffer.getDataType() == RasterBuffer.TYPE_INT){ |
|
364 |
buffer.setElem(j, i, l, buffer.getIntNoDataValue()); |
|
365 |
} else if (buffer.getDataType() == RasterBuffer.TYPE_SHORT){ |
|
366 |
buffer.setElem(j, i, l, buffer.getShortNoDataValue()); |
|
367 |
} |
|
368 |
}catch (InterruptedException ex){ |
|
369 |
|
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
373 |
} |
|
374 |
} |
|
375 |
} |
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
/** |
|
320 | 380 |
* Acciones que se realizan al finalizar de crear los recortes de imagen. |
321 | 381 |
* Este m?todo es llamado por el thread TailRasterProcess al finalizar. |
322 | 382 |
*/ |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/vectorizacion/clip/ClipProcess.java | ||
---|---|---|
82 | 82 |
double h = Math.abs((data.getWCCoordinates()[1] - data.getWCCoordinates()[3]) / sourceLayer.getCellSize()); |
83 | 83 |
clippingProcess.addParam("resolution", new int[]{(int) (w * data.getScaleSelectedValue()), (int) (h * data.getScaleSelectedValue())}); |
84 | 84 |
clippingProcess.addParam("showenddialog", true); |
85 |
if (data.getSelectedROIs() != null){ |
|
86 |
clippingProcess.addParam("selectedrois", data.getSelectedROIs()); |
|
87 |
} |
|
85 | 88 |
clippingProcess.start(); |
86 | 89 |
} |
87 | 90 |
|
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/vectorizacion/clip/ClipListener.java | ||
---|---|---|
99 | 99 |
panel.getSelectionAreaPanel().getROI().addActionListener(this); |
100 | 100 |
panel.getSelectionAreaPanel().getButtonBarContainer().getButton(0).addActionListener(this); |
101 | 101 |
panel.getSelectionAreaPanel().getButtonBarContainer().getButton(1).addActionListener(this); |
102 |
panel.getSelectionAreaPanel().getROISelector().addActionListener(this); |
|
103 |
panel.getSelectionAreaPanel().getAreaSelector().addActionListener(this); |
|
104 |
panel.getSelectionAreaPanel().getVectorizeAllBBox().addActionListener(this); |
|
105 |
panel.getSelectionAreaPanel().getVectorizeOnlyInside().addActionListener(this); |
|
102 | 106 |
panel.getSelectionAreaPanel().getTableContainer().getModel().addTableModelListener(this); |
103 | 107 |
panel.getComboOutputScale().addActionListener(this); |
104 | 108 |
} |
... | ... | |
142 | 146 |
RasterToolsUtil.addWindow(roiManagerDialog); |
143 | 147 |
} |
144 | 148 |
|
149 |
if (e.getSource().equals(panel.getSelectionAreaPanel().getROISelector()) || |
|
150 |
e.getSource().equals(panel.getSelectionAreaPanel().getAreaSelector()) || |
|
151 |
e.getSource().equals(panel.getSelectionAreaPanel().getVectorizeAllBBox()) || |
|
152 |
e.getSource().equals(panel.getSelectionAreaPanel().getVectorizeOnlyInside())){ |
|
153 |
addROIs(); |
|
154 |
} |
|
155 |
|
|
145 | 156 |
//Cambio de escala |
146 | 157 |
if(e.getSource() == panel.getComboOutputScale()) { |
147 | 158 |
data.setScaleSelected(panel.getComboOutputScale().getSelectedIndex()); |
... | ... | |
333 | 344 |
} |
334 | 345 |
|
335 | 346 |
/** |
347 |
* A?ade o elimina el par?metro selectedrois en funci?n del estado de los |
|
348 |
* controles del panel |
|
349 |
*/ |
|
350 |
private void addROIs(){ |
|
351 |
if (panel.getSelectionAreaPanel().getAreaSelector().isSelected()){ |
|
352 |
data.setSelectedROIs(null); |
|
353 |
}else{ |
|
354 |
if(panel.getSelectionAreaPanel().getVectorizeOnlyInside().isSelected()){ |
|
355 |
data.setSelectedROIs(getSelectedROIs()); |
|
356 |
} else { |
|
357 |
data.setSelectedROIs(null); |
|
358 |
} |
|
359 |
} |
|
360 |
} |
|
361 |
|
|
362 |
|
|
363 |
/** |
|
336 | 364 |
* Gesti?n de eventos producidos en la tabla con la lista de ROIs |
337 | 365 |
* @param e |
338 | 366 |
*/ |
339 | 367 |
public void tableChanged(TableModelEvent e) { |
340 | 368 |
assignROISExtent(); |
369 |
addROIs(); |
|
341 | 370 |
} |
342 | 371 |
|
343 | 372 |
/* |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/vectorizacion/clip/ClipData.java | ||
---|---|---|
19 | 19 |
package org.gvsig.rastertools.vectorizacion.clip; |
20 | 20 |
|
21 | 21 |
import java.awt.geom.Point2D; |
22 |
import java.util.ArrayList; |
|
22 | 23 |
import java.util.Observable; |
23 | 24 |
|
24 | 25 |
/** |
... | ... | |
41 | 42 |
private Point2D lrWc = new Point2D.Double(); |
42 | 43 |
private Point2D ulPx = new Point2D.Double(); |
43 | 44 |
private Point2D lrPx = new Point2D.Double(); |
45 |
/** |
|
46 |
* Lista de rois seleccionadas |
|
47 |
*/ |
|
48 |
private ArrayList selectedrois = new ArrayList(); |
|
44 | 49 |
|
45 | 50 |
/** |
46 | 51 |
* Actualiza datos y llama al update de los observadores |
... | ... | |
155 | 160 |
} |
156 | 161 |
|
157 | 162 |
/** |
163 |
* Obtiene la lista de rois seleccionadas. |
|
164 |
* @return |
|
165 |
*/ |
|
166 |
public ArrayList getSelectedROIs() { |
|
167 |
return selectedrois; |
|
168 |
} |
|
169 |
|
|
170 |
/** |
|
158 | 171 |
* Asigna las coordenadas del mundo real a partir de n?meros en coma flotante. |
159 | 172 |
* @param minx coordenada m?nima de X |
160 | 173 |
* @param miny coordenada m?nima de Y |
... | ... | |
247 | 260 |
} |
248 | 261 |
|
249 | 262 |
/** |
263 |
* Asigna la lista de ROIs seleccionadas. |
|
264 |
* @param selrois |
|
265 |
*/ |
|
266 |
public void setSelectedROIs(ArrayList selrois){ |
|
267 |
selectedrois = selrois; |
|
268 |
} |
|
269 |
|
|
270 |
/** |
|
250 | 271 |
* Inicializa los valores a cero. Esto se hace cuando la selecci?n es fuera del ?rea. |
251 | 272 |
*/ |
252 | 273 |
public void setOutOfArea() { |
Also available in: Unified diff