1 |
1 |
package com.iver.cit.gvsig.gui.Panels;
|
2 |
2 |
|
|
3 |
import java.awt.Component;
|
3 |
4 |
import java.awt.FlowLayout;
|
4 |
5 |
import java.awt.GridBagConstraints;
|
5 |
6 |
import java.awt.GridBagLayout;
|
|
7 |
import java.awt.geom.Point2D;
|
6 |
8 |
|
7 |
9 |
import javax.swing.JButton;
|
8 |
10 |
import javax.swing.JComboBox;
|
9 |
11 |
import javax.swing.JLabel;
|
|
12 |
import javax.swing.JOptionPane;
|
10 |
13 |
import javax.swing.JPanel;
|
11 |
14 |
import javax.swing.JTextField;
|
12 |
15 |
|
... | ... | |
18 |
21 |
public class SelectPointsPanel extends JPanel {
|
19 |
22 |
|
20 |
23 |
private JPanel pGeneral = null;
|
21 |
|
private JPanel pFileSelection = null;
|
22 |
|
private JPanel pControls = null;
|
|
24 |
private JPanel pPointSelection = null;
|
|
25 |
private JPanel pControlPoint = null;
|
23 |
26 |
private JButton bPrev = null;
|
24 |
27 |
private JComboBox cPoint = null;
|
25 |
28 |
private JLabel lNumberOfPoints = null;
|
26 |
29 |
private JLabel lPoint = null;
|
27 |
30 |
private JButton bNext = null;
|
28 |
31 |
private JButton bNew = null;
|
29 |
|
private JPanel pPoint = null;
|
|
32 |
private JPanel pInfoPoint = null;
|
30 |
33 |
private JPanel pX = null;
|
31 |
34 |
private JPanel pY = null;
|
32 |
35 |
private JPanel pLatitud = null;
|
... | ... | |
40 |
43 |
private JTextField tLatitud = null;
|
41 |
44 |
private JTextField tLongitud = null;
|
42 |
45 |
|
|
46 |
private JPanel pControls = null;
|
|
47 |
private JPanel pSelectFromView = null;
|
|
48 |
private JButton bSelectFromView = null;
|
|
49 |
private FLyrPoints lyrPoints = null;
|
|
50 |
|
43 |
51 |
/**
|
44 |
52 |
* This is the default constructor
|
45 |
53 |
*/
|
... | ... | |
80 |
88 |
pGeneral = new JPanel();
|
81 |
89 |
pGeneral.setLayout(new GridBagLayout());
|
82 |
90 |
pGeneral.setPreferredSize(new java.awt.Dimension(400,240));
|
83 |
|
pGeneral.add(getPFileSelection(), gridBagConstraints);
|
84 |
|
pGeneral.add(getPControls(), gridBagConstraints1);
|
|
91 |
pGeneral.add(getPPointSelection(), gridBagConstraints);
|
|
92 |
pGeneral.add(getPControlPoint(), gridBagConstraints1);
|
85 |
93 |
}
|
86 |
94 |
return pGeneral;
|
87 |
95 |
}
|
... | ... | |
91 |
99 |
*
|
92 |
100 |
* @return javax.swing.JPanel
|
93 |
101 |
*/
|
94 |
|
private JPanel getPFileSelection() {
|
95 |
|
if (pFileSelection == null) {
|
|
102 |
private JPanel getPPointSelection() {
|
|
103 |
if (pPointSelection == null) {
|
96 |
104 |
lPoint = new JLabel();
|
97 |
|
lPoint.setText("Punto");
|
|
105 |
lPoint.setText(PluginServices.getText(this, "punto"));
|
98 |
106 |
lPoint.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
99 |
107 |
lPoint.setPreferredSize(new java.awt.Dimension(46,15));
|
100 |
108 |
lNumberOfPoints = new JLabel();
|
101 |
|
lNumberOfPoints.setText("de 1");
|
|
109 |
lNumberOfPoints.setText(PluginServices.getText(this, "de") + " 1");
|
102 |
110 |
lNumberOfPoints.setPreferredSize(new java.awt.Dimension(37,15));
|
103 |
111 |
FlowLayout flowLayout = new FlowLayout();
|
104 |
112 |
flowLayout.setVgap(8);
|
105 |
113 |
flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
|
106 |
|
pFileSelection = new JPanel();
|
107 |
|
pFileSelection.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.black));
|
108 |
|
pFileSelection.setLayout(flowLayout);
|
109 |
|
pFileSelection.setPreferredSize(new java.awt.Dimension(380,50));
|
110 |
|
pFileSelection.add(getBNew(), null);
|
111 |
|
pFileSelection.add(getBPrev(), null);
|
112 |
|
pFileSelection.add(lPoint, null);
|
113 |
|
pFileSelection.add(getCPoint(), null);
|
114 |
|
pFileSelection.add(lNumberOfPoints, null);
|
115 |
|
pFileSelection.add(getBNext(), null);
|
|
114 |
pPointSelection = new JPanel();
|
|
115 |
pPointSelection.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.black));
|
|
116 |
pPointSelection.setLayout(flowLayout);
|
|
117 |
pPointSelection.setPreferredSize(new java.awt.Dimension(380,50));
|
|
118 |
pPointSelection.add(getBPrev(), null);
|
|
119 |
pPointSelection.add(lPoint, null);
|
|
120 |
pPointSelection.add(getCPoint(), null);
|
|
121 |
pPointSelection.add(lNumberOfPoints, null);
|
|
122 |
pPointSelection.add(getBNext(), null);
|
|
123 |
pPointSelection.add(getBNew(), null);
|
116 |
124 |
}
|
117 |
|
return pFileSelection;
|
|
125 |
return pPointSelection;
|
118 |
126 |
}
|
119 |
127 |
|
120 |
128 |
/**
|
121 |
129 |
* This method initializes pControls
|
122 |
130 |
*
|
123 |
131 |
*/
|
124 |
|
private JPanel getPControls() {
|
125 |
|
if (pControls == null) {
|
|
132 |
private JPanel getPControlPoint() {
|
|
133 |
if (pControlPoint == null) {
|
|
134 |
GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
|
126 |
135 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
|
127 |
|
gridBagConstraints2.gridx = 0;
|
128 |
|
gridBagConstraints2.insets = new java.awt.Insets(0,180,0,0);
|
|
136 |
gridBagConstraints2.gridx = 1;
|
|
137 |
gridBagConstraints2.insets = new java.awt.Insets(0,0,0,0);
|
129 |
138 |
gridBagConstraints2.gridy = 0;
|
130 |
|
pControls = new JPanel();
|
131 |
|
pControls.setLayout(new GridBagLayout());
|
132 |
|
pControls.setPreferredSize(new java.awt.Dimension(380,160));
|
133 |
|
pControls.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0));
|
134 |
|
pControls.add(getPPoint(), gridBagConstraints2);
|
|
139 |
pControlPoint = new JPanel();
|
|
140 |
pControlPoint.setLayout(new GridBagLayout());
|
|
141 |
pControlPoint.setPreferredSize(new java.awt.Dimension(380,160));
|
|
142 |
pControlPoint.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0));
|
|
143 |
gridBagConstraints11.gridy = 0;
|
|
144 |
gridBagConstraints11.gridx = 0;
|
|
145 |
pControlPoint.add(getPInfoPoint(), gridBagConstraints2);
|
|
146 |
pControlPoint.add(getPControls(), gridBagConstraints11);
|
135 |
147 |
}
|
136 |
|
return pControls;
|
|
148 |
return pControlPoint;
|
137 |
149 |
}
|
138 |
150 |
|
139 |
151 |
/**
|
... | ... | |
185 |
197 |
}
|
186 |
198 |
|
187 |
199 |
/**
|
188 |
|
* This method initializes bNew
|
|
200 |
* Obtiene una capa de puntos. Si no existe crea una.
|
|
201 |
* @return
|
|
202 |
*/
|
|
203 |
private FLyrPoints getLyrPoint(){
|
|
204 |
//Buscamos una capa FlyrPoint en la vista y si no la hay la creamos
|
|
205 |
View theView = (View) PluginServices.getMDIManager().getActiveView();
|
|
206 |
|
|
207 |
//Si todavia no hay ninguna cargada la buscamos
|
|
208 |
if(lyrPoints == null){
|
|
209 |
for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
|
|
210 |
FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
|
|
211 |
if(lyr instanceof FLyrPoints)
|
|
212 |
lyrPoints = (FLyrPoints)lyr;
|
|
213 |
}
|
|
214 |
}
|
|
215 |
|
|
216 |
//Si no hemos encontrado ninguna la creamos
|
|
217 |
if(lyrPoints == null){
|
|
218 |
lyrPoints = new FLyrPoints();
|
|
219 |
lyrPoints.setName("layerPoints");
|
|
220 |
lyrPoints.setVisible(true);
|
|
221 |
theView.getMapControl().getMapContext().getLayers().addLayer(lyrPoints);
|
|
222 |
}
|
|
223 |
return lyrPoints;
|
|
224 |
}
|
|
225 |
|
|
226 |
/**
|
|
227 |
* Este m?todo inicializa el bot?n que crea un nuevo punto de georreferenciaci?n.
|
189 |
228 |
*
|
190 |
229 |
* @return javax.swing.JButton
|
191 |
230 |
*/
|
... | ... | |
195 |
234 |
bNew.setText(PluginServices.getText(this, "nuevo"));
|
196 |
235 |
bNew.addActionListener(new java.awt.event.ActionListener() {
|
197 |
236 |
public void actionPerformed(java.awt.event.ActionEvent e) {
|
198 |
|
//Buscamos una capa FlyrPoint en la vista y si no la hay la creamos
|
199 |
|
View theView = (View) PluginServices.getMDIManager().getActiveView();
|
200 |
|
FLyrPoints lyrPoints = null;
|
201 |
|
for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
|
202 |
|
FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
|
203 |
|
if(lyr instanceof FLyrPoints)
|
204 |
|
lyrPoints = (FLyrPoints)lyr;
|
|
237 |
getLyrPoint();
|
|
238 |
//Si hay alg?n punto en la lista se guarda en la capa
|
|
239 |
if(getCPoint().getSelectedIndex() != -1){
|
|
240 |
Point2D pixel = null, map = null;
|
|
241 |
if( getTX().getText().equals("") ||
|
|
242 |
getTY().getText().equals("") ||
|
|
243 |
getLatitud().getText().equals("") ||
|
|
244 |
getLongitud().getText().equals("")){
|
|
245 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),
|
|
246 |
PluginServices.getText(this, "coordenadas_vacias"));
|
|
247 |
return;
|
|
248 |
}
|
|
249 |
/*pixel = new Point2D.Double( Double.valueOf(getTX().getText()),
|
|
250 |
Double.valueOf(getTY().getText()));
|
|
251 |
map = new Point2D.Double( Double.valueOf(getLatitud().getText()),
|
|
252 |
Double.valueOf(getLongitud().getText()));*/
|
|
253 |
//lyrPoints.updatePoint()
|
205 |
254 |
}
|
206 |
|
|
207 |
|
//Creamos la capa si no existe
|
208 |
|
if(lyrPoints == null){
|
209 |
|
lyrPoints = new FLyrPoints();
|
210 |
|
lyrPoints.setName("layerPoints");
|
211 |
|
lyrPoints.setVisible(true);
|
212 |
|
theView.getMapControl().getMapContext().getLayers().addLayer(lyrPoints);
|
213 |
|
}
|
214 |
|
lyrPoints.setLastTool(theView.getMapControl().getTool());
|
215 |
|
theView.getMapControl().setTool("pointLyrSelection");
|
|
255 |
getLyrPoint();
|
|
256 |
getTX().setText("");
|
|
257 |
getTY().setText("");
|
|
258 |
getLatitud().setText("");
|
|
259 |
getLongitud().setText("");
|
|
260 |
getCPoint().addItem("" + (lyrPoints.getCountPoints() + 1));
|
216 |
261 |
}
|
217 |
262 |
});
|
218 |
263 |
}
|
... | ... | |
220 |
265 |
}
|
221 |
266 |
|
222 |
267 |
/**
|
|
268 |
* Este m?todo inicializa el bot?n seleccionar desde la vista.
|
|
269 |
*
|
|
270 |
* @return javax.swing.JButton
|
|
271 |
*/
|
|
272 |
private JButton getBSelectFromView() {
|
|
273 |
if (bSelectFromView == null) {
|
|
274 |
bSelectFromView = new JButton();
|
|
275 |
bSelectFromView.setText(PluginServices.getText(this, "seleccionar"));
|
|
276 |
bSelectFromView.addActionListener(new java.awt.event.ActionListener() {
|
|
277 |
public void actionPerformed(java.awt.event.ActionEvent e) {
|
|
278 |
View theView = (View) PluginServices.getMDIManager().getActiveView();
|
|
279 |
getLyrPoint();
|
|
280 |
lyrPoints.setLastTool(theView.getMapControl().getTool());
|
|
281 |
theView.getMapControl().setTool("pointLyrSelection");
|
|
282 |
}
|
|
283 |
});
|
|
284 |
}
|
|
285 |
return bSelectFromView;
|
|
286 |
}
|
|
287 |
|
|
288 |
/**
|
223 |
289 |
* This method initializes pPoint
|
224 |
290 |
*
|
225 |
291 |
* @return javax.swing.JPanel
|
226 |
292 |
*/
|
227 |
|
private JPanel getPPoint() {
|
228 |
|
if (pPoint == null) {
|
|
293 |
private JPanel getPInfoPoint() {
|
|
294 |
if (pInfoPoint == null) {
|
229 |
295 |
GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
|
230 |
296 |
gridBagConstraints6.insets = new java.awt.Insets(0,0,0,0);
|
231 |
297 |
gridBagConstraints6.gridy = 3;
|
... | ... | |
245 |
311 |
gridBagConstraints3.gridy = 0;
|
246 |
312 |
gridBagConstraints3.ipadx = 0;
|
247 |
313 |
gridBagConstraints3.gridx = 0;
|
248 |
|
pPoint = new JPanel();
|
249 |
|
pPoint.setLayout(new GridBagLayout());
|
250 |
|
pPoint.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "punto"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
251 |
|
pPoint.setPreferredSize(new java.awt.Dimension(200,160));
|
252 |
|
pPoint.add(getPX(), gridBagConstraints3);
|
253 |
|
pPoint.add(getPY(), gridBagConstraints4);
|
254 |
|
pPoint.add(getPLatitud(), gridBagConstraints5);
|
255 |
|
pPoint.add(getPLongitud(), gridBagConstraints6);
|
|
314 |
pInfoPoint = new JPanel();
|
|
315 |
pInfoPoint.setLayout(new GridBagLayout());
|
|
316 |
pInfoPoint.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "punto"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
|
317 |
pInfoPoint.setPreferredSize(new java.awt.Dimension(200,160));
|
|
318 |
pInfoPoint.add(getPX(), gridBagConstraints3);
|
|
319 |
pInfoPoint.add(getPY(), gridBagConstraints4);
|
|
320 |
pInfoPoint.add(getPLatitud(), gridBagConstraints5);
|
|
321 |
pInfoPoint.add(getPLongitud(), gridBagConstraints6);
|
256 |
322 |
}
|
257 |
|
return pPoint;
|
|
323 |
return pInfoPoint;
|
258 |
324 |
}
|
259 |
325 |
|
260 |
326 |
/**
|
... | ... | |
292 |
358 |
pY.setLayout(flowLayout1);
|
293 |
359 |
pY.setPreferredSize(new java.awt.Dimension(185,29));
|
294 |
360 |
pY.add(lY, null);
|
295 |
|
pY.add(getJTextField(), null);
|
|
361 |
pY.add(getTY(), null);
|
296 |
362 |
}
|
297 |
363 |
return pY;
|
298 |
364 |
}
|
... | ... | |
312 |
378 |
pLatitud.setLayout(flowLayout3);
|
313 |
379 |
pLatitud.setPreferredSize(new java.awt.Dimension(185,29));
|
314 |
380 |
pLatitud.add(lLatitud, null);
|
315 |
|
pLatitud.add(getJTextField1(), null);
|
|
381 |
pLatitud.add(getLatitud(), null);
|
316 |
382 |
}
|
317 |
383 |
return pLatitud;
|
318 |
384 |
}
|
... | ... | |
332 |
398 |
pLongitud.setLayout(flowLayout4);
|
333 |
399 |
pLongitud.setPreferredSize(new java.awt.Dimension(185,29));
|
334 |
400 |
pLongitud.add(lLongitud, null);
|
335 |
|
pLongitud.add(getJTextField2(), null);
|
|
401 |
pLongitud.add(getLongitud(), null);
|
336 |
402 |
}
|
337 |
403 |
return pLongitud;
|
338 |
404 |
}
|
... | ... | |
355 |
421 |
*
|
356 |
422 |
* @return javax.swing.JTextField
|
357 |
423 |
*/
|
358 |
|
private JTextField getJTextField() {
|
|
424 |
private JTextField getTY() {
|
359 |
425 |
if (tY == null) {
|
360 |
426 |
tY = new JTextField();
|
361 |
427 |
tY.setPreferredSize(new java.awt.Dimension(90,19));
|
... | ... | |
368 |
434 |
*
|
369 |
435 |
* @return javax.swing.JTextField
|
370 |
436 |
*/
|
371 |
|
private JTextField getJTextField1() {
|
|
437 |
private JTextField getLatitud() {
|
372 |
438 |
if (tLatitud == null) {
|
373 |
439 |
tLatitud = new JTextField();
|
374 |
440 |
tLatitud.setPreferredSize(new java.awt.Dimension(111,19));
|
... | ... | |
381 |
447 |
*
|
382 |
448 |
* @return javax.swing.JTextField
|
383 |
449 |
*/
|
384 |
|
private JTextField getJTextField2() {
|
|
450 |
private JTextField getLongitud() {
|
385 |
451 |
if (tLongitud == null) {
|
386 |
452 |
tLongitud = new JTextField();
|
387 |
453 |
tLongitud.setPreferredSize(new java.awt.Dimension(111,19));
|
... | ... | |
389 |
455 |
return tLongitud;
|
390 |
456 |
}
|
391 |
457 |
|
392 |
|
}
|
|
458 |
/**
|
|
459 |
* This method initializes jPanel
|
|
460 |
*
|
|
461 |
* @return javax.swing.JPanel
|
|
462 |
*/
|
|
463 |
private JPanel getPControls() {
|
|
464 |
if (pControls == null) {
|
|
465 |
pControls = new JPanel();
|
|
466 |
pControls.setPreferredSize(new java.awt.Dimension(180,160));
|
|
467 |
pControls.add(getPSelectFromView(), null);
|
|
468 |
}
|
|
469 |
return pControls;
|
|
470 |
}
|
|
471 |
/**
|
|
472 |
* This method initializes jPanel
|
|
473 |
*
|
|
474 |
* @return javax.swing.JPanel
|
|
475 |
*/
|
|
476 |
private JPanel getPSelectFromView() {
|
|
477 |
if (pSelectFromView == null) {
|
|
478 |
pSelectFromView = new JPanel();
|
|
479 |
pSelectFromView.setPreferredSize(new java.awt.Dimension(150,35));
|
|
480 |
pSelectFromView.add(getBSelectFromView(), null);
|
|
481 |
}
|
|
482 |
return pSelectFromView;
|
|
483 |
}
|
|
484 |
|
|
485 |
}
|