root / tags / v1_1_Build_1004 / libraries / libCq_CMS_praster / src / org / cresques / ui / raster / CutRasterPanel.java @ 12319
History | View | Annotate | Download (21.2 KB)
1 | 8026 | nacho | /*
|
---|---|---|---|
2 | * Created on 22-ago-2006
|
||
3 | *
|
||
4 | */
|
||
5 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
6 | *
|
||
7 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
8 | *
|
||
9 | * This program is free software; you can redistribute it and/or
|
||
10 | * modify it under the terms of the GNU General Public License
|
||
11 | * as published by the Free Software Foundation; either version 2
|
||
12 | * of the License, or (at your option) any later version.
|
||
13 | *
|
||
14 | * This program is distributed in the hope that it will be useful,
|
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
17 | * GNU General Public License for more details.
|
||
18 | *
|
||
19 | * You should have received a copy of the GNU General Public License
|
||
20 | * along with this program; if not, write to the Free Software
|
||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
22 | */
|
||
23 | package org.cresques.ui.raster; |
||
24 | |||
25 | import java.awt.BorderLayout; |
||
26 | import java.awt.FlowLayout; |
||
27 | import java.awt.GridBagConstraints; |
||
28 | import java.awt.GridBagLayout; |
||
29 | import java.awt.geom.Rectangle2D; |
||
30 | |||
31 | import javax.swing.ImageIcon; |
||
32 | import javax.swing.JButton; |
||
33 | import javax.swing.JCheckBox; |
||
34 | import javax.swing.JLabel; |
||
35 | import javax.swing.JPanel; |
||
36 | |||
37 | import org.cresques.io.data.ICutRaster; |
||
38 | import org.cresques.ui.raster.listener.CutRasterListener; |
||
39 | import org.gvsig.gui.beans.buttonBar.ButtonBarContainer; |
||
40 | import org.gvsig.gui.beans.coordDataInput.CoordDataInputContainer; |
||
41 | import org.gvsig.gui.beans.table.TableContainer; |
||
42 | import org.gvsig.i18n.Messages; |
||
43 | import java.awt.Dimension; |
||
44 | |||
45 | public class CutRasterPanel extends BaseComponent{ |
||
46 | |||
47 | private int wPanel = 420, hPanel = 534; |
||
48 | private int wComp = wPanel - 6, hComp = hPanel - 40; |
||
49 | private int wTable = wComp - 10; |
||
50 | private int hTable = hComp - 370 ; |
||
51 | |||
52 | private JPanel pTailImage = null; |
||
53 | private CoordDataInputContainer pCoordPixel = null; |
||
54 | private CoordDataInputContainer pCoordReal = null; |
||
55 | private ButtonBarContainer pResize = null; |
||
56 | private JButton jButton = null; |
||
57 | |||
58 | private ResolutionPanel pResolution = null; |
||
59 | |||
60 | private JPanel pSelection = null; |
||
61 | private TableContainer tSelection = null; |
||
62 | private String[] columnNames = {Messages.getText("bandas"), Messages.getText("nombre")}; |
||
63 | private int[] columnWidths = {75, 305}; |
||
64 | private boolean contract = true; |
||
65 | |||
66 | private JPanel pCheck = null; |
||
67 | private JCheckBox jCheckBox = null; |
||
68 | private JLabel jLabel = null; |
||
69 | private JPanel pButtons = null; |
||
70 | private JPanel pAccept = null; |
||
71 | private JButton bSave = null; |
||
72 | private JButton bAccept = null; |
||
73 | private JButton bCancel = null; |
||
74 | private JPanel pBorder = null; |
||
75 | private CutRasterListener tailImageListener = null; |
||
76 | /**
|
||
77 | * Valores reales para el ancho, alto y tama?o de celda. Esto es necesario porque
|
||
78 | * en la caja de texto se guardan con decimales recortados y cuando se pide el valor
|
||
79 | * se devuelven completos.
|
||
80 | */
|
||
81 | private double realWidth, realHeight, realCellSize; |
||
82 | /**
|
||
83 | * Relaci?n entre el ancho y alto en pixeles de la imagen
|
||
84 | */
|
||
85 | private double relWidthHeight = 0; |
||
86 | /**
|
||
87 | * Clase que instancia a esta y que implemente ITailRaster.
|
||
88 | */
|
||
89 | private ICutRaster parent = null; |
||
90 | |||
91 | /**
|
||
92 | * Valores reales para el tama?o de la ventana. Esto es necesario porque
|
||
93 | * en la caja de texto se guardan con decimales recortados y cuando se pide el valor
|
||
94 | * se devuelven completos.
|
||
95 | */
|
||
96 | private double wcMinX, wcMinY, wcMaxX, wcMaxY; |
||
97 | private double pxMinX, pxMinY, pxMaxX, pxMaxY; |
||
98 | |||
99 | |||
100 | |||
101 | /**
|
||
102 | * This is the default constructor
|
||
103 | */
|
||
104 | public CutRasterPanel(Rectangle2D extent, int widthPx, int heightPx, ICutRaster parent) { |
||
105 | super();
|
||
106 | this.parent = parent;
|
||
107 | initialize(); |
||
108 | tailImageListener = new CutRasterListener(this, extent, widthPx, heightPx, parent); |
||
109 | } |
||
110 | |||
111 | /**
|
||
112 | * This method initializes this
|
||
113 | *
|
||
114 | * @return void
|
||
115 | */
|
||
116 | private void initialize() { |
||
117 | FlowLayout flowLayout = new FlowLayout(); |
||
118 | flowLayout.setHgap(0);
|
||
119 | flowLayout.setVgap(0);
|
||
120 | this.setLayout(flowLayout);
|
||
121 | this.add(getPTailImage(), null); |
||
122 | this.setSize(wPanel, hPanel);
|
||
123 | if(contract){
|
||
124 | this.getPResolution().setVisible(false); |
||
125 | this.getPSelection().setVisible(false); |
||
126 | this.getPCheck().setVisible(false); |
||
127 | this.setSize(wPanel, hPanel - hTable - 120 - 30); |
||
128 | this.getPTailImage().setPreferredSize(new java.awt.Dimension(wPanel, hPanel - hTable - 120 - 30)); |
||
129 | this.getPBorder().setSize(wComp, hComp - hTable - 120 - 30); |
||
130 | this.getPBorder().setPreferredSize(new java.awt.Dimension(wComp, hComp - hTable - 120 - 30)); |
||
131 | } |
||
132 | } |
||
133 | |||
134 | /**
|
||
135 | * This method initializes jPanel
|
||
136 | *
|
||
137 | * @return javax.swing.JPanel
|
||
138 | */
|
||
139 | private JPanel getPTailImage() { |
||
140 | if (pTailImage == null) { |
||
141 | GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); |
||
142 | gridBagConstraints5.gridx = 0;
|
||
143 | gridBagConstraints5.gridy = 0;
|
||
144 | GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); |
||
145 | gridBagConstraints8.gridx = 0;
|
||
146 | gridBagConstraints8.gridy = 6;
|
||
147 | GridBagConstraints gridBagConstraints7 = new GridBagConstraints(); |
||
148 | gridBagConstraints7.gridx = 0;
|
||
149 | gridBagConstraints7.gridy = 6;
|
||
150 | pTailImage = new JPanel(); |
||
151 | pTailImage.setLayout(new GridBagLayout()); |
||
152 | pTailImage.setPreferredSize(new java.awt.Dimension(wPanel,hPanel));
|
||
153 | pTailImage.add(getPButtons(), gridBagConstraints8); |
||
154 | pTailImage.add(getPBorder(), gridBagConstraints5); |
||
155 | } |
||
156 | return pTailImage;
|
||
157 | } |
||
158 | |||
159 | /**
|
||
160 | * This method initializes jPanel
|
||
161 | *
|
||
162 | * @return javax.swing.JPanel
|
||
163 | */
|
||
164 | public CoordDataInputContainer getPCoordPixel() {
|
||
165 | if (pCoordPixel == null) { |
||
166 | pCoordPixel = new CoordDataInputContainer(wTable, 90); |
||
167 | pCoordPixel.setParameters(Messages.getText("coordenadas_pixel"),
|
||
168 | Messages.getText("sup_izq"),
|
||
169 | "X" ,"Y", |
||
170 | Messages.getText("inf_der"),
|
||
171 | "X", "Y"); |
||
172 | pCoordPixel.setDecimalValues(true);
|
||
173 | } |
||
174 | return pCoordPixel;
|
||
175 | } |
||
176 | |||
177 | /**
|
||
178 | * This method initializes jPanel1
|
||
179 | *
|
||
180 | * @return javax.swing.JPanel
|
||
181 | */
|
||
182 | public CoordDataInputContainer getPCoordReal() {
|
||
183 | if (pCoordReal == null) { |
||
184 | pCoordReal = new CoordDataInputContainer(wTable, 90); |
||
185 | pCoordReal.setParameters(Messages.getText("coordenadas_reales"),
|
||
186 | Messages.getText("sup_izq"),
|
||
187 | "X" ,"Y", |
||
188 | Messages.getText("inf_der"),
|
||
189 | "X", "Y"); |
||
190 | pCoordReal.setDecimalValues(true);
|
||
191 | } |
||
192 | return pCoordReal;
|
||
193 | } |
||
194 | |||
195 | /**
|
||
196 | * This method initializes jPanel
|
||
197 | *
|
||
198 | * @return javax.swing.JPanel
|
||
199 | */
|
||
200 | public ButtonBarContainer getPResize() {
|
||
201 | if (pResize == null) { |
||
202 | pResize = new ButtonBarContainer();
|
||
203 | pResize.setPreferredSize(new java.awt.Dimension(wTable - 4, 32)); |
||
204 | pResize.addButton("fullExtent.png", Messages.getText("fullExtent"), 0); |
||
205 | pResize.addButton("selectTool.png", Messages.getText("select_tool"), 1); |
||
206 | pResize.addButton("down.png", Messages.getText("expandir"), 2); |
||
207 | pResize.setButtonAlignment("right");
|
||
208 | pResize.setComponentBorder(true);
|
||
209 | |||
210 | } |
||
211 | return pResize;
|
||
212 | } |
||
213 | |||
214 | |||
215 | /**
|
||
216 | * This method initializes jPanel
|
||
217 | *
|
||
218 | * @return javax.swing.JPanel
|
||
219 | */
|
||
220 | public ResolutionPanel getPResolution() {
|
||
221 | if (pResolution == null) { |
||
222 | pResolution = new ResolutionPanel();
|
||
223 | pResolution.setPreferredSize(new java.awt.Dimension(wTable,120)); |
||
224 | pResolution.setComponentSize(wTable,120);
|
||
225 | } |
||
226 | return pResolution;
|
||
227 | } |
||
228 | |||
229 | /**
|
||
230 | * This method initializes jPanel1
|
||
231 | *
|
||
232 | * @return javax.swing.JPanel
|
||
233 | */
|
||
234 | private JPanel getPSelection() { |
||
235 | if (pSelection == null) { |
||
236 | pSelection = new JPanel(); |
||
237 | pSelection.setLayout(new FlowLayout()); |
||
238 | pSelection.setPreferredSize(new java.awt.Dimension(wTable,hTable));
|
||
239 | pSelection.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Messages.getText("seleccion_bandas"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10), null)); |
||
240 | pSelection.add(getTSelection(), null);
|
||
241 | |||
242 | } |
||
243 | return pSelection;
|
||
244 | } |
||
245 | |||
246 | /**
|
||
247 | * Obtiene la tabla de selecci?n de bandas
|
||
248 | * @return Tabla de selecci?n de bandas
|
||
249 | */
|
||
250 | public TableContainer getTSelection(){
|
||
251 | if (tSelection == null) { |
||
252 | tSelection = new TableContainer(wTable - 20, hTable - 40, columnNames, columnWidths); |
||
253 | tSelection.setModel("CheckBoxModel");
|
||
254 | tSelection.setControlVisible(false);
|
||
255 | tSelection.initialize(); |
||
256 | } |
||
257 | |||
258 | return tSelection;
|
||
259 | } |
||
260 | |||
261 | /**
|
||
262 | * This method initializes jPanel
|
||
263 | *
|
||
264 | * @return javax.swing.JPanel
|
||
265 | */
|
||
266 | private JPanel getPButtons() { |
||
267 | if (pButtons == null) { |
||
268 | pButtons = new JPanel(); |
||
269 | pButtons.setLayout(new BorderLayout()); |
||
270 | pButtons.setPreferredSize(new java.awt.Dimension(wTable,30)); |
||
271 | pButtons.add(getPAccept(), java.awt.BorderLayout.EAST); |
||
272 | } |
||
273 | return pButtons;
|
||
274 | } |
||
275 | |||
276 | /**
|
||
277 | * This method initializes jPanel
|
||
278 | *
|
||
279 | * @return javax.swing.JPanel
|
||
280 | */
|
||
281 | private JPanel getPAccept() { |
||
282 | if (pAccept == null) { |
||
283 | FlowLayout flowLayout1 = new FlowLayout(); |
||
284 | flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT); |
||
285 | flowLayout1.setVgap(5);
|
||
286 | flowLayout1.setHgap(2);
|
||
287 | pAccept = new JPanel(); |
||
288 | pAccept.setLayout(flowLayout1); |
||
289 | pAccept.setPreferredSize(new java.awt.Dimension(350,30)); |
||
290 | pAccept.add(getBSave(), null);
|
||
291 | pAccept.add(getBAccept(), null);
|
||
292 | pAccept.add(getBCancel(), null);
|
||
293 | } |
||
294 | return pAccept;
|
||
295 | } |
||
296 | |||
297 | /**
|
||
298 | * This method initializes getBAccept
|
||
299 | *
|
||
300 | * @return javax.swing.JButton
|
||
301 | */
|
||
302 | public JButton getBSave() { |
||
303 | if (bSave == null) { |
||
304 | bSave = new JButton(); |
||
305 | bSave.setPreferredSize(new java.awt.Dimension(85,25)); |
||
306 | bSave.setText(Messages.getText("salvar"));
|
||
307 | bSave.setEnabled(false);
|
||
308 | } |
||
309 | return bSave;
|
||
310 | } |
||
311 | |||
312 | /**
|
||
313 | * This method initializes getBAccept
|
||
314 | *
|
||
315 | * @return javax.swing.JButton
|
||
316 | */
|
||
317 | public JButton getBAccept() { |
||
318 | if (bAccept == null) { |
||
319 | bAccept = new JButton(); |
||
320 | bAccept.setPreferredSize(new java.awt.Dimension(85,25)); |
||
321 | bAccept.setText(Messages.getText("aplicar"));
|
||
322 | } |
||
323 | return bAccept;
|
||
324 | } |
||
325 | |||
326 | /**
|
||
327 | * This method initializes getBCancel
|
||
328 | *
|
||
329 | * @return javax.swing.JButton
|
||
330 | */
|
||
331 | public JButton getBCancel() { |
||
332 | if (bCancel == null) { |
||
333 | bCancel = new JButton(); |
||
334 | bCancel.setPreferredSize(new java.awt.Dimension(85,25)); |
||
335 | bCancel.setText(Messages.getText("cerrar"));
|
||
336 | } |
||
337 | return bCancel;
|
||
338 | } |
||
339 | |||
340 | /**
|
||
341 | * This method initializes jPanel
|
||
342 | *
|
||
343 | * @return javax.swing.JPanel
|
||
344 | */
|
||
345 | private JPanel getPBorder() { |
||
346 | if (pBorder == null) { |
||
347 | GridBagConstraints gridBagConstraints31 = new GridBagConstraints(); |
||
348 | gridBagConstraints31.gridx = 0;
|
||
349 | gridBagConstraints31.gridy = 5;
|
||
350 | GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
||
351 | gridBagConstraints3.gridx = 0;
|
||
352 | gridBagConstraints3.gridy = 4;
|
||
353 | GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
||
354 | gridBagConstraints2.gridx = 0;
|
||
355 | gridBagConstraints2.gridy = 3;
|
||
356 | GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
||
357 | gridBagConstraints4.gridx = 0;
|
||
358 | gridBagConstraints4.gridy = 2;
|
||
359 | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
||
360 | gridBagConstraints1.gridx = 0;
|
||
361 | gridBagConstraints1.gridy = 1;
|
||
362 | GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
||
363 | gridBagConstraints.gridx = 0;
|
||
364 | gridBagConstraints.gridy = 0;
|
||
365 | pBorder = new JPanel(); |
||
366 | pBorder.setLayout(new GridBagLayout()); |
||
367 | pBorder.setPreferredSize(new java.awt.Dimension(wComp,hComp));
|
||
368 | pBorder.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); |
||
369 | pBorder.add(getPCoordPixel(), gridBagConstraints); |
||
370 | pBorder.add(getPCoordReal(), gridBagConstraints1); |
||
371 | pBorder.add(getPResize(), gridBagConstraints4); |
||
372 | pBorder.add(getPResolution(), gridBagConstraints2); |
||
373 | pBorder.add(getPSelection(), gridBagConstraints3); |
||
374 | pBorder.add(getPCheck(), gridBagConstraints31); |
||
375 | } |
||
376 | return pBorder;
|
||
377 | } |
||
378 | |||
379 | /**
|
||
380 | * This method initializes jPanel
|
||
381 | *
|
||
382 | * @return javax.swing.JPanel
|
||
383 | */
|
||
384 | private JPanel getPCheck() { |
||
385 | if (pCheck == null) { |
||
386 | jLabel = new JLabel(); |
||
387 | jLabel.setText(Messages.getText("crear_1_capa_por_banda"));
|
||
388 | pCheck = new JPanel(); |
||
389 | pCheck.setLayout(new BorderLayout()); |
||
390 | pCheck.setPreferredSize(new Dimension(410 - 10, 30)); |
||
391 | pCheck.add(getCbOneLyrPerBand(), java.awt.BorderLayout.WEST); |
||
392 | pCheck.add(jLabel, java.awt.BorderLayout.CENTER); |
||
393 | } |
||
394 | return pCheck;
|
||
395 | } |
||
396 | |||
397 | /**
|
||
398 | * This method initializes jCheckBox1
|
||
399 | *
|
||
400 | * @return javax.swing.JCheckBox
|
||
401 | */
|
||
402 | public JCheckBox getCbOneLyrPerBand() { |
||
403 | if (jCheckBox == null) { |
||
404 | jCheckBox = new JCheckBox(); |
||
405 | } |
||
406 | return jCheckBox;
|
||
407 | } |
||
408 | |||
409 | /***************************Metodos***************************/
|
||
410 | |||
411 | |||
412 | public void setComponentSize(int w, int h){ |
||
413 | /*wPanel = w; hPanel = h;
|
||
414 | wComp = wPanel - 6; hComp = hPanel - 40;
|
||
415 | hTable = hComp - 412;
|
||
416 | wTable = wComp - 10;
|
||
417 | |||
418 | if (contract){
|
||
419 | this.setSize(wPanel, hPanel - hTable - 120 - 30);
|
||
420 | pTailImage.setPreferredSize(new java.awt.Dimension(wPanel, hPanel - hTable - 120 - 30));
|
||
421 | this.getPBorder().setSize(wComp, hComp - hTable - 120 - 30);
|
||
422 | this.getPBorder().setPreferredSize(new java.awt.Dimension(wComp, hComp - hTable - 120 - 30));
|
||
423 | }
|
||
424 | if (!contract){
|
||
425 | this.setSize(wPanel, hPanel);
|
||
426 | pTailImage.setPreferredSize(new java.awt.Dimension(wPanel, hPanel));
|
||
427 | this.getPBorder().setSize(wComp, hComp);
|
||
428 | this.getPBorder().setPreferredSize(new java.awt.Dimension(wComp, hComp));
|
||
429 | |||
430 | }
|
||
431 | |||
432 | pCoordPixel.setComponentSize(wTable, 90);
|
||
433 | pCoordReal.setComponentSize(wTable, 90);
|
||
434 | pResize.setPreferredSize(new java.awt.Dimension(wTable - 4,32));
|
||
435 | pResolution.setPreferredSize(new java.awt.Dimension(wTable,120));
|
||
436 | pResolution.setComponentSize(wTable,120);
|
||
437 | pSelection.setPreferredSize(new java.awt.Dimension(wTable,hTable));
|
||
438 | pSelection.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Messages.getText("seleccion_bandas"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10), null));
|
||
439 | tSelection.setComponentSize(wTable - 20, hTable - 40);
|
||
440 | pCheck.setPreferredSize(new java.awt.Dimension(wTable,30));
|
||
441 | pButtons.setPreferredSize(new java.awt.Dimension(wTable,30));*/
|
||
442 | |||
443 | |||
444 | } |
||
445 | |||
446 | /**
|
||
447 | * Devuelve los valores de las coordenadas p?xel
|
||
448 | * introducidas por el usuario.
|
||
449 | * @return
|
||
450 | */
|
||
451 | public String[] getCoordPixel(){ |
||
452 | String[] s = {String.valueOf(pxMinX), String.valueOf(pxMinY), String.valueOf(pxMaxX), String.valueOf(pxMaxY)}; |
||
453 | return s;
|
||
454 | } |
||
455 | |||
456 | /**
|
||
457 | * Asigna los valores de las coordenadas p?xel.
|
||
458 | * @return
|
||
459 | */
|
||
460 | private void setCoordPixel(String[] values){ |
||
461 | this.pCoordPixel.setValues(values);
|
||
462 | } |
||
463 | |||
464 | /**
|
||
465 | * Devuelve los valores de las coordenadas reales
|
||
466 | * introducidas por el usuario.
|
||
467 | * @return
|
||
468 | */
|
||
469 | public String[] getCoordReal(){ |
||
470 | String[] s = {String.valueOf(wcMinX), String.valueOf(wcMaxY), String.valueOf(wcMaxX), String.valueOf(wcMinY)}; |
||
471 | return s;
|
||
472 | } |
||
473 | |||
474 | /**
|
||
475 | * Asigna los valores de las coordenadas reales.
|
||
476 | * @return
|
||
477 | */
|
||
478 | private void setCoordReal(String[] values){ |
||
479 | this.pCoordReal.setValues(values);
|
||
480 | } |
||
481 | |||
482 | /**
|
||
483 | * Asigna las coordenadas del mundo real a partir de n?meros en coma flotante.
|
||
484 | * @param minx coordenada m?nima de X
|
||
485 | * @param miny coordenada m?nima de Y
|
||
486 | * @param maxx coordenada m?xima de X
|
||
487 | * @param maxy coordenada m?xima de Y
|
||
488 | * @param dec N?mero de decimales a mostrar en la caja de texto
|
||
489 | */
|
||
490 | public void setCoorRealFromDouble(double minx, double miny, double maxx, double maxy, int dec){ |
||
491 | wcMinX = minx; |
||
492 | wcMinY = miny; |
||
493 | wcMaxX = maxx; |
||
494 | wcMaxY = maxy; |
||
495 | setCoordReal(getCoord(minx, miny, maxx, maxy, dec)); |
||
496 | } |
||
497 | |||
498 | /**
|
||
499 | * Asigna las coordenadas pixel a partir de n?meros en coma flotante.
|
||
500 | * @param minx coordenada m?nima de X
|
||
501 | * @param miny coordenada m?nima de Y
|
||
502 | * @param maxx coordenada m?xima de X
|
||
503 | * @param maxy coordenada m?xima de Y
|
||
504 | * @param dec N?mero de decimales a mostrar en la caja de texto
|
||
505 | */
|
||
506 | public void setCoorPixelFromDouble(double minx, double miny, double maxx, double maxy, int dec){ |
||
507 | pxMinX = minx; |
||
508 | pxMinY = miny; |
||
509 | pxMaxX = maxx; |
||
510 | pxMaxY = maxy; |
||
511 | setCoordPixel(getCoord(minx, miny, maxx, maxy, dec)); |
||
512 | } |
||
513 | |||
514 | /**
|
||
515 | * Obtiene un texto con las coordenadas a partir de n?meros en coma flotante.
|
||
516 | * @param minx coordenada m?nima de X
|
||
517 | * @param miny coordenada m?nima de Y
|
||
518 | * @param maxx coordenada m?xima de X
|
||
519 | * @param maxy coordenada m?xima de Y
|
||
520 | * @param dec N?mero de decimales a mostrar en la caja de texto
|
||
521 | */
|
||
522 | private String[] getCoord(double minx, double miny, double maxx, double maxy, int dec){ |
||
523 | String[] coordPx = new String[4]; |
||
524 | int indexPoint = String.valueOf(minx).indexOf('.'); |
||
525 | try{
|
||
526 | coordPx[0] = String.valueOf(minx).substring(0, indexPoint + dec); |
||
527 | }catch(StringIndexOutOfBoundsException ex){ |
||
528 | coordPx[0] = String.valueOf(minx); |
||
529 | } |
||
530 | indexPoint = String.valueOf(miny).indexOf('.'); |
||
531 | try{
|
||
532 | coordPx[1] = String.valueOf(miny).substring(0, indexPoint + dec); |
||
533 | }catch(StringIndexOutOfBoundsException ex){ |
||
534 | coordPx[1] = String.valueOf(miny); |
||
535 | } |
||
536 | indexPoint = String.valueOf(maxx).indexOf('.'); |
||
537 | try{
|
||
538 | coordPx[2] = String.valueOf(maxx).substring(0, indexPoint + dec); |
||
539 | }catch(StringIndexOutOfBoundsException ex){ |
||
540 | coordPx[2] = String.valueOf(maxx); |
||
541 | } |
||
542 | indexPoint = String.valueOf(maxy).indexOf('.'); |
||
543 | try{
|
||
544 | coordPx[3] = String.valueOf(maxy).substring(0, indexPoint + dec); |
||
545 | }catch(StringIndexOutOfBoundsException ex){ |
||
546 | coordPx[3] = String.valueOf(maxy); |
||
547 | } |
||
548 | return coordPx;
|
||
549 | } |
||
550 | |||
551 | /**
|
||
552 | * Asigna el valor del campo "tama?o de celda" a partir del double que lo representa
|
||
553 | * y con el n?mero de decimales que se especifica en el par?metro dec
|
||
554 | * @param cellSize Tama?o de celda en double
|
||
555 | * @param dec N?mero de decimales
|
||
556 | */
|
||
557 | public void setCellSizeText(double cellSize, int dec){ |
||
558 | realCellSize = cellSize; |
||
559 | pResolution.setCellSizeText(cellSize, dec); |
||
560 | } |
||
561 | |||
562 | /**
|
||
563 | * Asigna el valor del campo "Ancho" a partir del double que lo representa
|
||
564 | * y con el n?mero de decimales que se especifica en el par?metro dec
|
||
565 | * @param width Ancho
|
||
566 | * @param dec N?mero de decimales
|
||
567 | */
|
||
568 | public void setWidthText(double width, int dec){ |
||
569 | realWidth = width; |
||
570 | pResolution.setWidthText(width, dec); |
||
571 | } |
||
572 | |||
573 | /**
|
||
574 | * Asigna el valor del campo "Alto" a partir del double que lo representa
|
||
575 | * y con el n?mero de decimales que se especifica en el par?metro dec
|
||
576 | * @param height Alto
|
||
577 | * @param dec N?mero de decimales
|
||
578 | */
|
||
579 | public void setHeightText(double height, int dec){ |
||
580 | realHeight = height; |
||
581 | pResolution.setHeightText(height, dec); |
||
582 | } |
||
583 | |||
584 | /**
|
||
585 | * Asigna la relaci?n entre el ancho y alto de la imagen
|
||
586 | * @param rel
|
||
587 | */
|
||
588 | public void setRelWidthHeight(double rel){ |
||
589 | relWidthHeight = rel; |
||
590 | } |
||
591 | |||
592 | /**
|
||
593 | * Obtiene la relaci?n entre el ancho y alto de la imagen
|
||
594 | * @return
|
||
595 | */
|
||
596 | public double getRelWidthHeight(){ |
||
597 | return relWidthHeight;
|
||
598 | } |
||
599 | |||
600 | /**
|
||
601 | * Devuelve el valor del campo "tama?o de celda"
|
||
602 | * @return
|
||
603 | */
|
||
604 | public double getCellSizeText(){ |
||
605 | return realCellSize;
|
||
606 | } |
||
607 | |||
608 | /**
|
||
609 | * Devuelve el valor del campo "tama?o de celda"
|
||
610 | * @return
|
||
611 | */
|
||
612 | public double getWidthText(){ |
||
613 | return realWidth;
|
||
614 | } |
||
615 | |||
616 | /**
|
||
617 | * Devuelve el valor del campo "tama?o de celda"
|
||
618 | * @return
|
||
619 | */
|
||
620 | public double getHeightText(){ |
||
621 | return realHeight;
|
||
622 | } |
||
623 | |||
624 | /**
|
||
625 | * Expande o contrae el panel inferior seg?n el estado en el que se encuentre.
|
||
626 | *
|
||
627 | */
|
||
628 | public void contractExpandPanel(){ |
||
629 | boolean aux = contract;
|
||
630 | if (aux){
|
||
631 | this.setSize(wPanel, hPanel);
|
||
632 | pTailImage.setPreferredSize(new java.awt.Dimension(wPanel, hPanel));
|
||
633 | this.getPBorder().setSize(wComp, hComp);
|
||
634 | this.getPBorder().setPreferredSize(new java.awt.Dimension(wComp, hComp)); |
||
635 | this.getPResolution().setVisible(true); |
||
636 | this.getPSelection().setVisible(true); |
||
637 | this.getPCheck().setVisible(true); |
||
638 | } |
||
639 | if (!aux){
|
||
640 | this.setSize(wPanel, hPanel - hTable - 120 - 30); |
||
641 | pTailImage.setPreferredSize(new java.awt.Dimension(wPanel, hPanel - hTable - 120 - 30)); |
||
642 | this.getPBorder().setSize(wComp, hComp - hTable - 120 - 30); |
||
643 | this.getPBorder().setPreferredSize(new java.awt.Dimension(wComp, hComp - hTable - 120 - 30)); |
||
644 | this.getPResolution().setVisible(false); |
||
645 | this.getPSelection().setVisible(false); |
||
646 | this.getPCheck().setVisible(false); |
||
647 | } |
||
648 | this.validate();
|
||
649 | if (aux) contract = false; |
||
650 | else contract = true; |
||
651 | |||
652 | if (contract == true){ |
||
653 | pResize.getButton(2).setToolTipText("expandir"); |
||
654 | pResize.getButton(2).setIcon(new ImageIcon(getClass().getResource("images/down.png"))); |
||
655 | } |
||
656 | if (contract == false){ |
||
657 | pResize.getButton(2).setToolTipText("contraer"); |
||
658 | pResize.getButton(2).setIcon(new ImageIcon(getClass().getResource("images/up.png"))); |
||
659 | } |
||
660 | |||
661 | } |
||
662 | |||
663 | /**
|
||
664 | * Obtiene la coordenada de m?xima X en pixel.
|
||
665 | * @return Coordenada de m?xima X en pixel
|
||
666 | */
|
||
667 | public double getPxMaxX() { |
||
668 | return pxMaxX;
|
||
669 | } |
||
670 | |||
671 | /**
|
||
672 | * Obtiene la coordenada de m?xima Y en pixel.
|
||
673 | * @return Coordenada de m?xima Y en pixel
|
||
674 | */
|
||
675 | public double getPxMaxY() { |
||
676 | return pxMaxY;
|
||
677 | } |
||
678 | |||
679 | /**
|
||
680 | * Obtiene la coordenada de m?nima X en pixel.
|
||
681 | * @return Coordenada de m?nima X en pixel
|
||
682 | */
|
||
683 | public double getPxMinX() { |
||
684 | return pxMinX;
|
||
685 | } |
||
686 | |||
687 | /**
|
||
688 | * Obtiene la coordenada de m?nima Y en pixel.
|
||
689 | * @return Coordenada de m?nima Y en pixel
|
||
690 | */
|
||
691 | public double getPxMinY() { |
||
692 | return pxMinY;
|
||
693 | } |
||
694 | |||
695 | /**
|
||
696 | * Obtiene la coordenada de m?xima X real.
|
||
697 | * @return Coordenada de m?xima X real.
|
||
698 | */
|
||
699 | public double getWcMaxX() { |
||
700 | return wcMaxX;
|
||
701 | } |
||
702 | |||
703 | /**
|
||
704 | * Obtiene la coordenada de m?xima Y real.
|
||
705 | * @return Coordenada de m?xima Y real
|
||
706 | */
|
||
707 | public double getWcMaxY() { |
||
708 | return wcMaxY;
|
||
709 | } |
||
710 | |||
711 | /**
|
||
712 | * Obtiene la coordenada de m?nima X real.
|
||
713 | * @return Coordenada de m?nima X real
|
||
714 | */
|
||
715 | public double getWcMinX() { |
||
716 | return wcMinX;
|
||
717 | } |
||
718 | |||
719 | /**
|
||
720 | * Obtiene la coordenada de m?nima Y real.
|
||
721 | * @return Coordenada de m?nima Y real
|
||
722 | */
|
||
723 | public double getWcMinY() { |
||
724 | return wcMinY;
|
||
725 | } |
||
726 | |||
727 | |||
728 | } |