Revision 8816

View differences:

trunk/libraries/libJCRS/src/org/gvsig/crs/gui/listeners/CRSMainTrPanelListener.java
46 46
import java.awt.event.ActionListener;
47 47
import java.awt.event.ItemEvent;
48 48
import java.awt.event.ItemListener;
49
import java.awt.event.KeyEvent;
50
import java.awt.event.KeyListener;
49 51
import java.awt.event.MouseEvent;
50 52
import java.awt.event.MouseListener;
51 53
import java.sql.ResultSet;
......
71 73
import com.iver.cit.gvsig.gui.View;
72 74

  
73 75
public class CRSMainTrPanelListener implements ActionListener, DocumentListener,
74
	ListSelectionListener, ItemListener, MouseListener{
76
	ListSelectionListener, ItemListener, MouseListener, KeyListener{
75 77

  
76 78
	private CRSMainTrPanel panel = null;	
77 79
	
......
88 90
				panel.setEpsg_tr(false);
89 91
			}
90 92
			else if (panel.isManual_tr()) {
91
				if (panel.getManualTrPanel().correctJTextField()){
93
				boolean domain = panel.getManualTrPanel().correctJTextField();
94
				if (domain && panel.getManualTrPanel().correctDomain()){
92 95
					panel.setProjection(panel.getManualTrPanel().getProjection());
93 96
					panel.setManual_tr(false);
94 97
				}
95
				else {
98
				else if (!domain) {
96 99
					JOptionPane.showMessageDialog(panel, 
97 100
							PluginServices.getText(this,"numeric_format"), 
98
							"Warning...", JOptionPane.WARNING_MESSAGE);
101
							"Warning...", JOptionPane.WARNING_MESSAGE);					
99 102
					return;
103
				}				
104
				else {
105
					JOptionPane.showMessageDialog(panel, "Algunos campos tienen un "+
106
							PluginServices.getText(this,"incorrect_domain"), 
107
							"Warning...", JOptionPane.WARNING_MESSAGE);					
108
					return;
100 109
				}
101 110
			}
102 111
			else if (panel.isNads_tr()) {
......
105 114
				panel.setNads_tr(false);
106 115
			}
107 116
			else{
108
				panel.setSin_tr(true);
109
				panel.setProjection(panel.getProjection());
117
				IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow();
118
		    	View activeView = (com.iver.cit.gvsig.gui.View) activeWindow;
119
		    	if (panel.getProjection().getAbrev().equals(((ICrs) activeView.getMapControl().getProjection()).getAbrev()) ){
120
		    		panel.setCancelYes(true);
121
					panel.setProjection(panel.getCrsfirst());    		
122
		    	} else {
123
					panel.setSin_tr(true);
124
					panel.setProjection(panel.getProjection());
125
		    	}
126
				
110 127
			}
111 128
			
112 129
			/*
......
154 171
					panel.getManualTrPanel().setWKT(panel.getCrsMainPanel().getRecentsPanel().getCrs().getWKT());
155 172
					panel.getManualTrPanel().setCode(panel.getCrsMainPanel().getRecentsPanel().getCodeCRS());
156 173
				}
174
				if(!panel.getManualTrPanel().getStatus()) {
175
					panel.getJButtonAccept().setEnabled(false);
176
				}
157 177
				panel.setManual_tr(true);
158 178
			    cl.show(panel.getJPanelMain(), "manual");		    
159 179
			}		
......
621 641
		
622 642
	}
623 643

  
644
	public void keyPressed(KeyEvent arg0) {
645
		// TODO Auto-generated method stub
646
		
647
	}
648

  
649
	public void keyReleased(KeyEvent e) {
650
		// TODO Auto-generated method stub
651
		//if (e.getKeyCode())
652
		if(!panel.getManualTrPanel().getStatus()) {
653
			panel.getJButtonAccept().setEnabled(false);
654
		}
655
		else panel.getJButtonAccept().setEnabled(true);		
656
	}
657

  
658
	public void keyTyped(KeyEvent arg0) {
659
		// TODO Auto-generated method stub
660
		
661
	}
662

  
624 663
}
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/CRSMainTrPanel.java
101 101
		this.add(getButtons(), BorderLayout.SOUTH);
102 102
		
103 103
		setListeners();
104
		/*
105
		 * cargamos en la capa el CRS que hemos fijado en la vista en el primer caso
106
		 * o el que pusimos en la ultima eleccion del crs para la capa
107
		 */		
108 104
		
109
		/*habra que hacerlo para que lo printe en el primer panel que pongamos
110
		 * en nuestro caso seria en el de recientes
111
		 */
112
		/*String sour = curProj.getCrsWkt().getAuthority()[0];
113
		if (sour.equals("EPSG")){
114
			crsMainPanel.getEpsgPanel().loadViewCRS(curProj.getCode());
115
			crsMainPanel.getEpsgPanel().getJTable().setRowSelectionInterval(0,0);
116
		}else if(sour.equals("IAU2000")){
117
			crsMainPanel.getIauPanel().loadViewCRS(curProj.getCode());
118
			crsMainPanel.getIauPanel().getJTable().setRowSelectionInterval(0,0);
119
		}*/
120
		
121 105
		setDataSource(crsMainPanel.getDataSource());
122 106
		
123 107
		crsMainPanel.getRecentsPanel().loadRecents();
......
318 302
		rowSMEpsgTr.addListSelectionListener(listener);
319 303
		
320 304
		getNadsTrPanel().getJComboNadFile().addItemListener(listener);
305
		
306
		getManualTrPanel().getTx_Translation().addKeyListener(listener);
307
		getManualTrPanel().getTy_Translation().addKeyListener(listener);
308
		getManualTrPanel().getTz_Translation().addKeyListener(listener);
309
		getManualTrPanel().getTx_Rotation().addKeyListener(listener);
310
		getManualTrPanel().getTy_Rotation().addKeyListener(listener);
311
		getManualTrPanel().getTz_Rotation().addKeyListener(listener);
312
		getManualTrPanel().getTscale().addKeyListener(listener);
321 313
	}
322 314
	
323 315
	public void compareDatum(String wktSource){
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/TransformationManualPanel.java
29 29
import com.iver.andami.ui.mdiManager.IWindow;
30 30
import com.iver.andami.ui.mdiManager.WindowInfo;
31 31

  
32
public class TransformationManualPanel extends JPanel implements KeyListener{
32
public class TransformationManualPanel extends JPanel {
33 33
	
34 34
	private static final long serialVersionUID = 1L;
35 35
	
......
51 51
	private JTextField tz_Rotation;
52 52
	private JTextField tScale;
53 53
	
54
	private JLabel domainTranslation;
55
	private JLabel domainRotation;
56
	private JLabel domainScale;
57
	
54 58
	private JLabel wkt;
55 59
	private JTextArea info;	
56 60
	int codeEpsg;
......
71 75
	public JPanel getJPanel(){
72 76
		if (panel == null) {
73 77
			panel = new JPanel();
74
			panel.setLayout(new GridLayout(0,4));
78
			panel.setLayout(new GridLayout(0,3));
75 79
			panel.setLayout(new FlowLayout(FlowLayout.LEFT,10,20));
76 80
			panel.setBorder(
77 81
				    BorderFactory.createCompoundBorder(
......
82 86
			panel.setPreferredSize(new Dimension(525,400));
83 87
			panel.add(getX_Translation(),null);
84 88
			panel.add(getTx_Translation(),null);
89
			panel.add(getDomainTranslation(), null);			
90
			panel.add(getY_Translation(),null);
91
			panel.add(getTy_Translation(),null);
92
			panel.add(getDomainTranslation(), null);
93
			panel.add(getZ_Translation(),null);
94
			panel.add(getTz_Translation(),null);
95
			panel.add(getDomainTranslation(), null);
85 96
			panel.add(getX_Rotation(),null);
86 97
			panel.add(getTx_Rotation(),null);
87
			panel.add(getY_Translation(),null);
88
			panel.add(getTy_Translation(),null);
98
			panel.add(getDomainRotation(), null);
89 99
			panel.add(getY_Rotation(),null);
90 100
			panel.add(getTy_Rotation(),null);
91
			panel.add(getZ_Translation(),null);
92
			panel.add(getTz_Translation(),null);
101
			panel.add(getDomainRotation(), null);			
93 102
			panel.add(getZ_Rotation(),null);
94 103
			panel.add(getTz_Rotation(),null);
104
			panel.add(getDomainRotation(), null);
95 105
			panel.add(getScale(),null);
96 106
			panel.add(getTscale(),null);
107
			panel.add(getDomainScale(), null);
97 108
			//panel.add(getJPanelParams(), null);
98 109
			//panel.add(getButtonPane(), null);
99 110
		}
100 111
		return panel;
101 112
	}
102 113
	
114
	private JLabel getDomainTranslation(){
115
		domainTranslation = new JLabel();
116
		domainTranslation.setPreferredSize(new Dimension(150, 20));
117
		domainTranslation.setText("[-1000.0, 1000.0]");
118
		return domainTranslation;
119
	}
120
	
121
	private JLabel getDomainRotation(){
122
		domainRotation = new JLabel();
123
		domainRotation.setPreferredSize(new Dimension(150, 20));
124
		domainRotation.setText("[-60.0, 60.0]");
125
		return domainRotation;
126
	}
127
	
128
	private JLabel getDomainScale(){
129
		domainScale = new JLabel();
130
		domainScale.setPreferredSize(new Dimension(150, 20));
131
		domainScale.setText("[-20.0, 20.0]");
132
		return domainScale;
133
	}
103 134

  
104 135
	private JLabel getX_Translation() {
105 136
		if(x_Translation == null ) {
......
178 209
		return scale;
179 210
	}
180 211
	
181
	private JTextField getTx_Translation() {
212
	public JTextField getTx_Translation() {
182 213
		if(tx_Translation == null ) {
183 214
			tx_Translation = new JTextField();
184 215
			tx_Translation.setPreferredSize(new Dimension(120,20));
......
190 221
		return tx_Translation;
191 222
	}
192 223
	
193
	private JTextField getTy_Translation() {
224
	public JTextField getTy_Translation() {
194 225
		if(ty_Translation == null ) {
195 226
			ty_Translation = new JTextField();
196 227
			ty_Translation.setPreferredSize(new Dimension(120,20));
......
202 233
		return ty_Translation;
203 234
	}
204 235
	
205
	private JTextField getTz_Translation() {
236
	public JTextField getTz_Translation() {
206 237
		if(tz_Translation == null ) {
207 238
			tz_Translation = new JTextField();
208 239
			tz_Translation.setPreferredSize(new Dimension(120,20));
......
214 245
		return tz_Translation;
215 246
	}
216 247
	
217
	private JTextField getTx_Rotation() {
248
	public JTextField getTx_Rotation() {
218 249
		if(tx_Rotation == null ) {
219 250
			tx_Rotation = new JTextField();
220 251
			tx_Rotation.setPreferredSize(new Dimension(120,20));
......
226 257
		return tx_Rotation;
227 258
	}
228 259
	
229
	private JTextField getTy_Rotation() {
260
	public JTextField getTy_Rotation() {
230 261
		if(ty_Rotation == null ) {
231 262
			ty_Rotation = new JTextField();
232 263
			ty_Rotation.setPreferredSize(new Dimension(120,20));
......
238 269
		return ty_Rotation;
239 270
	}
240 271
	
241
	private JTextField getTz_Rotation() {
272
	public JTextField getTz_Rotation() {
242 273
		if(tz_Rotation == null ) {
243 274
			tz_Rotation = new JTextField();
244 275
			tz_Rotation.setPreferredSize(new Dimension(120,20));
......
250 281
		return tz_Rotation;
251 282
	}
252 283
	
253
	private JTextField getTscale() {
284
	public JTextField getTscale() {
254 285
		if(tScale == null ) {
255 286
			tScale = new JTextField();
256 287
			tScale.setPreferredSize(new Dimension(120,20));
......
336 367
	
337 368
	public void keyPressed(KeyEvent e) {
338 369
		// TODO Auto-generated method stub
339
		/*
340
		 * Comprobaremos si todos los campos son 0, para en ese caso poner el
341
		 * boton de finalizar deshabilitado...
342
		 */
370
		if (e.getSource() == getTx_Translation()) {
371
			if (getTx_Translation().getText().equals("0"));
372
		}
373
		if (e.getSource() == getTy_Translation()) {
374
					
375
		}
376
		if (e.getSource() == getTz_Translation()) {
377
			
378
		}
379
		if (e.getSource() == getTx_Rotation()) {
380
			
381
		}
382
		if (e.getSource() == getTy_Rotation()) {
383
			
384
		}
385
		if (e.getSource() == getTz_Rotation()) {
386
			
387
		}
388
		if (e.getSource() == getScale()) {
389
			
390
		}
343 391
	}
344 392

  
345 393
	public void keyReleased(KeyEvent e) {
......
359 407
	public boolean correctJTextField(){
360 408
		boolean correct = true;
361 409
		
362
		if ((tx_Translation.getText().length()!=verify(tx_Translation.getText()).length())){
410
		if ((tx_Translation.getText().length()==0) || (tx_Translation.getText().length()!=verify(tx_Translation.getText()).length())){
363 411
			tx_Translation.setText("0");
364 412
			tx_Translation.setBackground(new Color(255,204,204));
365 413
			correct = false;
366 414
		}
367 415
		else tx_Translation.setBackground(new Color(255,255,255));
368
		if ((ty_Translation.getText().length()!=verify(ty_Translation.getText()).length())){
416
		if ((ty_Translation.getText().length()==0) || (ty_Translation.getText().length()!=verify(ty_Translation.getText()).length())){
369 417
			ty_Translation.setText("0");
370 418
			ty_Translation.setBackground(new Color(255,204,204));
371 419
			correct = false;
372 420
		}
373 421
		else ty_Translation.setBackground(new Color(255,255,255));
374
		if ((tz_Translation.getText().length()!=verify(tz_Translation.getText()).length())){
422
		if ((tz_Translation.getText().length()==0) || (tz_Translation.getText().length()!=verify(tz_Translation.getText()).length())){
375 423
			tz_Translation.setText("0");
376 424
			tz_Translation.setBackground(new Color(255,204,204));
377 425
			correct = false;
378 426
		}
379 427
		else tz_Translation.setBackground(new Color(255,255,255));
380
		if ((tx_Rotation.getText().length()!=verify(tx_Rotation.getText()).length())){
428
		if ((tx_Rotation.getText().length() == 0) || (tx_Rotation.getText().length()!=verify(tx_Rotation.getText()).length())){
381 429
			tx_Rotation.setText("0");
382 430
			tx_Rotation.setBackground(new Color(255,204,204));
383 431
			correct = false;
384 432
		}
385 433
		else tx_Rotation.setBackground(new Color(255,255,255));
386
		if ((ty_Rotation.getText().length()!=verify(ty_Rotation.getText()).length())){
434
		if ((ty_Rotation.getText().length() == 0) || (ty_Rotation.getText().length()!=verify(ty_Rotation.getText()).length())){
387 435
			ty_Rotation.setText("0");
388 436
			ty_Rotation.setBackground(new Color(255,204,204));
389 437
			correct = false;
390 438
		}
391 439
		else ty_Rotation.setBackground(new Color(255,255,255));
392
		if ((tz_Rotation.getText().length()!=verify(tz_Rotation.getText()).length())){
440
		if ((tz_Rotation.getText().length() == 0) || (tz_Rotation.getText().length()!=verify(tz_Rotation.getText()).length())){
393 441
			tz_Rotation.setText("0");
394 442
			tz_Rotation.setBackground(new Color(255,204,204));
395 443
			correct = false;
396 444
		}
397 445
		else tz_Rotation.setBackground(new Color(255,255,255));
398
		if ((tScale.getText().length()!=verify(tScale.getText()).length())){
446
		if ((tScale.getText().length() == 0) || (tScale.getText().length()!=verify(tScale.getText()).length())){
399 447
			tScale.setText("0");
400 448
			tScale.setBackground(new Color(255,204,204));
401 449
			correct = false;
......
425 473
		return num_cad;
426 474
	}
427 475
	
476
	public boolean correctDomain(){
477
		boolean correctDomain = true;
478
		double tx = Double.parseDouble(tx_Translation.getText());
479
		double ty = Double.parseDouble(ty_Translation.getText());
480
		double tz = Double.parseDouble(tz_Translation.getText());
481
		double rx = Double.parseDouble(tx_Rotation.getText());
482
		double ry = Double.parseDouble(ty_Rotation.getText());
483
		double rz = Double.parseDouble(tz_Rotation.getText());
484
		double sc = Double.parseDouble(tScale.getText());
485
		
486
		if (tx < -1000.0 || tx > 1000.0) {
487
			tx_Translation.setText("0");
488
			tx_Translation.setBackground(new Color(255,204,204));
489
			correctDomain = false;
490
		}
491
		else tx_Translation.setBackground(new Color(255,255,255));
492
		if (ty < -1000.0 || ty > 1000.0) {
493
			ty_Translation.setText("0");
494
			ty_Translation.setBackground(new Color(255,204,204));
495
			correctDomain = false;
496
		}
497
		else ty_Translation.setBackground(new Color(255,255,255));
498
		if (tz < -1000.0 || tz > 1000.0) {
499
			tz_Translation.setText("0");
500
			tz_Translation.setBackground(new Color(255,204,204));
501
			correctDomain = false;
502
		}
503
		else tz_Translation.setBackground(new Color(255,255,255));
504
		if (rx < -60.0 || rx > 60.0) {
505
			tx_Rotation.setText("0");
506
			tx_Rotation.setBackground(new Color(255,204,204));
507
			correctDomain = false;
508
		}
509
		else tx_Rotation.setBackground(new Color(255,255,255));
510
		if (ry < -60.0 || ry > 60.0) {
511
			ty_Rotation.setText("0");
512
			ty_Rotation.setBackground(new Color(255,204,204));
513
			correctDomain = false;
514
		}
515
		else ty_Rotation.setBackground(new Color(255,255,255));
516
		if (rz < -60.0 || rz > 60.0) {
517
			tz_Rotation.setText("0");
518
			tz_Rotation.setBackground(new Color(255,204,204));
519
			correctDomain = false;
520
		}
521
		else tz_Rotation.setBackground(new Color(255,255,255));
522
		if (sc < -20.0 || sc > 20.0) {
523
			tScale.setText("0");
524
			tScale.setBackground(new Color(255,204,204));
525
			correctDomain = false;
526
		}
527
		else tScale.setBackground(new Color(255,255,255));
528
		return correctDomain;
529
	}
530
	
531
	public boolean getStatus() {
532
		if ((tx_Translation.getText().equals("0") || tx_Translation.getText().equals("")) &&
533
				(ty_Translation.getText().equals("0")  || ty_Translation.getText().equals(""))&&
534
				(tz_Translation.getText().equals("0")  || tz_Translation.getText().equals(""))&&
535
				(tx_Rotation.getText().equals("0")  || tx_Rotation.getText().equals(""))&&
536
				(ty_Rotation.getText().equals("0")  || ty_Rotation.getText().equals(""))&&
537
				(tz_Rotation.getText().equals("0")  || tz_Rotation.getText().equals(""))&&
538
				(tScale.getText().equals("0")  || tScale.getText().equals("")))
539
			return false;
540
		else if (tx_Translation.getText().equals("") ||
541
				(ty_Translation.getText().equals(""))||
542
				(tz_Translation.getText().equals(""))||
543
				(tx_Rotation.getText().equals(""))||
544
				(ty_Rotation.getText().equals(""))||
545
				(tz_Rotation.getText().equals(""))||
546
				(tScale.getText().equals("")))
547
			return false;
548
			return true;
549
	}
550
	
428 551

  
429 552
}
trunk/extensions/extJCRS/config/text.properties
30 30
grids_en=Grids en
31 31
IAU2000=IAU2000
32 32
in=en
33
incorrect_domain=Dominio Incorrecto
33 34
infocrs=Info CRS
34 35
Informacion=Informaci\u00f3n
35 36
importar=Importar

Also available in: Unified diff