Revision 10631 trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/WFSAreaPanel.java

View differences:

WFSAreaPanel.java
33 33
import com.iver.andami.PluginServices;
34 34
import com.iver.andami.messages.NotificationManager;
35 35
import com.iver.cit.gvsig.fmap.ColorEvent;
36
import com.iver.cit.gvsig.fmap.DriverException;
37 36
import com.iver.cit.gvsig.fmap.ExtentEvent;
38 37
import com.iver.cit.gvsig.fmap.MapContext;
39 38
import com.iver.cit.gvsig.fmap.MapControl;
......
109 108
 *
110 109
 * $Id$
111 110
 * $Log$
112
 * Revision 1.25  2007-03-05 13:47:42  ppiqueras
111
 * Revision 1.26  2007-03-06 18:01:03  caballero
112
 * Exceptions
113
 *
114
 * Revision 1.25  2007/03/05 13:47:42  ppiqueras
113 115
 * Eliminadas l?neas que sobraban.
114 116
 *
115 117
 * Revision 1.24  2007/03/01 13:13:58  ppiqueras
......
196 198
 * There are two options to do this:
197 199
 *  - Indicating the coordinates of the top-left and down-right corners
198 200
 *  - Selecting the area with the mouse
199
 * 
201
 *
200 202
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
201 203
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
202 204
 */
......
217 219
	private final Rectangle DEFAULT_ZOOMCOMPLETE_ICON_BUTTON_RECTANGLE = new Rectangle(353, 85, 25, 25);
218 220
	private final Rectangle DEFAULT_ZOOMINANDOUTVIEWCENTERED_JCOMBOBOX_RECTANGLE = new Rectangle(380, 85, 47, 25);
219 221
	private final Rectangle DEFAULT_OTHER_TOOLS_JCOMBOBOX_RECTANGLE = new Rectangle(429, 85, 47, 25);
220
	
222

  
221 223
	private final int DISABLED_OPERATION = 0;
222 224
	private final int SELECTION_BY_COORDINATES_OPERATION = 1;
223 225
	private final int SELECTION_BY_AREA_OPERATION = 2;
224 226
	private boolean hasUserDefinedAnArea;
225
	
227

  
226 228
	private WFSWizardData data = null;
227 229
	private WFSParamsPanel parent = null;
228 230
	private AreaCoordinatesPanel coordinatesPanel = null;
......
238 240
	private JComboBoxWithImageIconItems jComboBoxZoomInAndOut = null;
239 241
	private JComboBoxWithImageIconItems jComboBoxZoomInAndOutViewCentered = null;
240 242
	private JComboBoxWithImageIconItems jComboBoxOtherTools = null;
241
	
243

  
242 244
	/* Tool identifier constants */
243 245
	private final String PAN_TOOL = "HAND";
244 246
	private final String ZOOM_IN_TOOL = "zoomIn"; // This constant must be 'zoomIn' for a correct operation of the tools 'Zoom In' and 'Zoom In Map Centered'
......
248 250
	private final String MEASURE_DISTANCES_TOOL = "MEASURE_DISTANCES";
249 251
	private final String MEASURE_AREA_TOOL = "MEASURE_AREA";
250 252
	/* End tool identifier constants */
251
	
252
	
253

  
254

  
253 255
	/**
254 256
	 * This method initializes
255 257
	 */
......
269 271
				null, PluginServices.getText(this, "select_by_area"),
270 272
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
271 273
				javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
272
		
274

  
273 275
		// By default, user hasn't defined an area
274 276
		this.hasUserDefinedAnArea = false;
275
		
277

  
276 278
		// Adds JPanel with the coordinates
277 279
		this.add(getCoordinatesPanel(), null);
278
		
279
		// Adds JComboBox to select a part of the graphical interface 
280

  
281
		// Adds JComboBox to select a part of the graphical interface
280 282
		this.add(getJComboBoxToolSelection(), null);
281 283
		this.getJComboBoxToolSelection().setSelectedIndex(0); // By default select first element
282
		
284

  
283 285
		// Adds JPanel with the view
284 286
		this.add(getSelectableMapAreaPanel(), null);
285
		
287

  
286 288
		initCoordinates();
287 289
	}
288 290

  
......
299 301
			getCoordinatesPanel().getJTextFieldVertex2Y().setText(Double.toString(r2d.getMinY()));
300 302
		}
301 303
	}
302
	
304

  
303 305
	/**
304
	 * This method initializes coordinatesPanel	
305
	 * 	
306
	 * @return javax.swing.JPanel	
306
	 * This method initializes coordinatesPanel
307
	 *
308
	 * @return javax.swing.JPanel
307 309
	 */
308 310
	private AreaCoordinatesPanel getCoordinatesPanel() {
309 311
		if (coordinatesPanel == null) {
......
314 316

  
315 317
	/**
316 318
	 * This method initializes jComboBoxToolSelection
317
	 * 
319
	 *
318 320
	 * @return  javax.swing.JComboBox
319 321
	 */
320 322
	private JComboBox getJComboBoxToolSelection() {
......
326 328
			jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "disabled"), this.DISABLED_OPERATION));
327 329
			jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_absolute_coordinates"), this.SELECTION_BY_COORDINATES_OPERATION));
328 330
			jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_coordinates_using_view"), this.SELECTION_BY_AREA_OPERATION));
329
			
331

  
330 332
			jComboBoxToolSelection.addActionListener(new ActionListener() {
331 333
				/*
332 334
				 * (non-Javadoc)
......
351 353
					 		}
352 354
					 		else {
353 355
					 			JOptionPane.showMessageDialog(jComboBoxToolSelection, PluginServices.getText(null, "there_is_no_layer_loaded_in_the_active_view"), PluginServices.getText(null, "information"), JOptionPane.INFORMATION_MESSAGE);
354
					 			
356

  
355 357
					 			// Select: no tools
356 358
					 			jComboBoxToolSelection.setSelectedIndex(0);
357 359
					 			disableCoorderatesRegionOperation();
......
359 361

  
360 362
					 		break;
361 363
					}
362
				}				
364
				}
363 365
			});
364 366
		}
365 367
		return jComboBoxToolSelection;
......
374 376
//		this.add(getJButtonRedo(), null);
375 377
		this.add(getJToggleButtonMove(), null);
376 378
		this.add(getJToggleButtonScaling(), null);
377
		
379

  
378 380
		getCoordinatesPanel().setAllTextFieldsEnabled(true);
379
		
381

  
380 382
 		// Only enable the area operation if there is data loaded in this MapControl
381 383
 		if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() > 0) {
382 384
 			getJToggleButtonMove().setEnabled(true);
......
403 405
		getJComboBoxZoomInAndOutViewCentered().revalidate(); // Force update this component
404 406
		this.add(getJComboBoxOtherTools(), null);
405 407
		getJComboBoxOtherTools().revalidate(); // Force update this component
406
		
408

  
407 409
		// Enables the MapControl area
408 410
		getSelectableMapAreaPanel().setEnabled(true);
409 411
	}
......
415 417
		// Removes associated icons
416 418
		this.remove(getJButtonUndo());
417 419
//		this.remove(getJButtonRedo());
418
		this.remove(getJToggleButtonMove());		
419
		this.remove(getJToggleButtonScaling());		
420
		this.remove(getJToggleButtonMove());
421
		this.remove(getJToggleButtonScaling());
420 422

  
421 423
		getCoordinatesPanel().setAllTextFieldsEnabled(false);
422 424
		getCoordinatesPanel().getJRadioButtonPreviewArea().setEnabled(false);
......
433 435
		this.remove(getJButtonZoomComplete());
434 436
		this.remove(getJComboBoxZoomInAndOutViewCentered());
435 437
		this.remove(getJComboBoxOtherTools());
436
		
438

  
437 439
		// Disables the MapControl area
438 440
		getSelectableMapAreaPanel().setEnabled(false);
439 441
	}
440 442

  
441 443
	/**
442 444
	 * This method initializes areaMapControlPanel
443
	 * 
445
	 *
444 446
	 * @return A reference to an object of SelectableMapControlAreaPanel
445 447
	 */
446 448
	private SelectableMapControlAreaPanel getSelectableMapAreaPanel() {
......
453 455

  
454 456
	/**
455 457
	 * This method initializes jButtonUndo
456
	 * 
458
	 *
457 459
	 * @return javax.swing.JButton
458 460
	 */
459 461
	private JButton getJButtonUndo() {
......
472 474
				}
473 475
			});
474 476
		}
