Revision 117 org.gvsig.wfs.app/trunk/org.gvsig.wfs.app/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/wfs/gui/panels/WFSAreaPanel.java

View differences:

WFSAreaPanel.java
31 31
import javax.swing.JToggleButton;
32 32
import javax.swing.SwingConstants;
33 33

  
34
import org.cresques.cts.IProjection;
34 35
import org.gvsig.andami.PluginServices;
35 36
import org.gvsig.andami.messages.NotificationManager;
36 37
import org.gvsig.andami.ui.mdiManager.IWindow;
......
82 83
 *
83 84
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
84 85
 * of the Valencian Government (CIT)
85
 * 
86
 *
86 87
 * This program is free software; you can redistribute it and/or
87 88
 * modify it under the terms of the GNU General Public License
88 89
 * as published by the Free Software Foundation; either version 2
89 90
 * of the License, or (at your option) any later version.
90
 * 
91
 *
91 92
 * This program is distributed in the hope that it will be useful,
92 93
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
93 94
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
94 95
 * GNU General Public License for more details.
95
 * 
96
 *
96 97
 * You should have received a copy of the GNU General Public License
97 98
 * along with this program; if not, write to the Free Software
98
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
99
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
99 100
 * MA  02110-1301, USA.
100
 * 
101
 *
101 102
 */
102 103

  
103 104
/**
......
130 131
    private static GeometryManager geometryManager = GeometryLocator.getGeometryManager();
131 132
    private final int DISABLED_OPERATION = 0;
132 133
    private final int SELECTION_BY_COORDINATES_OPERATION = 1;
133
    private final int SELECTION_BY_AREA_OPERATION = 2;   
134
    private final int SELECTION_BY_AREA_OPERATION = 2;
134 135
    //	private Rectangle2D lastExtentValid = null;
135 136
    private ExtentHistory previousExtentValids = null;
136 137

  
......
162 163

  
163 164
    private JPanel northPanel = null;
164 165

  
166
    private IProjection srs = null;
165 167

  
168

  
166 169
    /**
167 170
     * This method initializes
168 171
     */
......
175 178
     * Write the view coordinates into the coordinates panel
176 179
     */
