svn-gvsig-desktop / tags / v1_0_2_Build_894 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / selectionByTheme / SelectionByTheme.java @ 10309
History | View | Annotate | Download (9.75 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.gui.selectionByTheme; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.GridLayout; |
45 |
import java.util.ArrayList; |
46 |
|
47 |
import javax.swing.DefaultComboBoxModel; |
48 |
import javax.swing.JLabel; |
49 |
import javax.swing.JPanel; |
50 |
|
51 |
import org.gvsig.gui.beans.swing.JButton; |
52 |
|
53 |
import com.iver.andami.PluginServices; |
54 |
import com.iver.andami.ui.mdiManager.IWindow; |
55 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
56 |
import com.iver.utiles.swing.JComboBox; |
57 |
|
58 |
|
59 |
public class SelectionByTheme extends JPanel implements IWindow { |
60 |
public static final int EQUALS = 0; |
61 |
public static final int DISJOINT = 1; |
62 |
public static final int INTERSECTS = 2; |
63 |
public static final int TOUCHES = 3; |
64 |
public static final int CROSSES = 4; |
65 |
public static final int WITHIN = 5; |
66 |
public static final int CONTAINS = 6; |
67 |
public static final int OVERLAPS = 7; |
68 |
public final String[] textosAcciones = new String[] { |
69 |
PluginServices.getText(this, "Sean_iguales_a"), //"sean iguales a", |
70 |
PluginServices.getText(this, "Sean_disjuntos_a"), //"sean disjuntos a", |
71 |
PluginServices.getText(this, "Intersecten_con"), //"intersecten con", |
72 |
PluginServices.getText(this, "Toquen"), //"toquen", |
73 |
PluginServices.getText(this, "Crucen_con"), //"crucen con", |
74 |
PluginServices.getText(this, "Contengan"), //"contengan", |
75 |
PluginServices.getText(this, "Esten_contenidos_en"), //"est?n contenidos en", |
76 |
PluginServices.getText(this, "Se_superponen_a"), //"se superponen a" |
77 |
}; |
78 |
|
79 |
private SelectionByThemeModel dataSource = null; |
80 |
|
81 |
private ArrayList listeners = new ArrayList(); |
82 |
|
83 |
private JPanel jPanel = null; |
84 |
private JPanel jPanel1 = null; |
85 |
private JLabel jLabel = null; |
86 |
private JComboBox cmbAction = null; |
87 |
private JLabel jLabel1 = null; |
88 |
private JComboBox cmbCapas = null; |
89 |
private JButton btnNew = null; |
90 |
private JButton btnAdd = null; |
91 |
private JButton btnFrom = null; |
92 |
private JButton btnCancel = null; |
93 |
/**
|
94 |
* This is the default constructor
|
95 |
*/
|
96 |
public SelectionByTheme() {
|
97 |
super();
|
98 |
initialize(); |
99 |
} |
100 |
/**
|
101 |
* This method initializes this
|
102 |
*
|
103 |
* @return void
|
104 |
*/
|
105 |
private void initialize() { |
106 |
this.setLayout(new BorderLayout(10, 10)); |
107 |
this.add(new JLabel(), BorderLayout.NORTH); |
108 |
this.add(new JLabel(), BorderLayout.WEST); |
109 |
this.add(getJPanel(), BorderLayout.CENTER); |
110 |
this.add(getJPanel1(), BorderLayout.EAST); |
111 |
this.add(new JLabel(), BorderLayout.SOUTH); |
112 |
this.setSize(540, 95); |
113 |
} |
114 |
/**
|
115 |
* This method initializes jPanel
|
116 |
*
|
117 |
* @return JPanel
|
118 |
*/
|
119 |
private JPanel getJPanel() { |
120 |
if(jPanel == null) { |
121 |
jPanel = new JPanel(); |
122 |
java.awt.FlowLayout layFlowLayout1 = new java.awt.FlowLayout();
|
123 |
layFlowLayout1.setVgap(30);
|
124 |
jPanel.setLayout(new GridLayout(4, 2, 5, 5)); |
125 |
jPanel.add(getJLabel(), null);
|
126 |
jPanel.add(getCmbAction(), null);
|
127 |
jPanel.add(getJLabel1(), null);
|
128 |
jPanel.add(getCmbCapas(), null);
|
129 |
|
130 |
} |
131 |
return jPanel;
|
132 |
} |
133 |
/**
|
134 |
* This method initializes jPanel1
|
135 |
*
|
136 |
* @return JPanel
|
137 |
*/
|
138 |
private JPanel getJPanel1() { |
139 |
if(jPanel1 == null) { |
140 |
jPanel1 = new JPanel(); |
141 |
jPanel1.setLayout(new GridLayout(4, 1, 5, 5)); |
142 |
jPanel1.add(getBtnNew(), null);
|
143 |
jPanel1.add(getBtnAdd(), null);
|
144 |
jPanel1.add(getBtnFrom(), null);
|
145 |
jPanel1.add(getBtnCancel(), null);
|
146 |
jPanel1.setPreferredSize(new java.awt.Dimension(200,220)); |
147 |
} |
148 |
return jPanel1;
|
149 |
} |
150 |
/**
|
151 |
* This method initializes jLabel
|
152 |
*
|
153 |
* @return JLabel
|
154 |
*/
|
155 |
private JLabel getJLabel() { |
156 |
if(jLabel == null) { |
157 |
jLabel = new JLabel(); |
158 |
jLabel.setText(PluginServices.getText(this, "Seleccionar_de_las_capas_activas_los_elementos_que") + "... "); |
159 |
} |
160 |
return jLabel;
|
161 |
} |
162 |
/**
|
163 |
* This method initializes cmbAction
|
164 |
*
|
165 |
* @return JComboBox
|
166 |
*/
|
167 |
private JComboBox getCmbAction() { |
168 |
if(cmbAction == null) { |
169 |
cmbAction = new JComboBox(); |
170 |
cmbAction.setPreferredSize(new java.awt.Dimension(200,20)); |
171 |
DefaultComboBoxModel model = new DefaultComboBoxModel(textosAcciones); |
172 |
cmbAction.setModel(model); |
173 |
} |
174 |
return cmbAction;
|
175 |
} |
176 |
/**
|
177 |
* This method initializes jLabel1
|
178 |
*
|
179 |
* @return JLabel
|
180 |
*/
|
181 |
private JLabel getJLabel1() { |
182 |
if(jLabel1 == null) { |
183 |
jLabel1 = new JLabel(); |
184 |
jLabel1.setText(PluginServices.getText(this, "Elementos_seleccionados_de_la_capa")); |
185 |
} |
186 |
return jLabel1;
|
187 |
} |
188 |
/**
|
189 |
* This method initializes cmbCapas
|
190 |
*
|
191 |
* @return JComboBox
|
192 |
*/
|
193 |
private JComboBox getCmbCapas() { |
194 |
if(cmbCapas == null) { |
195 |
cmbCapas = new JComboBox(); |
196 |
cmbCapas.setPreferredSize(new java.awt.Dimension(200,20)); |
197 |
} |
198 |
return cmbCapas;
|
199 |
} |
200 |
/**
|
201 |
* This method initializes btnNew
|
202 |
*
|
203 |
* @return JButton
|
204 |
*/
|
205 |
private JButton getBtnNew() { |
206 |
if(btnNew == null) { |
207 |
btnNew = new JButton(); |
208 |
btnNew.setText(PluginServices.getText(this, "Nuevo_conjunto")); |
209 |
btnNew.setMargin(new java.awt.Insets(2,2,2,2)); |
210 |
btnNew.addActionListener(new java.awt.event.ActionListener() {
|
211 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
212 |
callNewListeners(cmbCapas.getSelectedIndex(), cmbAction.getSelectedIndex()); |
213 |
} |
214 |
}); |
215 |
} |
216 |
return btnNew;
|
217 |
} |
218 |
/**
|
219 |
* This method initializes btnAdd
|
220 |
*
|
221 |
* @return JButton
|
222 |
*/
|
223 |
private JButton getBtnAdd() { |
224 |
if(btnAdd == null) { |
225 |
btnAdd = new JButton(); |
226 |
btnAdd.setText(PluginServices.getText(this, "Anadir_al_conjunto")); |
227 |
btnAdd.setMargin(new java.awt.Insets(2,2,2,2)); |
228 |
btnAdd.addActionListener(new java.awt.event.ActionListener() {
|
229 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
230 |
callAddToListeners(cmbCapas.getSelectedIndex(), cmbAction.getSelectedIndex()); |
231 |
} |
232 |
}); |
233 |
} |
234 |
return btnAdd;
|
235 |
} |
236 |
/**
|
237 |
* This method initializes btnFrom
|
238 |
*
|
239 |
* @return JButton
|
240 |
*/
|
241 |
private JButton getBtnFrom() { |
242 |
if(btnFrom == null) { |
243 |
btnFrom = new JButton(); |
244 |
btnFrom.setText(PluginServices.getText(this, "Seleccionar_del_conjunto")); |
245 |
btnFrom.setMargin(new java.awt.Insets(2,2,2,2)); |
246 |
btnFrom.addActionListener(new java.awt.event.ActionListener() {
|
247 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
248 |
callFromListeners(cmbCapas.getSelectedIndex(), cmbAction.getSelectedIndex()); |
249 |
} |
250 |
}); |
251 |
} |
252 |
return btnFrom;
|
253 |
} |
254 |
/**
|
255 |
* This method initializes btnCancel
|
256 |
*
|
257 |
* @return JButton
|
258 |
*/
|
259 |
private JButton getBtnCancel() { |
260 |
if(btnCancel == null) { |
261 |
btnCancel = new JButton(); |
262 |
btnCancel.setText(PluginServices.getText(this, "Cancel")); |
263 |
btnCancel.setMargin(new java.awt.Insets(2,2,2,2)); |
264 |
btnCancel.addActionListener(new java.awt.event.ActionListener() {
|
265 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
266 |
PluginServices.getMDIManager().closeWindow(SelectionByTheme.this); |
267 |
} |
268 |
}); |
269 |
} |
270 |
return btnCancel;
|
271 |
} |
272 |
|
273 |
/**
|
274 |
* @return
|
275 |
*/
|
276 |
public SelectionByThemeModel getModel() {
|
277 |
return dataSource;
|
278 |
} |
279 |
|
280 |
/**
|
281 |
* @param source
|
282 |
*/
|
283 |
public void setModel(SelectionByThemeModel source) { |
284 |
dataSource = source; |
285 |
String[] nameLayers = new String[dataSource.getLayers().getLayersCount()]; |
286 |
for (int i=0; i < nameLayers.length; i++) |
287 |
nameLayers[i] = dataSource.getLayers().getLayer(i).getName(); |
288 |
DefaultComboBoxModel model =
|
289 |
new DefaultComboBoxModel(nameLayers); |
290 |
cmbCapas.setModel(model); |
291 |
} |
292 |
/**
|
293 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
294 |
*/
|
295 |
public WindowInfo getWindowInfo() {
|
296 |
WindowInfo vi = new WindowInfo(WindowInfo.MODALDIALOG);
|
297 |
vi.setWidth(this.getWidth()+8); |
298 |
vi.setHeight(this.getHeight());
|
299 |
vi.setTitle(PluginServices.getText(this, "Seleccion_por_capa")); |
300 |
return vi;
|
301 |
} |
302 |
|
303 |
private void callNewListeners(int selection, int actionCode){ |
304 |
for (int i = 0; i < listeners.size(); |
305 |
i++) { |
306 |
SelectionByThemeListener l = (SelectionByThemeListener) listeners.get(i); |
307 |
l.newSet(dataSource.getLayers().getActives(), dataSource.getLayers().getLayer(selection), actionCode); |
308 |
} |
309 |
|
310 |
} |
311 |
|
312 |
private void callAddToListeners(int selection, int actionCode){ |
313 |
for (int i = 0; i < listeners.size(); |
314 |
i++) { |
315 |
SelectionByThemeListener l = (SelectionByThemeListener) listeners.get(i); |
316 |
l.addToSet(dataSource.getLayers().getActives(), dataSource.getLayers().getLayer(selection), actionCode); |
317 |
} |
318 |
|
319 |
} |
320 |
|
321 |
private void callFromListeners(int selection, int actionCode){ |
322 |
for (int i = 0; i < listeners.size(); |
323 |
i++) { |
324 |
SelectionByThemeListener l = (SelectionByThemeListener) listeners.get(i); |
325 |
l.fromSet(dataSource.getLayers().getActives(), dataSource.getLayers().getLayer(selection), actionCode); |
326 |
} |
327 |
|
328 |
} |
329 |
|
330 |
/**
|
331 |
* DOCUMENT ME!
|
332 |
*
|
333 |
* @param arg0
|
334 |
*
|
335 |
* @return
|
336 |
*/
|
337 |
public boolean addSelectionListener(SelectionByThemeListener arg0) { |
338 |
return listeners.add(arg0);
|
339 |
} |
340 |
|
341 |
/**
|
342 |
* DOCUMENT ME!
|
343 |
*
|
344 |
* @param arg0
|
345 |
*
|
346 |
* @return
|
347 |
*/
|
348 |
public boolean removeSelectionListener(SelectionByThemeListener arg0) { |
349 |
return listeners.remove(arg0);
|
350 |
} |
351 |
/**
|
352 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
353 |
*/
|
354 |
public void viewActivated() { |
355 |
} |
356 |
|
357 |
} // @jve:visual-info decl-index=0 visual-constraint="10,10"
|