Revision 8127 trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/TransformationManualPanel.java

View differences:

TransformationManualPanel.java
8 8
import java.awt.Font;
9 9
import java.awt.GridLayout;
10 10
import java.awt.event.ActionEvent;
11
import java.awt.event.KeyEvent;
12
import java.awt.event.KeyListener;
11 13

  
12 14
import javax.swing.BorderFactory;
13 15
import javax.swing.JButton;
14 16
import javax.swing.JLabel;
17
import javax.swing.JOptionPane;
15 18
import javax.swing.JPanel;
16 19
import javax.swing.JScrollPane;
17 20
import javax.swing.JTextArea;
......
25 28
import com.iver.andami.ui.mdiManager.IWindow;
26 29
import com.iver.andami.ui.mdiManager.WindowInfo;
27 30

  
28
public class TransformationManualPanel extends JPanel{
31
public class TransformationManualPanel extends JPanel implements KeyListener{
29 32
	
30 33
	private static final long serialVersionUID = 1L;
31 34
	
......
106 109
			x_Translation.setPreferredSize(new Dimension(120,20));
107 110
			//x_Translation.setFont(new Font("x_Translation:",Font.BOLD,15));
108 111
			x_Translation.setText(PluginServices.getText(this,"x_Translation:"));
112
			
109 113
		}
110 114
		return x_Translation;
111 115
	}
......
116 120
			y_Translation.setPreferredSize(new Dimension(120,20));
117 121
			//y_Translation.setFont(new Font("y_Translation:",Font.BOLD,15));
118 122
			y_Translation.setText(PluginServices.getText(this,"y_Translation:"));
123
			
119 124
		}
120 125
		return y_Translation;
121 126
	}
......
126 131
			z_Translation.setPreferredSize(new Dimension(120,20));
127 132
			//z_Translation.setFont(new Font("z_Translation:",Font.BOLD,15));
128 133
			z_Translation.setText(PluginServices.getText(this,"z_Translation:"));
134
			
129 135
		}
130 136
		return z_Translation;
131 137
	}
......
136 142
			x_Rotation.setPreferredSize(new Dimension(120,20));
137 143
			//x_Rotation.setFont(new Font("x_Rotation:",Font.BOLD,15));
138 144
			x_Rotation.setText(PluginServices.getText(this,"x_Rotation:"));
145
			
139 146
		}
140 147
		return x_Rotation;
141 148
	}
......
146 153
			y_Rotation.setPreferredSize(new Dimension(120,20));
147 154
			//y_Rotation.setFont(new Font("x_Rotation:",Font.BOLD,15));
148 155
			y_Rotation.setText(PluginServices.getText(this,"y_Rotation:"));
156
			
149 157
		}
150 158
		return y_Rotation;
151 159
	}
......
156 164
			z_Rotation.setPreferredSize(new Dimension(120,20));
157 165
			//z_Rotation.setFont(new Font("x_Translation:",Font.BOLD,15));
158 166
			z_Rotation.setText(PluginServices.getText(this,"z_Rotation:"));
167
			
159 168
		}
160 169
		return z_Rotation;
161 170
	}
......
166 175
			scale.setPreferredSize(new Dimension(120,20));
167 176
			//scale.setFont(new Font("scale:",Font.BOLD,15));
168 177
			scale.setText(PluginServices.getText(this,"scale:"));
178
			
169 179
		}
170 180
		return scale;
171 181
	}
......
177 187
			//tx_Translation.setFont(new Font("",Font.ITALIC,10));
178 188
			tx_Translation.setText("0");
179 189
			tx_Translation.setEditable(true);
190
			tx_Translation.addKeyListener(this);
180 191
		}
181 192
		return tx_Translation;
182 193
	}
......
188 199
			//ty_Translation.setFont(new Font("",Font.ITALIC,10));
189 200
			ty_Translation.setText("0");
190 201
			ty_Translation.setEditable(true);
202
			ty_Translation.addKeyListener(this);
191 203
		}
192 204
		return ty_Translation;
193 205
	}
......
199 211
			//tz_Translation.setFont(new Font("",Font.ITALIC,10));
200 212
			tz_Translation.setText("0");
201 213
			tz_Translation.setEditable(true);
214
			tz_Translation.addKeyListener(this);
202 215
		}
203 216
		return tz_Translation;
204 217
	}
......
210 223
			//tx_Rotation.setFont(new Font("",Font.ITALIC,10));
211 224
			tx_Rotation.setText("0");
212 225
			tx_Rotation.setEditable(true);
226
			tx_Rotation.addKeyListener(this);
213 227
		}
214 228
		return tx_Rotation;
215 229
	}
......
221 235
			//ty_Rotation.setFont(new Font("",Font.ITALIC,10));
222 236
			ty_Rotation.setText("0");
223 237
			ty_Rotation.setEditable(true);
238
			ty_Rotation.addKeyListener(this);
224 239
		}
225 240
		return ty_Rotation;
226 241
	}
......
232 247
			//tz_Rotation.setFont(new Font("",Font.ITALIC,10));
233 248
			tz_Rotation.setText("0");
234 249
			tz_Rotation.setEditable(true);
250
			tz_Rotation.addKeyListener(this);
235 251
		}
236 252
		return tz_Rotation;
237 253
	}
......
243 259
			//tScale.setFont(new Font("",Font.ITALIC,10));
