Revision 11393
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/cutting/CuttingProcess.java | ||
---|---|---|
34 | 34 |
import org.gvsig.rastertools.cutting.ui.listener.CuttingPanelListener; |
35 | 35 |
|
36 | 36 |
/** |
37 |
* <code>CuttingProcess</code> es un proceso que usa un <code>Thread</code> |
|
38 |
* para calcular el recorte de una capa. |
|
37 | 39 |
* |
38 |
* |
|
39 | 40 |
* @version 24/04/2007 |
40 | 41 |
* @author Borja S?nchez Zamorano (borja.sanchez@iver.es) |
41 | 42 |
*/ |
42 | 43 |
public class CuttingProcess implements Runnable, IncrementableListener { |
43 |
// private GeoRasterWriter writer = null; |
|
44 | 44 |
private String fileName = ""; |
45 | 45 |
private IncrementableTask incrementableTask = null; |
46 | 46 |
private volatile Thread blinker = null; |
... | ... | |
53 | 53 |
private int[] dValues = null; |
54 | 54 |
|
55 | 55 |
/** |
56 |
* Constructor |
|
57 |
* @param vp ViewPortData |
|
58 |
* @param dimension Dimension |
|
59 |
* @param rast Objeto servidor de datos |
|
60 |
* @param fName Nombre del fichero de salida |
|
61 |
* @param params Par?metros del escritor |
|
62 |
*/ |
|
56 |
* Variables de la resoluci?n de salida |
|
57 |
*/ |
|
58 |
private int resolutionWidth = 0, resolutionHeight = 0; |
|
59 |
|
|
60 |
/** |
|
61 |
* Crea un <code>CuttingProcess</code> para generar un recorte |
|
62 |
* @param cuttingPanelListener |
|
63 |
* @param dValues |
|
64 |
* @param fileName |
|
65 |
* @param writerBufferServer |
|
66 |
* @param rasterMultiDataset |
|
67 |
* @param extent |
|
68 |
* @param drawableBands |
|
69 |
* @param oneLayerPerBand |
|
70 |
*/ |
|
63 | 71 |
public CuttingProcess(CuttingPanelListener cuttingPanelListener, int[] dValues, String fileName, WriterBufferServer writerBufferServer, RasterMultiDataset rasterMultiDataset, Extent extent, int[] drawableBands, boolean oneLayerPerBand) { |
64 | 72 |
this.fileName = fileName; |
65 | 73 |
this.writerBufferServer = writerBufferServer; |
... | ... | |
72 | 80 |
} |
73 | 81 |
|
74 | 82 |
/** |
75 |
* Arranca el proceso de salvado a raster
|
|
83 |
* Arranca el proceso de recorte de un layer
|
|
76 | 84 |
*/ |
77 | 85 |
public void start() { |
78 | 86 |
blinker = new Thread(this); |
... | ... | |
80 | 88 |
} |
81 | 89 |
|
82 | 90 |
/** |
83 |
* Detiene el proceso de salvado a raster |
|
91 |
* Establecer la resolucion de salida al crear el recorte |
|
92 |
* @param width |
|
93 |
* @param height |
|
84 | 94 |
*/ |
85 |
public synchronized void stop() {
|
|
86 |
blinker = null;
|
|
87 |
notify();
|
|
95 |
public void setResolution(int width, int height) {
|
|
96 |
resolutionWidth = width;
|
|
97 |
resolutionHeight = height;
|
|
88 | 98 |
} |
89 | 99 |
|
100 |
/** |
|
101 |
* Escribir el recorte en disco usando las bandas especificadas |
|
102 |
* @param file Ruta completa del fichero |
|
103 |
* @param bands Array de bandas que se quieren guardar en dicho fichero |
|
104 |
* @throws NotSupportedExtensionException |
|
105 |
* @throws RasterDriverException |
|
106 |
* @throws IOException |
|
107 |
*/ |
|
90 | 108 |
private void WriteFile(String file, int[] bands) |
91 | 109 |
throws NotSupportedExtensionException, RasterDriverException, IOException { |
92 | 110 |
|
93 | 111 |
BufferFactory bufferFactory = new BufferFactory(rasterMultiDataset); |
94 | 112 |
bufferFactory.addDrawableBands(bands); |
95 |
bufferFactory.setAreaOfInterest(dValues[0], dValues[3], dValues[2] - dValues[0], dValues[1] - dValues[3], (int) cuttingPanelListener.getCuttingPanel().getWidthText(), (int) cuttingPanelListener.getCuttingPanel().getHeightText());
|
|
113 |
bufferFactory.setAreaOfInterest(dValues[0], dValues[3], dValues[2] - dValues[0], dValues[1] - dValues[3], resolutionWidth, resolutionHeight);
|
|
96 | 114 |
|
97 | 115 |
IBuffer buffer = bufferFactory.getRasterBuf(); |
98 | 116 |
|
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/cutting/ui/CuttingPanel.java | ||
---|---|---|
67 | 67 |
|
68 | 68 |
private int wPanel = 420; |
69 | 69 |
|
70 |
private CuttingDialog cuttingDialog = null; |
|
71 |
|
|
70 | 72 |
private CoordDataInputContainer coor_pixel = null; |
71 | 73 |
private CoordDataInputContainer coor_reales = null; |
72 | 74 |
private ButtonBarContainer buttonBarContainer = null; |
73 | 75 |
private JPanel pSelection = null; |
76 |
private JPanel jOptions = null; |
|
77 |
private JPanel jPNameFile = null; |
|
74 | 78 |
private TableContainer tSelection = null; |
79 |
private ResolutionPanel pResolution = null; |
|
75 | 80 |
private JCheckBox jCheckBox = null; |
76 | 81 |
private JCheckBox jCheckLoadLayerInToc = null; |
77 | 82 |
private JCheckBox jCheckSaveFile = null; |
78 |
private ResolutionPanel pResolution = null; |
|
79 |
private CuttingDialog cuttingDialog = null; |
|
80 |
private JPanel jOptions = null; |
|
81 |
private JPanel jPNameFile = null; |
|
82 | 83 |
private JTextField filenameTextField = null; |
83 |
|
|
84 | 84 |
private JTabbedPane jTabbedPane1 = null; |
85 | 85 |
|
86 |
FLayer fLayer = null;
|
|
86 |
private FLayer fLayer = null;
|
|
87 | 87 |
|
88 | 88 |
/** |
89 |
* Variable para numerar las nuevos recortes creados. |
|
90 |
* @see #setNewLayerText() |
|
91 |
*/ |
|
92 |
static int numberNewLayer = 1; |
|
93 |
|
|
94 |
/** |
|
89 | 95 |
* Valores reales para el ancho, alto y tama?o de celda. Esto es necesario porque |
90 | 96 |
* en la caja de texto se guardan con decimales recortados y cuando se pide el valor |
91 | 97 |
* se devuelven completos. |
92 | 98 |
*/ |
93 |
private double realWidth, realHeight, realCellSize;
|
|
99 |
private double realWidth, realHeight;
|
|
94 | 100 |
|
95 | 101 |
/** |
96 | 102 |
* Relaci?n entre el ancho y alto en pixeles de la imagen |
97 | 103 |
*/ |
98 |
private double relWidthHeight = 0;
|
|
104 |
private double relWidthHeight = 0;
|
|
99 | 105 |
|
100 | 106 |
/** |
101 | 107 |
* Valores reales para el tama?o de la ventana. Esto es necesario porque |
... | ... | |
160 | 166 |
return cuttingDialog; |
161 | 167 |
} |
162 | 168 |
|
169 |
/** |
|
170 |
* Especificar el nombre de la nueva capa para el recuadro de texto, |
|
171 |
* incrementa tambi?n el contador de nuevos recortes. |
|
172 |
*/ |
|
173 |
public void setNewLayerText() { |
|
174 |
filenameTextField.setText("NewCutLayer_" + CuttingPanel.numberNewLayer); |
|
175 |
CuttingPanel.numberNewLayer++; |
|
176 |
} |
|
177 |
|
|
163 | 178 |
public FLayer getFLayer() { |
164 | 179 |
return fLayer; |
165 | 180 |
} |
... | ... | |
442 | 457 |
public JTextField getFilenameTextField() { |
443 | 458 |
if (filenameTextField == null) { |
444 | 459 |
filenameTextField = new JTextField(); |
445 |
filenameTextField.setText("cutlayer"); |
|
446 | 460 |
filenameTextField.setPreferredSize(new Dimension(150, filenameTextField.getPreferredSize().height)); |
447 | 461 |
} |
448 | 462 |
return filenameTextField; |
... | ... | |
513 | 527 |
* @param dec N?mero de decimales |
514 | 528 |
*/ |
515 | 529 |
public void setCellSizeText(double cellSize, int dec){ |
516 |
realCellSize = cellSize; |
|
517 | 530 |
getPResolution().setCellSizeText(cellSize, dec); |
518 | 531 |
} |
519 | 532 |
|
... | ... | |
674 | 687 |
return wcMinY; |
675 | 688 |
} |
676 | 689 |
|
677 |
/** |
|
678 |
* Asigna el valor inicial en ancho y alto de la ventana en pixeles . |
|
679 |
* @param w Ancho en pixeles |
|
680 |
* @param h Alto en pixeles |
|
681 |
*/ |
|
682 |
public void setInitValuesToSize(double w, double h){ |
|
683 |
cuttingPanelListener.setInitValuesToSize(w, h); |
|
684 |
} |
|
685 |
|
|
686 | 690 |
public MapControl getMapControl() { |
687 | 691 |
return mapControl; |
688 | 692 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/cutting/ui/listener/CuttingMouseViewListener.java | ||
---|---|---|
124 | 124 |
cuttingPanel.setHeightText(r.getHeight(), 0); |
125 | 125 |
cuttingPanel.setCellSizeText((rect.getWidth() / r.getWidth()), 4); |
126 | 126 |
cuttingPanel.setRelWidthHeight((double) (r.getWidth() / r.getHeight())); |
127 |
cuttingPanel.setInitValuesToSize(r.getWidth(), r.getHeight()); |
|
128 | 127 |
if (currentTool != null) |
129 | 128 |
mapControl.setTool(currentTool); |
130 | 129 |
} catch (NumberFormatException e) { |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/cutting/ui/listener/CuttingPanelListener.java | ||
---|---|---|
74 | 74 |
private int heightPx = 0; |
75 | 75 |
|
76 | 76 |
/** |
77 |
* Valores iniciales de ancho y alto en pixeles de la ventana. |
|
78 |
*/ |
|
79 |
private double initWidth=0, initHeight=0; |
|
80 |
|
|
81 |
/** |
|
82 | 77 |
* Recuerda la ?ltima ruta seleccionada por el usuario |
83 | 78 |
*/ |
84 | 79 |
private static String lastPath = "./"; |
... | ... | |
202 | 197 |
panel.setHeightText(r.getHeight(), 0); |
203 | 198 |
panel.setCellSizeText((extent.getWidth() / r.getWidth()), 4); |
204 | 199 |
panel.setRelWidthHeight((double) (r.getWidth() / r.getHeight())); |
205 |
setInitValuesToSize(r.getWidth(), r.getHeight()); |
|
206 | 200 |
return; |
207 | 201 |
} |
208 | 202 |
|
... | ... | |
306 | 300 |
panel.setHeightText(pxWindow.getHeight(), 0); |
307 | 301 |
panel.setCellSizeText((newWC.getWidth() / pxWindow.getWidth()), 4); |
308 | 302 |
panel.setRelWidthHeight((double)(pxWindow.getWidth() / pxWindow.getHeight())); |
309 |
setInitValuesToSize(pxWindow.getWidth(), pxWindow.getHeight()); |
|
310 | 303 |
} else { |
311 | 304 |
Rectangle2D mapWindow = getMapWindow(); |
312 | 305 |
if(mapWindow == null) |
... | ... | |
317 | 310 |
panel.setHeightText(newPx.getHeight(), 0); |
318 | 311 |
panel.setCellSizeText((mapWindow.getWidth() / newPx.getWidth()), 4); |
319 | 312 |
panel.setRelWidthHeight((double)(newPx.getWidth() / newPx.getHeight())); |
320 |
setInitValuesToSize(newPx.getWidth(), newPx.getHeight()); |
|
321 | 313 |
} |
322 |
|
|
323 | 314 |
} catch (NumberFormatException ex) { |
324 | 315 |
return; |
325 | 316 |
} |
326 | 317 |
} |
327 | 318 |
} |
328 | 319 |
|
329 |
/** |
|
330 |
* Asigna el valor inicial en ancho y alto de la ventana en pixeles . |
|
331 |
* @param w Ancho en pixeles |
|
332 |
* @param h Alto en pixeles |
|
333 |
*/ |
|
334 |
public void setInitValuesToSize(double w, double h){ |
|
335 |
initWidth = w; |
|
336 |
initHeight = h; |
|
337 |
} |
|
338 |
|
|
339 | 320 |
public void rectangle(RectangleEvent event) throws BehaviorException { |
340 | 321 |
} |
341 | 322 |
|
... | ... | |
365 | 346 |
// Bot?n de Aplicar |
366 | 347 |
if (e.getButton() == ButtonsPanel.BUTTON_APPLY) { |
367 | 348 |
accept(); |
368 |
// TODO: Cambiar el nombre del fichero
|
|
349 |
getCuttingPanel().setNewLayerText();
|
|
369 | 350 |
} |
370 | 351 |
|
371 | 352 |
// Bot?n de Cerrar |
... | ... | |
487 | 468 |
Extent extent = new Extent(minX, maxY, maxX, minY); |
488 | 469 |
|
489 | 470 |
CuttingProcess cuttingProcess = new CuttingProcess(this, dValues, filename, dataWriter1, rasterMultiDataset, extent, drawableBands, getCuttingPanel().getCbOneLyrPerBand().isSelected()); |
471 |
cuttingProcess.setResolution((int) getCuttingPanel().getWidthText(), (int) getCuttingPanel().getHeightText()); |
|
490 | 472 |
IncrementableTask incrementableTask = new IncrementableTask(dataWriter1); |
491 | 473 |
cuttingProcess.setIncrementableTask(incrementableTask); |
492 | 474 |
incrementableTask.showWindow(); |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/ui/HistogramPanel.java | ||
---|---|---|
400 | 400 |
list = null; |
401 | 401 |
} |
402 | 402 |
} catch (NotInitializeException e) { |
403 |
// TODO Auto-generated catch block |
|
404 | 403 |
e.printStackTrace(); |
405 | 404 |
} |
406 | 405 |
} |
Also available in: Unified diff