475
		
477

  
476 478
		return jButtonUndo;
477 479
	}
478
	
480

  
479 481
//	/**
480 482
//	 * This method initializes jButtonUndo
481
//	 * 
483
//	 *
482 484
//	 * @return javax.swing.JButton
483 485
//	 */
484 486
//	private JButton getJButtonRedo() {
......
488 490
//			jButtonRedo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/edit-redo.png")));
489 491
//			jButtonRedo.setToolTipText(PluginServices.getText(this, "following_area"));
490 492
//		}
491
//		
493
//
492 494
//		return jButtonRedo;
493 495
//	}
494
	
496

  
495 497
	/**
496 498
	 * This method initializes jToggleButtonMove
497
	 * 
499
	 *
498 500
	 * @return javax.swing.JButton
499 501
	 */
500 502
	private JToggleButton getJToggleButtonMove() {
......
515 517
				}
516 518
			});
517 519
		}
518
		
520

  
519 521
		return jToggleButtonMove;
520 522
	}
521
	
523

  
522 524
	/**
523 525
	 * This method initializes jToggleButtonScaling
524
	 * 
526
	 *
525 527
	 * @return javax.swing.JButton
526 528
	 */
527 529
	private JToggleButton getJToggleButtonScaling() {
......
542 544
				}
543 545
			});
544 546
		}
545
		
547

  
546 548
		return jToggleButtonScaling;
547 549
	}
548 550
	/**
549
	 * This method initializes jButtonPan	
550
	 * 	
551
	 * @return javax.swing.JButton	
551
	 * This method initializes jButtonPan
552
	 *
553
	 * @return javax.swing.JButton
552 554
	 */
553 555
	private JButton getJButtonPan() {
554 556
		if (jButtonPan == null) {
......
570 572
	}
571 573

  
572 574
	/**
573
	 * This method initializes jComboBoxZoomInAndOut	
574
	 * 	
575
	 * This method initializes jComboBoxZoomInAndOut
576
	 *
575 577
	 * @return A JComboBoxWithImageIconItems object reference
576 578
	 */
577 579
	private JComboBoxWithImageIconItems getJComboBoxZoomInAndOut() {
......
597 599
	}
598 600

  
599 601
	/**
600
	 * This method initializes jButtonZoomPrevious	
601
	 * 	
602
	 * @return javax.swing.JButton	
602
	 * This method initializes jButtonZoomPrevious
603
	 *
604
	 * @return javax.swing.JButton
603 605
	 */
604 606
	private JButton getJButtonZoomPrevious() {
605 607
		if (jButtonZoomPrevious == null) {
......
621 623
	}
622 624

  
623 625
	/**
624
	 * This method initializes jButtonZoomComplete	
625
	 * 	
626
	 * @return javax.swing.JButton	
626
	 * This method initializes jButtonZoomComplete
627
	 *
628
	 * @return javax.swing.JButton
627 629
	 */
628 630
	private JButton getJButtonZoomComplete() {
629 631
		if (jButtonZoomComplete == null) {
......
637 639
				 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
638 640
				 */
639 641
				public void mouseClicked(MouseEvent e) {
640
					try {
641
						getSelectableMapAreaPanel().getViewPort().setExtent(getSelectableMapAreaPanel().getMapContext().getLayers().getFullExtent());
642
						View view =((View)PluginServices.getMDIManager().getActiveWindow());
643
						view.repaintMap();
644
					} catch (DriverException de) {
645
						NotificationManager.addError("Error obteniendo el full extent",	de);
646
					}
642
					getSelectableMapAreaPanel().getViewPort().setExtent(getSelectableMapAreaPanel().getMapContext().getLayers().getFullExtent());
643
					View view =((View)PluginServices.getMDIManager().getActiveWindow());
644
					view.repaintMap();
647 645
				}
648 646
			});
649 647
		}
......
651 649
	}
652 650

  
653 651
	/**
654
	 * This method initializes jComboBoxZoomInAndOut	
655
	 * 	
656
	 * @return A JComboBoxWithImageIconItems object reference	
652
	 * This method initializes jComboBoxZoomInAndOut
653
	 *
654
	 * @return A JComboBoxWithImageIconItems object reference
657 655
	 */
658 656
	private JComboBoxWithImageIconItems getJComboBoxZoomInAndOutViewCentered() {
659 657
		if (jComboBoxZoomInAndOutViewCentered == null) {
......
669 667
				public void actionPerformed(ActionEvent e) {
670 668
					JComboBoxWithImageIconItems cb = (JComboBoxWithImageIconItems)e.getSource();
671 669
					ImageIconItemInfo iiii = (ImageIconItemInfo)cb.getSelectedItem();
672
			
670

  
673 671
					if (((String)iiii.getItemValue()).compareTo(ZOOM_IN_VIEW_CENTERED_TOOL) == 0) {
674 672
						getSelectableMapAreaPanel().zoomIn();
675 673
					}
......
681 679
		}
682 680
		return jComboBoxZoomInAndOutViewCentered;
683 681
	}
684
	
682

  
685 683
	/**
686
	 * This method initializes jComboBoxOtherTools	
687
	 * 	
688
	 * @return A JComboBoxWithImageIconItems object reference 	
684
	 * This method initializes jComboBoxOtherTools
685
	 *
686
	 * @return A JComboBoxWithImageIconItems object reference
689 687
	 */
690 688
	private JComboBoxWithImageIconItems getJComboBoxOtherTools() {
691 689
		if (jComboBoxOtherTools == null) {
......
705 703
				}
706 704
	        });
707 705
		}
708
		
706

  
709 707
		return jComboBoxOtherTools;
710 708
	}
711
	
709

  
712 710
	/**
713 711
	 * Goes to previous zoom
714 712
	 */
......
721 719
			getCoordinatesPanel().updateCoordinates(vp.getExtent());
722 720
		}
723 721
	}
724
		
