Revision 12822 branches/v10/libraries/libCq_CMS_praster/src/org/cresques/ui/raster/listener/CutRasterListener.java
CutRasterListener.java | ||
---|---|---|
29 | 29 |
* Clase que instancia a esta y que implemente ITailRaster. |
30 | 30 |
*/ |
31 | 31 |
private ICutRaster parent = null; |
32 |
|
|
33 |
|
|
32 |
|
|
33 |
|
|
34 | 34 |
/** |
35 | 35 |
* Contructor |
36 | 36 |
* @param panel |
... | ... | |
41 | 41 |
this.widthPx = widthPx; |
42 | 42 |
this.heightPx = heightPx; |
43 | 43 |
this.parent = parent; |
44 |
|
|
44 |
|
|
45 | 45 |
panel.getPCoordPixel().getPDataInput11().getJTextField().addKeyListener(this); |
46 | 46 |
panel.getPCoordPixel().getPDataInput11().getJTextField().addFocusListener(this); |
47 | 47 |
panel.getPCoordPixel().getPDataInput12().getJTextField().addKeyListener(this); |
... | ... | |
50 | 50 |
panel.getPCoordPixel().getPDataInput21().getJTextField().addFocusListener(this); |
51 | 51 |
panel.getPCoordPixel().getPDataInput22().getJTextField().addKeyListener(this); |
52 | 52 |
panel.getPCoordPixel().getPDataInput22().getJTextField().addFocusListener(this); |
53 |
|
|
53 |
|
|
54 | 54 |
panel.getPCoordReal().getPDataInput11().getJTextField().addKeyListener(this); |
55 | 55 |
panel.getPCoordReal().getPDataInput11().getJTextField().addFocusListener(this); |
56 | 56 |
panel.getPCoordReal().getPDataInput12().getJTextField().addKeyListener(this); |
... | ... | |
59 | 59 |
panel.getPCoordReal().getPDataInput21().getJTextField().addFocusListener(this); |
60 | 60 |
panel.getPCoordReal().getPDataInput22().getJTextField().addKeyListener(this); |
61 | 61 |
panel.getPCoordReal().getPDataInput22().getJTextField().addFocusListener(this); |
62 |
|
|
62 |
|
|
63 | 63 |
panel.getPResolution().getCCellSize().getJTextField().addKeyListener(this); |
64 | 64 |
panel.getPResolution().getCCellSize().getJTextField().addFocusListener(this); |
65 | 65 |
panel.getPResolution().getCWidth().getJTextField().addKeyListener(this); |
66 | 66 |
panel.getPResolution().getCWidth().getJTextField().addFocusListener(this); |
67 | 67 |
panel.getPResolution().getCHeight().getJTextField().addKeyListener(this); |
68 | 68 |
panel.getPResolution().getCHeight().getJTextField().addFocusListener(this); |
69 |
|
|
69 |
|
|
70 | 70 |
panel.getPResize().getButton(0).addActionListener(this); |
71 | 71 |
panel.getPResize().getButton(1).addActionListener(this); |
72 | 72 |
panel.getPResize().getButton(2).addActionListener(this); |
73 | 73 |
} |
74 |
|
|
74 |
|
|
75 | 75 |
/** |
76 | 76 |
* Comprueba si todos los campos de coordenadas est?n llenos |
77 | 77 |
* @return true si todos los campos de coordenadas est?n llenos y false si hay alguno vacio. |
... | ... | |
88 | 88 |
return false; |
89 | 89 |
return true; |
90 | 90 |
} |
91 |
|
|
91 |
|
|
92 | 92 |
/** |
93 | 93 |
* Obtiene un rectangulo con la ventana en pixeles. Estos datos son leidos desde el interfaz. |
94 | 94 |
* @return Rectangle2D |
95 | 95 |
*/ |
96 |
private Rectangle2D getPxWindow(){
|
|
96 |
private Rectangle2D getPxWindow(){ |
|
97 | 97 |
if(panel.getPxMinX() == 0 && panel.getPxMinY() == 0 && panel.getPxMaxX() == 0 && panel.getPxMaxY() == 0) |
98 | 98 |
return null; |
99 | 99 |
return new Rectangle2D.Double(panel.getPxMinX(), panel.getPxMinY(), Math.abs(panel.getPxMaxX() - panel.getPxMinX()), Math.abs(panel.getPxMaxY() - panel.getPxMinY())); |
100 | 100 |
} |
101 |
|
|
101 |
|
|
102 | 102 |
/** |
103 | 103 |
* Obtiene un rectangulo con la ventana en coordenadas reales. Estos datos son leidos desde el interfaz. |
104 | 104 |
* @return Rectangle2D |
... | ... | |
108 | 108 |
return null; |
109 | 109 |
return new Rectangle2D.Double(panel.getWcMinX(), panel.getWcMaxY(), Math.abs(panel.getWcMaxX() - panel.getWcMinX()), Math.abs(panel.getWcMaxY() - panel.getWcMinY())); |
110 | 110 |
} |
111 |
|
|
111 |
|
|
112 | 112 |
/** |
113 | 113 |
* Recalcula el valor de los campos de coordenadas reales y pixel. Cuando modificamos alg?n campo |
114 | 114 |
* de las coordenadas reales se modifican los pixeles y viceversa. |
... | ... | |
119 | 119 |
if(isFieldsFill()){ |
120 | 120 |
try{ |
121 | 121 |
if(modifyPx){ |
122 |
Rectangle2D pxWindow = getPxWindow();
|
|
122 |
Rectangle2D pxWindow = getPxWindow(); |
|
123 | 123 |
if(pxWindow == null) |
124 | 124 |
return; |
125 | 125 |
Rectangle2D newWC = Utilities.getMapRectFromPxRect(extent, widthPx, heightPx, pxWindow); |
... | ... | |
141 | 141 |
panel.setRelWidthHeight((double)(newPx.getWidth() / newPx.getHeight())); |
142 | 142 |
parent.setInitValuesToSize(newPx.getWidth(), newPx.getHeight()); |
143 | 143 |
} |
144 |
|
|
144 |
|
|
145 | 145 |
}catch(NumberFormatException ex){ |
146 | 146 |
return; |
147 | 147 |
} |
148 | 148 |
} |
149 | 149 |
} |
150 | 150 |
|
151 |
|
|
151 |
|
|
152 | 152 |
public void actionPerformed(ActionEvent e) { |
153 | 153 |
//Bot?n de selecci?n del extent completo |
154 | 154 |
//Modificamos las coordenadas reales y recalculamos las coordenadas pixel |
155 | 155 |
if (e.getSource() == panel.getPResize().getButton(0)){ |
156 |
panel.setCoorRealFromDouble(extent.getMinX(), extent.getMaxY(), extent.getMaxX(), extent.getMinY(), 6); |
|
157 |
Rectangle2D r = org.cresques.util.Utilities.getPxRectFromMapRect(extent, widthPx, heightPx, extent); |
|
158 |
panel.setCoorPixelFromDouble(r.getMinX(), r.getMinY(), r.getMaxX(), r.getMaxY(), 3); |
|
159 |
panel.setWidthText(r.getWidth(), 0); |
|
160 |
panel.setHeightText(r.getHeight(), 0); |
|
161 |
panel.setCellSizeText((extent.getWidth() / r.getWidth()), 4); |
|
162 |
panel.setRelWidthHeight((double)(r.getWidth() / r.getHeight())); |
|
163 |
parent.setInitValuesToSize(r.getWidth(), r.getHeight()); |
|
156 |
panel.selectLayerFullExtend(); |
|
164 | 157 |
} |
165 |
|
|
158 |
|
|
166 | 159 |
//Bot?n de selecci?n de la herramienta de seleccionar desde la vista |
167 | 160 |
if (e.getSource() == panel.getPResize().getButton(1)){ |
168 | 161 |
parent.selectToolButton(); |
169 | 162 |
} |
170 |
|
|
163 |
|
|
171 | 164 |
//Bot?n de contraer y expandir el panel |
172 | 165 |
if (e.getSource() == panel.getPResize().getButton(2)) |
173 | 166 |
panel.contractExpandPanel(); |
... | ... | |
175 | 168 |
|
176 | 169 |
public void keyPressed(KeyEvent e) { |
177 | 170 |
// TODO Auto-generated method stub |
178 |
|
|
171 |
|
|
179 | 172 |
} |
180 | 173 |
|
181 | 174 |
/** |
182 | 175 |
* Al producirse un evento de perdida de foco o pulsaci?n de "enter" en un campo de texto de coordenadas |
183 |
* hay que asignar el nuevo valor introducido.
|
|
176 |
* hay que asignar el nuevo valor introducido. |
|
184 | 177 |
* @param obj |
185 | 178 |
*/ |
186 | 179 |
private void eventJTextField(Object obj){ |
187 | 180 |
try{ |
188 | 181 |
if( obj == panel.getPCoordPixel().getPDataInput11().getJTextField()) |
189 |
panel.setCoorPixelFromDouble(Double.valueOf(panel.getPCoordPixel().getPDataInput11().getJTextField().getText()).doubleValue(),
|
|
182 |
panel.setCoorPixelFromDouble(Double.valueOf(panel.getPCoordPixel().getPDataInput11().getJTextField().getText()).doubleValue(), |
|
190 | 183 |
panel.getPxMinY(), panel.getPxMaxX(), panel.getPxMaxY(), 3); |
191 | 184 |
if( obj == panel.getPCoordPixel().getPDataInput12().getJTextField()) |
192 |
panel.setCoorPixelFromDouble(panel.getPxMinX(), Double.valueOf(panel.getPCoordPixel().getPDataInput12().getJTextField().getText()).doubleValue(),
|
|
185 |
panel.setCoorPixelFromDouble(panel.getPxMinX(), Double.valueOf(panel.getPCoordPixel().getPDataInput12().getJTextField().getText()).doubleValue(), |
|
193 | 186 |
panel.getPxMaxX(), panel.getPxMaxY(), 3); |
194 | 187 |
if( obj == panel.getPCoordPixel().getPDataInput21().getJTextField()) |
195 | 188 |
panel.setCoorPixelFromDouble(panel.getPxMinX(), panel.getPxMinY(), |
... | ... | |
197 | 190 |
if( obj == panel.getPCoordPixel().getPDataInput22().getJTextField()) |
198 | 191 |
panel.setCoorPixelFromDouble(panel.getPxMinX(), panel.getPxMinY(), |
199 | 192 |
panel.getPxMaxX(), Double.valueOf(panel.getPCoordPixel().getPDataInput22().getJTextField().getText()).doubleValue(), 3); |
200 |
|
|
193 |
|
|
201 | 194 |
if( obj == panel.getPCoordReal().getPDataInput11().getJTextField()) |
202 |
panel.setCoorRealFromDouble(Double.valueOf(panel.getPCoordReal().getPDataInput11().getJTextField().getText()).doubleValue(),
|
|
195 |
panel.setCoorRealFromDouble(Double.valueOf(panel.getPCoordReal().getPDataInput11().getJTextField().getText()).doubleValue(), |
|
203 | 196 |
panel.getWcMinY(), panel.getWcMaxX(), panel.getWcMaxY(), 6); |
204 | 197 |
if( obj == panel.getPCoordReal().getPDataInput12().getJTextField()) |
205 |
panel.setCoorRealFromDouble(panel.getWcMinX(), Double.valueOf(panel.getPCoordReal().getPDataInput12().getJTextField().getText()).doubleValue(),
|
|
198 |
panel.setCoorRealFromDouble(panel.getWcMinX(), Double.valueOf(panel.getPCoordReal().getPDataInput12().getJTextField().getText()).doubleValue(), |
|
206 | 199 |
panel.getWcMaxX(), panel.getWcMaxY(), 6); |
207 | 200 |
if( obj == panel.getPCoordReal().getPDataInput21().getJTextField()) |
208 | 201 |
panel.setCoorRealFromDouble(panel.getWcMinX(), panel.getWcMinY(), |
... | ... | |
214 | 207 |
//No hay valores parseables a decimal en las cajas de texto. No hacemos nada |
215 | 208 |
} |
216 | 209 |
} |
217 |
|
|
210 |
|
|
218 | 211 |
/** |
219 | 212 |
* Cuando se presiona la tecla enter sobre los campos de texto se recalculan las |
220 | 213 |
* coordenadas. Si se ha presionado sobre los cuadro correspondientes a las coordenadas |
... | ... | |
251 | 244 |
panel.setWidthText(mapWindow.getWidth() / ps, 0); |
252 | 245 |
panel.setHeightText((mapWindow.getWidth() / ps) / panel.getRelWidthHeight(), 0); |
253 | 246 |
} |
254 |
|
|
247 |
|
|
255 | 248 |
if(e.getSource() == panel.getPResolution().getCWidth().getJTextField()){ |
256 | 249 |
//Cambiamos wPx ==> hPx=wPx/rel & PS=wWC/wPx |
257 | 250 |
double wPx = 0; |
... | ... | |
268 | 261 |
panel.setHeightText(wPx / panel.getRelWidthHeight(), 0); |
269 | 262 |
panel.setCellSizeText((mapWindow.getWidth() / wPx), 4); |
270 | 263 |
} |
271 |
|
|
264 |
|
|
272 | 265 |
if(e.getSource() == panel.getPResolution().getCHeight().getJTextField()){ |
273 |
//Cambiamos hPx ==> wPx=rel*wPx & PS=hWC/hPx
|
|
266 |
//Cambiamos hPx ==> wPx=rel*wPx & PS=hWC/hPx |
|
274 | 267 |
double hPx = 0; |
275 | 268 |
try{ |
276 | 269 |
hPx = Double.parseDouble(panel.getPResolution().getCHeight().getJTextField().getText()); |
... | ... | |
294 | 287 |
|
295 | 288 |
public void focusGained(FocusEvent e) { |
296 | 289 |
// TODO Auto-generated method stub |
297 |
|
|
290 |
|
|
298 | 291 |
} |
299 | 292 |
|
300 | 293 |
/** |
... | ... | |
318 | 311 |
recalcCoordFields(false); |
319 | 312 |
} |
320 | 313 |
} |
321 |
|
|
322 |
|
|
314 |
|
|
315 |
|
|
323 | 316 |
} |
Also available in: Unified diff