Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extWFS2 / src / org / gvsig / wfs / gui / panels / WFSFormatPanel.java @ 36037

History | View | Annotate | Download (4.73 KB)

1
package org.gvsig.wfs.gui.panels;
2

    
3
import java.util.ArrayList;
4
import java.util.Collection;
5
import java.util.TreeSet;
6
import java.util.Vector;
7

    
8
import javax.swing.AbstractListModel;
9
import javax.swing.JList;
10
import javax.swing.JPanel;
11
import javax.swing.JScrollPane;
12

    
13
import org.gvsig.andami.PluginServices;
14
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature;
15

    
16

    
17
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
18
 *
19
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
20
 *
21
 * This program is free software; you can redistribute it and/or
22
 * modify it under the terms of the GNU General Public License
23
 * as published by the Free Software Foundation; either version 2
24
 * of the License, or (at your option) any later version.
25
 *
26
 * This program is distributed in the hope that it will be useful,
27
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 * GNU General Public License for more details.
30
 *
31
 * You should have received a copy of the GNU General Public License
32
 * along with this program; if not, write to the Free Software
33
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
34
 *
35
 * For more information, contact:
36
 *
37
 *  Generalitat Valenciana
38
 *   Conselleria d'Infraestructures i Transport
39
 *   Av. Blasco Ib??ez, 50
40
 *   46010 VALENCIA
41
 *   SPAIN
42
 *
43
 *      +34 963862235
44
 *   gvsig@gva.es
45
 *      www.gvsig.gva.es
46
 *
47
 *    or
48
 *
49
 *   IVER T.I. S.A
50
 *   Salamanca 50
51
 *   46005 Valencia
52
 *   Spain
53
 *
54
 *   +34 963163400
55
 *   dac@iver.es
56
 */
57
/* CVS MESSAGES:
58
 *
59
 * $Id: WFSFormatPanel.java 5856 2006-06-15 07:50:58Z jorpiell $
60
 * $Log$
61
 * Revision 1.1  2006-06-15 07:50:58  jorpiell
62
 * A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
63
 *
64
 *
65
 */
66
/**
67
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
68
 */
69
public class WFSFormatPanel extends JPanel {
70
        private JPanel srsPanel = null;
71
        private JScrollPane jScrollPane2 = null;
72
        private JList lstSRSs = null;
73

    
74
        /**
75
         * This method initializes 
76
         * 
77
         */
78
        public WFSFormatPanel() {
79
                super();
80
                initialize();
81
        }
82

    
83
        /**
84
         * This method initializes this
85
         * 
86
         */
87
        private void initialize() {
88
                this.setLayout(null);
89
                this.setBounds(10, 5, 481, 427);
90
                this.add(getSrsPanel(), null);
91
                        
92
        }
93

    
94
        /**
95
         * This method initializes srsPanel        
96
         *         
97
         * @return javax.swing.JPanel        
98
         */
99
        private JPanel getSrsPanel() {
100
                if (srsPanel == null) {
101
                        srsPanel = new JPanel();
102
                        srsPanel.setLayout(null);
103
                        srsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
104
                    null, PluginServices.getText(this, "seleccionar_srs"),
105
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
106
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
107
                        srsPanel.setBounds(7, 10, 453, 168);
108
                        srsPanel.add(getJScrollPane2(), null);
109
                }
110
                return srsPanel;
111
        }
112
        
113
        /**
114
         * This method initializes jScrollPane2
115
         *
116
         * @return javax.swing.JScrollPane
117
         */
118
        private javax.swing.JScrollPane getJScrollPane2() {
119
                if (jScrollPane2 == null) {
120
                        jScrollPane2 = new javax.swing.JScrollPane();
121
                        jScrollPane2.setBounds(5, 23, 442, 141);
122
                        jScrollPane2.setViewportView(getLstSRSs());
123
                        jScrollPane2.setPreferredSize(new java.awt.Dimension(100, 200));
124
                }
125

    
126
                return jScrollPane2;
127
        }
128
        
129
        /**
130
         * This method initializes lstSRSs
131
         *
132
         * @return javax.swing.JList
133
         */
134
        public javax.swing.JList getLstSRSs() {
135
                if (lstSRSs == null) {
136
                        lstSRSs = new javax.swing.JList();
137
                        lstSRSs.setModel(new SRSListModel());
138
                        lstSRSs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
139
                        lstSRSs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
140
                                public void valueChanged(
141
                                                javax.swing.event.ListSelectionEvent e) {
142
                                        int i = lstSRSs.getSelectedIndex();                                        
143
                                }
144
                        });
145
                }
146

    
147
                return lstSRSs;
148
        }
149

    
150
        /**
151
         * Refresh the panel
152
         * @param feature
153
         */
154
        public void refresh(WFSSelectedFeature feature) {
155
                setFormats(feature);        
156
        }
157
        
158
        /**
159
         * Sets a SRS list
160
         * @param feature
161
         */
162
        private void setFormats(WFSSelectedFeature feature){
163
                getLstSRSs().setListData(new Object[0]);
164
                Vector srs = feature.getSrs();
165
                getLstSRSs().setListData(srs.toArray());
166
        }
167
        
168
        public class SRSListModel extends AbstractListModel {
169
                private static final long serialVersionUID = -6134561791965083588L;
170
                ArrayList srs = new ArrayList();
171
                
172
                public int getSize() {
173
                        return srs.size();
174
                }
175

    
176
                public Object getElementAt(int index) {
177
                        return srs.get(index);
178
                }
179
                
180
                public void setAll(Collection c) {
181
                        
182
                        srs.clear();
183
                        srs.addAll(c);
184
                }
185
                
186
                public Collection intersect(Collection c) {
187
                        TreeSet resul = new TreeSet();
188
                    for (int i = 0; i < srs.size(); i++) {
189
                                if (c.contains(srs.get(i)))
190
                                        resul.add(srs.get(i));
191
                        }
192
                    return resul;        
193
                }
194
        }
195
}