722

  
725 723
	/**
726 724
	 * Sets the extent
727
	 * 
725
	 *
728 726
	 * @param java.awt.geom.Rectangle2D
729 727
	 */
730 728
	public void setExtent(Rectangle2D extent) {
731 729
		if (extent != null) {
732 730
			// Update coordinates in text fields
733 731
			getCoordinatesPanel().updateCoordinates(extent);
734
			
732

  
735 733
			// If there is any layer loaded in the MapControl -> set the extent
736 734
			if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() > 0) {
737 735
				getSelectableMapAreaPanel().getMapContext().getViewPort().setExtent(extent);
......
741 739

  
742 740
	/**
743 741
	 * Gets the extent: a 'Rectangle2D.Double' object reference or 'null' if there is no data or if the data is invalid or user hasn't defined an area
744
	 * 
742
	 *
745 743
	 * @return java.awt.geom.Rectangle2D or null if the data is invalid
746 744
	 */
747 745
	public Rectangle2D getExtent() {
......
760 758
			}
761 759
		}
762 760
	}
763
	
761

  
764 762
	/**
765 763
	 * Set parent's 'Applicable' button enable or disable according the value of the parameter
766
	 * 
764
	 *
767 765
	 * @param b A boolean value
768 766
	 */
769 767
	private void setApplicable(boolean b) {
......
773 771

  
774 772
	/**
775 773
	 * If there is some coordinate text field that has text, returns true; else returns false
776
	 * 
774
	 *
777 775
	 * @return A boolean value
778 776
	 */
779 777
	public boolean areThereSomeCoordinatesWritten() {
......
782 780

  
783 781
	/**
784 782
	 * If there is some coordinate text field that isn't undefined, returns true; else returns false
785
	 * 
783
	 *
786 784
	 * @return A boolean value
787 785
	 */
788 786
	public boolean areThereSomeCoordinatesUndefined() {
789 787
		return getCoordinatesPanel().isThereAnyCoordinateUndefined();
790 788
	}
791
	
789

  
792 790
	/**
793 791
	 * If user has or hasn't defined an area
794
	 * 
792
	 *
795 793
	 * @return A boolean value
796 794
	 */
797 795
	public boolean hasUserDefinedAnArea() {
798 796
		if (areThereSomeCoordinatesUndefined())
799 797
			return false;
800
		
798

  
801 799
		if (getCoordinatesPanel().validVertexes()) {
802 800
			View activeView = (View) PluginServices.getMDIManager().getActiveWindow();
803 801
			Rectangle2D r2d = activeView.getMapControl().getViewPort().getExtent();
......
807 805
		else {
808 806
			return false; // Returns null if coordinates aren't valid
809 807
		}
810
		
808

  
811 809
	}
812
	
810

  
813 811
	/**
814 812
	 * Represents an object that stores the necessary information for know each operation of the 'jComboBoxToolSelection'
815
	 * 
813
	 *
816 814
	 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
817 815
	 */
818 816
	private class ItemOperation {
819 817
		String _name;
820 818
		int _operation;
821
		
819

  
822 820
		/**
823 821
		 * Default constructor with two parameters
824
		 * 
822
		 *
825 823
		 * @param name Name of the operation
826 824
		 * @param operation A code that identifies the operation
827 825
		 */
......
829 827
			_name = new String(name);
830 828
			_operation = operation;
831 829
		}
832
		
830

  
833 831
		/**
834 832
		 * Returns the name of the operation
835
		 * 
833
		 *
836 834
		 * @return An String
837 835
		 */
838 836
		public String getName() {
839 837
			return _name;
840 838
		}
841
		
839

  
842 840
		/**
843 841
		 * Returns the code that identifies the operation
844
		 * 
842
		 *
845 843
		 * @return An integer value
846 844
		 */
847 845
		public int getOperation() {
848 846
			return _operation;
849 847
		}
850
		
848

  
851 849
		/**
852 850
		 * The name of the operation that will use JComboBox
853 851
		 */
......
855 853
			return _name;
856 854
		}
857 855
	}
858
	
856

  
859 857
	/**
860 858
	 * This class is a panel width four fields for indicate the coordinates of two points:
861 859
	 *   One for the ritgh-up point and another for the left-down point of a rectangle area
862
	 * 
860
	 *
863 861
	 * @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
864
	 * @author Jorge Piera Llodr? (piera_jor@gva.es) 
862
	 * @author Jorge Piera Llodr? (piera_jor@gva.es)
865 863
	 */
866 864
	private class AreaCoordinatesPanel extends JPanel implements Serializable {
867 865
		private final Rectangle DEFAULT_JRADIOBUTTON_GO_TO_AREA_RECTANGLE = new Rectangle(412, 5, 67, 50);  //  @jve:decl-index=0:
......
874 872
		private final int DEFAULT_COORDINATE_HEIGHT = 25;
875 873
		private final Dimension DEFAULT_JLABEL_VERTEX_DIMENSION = new Dimension(60, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT);  //  @jve:decl-index=0:
876 874
		private final int DEFAULT_XY_COORDINATES_WIDTH = 2 * DEFAULT_COORDINATE_WIDTH + DEFAULT_JLABEL_VERTEX_DIMENSION.width + 10 ;
877
		
875

  
878 876
		private final String JTEXTFIELD_V1X_NAME = "V1X";
879 877
		private final String JTEXTFIELD_V1Y_NAME = "V1Y";
880 878
		private final String JTEXTFIELD_V2X_NAME = "V2X";
881 879
		private final String JTEXTFIELD_V2Y_NAME = "V2Y";
882
		
880

  
883 881
		private final short JTEXTFIELD_V1X = 1;
884 882
		private final short JTEXTFIELD_V1Y = 2;
885 883
		private final short JTEXTFIELD_V2X = 3;
......
891 889
		private JPanel jPanelVertex1Y = null;
892 890
		private JPanel jPanelVertex2X = null;
893 891
		private JPanel jPanelVertex2Y = null;
894
		
892

  
895 893
		private JLabel jLabelVertex1 = null;
896 894
		private JLabel jLabelVertex2 = null;
897 895
		private JLabel jLabelVertex1X = null;
......
910 908
		private boolean hasChanged_v2Y;
911 909
		private short last_Coordinate_that_Loose_the_Focus; // 0 -> any; 1 -> V1X; 2 -> V1Y; 3 -> V2X; 4 -> V2Y
912 910
		private String previous_Coordinate_Value[];
913
		
911

  
914 912
		private short current_coordinate_with_focus;
915
		
913

  
916 914
		private FocusListener focusListenerForCoordinateValidation = null;
917 915
		private KeyListener keyListenerForCoordinateValidation = null;
918 916

  
......
926 924

  
927 925
		/**
928 926
		 * This method initializes this
929
		 * 
927
		 *
930 928
		 * @return void
931 929
		 */
932 930
		private void initialize() {
......
950 948
			this.add(getJPanelVertex2());
951 949
			this.add(getJRadioButtonPreviewArea());
952 950
		}
953
		
951

  
954 952
		/**
955 953
		 * Returns the default width of this component
956
		 * 
954
		 *
957 955
		 * @return The default width
958 956
		 */
959 957
		public int getDefaultWidth() {
960 958
			return DEFAULT_COORDINATE_WIDTH * 2;
961 959
		}
962
		
960

  
963 961
		/**
964 962
		 * Returns the default height of this component
965
		 * 
963
		 *
966 964
		 * @return The default height
967 965
		 */
968 966
		public int getDefaultHeight() {
......
978 976
			hasChanged_v2X = false;
979 977
			hasChanged_v2Y = false;
980 978
		}
981
		
979

  
982 980
		/**last_Coordinated_that_Changed
983 981
		 * This method initializes jPanelVertex1
984
		 * 
982
		 *
985 983
		 * @return javax.swing.JPanel
986 984
		 */
987 985
		private JPanel getJPanelVertex1() {
......
993 991
				jPanelVertex1.add(getJPanelVertex1X(), null);
994 992
				jPanelVertex1.add(getJPanelVertex1Y(), null);
995 993
			}
996
			
994

  
997 995
			return jPanelVertex1;
998 996
		}
999
		
997

  
1000 998
		/**
1001 999
		 * This method initializes jPanelVertex2
1002
		 * 
1000
		 *
1003 1001
		 * @return javax.swing.JPanel
1004 1002
		 */
1005 1003
		private JPanel getJPanelVertex2() {
......
1011 1009
				jPanelVertex2.add(getJPanelVertex2X(), null);
1012 1010
				jPanelVertex2.add(getJPanelVertex2Y(), null);
1013 1011
			}
1014
			
1012

  
1015 1013
			return jPanelVertex2;
1016 1014
		}