244 260
			tScale.setText("0");
245 261
			tScale.setEditable(true);
262
			tScale.addKeyListener(this);
246 263
		}
247 264
		return tScale;
248 265
	}
......
323 340
		
324 341
	public static boolean isPressed() { return pressed; }
325 342
	
343
	public void keyPressed(KeyEvent e) {
344
		// TODO Auto-generated method stub
345
		if (e.getSource() == this.getTx_Translation()) {
346
			if (e.getKeyCode() == 46 || (e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || 
347
					(e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){						
348
			}
349
			else {
350
				JOptionPane.showMessageDialog(TransformationManualPanel.this, 
351
						"Only number format.", 
352
						"Warning...", JOptionPane.WARNING_MESSAGE);
353
				String aux = tx_Translation.getText();
354
				if (aux.length() == 1 || aux.length() == 0){
355
					tx_Translation.setText("");
356
				}
357
				else {
358
					tx_Translation.setText(aux.substring(0, aux.length()-1));
359
				}
360
			}
361
		}
362
		
363
		if (e.getSource() == this.getTx_Rotation()) {
364
			if (e.getKeyCode() == 46 || (e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || 
365
					(e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){						
366
			}
367
			else {
368
				JOptionPane.showMessageDialog(TransformationManualPanel.this, 
369
						"Only number format.", 
370
						"Warning...", JOptionPane.WARNING_MESSAGE);
371
				String aux = tx_Rotation.getText();
372
				if (aux.length() == 1 || aux.length() == 0){
373
					tx_Rotation.setText("");
374
				}
375
				else {
376
					tx_Rotation.setText(aux.substring(0, aux.length()-1));
377
				}
378
			}
379
		}
380
		
381
		if (e.getSource() == this.getTy_Translation()) {
382
			if (e.getKeyCode() == 46 || (e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || 
383
					(e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){						
384
			}
385
			else {
386
				JOptionPane.showMessageDialog(TransformationManualPanel.this, 
387
						"Only number format.", 
388
						"Warning...", JOptionPane.WARNING_MESSAGE);
389
				String aux = ty_Translation.getText();
390
				if (aux.length() == 1 || aux.length() == 0){
391
					ty_Translation.setText("");
392
				}
393
				else {
394
					ty_Translation.setText(aux.substring(0, aux.length()-1));
395
				}
396
			}
397
		}
398
		
399
		if (e.getSource() == this.getTy_Rotation()) {
400
			if (e.getKeyCode() == 46 || (e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || 
401
					(e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){						
402
			}
403
			else {
404
				JOptionPane.showMessageDialog(TransformationManualPanel.this, 
405
						"Only number format.", 
406
						"Warning...", JOptionPane.WARNING_MESSAGE);
407
				String aux = ty_Rotation.getText();
408
				if (aux.length() == 1 || aux.length() == 0){
409
					ty_Rotation.setText("");
410
				}
411
				else {
412
					ty_Rotation.setText(aux.substring(0, aux.length()-1));
413
				}
414
			}
415
		}
416
		
417
		if (e.getSource() == this.getTz_Translation()) {
418
			if (e.getKeyCode() == 46 || (e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || 
419
					(e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){						
420
			}
421
			else {
422
				JOptionPane.showMessageDialog(TransformationManualPanel.this, 
423
						"Only number format.", 
424
						"Warning...", JOptionPane.WARNING_MESSAGE);
425
				String aux = tz_Translation.getText();
426
				if (aux.length() == 1 || aux.length() == 0){
427
					tz_Translation.setText("");
428
				}
429
				else {
430
					tz_Translation.setText(aux.substring(0, aux.length()-1));
431
				}
432
			}
433
		}
434
		
435
		if (e.getSource() == this.getTz_Rotation()) {
436
			if (e.getKeyCode() == 46 || (e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || 
437
					(e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){						
438
			}
439
			else {
440
				JOptionPane.showMessageDialog(TransformationManualPanel.this, 
441
						"Only number format.", 
442
						"Warning...", JOptionPane.WARNING_MESSAGE);
443
				String aux = tz_Rotation.getText();
444
				if (aux.length() == 1 || aux.length() == 0){
445
					tz_Rotation.setText("");
446
				}
447
				else {
448
					tz_Rotation.setText(aux.substring(0, aux.length()-1));
449
				}
450
			}
451
		}
452
		
453
		if (e.getSource() == this.getTscale()) {
454
			if (e.getKeyCode() == 46 || (e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || 
455
					(e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){						
456
			}
457
			else {
458
				JOptionPane.showMessageDialog(TransformationManualPanel.this, 
459
						"Only number format.", 
460
						"Warning...", JOptionPane.WARNING_MESSAGE);
461
				String aux = tScale.getText();
462
				if (aux.length() == 1 || aux.length() == 0){
463
					tScale.setText("");
464
				}
465
				else {
466
					tScale.setText(aux.substring(0, aux.length()-1));
467
				}
468
			}
469
		}
470
	}
326 471

  
472
	public void keyReleased(KeyEvent e) {
473
		// TODO Auto-generated method stub
474
		
475
	}
476

  
477
	public void keyTyped(KeyEvent e) {
478
		// TODO Auto-generated method stub
479
		
480
	}
481
	
482

  
327 483
}

Also available in: Unified diff