177 180
    private void initCoordinates() {
178
        
181

  
179 182
        IWindow wi = PluginServices.getMDIManager().getActiveWindow();
180
        
183

  
181 184
        if (!(wi instanceof IView)) {
182 185
            return;
183 186
        }
184
        
187

  
185 188
        // We will use the adjusted extent because increases the usability
186
        Envelope envelope = ((IView) wi).getMapControl().getViewPort().getAdjustedEnvelope();
189
        ViewPort viewPort = ((IView) wi).getMapControl().getViewPort();
190
		Envelope envelope = viewPort.getAdjustedEnvelope();
187 191
        if (envelope != null){
188 192
            previousExtentValids.put(new Rectangle2D.Double(envelope.getMinimum(0),
189 193
                envelope.getMinimum(1),
......
193 197
            setCoordinates(envelope.getMaximum(0), envelope.getMaximum(1),
194 198
                envelope.getMinimum(0), envelope.getMinimum(1));
195 199
        }
200
        setSrs(viewPort.getProjection());
196 201
    }
197 202

  
198 203
    /**
......
254 259
            jEnablingCheckBox.setBounds(DEFAULT_ENABLING_CHECKBOX_RECTANGLE);
255 260
            jEnablingCheckBox.setToolTipText(PluginServices.getText(this, "enable_filter_by_area"));
256 261
            jEnablingCheckBox.setSelected(false);
257
            jEnablingCheckBox.addItemListener(new ItemListener() {          
262
            jEnablingCheckBox.addItemListener(new ItemListener() {
258 263
                public void itemStateChanged(ItemEvent e) {
259 264
                    if (e.getStateChange() == ItemEvent.SELECTED) {
260 265
                        jEnablingCheckBox.setToolTipText(PluginServices.getText(this, "disable_filter_by_area"));
......
347 352
                if (windows[i] instanceof IView){
348 353
                    view = (IView)windows[i];
349 354
                }
350
            }        
355
            }
351 356

  
352 357
            ViewPort viewPort = view.getMapControl().getMapContext().getViewPort();
353 358

  
......
666 671
            return null;
667 672

  
668 673
        if (getCoordinatesPanel().areAllCoordinatesUndefined()) {
669
            return null; 
674
            return null;
670 675
        }
671 676
        else {
672
            if (getCoordinatesPanel().validVertexes()) {				
677
            if (getCoordinatesPanel().validVertexes()) {
673 678
                try {
674 679
                    return getCoordinatesPanel().getSurface();
675 680
                } catch (CreateGeometryException e) {
......
690 695
        }
691 696
    }
692 697

  
698
    public IProjection getSrs() {
699
    	return this.srs;
700
    }
701

  
702
    public void setSrs(IProjection srs){
703
    	this.srs = srs;
704
    }
705

  
693 706
    /**
694 707
     * Set parent's 'Applicable' button enable or disable according the value of the parameter
695 708
     *
......
747 760
            // Adds the extent of the viewport of the current active view
748 761
            AbstractViewPanel view = (AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow();
749 762
            ViewPort vP = view.getMapControl().getMapContext().getViewPort();
763
            setSrs(vP.getProjection());
750 764

  
765

  
751 766
            // Update extent (we will use the adjusted extent because increases the usability)
752 767
            Envelope envelope = vP.getAdjustedExtent();
753 768
            //			Rectangle2D r2D = vP.getExtent();
......
853 868
    private class AreaCoordinatesPanel extends JPanel {
854 869
        private final Rectangle DEFAULT_JBUTTON_GO_TO_AREA_RECTANGLE = new Rectangle(412, 5, 62, 51);  //  @jve:decl-index=0:
855 870
        private final int DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT = 20;
856
        private final int DEFAULT_COORDIANTE_LABEL_WIDTH = 20;
871
        private final int DEFAULT_COORDINATE_LABEL_WIDTH = 20;
857 872
        private final int DEFAULT_TEXT_FIELDS_WIDTH = 132;
858 873
        private final int DEFAULT_X_LOCATION = 8;
859 874
        private final int DEFAULT_Y_LEFT_UP_CORNER_LOCATION = 6;
860
        private final int DEFAULT_COORDINATE_WIDTH = DEFAULT_COORDIANTE_LABEL_WIDTH + DEFAULT_TEXT_FIELDS_WIDTH + 10;
875
        private final int DEFAULT_COORDINATE_WIDTH = DEFAULT_COORDINATE_LABEL_WIDTH + DEFAULT_TEXT_FIELDS_WIDTH + 10;
861 876
        private final int DEFAULT_COORDINATE_HEIGHT = 25;
862 877
        private final Dimension DEFAULT_JLABEL_VERTEX_DIMENSION = new Dimension(60, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT);  //  @jve:decl-index=0:
863 878
        private final int DEFAULT_XY_COORDINATES_WIDTH = 2 * DEFAULT_COORDINATE_WIDTH + DEFAULT_JLABEL_VERTEX_DIMENSION.width + 10 ;
......
936 951
            gridBagConstraints.gridx = 0;
937 952
            gridBagConstraints.gridy = 0;
938 953
            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
939
            gridBagConstraints.weightx = 1.0;				
954
            gridBagConstraints.weightx = 1.0;
940 955
            this.add(getJPanelVertex1(), gridBagConstraints);
941 956

  
942 957
            gridBagConstraints = new java.awt.GridBagConstraints();
943 958
            gridBagConstraints.gridx = 1;
944 959
            gridBagConstraints.gridy = 0;
945 960
            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
946
            gridBagConstraints.weightx = 1.0;	
961
            gridBagConstraints.weightx = 1.0;
947 962
            this.add(getJPanelVertex2(), gridBagConstraints);
948 963

  
949 964
            gridBagConstraints = new java.awt.GridBagConstraints();
950 965
            gridBagConstraints.gridx = 2;
951 966
            gridBagConstraints.gridy = 0;
952 967
            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
953
            gridBagConstraints.weightx = 1.0;	
968
            gridBagConstraints.weightx = 1.0;
954 969
            this.add(getJButtonValidateArea(), gridBagConstraints);
955 970
        }
956 971

  
......
998 1013
                gridBagConstraints.gridx = 0;
999 1014
                gridBagConstraints.gridy = 0;
1000 1015
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1001
                gridBagConstraints.weightx = 1.0;			
1016
                gridBagConstraints.weightx = 1.0;
1002 1017
                jPanelVertex1.add(getJLabelVertex1(), gridBagConstraints);
1003 1018

  
1004 1019
                gridBagConstraints = new java.awt.GridBagConstraints();
......
1035 1050
                gridBagConstraints.gridx = 0;
1036 1051
                gridBagConstraints.gridy = 0;
1037 1052
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1038
                gridBagConstraints.weightx = 1.0;			
1053
                gridBagConstraints.weightx = 1.0;
1039 1054
                jPanelVertex2.add(getJLabelVertex2(), gridBagConstraints);
1040 1055

  
1041 1056
                gridBagConstraints = new java.awt.GridBagConstraints();
1042 1057
                gridBagConstraints.gridx = 0;
1043 1058
                gridBagConstraints.gridy = 1;
1044 1059
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1045
                gridBagConstraints.weightx = 1.0;						
1060
                gridBagConstraints.weightx = 1.0;
1046 1061
                jPanelVertex2.add(getJPanelVertex2X(), gridBagConstraints);
1047 1062

  
1048 1063
                gridBagConstraints = new java.awt.GridBagConstraints();
1049 1064
                gridBagConstraints.gridx = 0;
1050 1065
                gridBagConstraints.gridy = 2;
1051 1066
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1052
                gridBagConstraints.weightx = 1.0;			
1067
                gridBagConstraints.weightx = 1.0;
1053 1068
                jPanelVertex2.add(getJPanelVertex2Y(), gridBagConstraints);
1054 1069
            }
1055 1070

  
......
1164 1179
        private JLabel getJLabelVertex1X() {
1165 1180
            if (jLabelVertex1X == null) {
1166 1181
                jLabelVertex1X = new JLabel();
1167
                jLabelVertex1X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
1182
                jLabelVertex1X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDINATE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
1168 1183
                jLabelVertex1X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_right_up_vertex"));
1169 1184
                jLabelVertex1X.setText(PluginServices.getText(this, "x") + ":");
1170 1185
                jLabelVertex1X.setHorizontalAlignment(SwingConstants.CENTER);
......
1182 1197
        private JLabel getJLabelVertex2X() {
1183 1198
            if (jLabelVertex2X == null) {
1184 1199
                jLabelVertex2X = new JLabel();
1185
                jLabelVertex2X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
1200
                jLabelVertex2X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDINATE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
1186 1201
                jLabelVertex2X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_left_bottom_vertex"));
1187 1202
                jLabelVertex2X.setText(PluginServices.getText(this, "x") + ":");
1188 1203
                jLabelVertex2X.setHorizontalAlignment(SwingConstants.CENTER);
......
1200 1215
        private JLabel getJLabelVertex1Y() {
1201 1216
            if (jLabelVertex1Y == null) {
1202 1217
                jLabelVertex1Y = new JLabel();
1203
                jLabelVertex1Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
1218
                jLabelVertex1Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDINATE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
1204 1219
                jLabelVertex1Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_right_up_vertex"));
1205 1220
                jLabelVertex1Y.setText(PluginServices.getText(this, "y") + ":");
1206 1221
                jLabelVertex1Y.setHorizontalAlignment(SwingConstants.CENTER);
......
1218 1233
        private JLabel getJLabelVertex2Y() {
1219 1234
            if (jLabelVertex2Y == null) {
1220 1235
                jLabelVertex2Y = new JLabel();
1221
                jLabelVertex2Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
1236
                jLabelVertex2Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDINATE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
1222 1237
                jLabelVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_bottom_vertex"));
1223 1238
                jLabelVertex2Y.setText(PluginServices.getText(this, "y") + ":");
1224 1239
                jLabelVertex2Y.setHorizontalAlignment(SwingConstants.CENTER);
......
1551 1566
                }
1552 1567
            default:
1553 1568
                return true; // Avoid problems
1554
            }       
1569
            }
1555 1570
        }
1556 1571

  
1557 1572
        /**
......
1571 1586
                jButtonPreviewArea.addMouseListener(new MouseAdapter() {
1572 1587
                    public void mouseClicked(MouseEvent e) {
1573 1588
                        validVertexes();
1574
                    }                			
1589
                    }
1575 1590
                });
1576 1591
            }
1577 1592
            return jButtonPreviewArea;
......
1648 1663
            resetCoordinatesFlags();
1649 1664
        }
1650 1665

  
1666

  
1651 1667
        /**
1652 1668
         * Changes the color of all coordinates text fields to <code>c</code>.
1653 1669
         *
......
1909 1925
            double v1x = getDoubleValueOfJTextFieldV1X();
1910 1926
            double v1y = getDoubleValueOfJTextFieldV1Y();
1911 1927
            double v2x = getDoubleValueOfJTextFieldV2X();
1912
            double v2y = getDoubleValueOfJTextFieldV2Y();   
1928
            double v2y = getDoubleValueOfJTextFieldV2Y();
1913 1929

  
1914
            Surface surface = (Surface)geometryManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);              
1930
            Surface surface = (Surface)geometryManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
1915 1931
            surface.addMoveToVertex(geometryManager.createPoint(v1x, v1y, SUBTYPES.GEOM2D));
1916 1932
            surface.addVertex(geometryManager.createPoint(v1x, v2y, SUBTYPES.GEOM2D));
1917 1933
            surface.addVertex(geometryManager.createPoint(v2x, v2y, SUBTYPES.GEOM2D));
1918
            surface.addVertex(geometryManager.createPoint(v2x, v1y, SUBTYPES.GEOM2D));            
1934
            surface.addVertex(geometryManager.createPoint(v2x, v1y, SUBTYPES.GEOM2D));
1919 1935
            surface.closePrimitive();
1920 1936

  
1921 1937
            return surface;
......
1923 1939

  
1924 1940
        public void setSurface(Surface surface){
1925 1941
            Envelope envelope = surface.getEnvelope();
1926
            updateCoordinates(envelope);           
1942
            updateCoordinates(envelope);
1927 1943
        }
1928 1944

  
1929 1945
        /**
......
2210 2226
        java.awt.GridBagConstraints gridBagConstraints;
2211 2227

  
2212 2228
        northPanel = new JPanel();
2213
        northPanel.setLayout(new java.awt.GridBagLayout());		
2229
        northPanel.setLayout(new java.awt.GridBagLayout());
2214 2230

  
2215 2231
        northPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
2216
            null, PluginServices.getText(this, "select_by_area"),
2232
            null, PluginServices.getText(this, "select_by_area_in_crs_of_view"),
2217 2233
            javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
2218 2234
            javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
2219 2235

  
......
2222 2238
        gridBagConstraints.gridx = 0;
2223 2239
        gridBagConstraints.gridy = 0;
2224 2240
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
2225
        gridBagConstraints.weightx = 1.0;	
2241
        gridBagConstraints.weightx = 1.0;
2226 2242
        northPanel.add(getCoordinatesPanel(), gridBagConstraints);
2227 2243

  
2228 2244
        // Adds a check box to enable or enable this kind of filtering

Also available in: Unified diff