1017
		
1015

  
1018 1016
		/**
1019 1017
		 * This method initializes jLabelVertex1
1020
		 * 
1018
		 *
1021 1019
		 * @return javax.swing.JPanel
1022 1020
		 */
1023 1021
		private JLabel getJLabelVertex1() {
......
1035 1033

  
1036 1034
		/**
1037 1035
		 * This method initializes jLabelVertex2
1038
		 * 
1036
		 *
1039 1037
		 * @return javax.swing.JPanel
1040 1038
		 */
1041 1039
		private JLabel getJLabelVertex2() {
......
1053 1051

  
1054 1052
		/**
1055 1053
		 * This method initializes jPanelVertex1X
1056
		 * 
1054
		 *
1057 1055
		 * @return javax.swing.JPanel
1058 1056
		 */
1059 1057
		private JPanel getJPanelVertex1X() {
......
1064 1062
				jPanelVertex1X.add(getJLabelVertex1X(), null);
1065 1063
				jPanelVertex1X.add(getJTextFieldVertex1X(), null);
1066 1064
			}
1067
			
1065

  
1068 1066
			return jPanelVertex1X;
1069 1067
		}
1070 1068

  
1071 1069
		/**
1072 1070
		 * This method initializes jPanelVertex1Y
1073
		 * 
1071
		 *
1074 1072
		 * @return javax.swing.JPanel
1075 1073
		 */
1076 1074
		private JPanel getJPanelVertex1Y() {
......
1081 1079
				jPanelVertex1Y.add(getJLabelVertex1Y(), null);
1082 1080
				jPanelVertex1Y.add(getJTextFieldVertex1Y(), null);
1083 1081
			}
1084
			
1082

  
1085 1083
			return jPanelVertex1Y;
1086 1084
		}
1087 1085

  
1088 1086
		/**
1089 1087
		 * This method initializes jPanelVertex2X
1090
		 * 
1088
		 *
1091 1089
		 * @return javax.swing.JPanel
1092 1090
		 */
1093 1091
		private JPanel getJPanelVertex2X() {
......
1098 1096
				jPanelVertex2X.add(getJLabelVertex2X(), null);
1099 1097
				jPanelVertex2X.add(getJTextFieldVertex2X(), null);
1100 1098
			}
1101
			
1099

  
1102 1100
			return jPanelVertex2X;
1103 1101
		}
1104
		
1102

  
1105 1103
		/**
1106 1104
		 * This method initializes jPanelVertex2Y
1107
		 * 
1105
		 *
1108 1106
		 * @return javax.swing.JPanel
1109 1107
		 */
1110 1108
		private JPanel getJPanelVertex2Y() {
......
1115 1113
				jPanelVertex2Y.add(getJLabelVertex2Y(), null);
1116 1114
				jPanelVertex2Y.add(getJTextFieldVertex2Y(), null);
1117 1115
			}
1118
			
1116

  
1119 1117
			return jPanelVertex2Y;
1120 1118
		}
1121 1119

  
1122 1120
		/**
1123 1121
		 * This method initializes jLabelVertex1X
1124
		 * 
1122
		 *
1125 1123
		 * @return  javax.swing.JLabel
1126 1124
		 */
1127 1125
		private JLabel getJLabelVertex1X() {
......
1134 1132
				jLabelVertex1X.setVerticalAlignment(SwingConstants.CENTER);
1135 1133
				jLabelVertex1X.setForeground(new Color(0, 0, 255)); // Blue color for text
1136 1134
			}
1137
			
1135

  
1138 1136
			return jLabelVertex1X;
1139 1137
		}
1140
		
1138

  
1141 1139
		/**
1142 1140
		 * This method initializes jLabelVertex2X
1143
		 * 
1141
		 *
1144 1142
		 * @return  javax.swing.JLabel
1145 1143
		 */
1146 1144
		private JLabel getJLabelVertex2X() {
......
1153 1151
				jLabelVertex2X.setVerticalAlignment(SwingConstants.CENTER);
1154 1152
				jLabelVertex2X.setForeground(new Color(128, 64, 0)); // Brown color for text
1155 1153
			}
1156
			
1154

  
1157 1155
			return jLabelVertex2X;
1158 1156
		}
1159
		
1157

  
1160 1158
		/**
1161 1159
		 * This method initializes jLabelVertex1Y
1162
		 * 
1160
		 *
1163 1161
		 * @return  javax.swing.JLabel
1164 1162
		 */
1165 1163
		private JLabel getJLabelVertex1Y() {
......
1172 1170
				jLabelVertex1Y.setVerticalAlignment(SwingConstants.CENTER);
1173 1171
				jLabelVertex1Y.setForeground(new Color(0, 0, 255)); // Blue color for text
1174 1172
			}
1175
			
1173

  
1176 1174
			return jLabelVertex1Y;
1177 1175
		}
1178
		
1176

  
1179 1177
		/**
1180 1178
		 * This method initializes jLabelVertex2Y
1181
		 * 
1179
		 *
1182 1180
		 * @return  javax.swing.JLabel
1183 1181
		 */
1184 1182
		private JLabel getJLabelVertex2Y() {
1185 1183
			if (jLabelVertex2Y == null) {
1186
				jLabelVertex2Y = new JLabel();			
1184
				jLabelVertex2Y = new JLabel();
1187 1185
				jLabelVertex2Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
1188 1186
				jLabelVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_bottom_vertex"));
1189 1187
				jLabelVertex2Y.setText(PluginServices.getText(this, "y") + ":");
......
1191 1189
				jLabelVertex2Y.setVerticalAlignment(SwingConstants.CENTER);
1192 1190
				jLabelVertex2Y.setForeground(new Color(128, 64, 0)); // Brown color for text
1193 1191
			}
1194
			
1192

  
1195 1193
			return jLabelVertex2Y;
1196 1194
		}
1197 1195

  
1198 1196
		/**
1199 1197
		 * Returns a focus listener for validate the text of a JTextField when that component loses its focus
1200
		 * 
1198
		 *
1201 1199
		 * @return java.awt.event.FocusListener
1202 1200
		 */
1203 1201
		private FocusListener getFocusListenerForCoordinateValidation() {
......
1223 1221

  
1224 1222
							return;
1225 1223
						}
1226
	
1224

  
1227 1225
						if (jTF.getName().compareTo(JTEXTFIELD_V2X_NAME) == 0) {
1228 1226
							current_coordinate_with_focus = JTEXTFIELD_V2X;
1229 1227

  
1230 1228
							return;
1231 1229
						}
1232
	
1230

  
1233 1231
						if (jTF.getName().compareTo(JTEXTFIELD_V2Y_NAME) == 0) {
1234 1232
							current_coordinate_with_focus = JTEXTFIELD_V2Y;
1235 1233

  
......
1237 1235
						}
1238 1236

  
1239 1237
					}
1240
					
1238

  
1241 1239
					/*
1242 1240
					 *  (non-Javadoc)
1243 1241
					 * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
......
1261 1259
							if (text.compareTo(last_Coordinates[1]) != 0) {
1262 1260
								hasChanged_v1Y = true;
1263 1261
							}
1264
								
1262

  
1265 1263
							return;
1266 1264
						}
1267 1265

  
......
1277 1275
							if (text.compareTo(last_Coordinates[3]) != 0) {
1278 1276
								hasChanged_v2Y = true;
1279 1277
							}
1280
								
1278

  
1281 1279
							return;
1282 1280
						}
1283 1281
					}
1284 1282
				};
1285 1283
			}
1286
			
1284

  
1287 1285
			return focusListenerForCoordinateValidation;
1288 1286
		}
1289
		
1287

  
1290 1288
		private KeyListener getKeyListenerForCoordinateValidation() {
1291 1289
			if (keyListenerForCoordinateValidation == null) {
1292 1290
				keyListenerForCoordinateValidation = new KeyListener() {
1293
					
1291

  
1294 1292
					public void keyPressed(KeyEvent e) {
1295 1293
					}
1296 1294

  
......
1302 1300
					}
1303 1301
				};
1304 1302
			}
1305
			
1303

  
1306 1304
			return keyListenerForCoordinateValidation;
1307 1305
		}
1308 1306

  
1309 1307
		/**
1310
		 * This method initializes jTextFieldVertex1X	
1311
		 * 	
1308
		 * This method initializes jTextFieldVertex1X
1309
		 *
1312 1310
		 * @return JTextFieldWithSpecificCaretPosition
1313 1311
		 */
1314 1312
		private JTextFieldWithSpecificCaretPosition getJTextFieldVertex1X() {
......
1324 1322
		}
1325 1323

  
1326 1324
		/**
1327
		 * This method initializes jTextFieldVertex1Y	
1328
		 * 	
1325
		 * This method initializes jTextFieldVertex1Y
1326
		 *
1329 1327
		 * @return JTextFieldWithSpecificCaretPosition
1330 1328
		 */
1331 1329
		private JTextFieldWithSpecificCaretPosition getJTextFieldVertex1Y() {
......
1341 1339
		}
1342 1340

  
1343 1341
		/**
1344
		 * This method initializes jTextFieldVertex2X	
1345
		 * 	
1346
		 * @return JTextFieldWithSpecificCaretPosition	
1342
		 * This method initializes jTextFieldVertex2X
1343
		 *
1344
		 * @return JTextFieldWithSpecificCaretPosition
1347 1345
		 */
1348 1346
		private JTextFieldWithSpecificCaretPosition getJTextFieldVertex2X() {
1349 1347
			if (jTextFieldVertex2X == null) {
......
1358 1356
		}
1359 1357

  
1360 1358
		/**
1361
		 * This method initializes jTextFieldVertex2Y	
1362
		 * 	
1359
		 * This method initializes jTextFieldVertex2Y
1360
		 *
1363 1361
		 * @return JTextFieldWithSpecificCaretPosition
1364 1362
		 */
1365 1363
		private JTextFieldWithSpecificCaretPosition getJTextFieldVertex2Y() {
1366 1364
			if (jTextFieldVertex2Y == null) {
1367 1365
				jTextFieldVertex2Y = new JTextFieldWithSpecificCaretPosition("");
1368
				jTextFieldVertex2Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));			
1366
				jTextFieldVertex2Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
1369 1367
				jTextFieldVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_bottom_vertex"));
1370 1368
				jTextFieldVertex2Y.addFocusListener(getFocusListenerForCoordinateValidation());
1371 1369
				jTextFieldVertex2Y.addKeyListener(getKeyListenerForCoordinateValidation());
......
1376 1374

  
1377 1375
		/**
1378 1376
		 * Retuns the double value of the text field V1X
1379
		 * 
1377
		 *
1380 1378
		 * @return A double number type
1381 1379
		 */
1382 1380
		public double getDoubleValueOfJTextFieldV1X() {
......
1385 1383

  
1386 1384
		/**
1387 1385
		 * Retuns the double value of the text field V1Y
1388
		 * 
1386
		 *
1389 1387
		 * @return A double number type
1390 1388
		 */
1391 1389
		public double getDoubleValueOfJTextFieldV1Y() {
......
1394 1392

  
1395 1393
		/**
1396 1394
		 * Retuns the double value of the text field V2X
1397
		 * 
1395
		 *
1398 1396
		 * @return A double number type
1399 1397
		 */
1400 1398
		public double getDoubleValueOfJTextFieldV2X() {
......
1403 1401

  
1404 1402
		/**
1405 1403
		 * Retuns the double value of the text field V2Y
1406
		 * 
1404
		 *
1407 1405
		 * @return A double number type
1408 1406
		 */
1409 1407
		public double getDoubleValueOfJTextFieldV2Y() {
1410
			return Double.parseDouble(getJTextFieldVertex2Y().getText());	
1408
			return Double.parseDouble(getJTextFieldVertex2Y().getText());
1411 1409
		}
1412 1410

  
1413 1411
		/**
1414 1412
		 * Retuns the double value of the last text field V1X value
1415
		 * 
1413
		 *
1416 1414
		 * @return A double number type
1417 1415
		 */
1418 1416
		public double getDoubleValueOfLastJTextFieldV1XValue() {
......
1421 1419

  
1422 1420
		/**
1423 1421
		 * Retuns the double value of the last text field V1Y value
1424
		 * 
1422
		 *
1425 1423
		 * @return A double number type
1426 1424
		 */
1427 1425
		public double getDoubleValueOfLastJTextFieldV1YValue() {
......
1430 1428

  
1431 1429
		/**
1432 1430
		 * Retuns the double value of the last text field V2X value
1433
		 * 
1431
		 *
1434 1432
		 * @return A double number type
1435 1433
		 */
1436 1434
		public double getDoubleValueOfLastJTextFieldV2XValue() {
......
1439 1437

  
1440 1438
		/**
1441 1439
		 * Retuns the double value of the last text field V2Y value
1442
		 * 
1440
		 *
1443 1441
		 * @return A double number type
1444 1442
		 */
1445 1443
		public double getDoubleValueOfLastJTextFieldV2YValue() {
1446
			return Double.parseDouble(last_Coordinates[3]);	
1444
			return Double.parseDouble(last_Coordinates[3]);
1447 1445
		}
1448
		
1446

  
1449 1447
		/**
1450 1448
		 * Validates the coordinate of a JTextField: returns true if it's valid; else returns false
1451
		 * 
1449
		 *
1452 1450
		 * @param coordinate javax.swing.JTextField
1453 1451
		 * @return A boolean value
1454 1452
		 */
1455 1453
		private boolean validateCoordinate(JTextField coordinate) {
1456 1454
			if (coordinate != null) {
1457
				// If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text 
1455
				// If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text
1458 1456
				if ((coordinate.getText().compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(coordinate.getText()))) {
1459 1457
//					JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
1460 1458
//					switch (last_Coordinate_that_Loose_the_Focus) {
......
1473 1471
//						default:
1474 1472
//							// Do nothing
1475 1473
//					}
1476
					
1474

  
1477 1475
					return false;
1478 1476
				}
1479 1477
				else {
......
1483 1481

  
1484 1482
			return false; // If coordinate is null
1485 1483
		}
1486
		
1484

  
1487 1485
		/**
1488 1486
		 * Validates the coordinate of a JTextField: returns true if it's valid; else returns false
1489
		 * 
1487
		 *
1490 1488
		 * @param coordinate javax.swing.JTextField
1491 1489
		 * @return A boolean value
1492 1490
		 */
1493 1491
		private boolean validateCoordinate(int coordinate_ID) {
1494 1492
			JTextField coordinate = null;
1495 1493
			String text;
1496
			
1494

  
1497 1495
			switch (coordinate_ID) {
1498 1496
				case JTEXTFIELD_V1X:
1499 1497
					coordinate = getJTextFieldVertex1X();
1500 1498
					text = coordinate.getText();
1501
					
1499

  
1502 1500
					if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
1503 1501
						JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
1504 1502
						coordinate.setText(previous_Coordinate_Value[0]); // Set last value
......
1513 1511
				case JTEXTFIELD_V1Y:
1514 1512
					coordinate = getJTextFieldVertex1Y();
1515 1513
					text = coordinate.getText();
1516
					
1514

  
1517 1515
					if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
1518 1516
						JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
1519 1517
						coordinate.setText(previous_Coordinate_Value[1]); // Set last value
......
1528 1526
				case JTEXTFIELD_V2X:
1529 1527
					coordinate = getJTextFieldVertex2X();
1530 1528
					text = coordinate.getText();
1531
					
1529

  
1532 1530
					if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
1533 1531
						JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
1534 1532
						coordinate.setText(previous_Coordinate_Value[2]); // Set last value
......
1543 1541
				case JTEXTFIELD_V2Y:
1544 1542
					coordinate = getJTextFieldVertex2Y();
1545 1543
					text = coordinate.getText();
1546
					
1544

  
1547 1545
					if ((text.compareTo("") != 0) && (! StringNumberUtilities.isRealNumberWithIntegerExponent(text))) {
1548 1546
						JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
1549 1547
						coordinate.setText(previous_Coordinate_Value[3]); // Set last value
......
1558 1556
				default:
1559 1557
					return true; // Avoid problems
1560 1558
			}
1561
			
1559

  
1562 1560
//			if (coordinate != null) {
1563
//				// If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text 
1561
//				// If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text
1564 1562
//					switch (coordinate_ID) {
1565 1563
//						case 1:
1566 1564
//							coordinate.setText(previous_Coordinate_Value[0]); // Set last value
......
1577 1575
//						default:
1578 1576
//							// Do nothing
1579 1577
//					}
1580
					
1578

  
1581 1579
//					return false;
1582 1580
//				}
1583 1581
//				else
......
1589 1587

  
1590 1588
		/**
1591 1589
		 * This method initializes jRadioButtonPreviewArea
1592
		 * 
1590
		 *
1593 1591
		 * @return javax.swing.JRadioButton
1594 1592
		 */
1595 1593
		private JRadioButton getJRadioButtonPreviewArea() {
......
1605 1603
					 */
1606 1604
					public void mouseClicked(MouseEvent e) {
1607 1605
				 		// Only enable the area operation if there is data loaded in this MapControl
1608
						
1606

  
1609 1607
						// Do nothing if there is no layer in the map control
1610 1608
				 		if (getSelectableMapAreaPanel().getMapContext().getLayers().getLayersCount() == 0) {
1611 1609
				 			return;
1612 1610
				 		}
1613
				 		
1611

  
1614 1612
						if ((validateCoordinate(getJTextFieldVertex1X())) && (validateCoordinate(getJTextFieldVertex1Y())) && (validateCoordinate(getJTextFieldVertex2X())) && (validateCoordinate(getJTextFieldVertex2Y()))) {
1615 1613
							ViewPort vP = getSelectableMapAreaPanel().getViewPort();
1616 1614
							if (vP != null) {
......
1621 1619
										double cx = getDoubleValueOfJTextFieldV1X();
1622 1620
										double cy = getDoubleValueOfJTextFieldV1Y();
1623 1621
										double sx, sy, aux;
1624
										
1622

  
1625 1623
										if (hasChanged_v1X) {
1626 1624
											aux = getDoubleValueOfLastJTextFieldV1XValue();
1627 1625
											if (aux == 0.0)
......
1631 1629
										}
1632 1630
										else
1633 1631
											sx = 1.0;
1634
										
1632

  
1635 1633
										if (hasChanged_v1Y) {
1636 1634
											aux = getDoubleValueOfLastJTextFieldV1YValue();
1637 1635
											if (aux == 0.0)
......
1641 1639
										}
1642 1640
										else
1643 1641
											sy = 1.0;
1644
										
1642

  
1645 1643
										if (sx == 1.0) {
1646 1644
											// It's supposed that sy != 1.0
1647 1645
											cx *= sy;
1648
											
1646

  
1649 1647
											if (cx < getDoubleValueOfJTextFieldV2X()) {
1650 1648
												JOptionPane.showMessageDialog(jRadioButtonPreviewArea, PluginServices.getText(jRadioButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jRadioButtonPreviewArea, "v1x") + " < " + PluginServices.getText(jRadioButtonPreviewArea, "v2x"), PluginServices.getText(jRadioButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
1651 1649
												restoreAllModifiedCoordinates(); // restores the coordinates
1652 1650
												return;
1653 1651
											}
1654
											
1652

  
1655 1653
											getJTextFieldVertex1X().setText(Double.toString(cx));
1656 1654
										}
1657 1655
										else {
1658 1656
											if (sy == 1.0) {
1659 1657
												// It's supposed that sx != 1.0
1660 1658
												cy *= sx;
1661
												
1659

  
1662 1660
												if (cy < getDoubleValueOfJTextFieldV2Y()) {
1663 1661
													JOptionPane.showMessageDialog(jRadioButtonPreviewArea, PluginServices.getText(jRadioButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jRadioButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jRadioButtonPreviewArea, "v2y"), PluginServices.getText(jRadioButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
1664 1662
													restoreAllModifiedCoordinates(); // restores the coordinates
1665 1663
													return;
1666 1664
												}
1667
												
1665

  
1668 1666
												getJTextFieldVertex1Y().setText(Double.toString(cy));
1669 1667
											}
1670 1668
											else {
......
1677 1675
											}
1678 1676
										}
1679 1677
									}
1680
									
1678

  
1681 1679
									// Scale Vertex2
1682 1680
									if ((hasChanged_v2X) || (hasChanged_v2Y)) {
1683 1681
										double cx = getDoubleValueOfJTextFieldV2X();
1684 1682
										double cy = getDoubleValueOfJTextFieldV2Y();
1685 1683
										double sx, sy, aux;
1686
										
1684

  
1687 1685
										if (hasChanged_v2X) {
1688 1686
											aux = getDoubleValueOfLastJTextFieldV2XValue();
1689 1687
											if (aux == 0.0)
......
1693 1691
										}
1694 1692
										else
1695 1693
											sx = 1.0;
1696
										
1694

  
1697 1695
										if (hasChanged_v2Y) {
1698 1696
											aux = getDoubleValueOfLastJTextFieldV2YValue();
1699 1697
											if (aux == 0.0)
......
1703 1701
										}
1704 1702
										else
1705 1703
											sy = 1.0;
1706
										
1704

  
1707 1705
										if (sx == 1.0) {
1708 1706
											// It's supposed that sy != 1.0
1709 1707
											cx *= sy;
1710
											
1708

  
1711 1709
											if (cx > getDoubleValueOfJTextFieldV1X()) {
1712 1710
												JOptionPane.showMessageDialog(jRadioButtonPreviewArea, PluginServices.getText(jRadioButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jRadioButtonPreviewArea, "v2x") + " > " + PluginServices.getText(jRadioButtonPreviewArea, "v1x"), PluginServices.getText(jRadioButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
1713 1711
												restoreAllModifiedCoordinates(); // restores the coordinates
......
1720 1718
											if (sy == 1.0) {
1721 1719
												// It's supposed that sx != 1.0
1722 1720
												cy *= sx;
1723
												
1721

  
1724 1722
												if (cy > getDoubleValueOfJTextFieldV1Y()) {
1725 1723
													JOptionPane.showMessageDialog(jRadioButtonPreviewArea, PluginServices.getText(jRadioButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jRadioButtonPreviewArea, "v2y") + " > " + PluginServices.getText(jRadioButtonPreviewArea, "v1y"), PluginServices.getText(jRadioButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
1726 1724
													restoreAllModifiedCoordinates(); // restores the coordinates
......
1738 1736
												}
1739 1737
											}
1740 1738
										}
1741
									}									
1739
									}
1742 1740
								}
1743 1741
								else {
1744 1742
									// If has to move the area
......
1748 1746
											double c1 = getDoubleValueOfJTextFieldV1X();
1749 1747
											double c2 = getDoubleValueOfJTextFieldV2X();
1750 1748
											double d1, d2;
1751
											
1749

  
1752 1750
											if (hasChanged_v1X)
1753 1751
												d1 = c1 - getDoubleValueOfLastJTextFieldV1XValue();
1754 1752
											else
1755 1753
												d1 = 0.0;
1756
											
1754

  
1757 1755
											if (hasChanged_v2X)
1758 1756
												d2 = c2 - getDoubleValueOfLastJTextFieldV2XValue();
1759 1757
											else
1760 1758
												d2 = 0.0;
1761
	
1759

  
1762 1760
											if (d1 == 0.0) {
1763 1761
												// It's supposed that d2 != 0
1764 1762
												c1 += d2;
1765
												
1763

  
1766 1764
												if (c1 < getDoubleValueOfJTextFieldV2X()) {
1767 1765
													JOptionPane.showMessageDialog(jRadioButtonPreviewArea, PluginServices.getText(jRadioButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jRadioButtonPreviewArea, "v1x") + " < " + PluginServices.getText(jRadioButtonPreviewArea, "v2x"), PluginServices.getText(jRadioButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
1768 1766
													restoreAllModifiedCoordinates(); // restores the coordinates
1769 1767
													return;
1770 1768
												}
1771
												
1769

  
1772 1770
												getJTextFieldVertex1X().setText(Double.toString(c1));
1773 1771
											}
1774 1772
											else {
......
1781 1779
														restoreAllModifiedCoordinates(); // restores the coordinates
1782 1780
														return;
1783 1781
													}
1784
													
1782

  
1785 1783
													getJTextFieldVertex2X().setText(Double.toString(c2));
1786 1784
												}
1787 1785
												else {
......
1794 1792
												}
1795 1793
											}
1796 1794
										}
1797
										
1795

  
1798 1796
										// Move in Y
1799 1797
										if ((hasChanged_v1Y) || (hasChanged_v2Y)) {
1800 1798
											double c1 = getDoubleValueOfJTextFieldV1Y();
1801 1799
											double c2 = getDoubleValueOfJTextFieldV2Y();
1802 1800
											double d1, d2;
1803
											
1801

  
1804 1802
											if (hasChanged_v1Y)
1805 1803
												d1 = c1 - getDoubleValueOfLastJTextFieldV1YValue();
1806 1804
											else
1807 1805
												d1 = 0.0;
1808
											
1806

  
1809 1807
											if (hasChanged_v2Y)
1810 1808
												d2 = c2 - getDoubleValueOfLastJTextFieldV2YValue();
1811 1809
											else
1812 1810
												d2 = 0.0;
1813
											
1811

  
1814 1812
											if (d1 == 0.0) {
1815 1813
												// It's supposed that d2 != 0
1816 1814
												c1 += d2;
1817
												
1815

  
1818 1816
												if (c1 < getDoubleValueOfJTextFieldV2Y()) {
1819 1817
													JOptionPane.showMessageDialog(jRadioButtonPreviewArea, PluginServices.getText(jRadioButtonPreviewArea, "problem_with_the_new_calculated_area") + ": " + PluginServices.getText(jRadioButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jRadioButtonPreviewArea, "v2y"), PluginServices.getText(jRadioButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
1820 1818
													restoreAllModifiedCoordinates(); // restores the coordinates
......
1833 1831
														restoreAllModifiedCoordinates(); // restores the coordinates
1834 1832
														return;
1835 1833
													}
1836
													
1834

  
1837 1835
													getJTextFieldVertex2Y().setText(Double.toString(c2));
1838 1836
												}
1839 1837
												else {
......
1849 1847
									}
1850 1848
									else {
1851 1849
										boolean canSetExtent = true;
1852
										
1850

  
1853 1851
										// Check if there is a impossible coordinate
1854 1852
										if (hasChanged_v1X) {
1855 1853
											if (getDoubleValueOfJTextFieldV1X() < getDoubleValueOfJTextFieldV2X()) {
......
1857 1855
												canSetExtent = false;
1858 1856
											}
1859 1857
										}
1860
										
1858

  
1861 1859
										if (hasChanged_v1Y) {
1862 1860
											if (getDoubleValueOfJTextFieldV1Y() < getDoubleValueOfJTextFieldV2Y()) {
1863 1861
												JOptionPane.showMessageDialog(jRadioButtonPreviewArea, PluginServices.getText(jRadioButtonPreviewArea, "v1y") + " < " + PluginServices.getText(jRadioButtonPreviewArea, "v2y"), PluginServices.getText(jRadioButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
......
1878 1876
												canSetExtent = false;
1879 1877
											}
1880 1878
										}
1881
										
1879

  
1882 1880
										// If can set the new Extent -> finish
1883 1881
										if (!canSetExtent) {
1884 1882
											restoreAllModifiedCoordinates(); // restores the coordinates
......
1886 1884
										}
1887 1885
									}
1888 1886
								}
1889
																
1887

  
1890 1888
								//Rectangle2D r2d = vP.getExtent();
1891 1889
								if (vP.getExtent() != null){
1892 1890
									vP.setExtent(getNewRectangleByCoordinates());
......
1897 1895
						else {
1898 1896
							JOptionPane.showMessageDialog(jRadioButtonPreviewArea, PluginServices.getText(jRadioButtonPreviewArea, "at_least_one_incorrect_coordinate"), PluginServices.getText(jRadioButtonPreviewArea, "error"), JOptionPane.ERROR_MESSAGE);
1899 1897
						}
1900
					}	
1898
					}
1901 1899
				});
1902
			}		
1900
			}
1903 1901
			return jRadioButtonPreviewArea;
1904 1902
		}
1905
		
1903

  
1906 1904
		/**
1907 1905
		 * Calculates the new rectangle using the coordinates of the text fields
1908
		 * 
1906
		 *
1909 1907
		 * @return java.awt.geom.Rectangle2D
1910 1908
		 */
1911 1909
		private Rectangle2D getNewRectangleByCoordinates() {
1912 1910
			return new Rectangle2D.Double(getDoubleValueOfJTextFieldV2X(), getDoubleValueOfJTextFieldV2Y(), getDoubleValueOfJTextFieldV1X() - getDoubleValueOfJTextFieldV2X(), getDoubleValueOfJTextFieldV1Y() - getDoubleValueOfJTextFieldV2Y());
1913 1911
		}
1914
		
1912

  
1915 1913
		/**
1916 1914
		 * Restores the value of all text fields with coordinates modified to their last value
1917 1915
		 */
......
1936 1934
				hasChanged_v2Y = false;
1937 1935
			}
1938 1936
		}
1939
		
1937

  
1940 1938
		/**
1941 1939
		 * Enables or disables all inner JTextField
1942
		 * 
1940
		 *
1943 1941
		 * @param b A boolean value
1944 1942
		 */
1945 1943
		public void setAllTextFieldsEnabled(boolean b) {
......
1951 1949

  
1952 1950
		/**
1953 1951
		 * Sets the extent into the text fields
1954
		 * 
1952
		 *
1955 1953
		 * @param extent java.awt.geom.Rectangle2D
1956 1954
		 */
1957 1955
		public void updateCoordinates(Rectangle2D extent){
1958 1956
			getJTextFieldVertex1X().setText(String.valueOf(extent.getMaxX()));
1959 1957
			last_Coordinates[0] = getJTextFieldVertex1X().getText();
1960 1958
			previous_Coordinate_Value[0] = last_Coordinates[0];
1961
			
1959

  
1962 1960
			getJTextFieldVertex1Y().setText(String.valueOf(extent.getMaxY()));
1963 1961
			last_Coordinates[1] = getJTextFieldVertex1Y().getText();
1964 1962
			previous_Coordinate_Value[1] = last_Coordinates[1];
1965
			
1963

  
1966 1964
			getJTextFieldVertex2X().setText(String.valueOf(extent.getMinX()));
1967 1965
			last_Coordinates[2] = getJTextFieldVertex2X().getText();
1968 1966
			previous_Coordinate_Value[2] = last_Coordinates[2];
1969
			
1967

  
1970 1968
			getJTextFieldVertex2Y().setText(String.valueOf(extent.getMinY()));
1971 1969
			last_Coordinates[3] = getJTextFieldVertex2Y().getText();
1972 1970
			previous_Coordinate_Value[3] = last_Coordinates[3];
1973
			
1971

  
1974 1972
			resetCoordinatesFlags();
1975 1973

  
1976 1974
			// Enable the 'Applicate' button
1977 1975
			setApplicable(true);
1978 1976
		}
1979
		
1977

  
1980 1978
		/**
1981 1979
		 * Validates all coordinates of both vertexes separately
1982
		 * 
1980
		 *
1983 1981
		 * @return A ValidationInfo object reference
1984 1982
		 */
1985 1983
		private ValidationInfo validVertexesCoordinates() {
1986 1984
			if (! validateCoordinate(getJTextFieldVertex1X())) {
1987 1985
				return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v1x"));
1988 1986
			}
1989
			
1987

  
1990 1988
			if (! validateCoordinate(getJTextFieldVertex1Y())) {
1991 1989
				return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v1y"));
1992 1990
			}
1993
			
1991

  
1994 1992
			if (! validateCoordinate(getJTextFieldVertex2X())) {
1995 1993
				return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v2x"));
1996 1994
			}
1997
			
1995

  
1998 1996
			if (! validateCoordinate(getJTextFieldVertex2Y())) {
1999 1997
				return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v2y"));
2000 1998
			}
......
2002 2000
			// If arrives here, all coordinates are valid
2003 2001
			return new ValidationInfo(true, "");
2004 2002
		}
2005
		
2003

  
2006 2004
		/**
2007 2005
		 * Validates that Vertex1 is in the right-up corner and the Vertex2 in the left-down corner of the area/rectangle <br>
2008 2006
		 * (It's supposed that coordinates of the vertexes are valid) <br>
2009 2007
		 * (It's supposed that going to right or up, the coordinate value increases)
2010
		 * 
2011
		 * @return A ValidationInfo object reference 
2008
		 *
2009
		 * @return A ValidationInfo object reference
2012 2010
		 */
2013 2011
		private ValidationInfo validVertexesPositions() {
2014 2012
			// Check if no coordinate it's defined
2015 2013
			if (getJTextFieldVertex1X().getText().compareTo("") == 0) {
2016 2014
				return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v1x"));
2017 2015
			}
2018
			
2016

  
2019 2017
			if (getJTextFieldVertex2X().getText().compareTo("") == 0) {
2020 2018
				return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v2x"));
2021 2019
			}
......
2023 2021
			if (getJTextFieldVertex1Y().getText().compareTo("") == 0) {
2024 2022
				return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v1y"));
2025 2023
			}
2026
			
2024

  
2027 2025
			if (getJTextFieldVertex2Y().getText().compareTo("") == 0) {
2028 2026
				return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v2y"));
2029 2027
			}
......
2040 2038
			// If arrives here -> vertexes positions are valid
2041 2039
			return new ValidationInfo(true, "");
2042 2040
		}
2043
		
2041

  
2044 2042
		/**
2045 2043
		 * Validate each coordinate of each vertex and the position of the vertexes
2046
		 * 
2044
		 *
2047 2045
		 * @return A boolean value
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff