Statistics
| Revision:

gvsig-raster / org.gvsig.raster.wms / trunk / org.gvsig.raster.wms / org.gvsig.raster.wms.app / org.gvsig.raster.wms.app.wmsclient / src / main / java / org / gvsig / raster / wms / app / wmsclient / gui / panel / WebMapContextSettingsPanel.java @ 1362

History | View | Annotate | Download (38 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
 
23
package org.gvsig.raster.wms.app.wmsclient.gui.panel;
24

    
25
import java.awt.Component;
26
import java.awt.Dimension;
27
import java.awt.FlowLayout;
28
import java.awt.geom.Rectangle2D;
29
import java.io.File;
30
import java.util.ArrayList;
31
import java.util.prefs.Preferences;
32

    
33
import javax.swing.ButtonGroup;
34
import javax.swing.JButton;
35
import javax.swing.JComboBox;
36
import javax.swing.JLabel;
37
import javax.swing.JOptionPane;
38
import javax.swing.JPanel;
39
import javax.swing.JRadioButton;
40
import javax.swing.JScrollPane;
41
import javax.swing.JTextArea;
42
import javax.swing.JTextField;
43
import javax.swing.SwingConstants;
44
import javax.swing.filechooser.FileFilter;
45

    
46
import org.gvsig.andami.PluginServices;
47
import org.gvsig.andami.messages.NotificationManager;
48
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
49
import org.gvsig.andami.ui.mdiManager.WindowInfo;
50
import org.gvsig.app.project.documents.view.DefaultViewDocument;
51
import org.gvsig.app.project.documents.view.ViewManager;
52
import org.gvsig.fmap.dal.exception.ReadException;
53
import org.gvsig.fmap.geom.primitive.Envelope;
54
import org.gvsig.fmap.mapcontext.MapContext;
55
import org.gvsig.gui.beans.swing.JFileChooser;
56
import org.gvsig.raster.wms.app.wmsclient.wmc.ExportWebMapContextExtension;
57
import org.gvsig.raster.wms.app.wmsclient.wmc.ImportWebMapContextExtension;
58
import org.gvsig.raster.wms.app.wmsclient.wmc.WebMapContext;
59
import org.gvsig.raster.wms.app.wmsclient.wmc.WebMapContextTags;
60

    
61
/**
62
 * A graphical form to fill up the customizable information of a destinantion
63
 * Web Map Context file.
64
 *
65
 * @author jaume dominguez faus - jaume.dominguez@iver.es
66
 *
67
 */
68
public class WebMapContextSettingsPanel extends JPanel implements SingletonWindow {
69
        private static final long serialVersionUID = 1L;
70
        public static Preferences fPrefs = Preferences.userRoot().node( "gvsig.mapcontext-settingspanel" );
71
        private JPanel simplePanel = null;
72
        private JPanel advancedPanel = null;
73
        private JPanel buttonsPanel = null;
74
        private JComboBox cmbVersion = null;
75
        private JLabel lblTitle = null;
76
        private JButton btnBrowseFileSystem = null;
77
        private JTextField txtTitle = null;
78
        private JLabel lblVersion = null;
79
        private JLabel lblId = null;
80
        private JTextField txtId = null;
81
        private JLabel lblFile = null;
82
        private JTextField txtFile = null;
83
        private JButton btnAdvanced = null;
84
        private JButton btnOk = null;
85
        private JButton btnCancel = null;
86
        private JLabel lblAbstract = null;
87
        private JLabel lblLogoURL = null;
88
        private JLabel lblDescriptionURL = null;
89
        private JTextArea txtAbstract = null;
90
        private JScrollPane scrlAbstract = null;
91
        private JTextField txtLogoURL = null;
92
        private JTextField txtDescriptionURL = null;
93
        private JPanel pnlMapSize = null;
94
        private JRadioButton rdBtnUseViewSize = null;
95
        private JRadioButton rdBtnCustomSize = null;
96
        private JLabel lblWidth = null;
97
        private JLabel lblHeight = null;
98
        private JTextField txtWidth = null;
99
        private JTextField txtHeight = null;
100
        private JPanel pnlContactInfo = null;
101
        private JTextField txtKeyWords = null;
102
        private JLabel lblKeyWords = null;
103
        private JLabel lblContactPerson = null;
104
        private JTextField txtContactPerson = null;
105
        private JLabel lblContactOrganization = null;
106
        private JTextField txtOrganization = null;
107
        private JLabel lblContactPosition = null;
108
        private JTextField txtContactPosition = null;
109
        private JLabel lblAddress = null;
110
        private JTextField txtAddress = null;
111
        private JLabel lblCity = null;
112
        private JTextField txtCity = null;
113
        private JLabel lblStateProvince = null;
114
        private JTextField txtStateOrProvince = null;
115
        private JLabel lblPostCode = null;
116
        private JTextField txtPostCode = null;
117
        private JLabel lblCountry = null;
118
        private JComboBox cmbCountries = null;
119
        private JLabel lblPhone = null;
120
        private JTextField txtTelephone = null;
121
        private JLabel lblFax = null;
122
        private JTextField txtFax = null;
123
        private JLabel lblEMail = null;
124
        private JTextField txtEMail = null;
125
        private boolean first = true;
126
        private boolean advanced = fPrefs.getBoolean("advanced-panel", false);
127
        private WindowInfo m_viewInfo;
128
        private String strAdvanced = PluginServices.getText(this, "advanced");
129
        private File targetFile;
130
        private WebMapContext wmc;
131
        private DefaultViewDocument[] exportableViews;
132
        private JLabel lblView = null;
133
        private JComboBox cmbViews = null;
134
        private String lastWidth, lastHeight;
135
        private int defaultWidth = 500;
136
        private int defaultHeight = 450;
137
        private JLabel lblExtent = null;
138
        private JRadioButton rdBtnCurrentViewExtent = null;
139
        private JRadioButton rdBtnFullExtent = null;
140
        private static String lastPath = null;
141

    
142
        protected boolean useFullExtent = fPrefs.getBoolean("use_full_extent", false);
143

    
144
        public WebMapContextSettingsPanel(DefaultViewDocument[] views) {
145
                super();
146
                exportableViews = views;
147
                initialize();
148
        }
149

    
150
        /**
151
         * This method initializes this
152
         *
153
         * @return void
154
         */
155
        private void initialize() {
156
                this.setLayout(null);
157

    
158
                switchPanels();
159
        }
160

    
161
        private void switchPanels() {
162
                this.removeAll();
163
                Dimension sz;
164
                this.add(getSimplePanel(), java.awt.BorderLayout.NORTH);
165
                if (advanced) {
166
                        this.add(getAdvancedPanel(), java.awt.BorderLayout.CENTER);
167
                        sz = new Dimension(535, 640);
168
                        btnAdvanced.setText(strAdvanced+"  <<");
169

    
170
                } else {
171
                        sz = new Dimension(535, 260);
172
                        btnAdvanced.setText(strAdvanced+"  >>");
173

    
174
                }
175

    
176
                this.setSize(sz);
177

    
178

    
179
                this.add(getButtonsPanel(), java.awt.BorderLayout.SOUTH);
180
                fPrefs.putBoolean("advanced-panel", advanced);
181
                if (!first) {
182
                        PluginServices.getMDIManager().changeWindowInfo(this, getWindowInfo());
183

    
184
                        PluginServices.getMDIManager().closeWindow(this);
185
                        PluginServices.getMDIManager().addWindow(this);
186
                }
187
                first = false;
188
        }
189

    
190
        public WindowInfo getWindowInfo() {
191

    
192
                m_viewInfo = new WindowInfo(WindowInfo.ICONIFIABLE);
193
                m_viewInfo.setTitle(PluginServices.getText(this, "web_map_context_settings"));
194
                m_viewInfo.setWidth(this.getWidth()+8);
195
                m_viewInfo.setHeight(getHeight());
196
                return m_viewInfo;
197
        }
198

    
199
        /**
200
         * This method initializes simplePanel
201
         *
202
         * @return javax.swing.JPanel
203
         */
204
        private JPanel getSimplePanel() {
205
                if (simplePanel == null) {
206
                        ButtonGroup group = new ButtonGroup();
207
                        lblExtent = new JLabel();
208
                        lblExtent.setBounds(9, 146, 79, 20);
209
                        lblExtent.setHorizontalTextPosition(SwingConstants.RIGHT);
210
                        lblExtent.setHorizontalAlignment(SwingConstants.RIGHT);
211
                        lblExtent.setText(PluginServices.getText(this, "map_extent")+":");
212
                        lblView = new JLabel();
213
                        lblView.setBounds(9, 24, 79, 20);
214
                        lblView.setHorizontalTextPosition(SwingConstants.RIGHT);
215
                        lblView.setHorizontalAlignment(SwingConstants.RIGHT);
216
                        lblView.setText(PluginServices.getText(this, ViewManager.TYPENAME)+":");
217
                        lblTitle = new JLabel();
218
                        lblTitle.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
219
                        lblTitle.setBounds(9, 48, 79, 20);
220
                        lblTitle.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
221
                        lblTitle.setText(PluginServices.getText(this, "title")+":");
222
                        lblId = new JLabel();
223
                        lblId.setBounds(9, 72, 79, 20);
224
                        lblId.setHorizontalTextPosition(SwingConstants.RIGHT);
225
                        lblId.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
226
                        lblId.setText(PluginServices.getText(this, "id")+":");
227
                        lblVersion = new JLabel();
228
                        lblVersion.setBounds(9, 120, 79, 20);
229
                        lblVersion.setHorizontalTextPosition(SwingConstants.RIGHT);
230
                        lblVersion.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
231
                        lblVersion.setText(PluginServices.getText(this, "version")+":");
232
                        lblFile = new JLabel();
233
                        lblFile.setBounds(9, 96, 79, 20);
234
                        lblFile.setHorizontalTextPosition(SwingConstants.RIGHT);
235
                        lblFile.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
236
                        lblFile.setText(PluginServices.getText(this, "file_name")+":");
237
                        simplePanel = new JPanel();
238
                        simplePanel.setLayout(null);
239
                        simplePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
240
                                          null, PluginServices.getText(this, "options"),
241
                                          javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
242
                                          javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
243
                        simplePanel.setBounds(new java.awt.Rectangle(0,0,535,196));
244
                        simplePanel.add(lblView, null);
245
                        simplePanel.add(getCmbViews(), null);
246
                        simplePanel.add(getTxtTitle(), null);
247
                        simplePanel.add(lblTitle, null);
248
                        simplePanel.add(getBtnBrowseFileSystem(), null);
249
                        simplePanel.add(lblVersion, null);
250
                        simplePanel.add(lblId, null);
251
                        simplePanel.add(getTxtId(), null);
252
                        simplePanel.add(lblFile, null);
253
                        simplePanel.add(getTxtFile(), null);
254
                        simplePanel.add(getBtnAdvanced(), null);
255
                        simplePanel.add(getCmbVersion(), null);
256
                        simplePanel.add(lblExtent, null);
257
                        simplePanel.add(getRdBtnCurrentViewExtent(), null);
258
                        simplePanel.add(getRdBtnFullExtent(), null);
259
                        group.add(getRdBtnCurrentViewExtent());
260
                        group.add(getRdBtnFullExtent());
261
                }
262
                return simplePanel;
263
        }
264

    
265
        /**
266
         * This method initializes advancedPanel
267
         *
268
         * @return javax.swing.JPanel
269
         */
270
        private JPanel getAdvancedPanel() {
271
                if (advancedPanel == null) {
272
                        lblKeyWords = new JLabel();
273
                        lblKeyWords.setBounds(10, 79, 99, 20);
274
                        lblKeyWords.setHorizontalTextPosition(SwingConstants.RIGHT);
275
                        lblKeyWords.setHorizontalAlignment(SwingConstants.RIGHT);
276
                        lblKeyWords.setText(PluginServices.getText(this, "keywords")+":");
277
                        lblDescriptionURL = new JLabel();
278
                        lblDescriptionURL.setBounds(10, 104, 99, 20);
279
                        lblDescriptionURL.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
280
                        lblDescriptionURL.setText(PluginServices.getText(this, "description_URL")+":");
281
                        lblDescriptionURL.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
282
                        lblLogoURL = new JLabel();
283
                        lblLogoURL.setBounds(10, 130, 99, 20);
284
                        lblLogoURL.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
285
                        lblLogoURL.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
286
                        lblLogoURL.setText(PluginServices.getText(this, "logo_URL")+":");
287
                        lblAbstract = new JLabel();
288
                        lblAbstract.setText(PluginServices.getText(this, "abstract")+":");
289
                        lblAbstract.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
290
                        lblAbstract.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
291
                        lblAbstract.setBounds(10, 27, 99, 20);
292
                        advancedPanel = new JPanel();
293
                        advancedPanel.setLayout(null);
294
                        advancedPanel.setBounds(0, 194, 535, 386);
295
                        advancedPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
296
                                          null, PluginServices.getText(this, "advanced_settings"),
297
                                          javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
298
                                          javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
299
                        advancedPanel.add(lblAbstract, null);
300
                        advancedPanel.add(lblKeyWords, null);
301
                        advancedPanel.add(lblLogoURL, null);
302
                        advancedPanel.add(lblDescriptionURL, null);
303
                        advancedPanel.add(getScrlAbstract(), null);
304
                        advancedPanel.add(getTxtLogoURL(), null);
305
                        advancedPanel.add(getTxtDescriptionURL(), null);
306
                        advancedPanel.add(getPnlMapSize(), null);
307
                        advancedPanel.add(getPnlContactInfo(), null);
308
                        advancedPanel.add(getTxtKeyWords(), null);
309
                }
310
                return advancedPanel;
311
        }
312

    
313
        /**
314
         * This method initializes buttonsPanel
315
         *
316
         * @return javax.swing.JPanel
317
         */
318
        private JPanel getButtonsPanel() {
319
                if (buttonsPanel == null) {
320
                        FlowLayout flowLayout = new FlowLayout();
321
                        flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
322
                        flowLayout.setVgap(1);
323
                        buttonsPanel = new JPanel();
324
                        buttonsPanel.setLayout(flowLayout);
325
                        buttonsPanel.add(getBtnOk(), null);
326
                        buttonsPanel.add(getBtnCancel(), null);
327
                }
328
                buttonsPanel.setBounds(0, this.getHeight()-60, 535, 38);
329

    
330
                return buttonsPanel;
331
        }
332

    
333
        /**
334
         * This method initializes cmbVersion
335
         *
336
         * @return javax.swing.JComboBox
337
         */
338
        private JComboBox getCmbVersion() {
339
                if (cmbVersion == null) {
340
                        cmbVersion = new JComboBox();
341
                        cmbVersion.setSize(89, 20);
342
                        cmbVersion.setLocation(91, 120);
343
                        for (int i = 0; i < WebMapContext.exportVersions.size(); i++) {
344
                                cmbVersion.addItem(WebMapContext.exportVersions.get(i));
345
                        }
346

    
347
                }
348
                return cmbVersion;
349
        }
350

    
351

    
352

    
353
        /**
354
         * This method initializes btnBrowseFileSystem
355
         *
356
         * @return javax.swing.JButton
357
         */
358
        private JButton getBtnBrowseFileSystem() {
359
                if (btnBrowseFileSystem == null) {
360
                        btnBrowseFileSystem = new JButton();
361
                        btnBrowseFileSystem.setBounds(403, 95, 120, 22);
362
                        btnBrowseFileSystem.addActionListener(new java.awt.event.ActionListener() {
363

    
364
                                public void actionPerformed(java.awt.event.ActionEvent e) {
365
                                        JFileChooser fc = new JFileChooser(ImportWebMapContextExtension.WMC_FILECHOOSER_ID, lastPath);
366
                                        fc.setFileFilter(new FileFilter() {
367
                                                public boolean accept(File f) {
368
                                                        return f.isDirectory() || f.getAbsolutePath().toLowerCase().endsWith(WebMapContext.FILE_EXTENSION);
369
                                                }
370

    
371
                                                public String getDescription() {
372
                                                        return PluginServices.getText(this, "ogc_mapcontext_file")+" (*.cml)";
373
                                                }
374
                                        });
375
                                        if (fc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION){
376

    
377
                                                String fileName = fc.getSelectedFile().getAbsolutePath();
378
                                                if (!fileName.toLowerCase().endsWith(WebMapContext.FILE_EXTENSION)) {
379
                                                        fileName += WebMapContext.FILE_EXTENSION;
380
                                                }
381
                                                targetFile = new File(fileName);
382
                                                getTxtFile().setText(fileName);
383
                                                lastPath  = fileName.substring(0, fileName.lastIndexOf(File.separatorChar));
384
                                        }
385

    
386
                                        fc = null;
387
                                }
388
                        });
389
                        btnBrowseFileSystem.setText(PluginServices.getText(this, "browse"));
390
                }
391
                return btnBrowseFileSystem;
392
        }
393

    
394
        /**
395
         * This method initializes txtTitle
396
         *
397
         * @return javax.swing.JTextField
398
         */
399
        private JTextField getTxtTitle() {
400
                if (txtTitle == null) {
401
                        txtTitle = new JTextField();
402
                        txtTitle.setBounds(91, 48, 432, 20);
403
                        txtTitle.setName(PluginServices.getText(this, "title"));
404
                }
405
                return txtTitle;
406
        }
407

    
408
        /**
409
         * This method initializes jTextField
410
         *
411
         * @return javax.swing.JTextField
412
         */
413
        private JTextField getTxtId() {
414
                if (txtId == null) {
415
                        txtId = new JTextField();
416
                        txtId.setBounds(91, 72, 432, 20);
417
                        txtId.setName(PluginServices.getText(this, "id"));
418
                }
419
                return txtId;
420
        }
421

    
422
        /**
423
         * This method initializes txtFile
424
         *
425
         * @return javax.swing.JTextField
426
         */
427
        private JTextField getTxtFile() {
428
                if (txtFile == null) {
429
                        txtFile = new JTextField();
430
                        txtFile.setBounds(91, 96, 308, 20);
431
                }
432
                return txtFile;
433
        }
434

    
435
        /**
436
         * This method initializes btnAdvanced
437
         *
438
         * @return javax.swing.JButton
439
         */
440
        private JButton getBtnAdvanced() {
441
                if (btnAdvanced == null) {
442
                        btnAdvanced = new JButton();
443
//                        btnAdvanced.setBounds(403, 160, 120, 25);
444
                        btnAdvanced.setLocation(403, 160);
445
                        btnAdvanced.addActionListener(new java.awt.event.ActionListener() {
446
                                public void actionPerformed(java.awt.event.ActionEvent e) {
447
                                        advanced = !advanced;
448
                                        switchPanels();
449
                                }
450
                        });
451
                }
452
                return btnAdvanced;
453
        }
454

    
455
        /**
456
         * This method initializes btnAceptar
457
         *
458
         * @return javax.swing.JButton
459
         */
460
        private JButton getBtnOk() {
461
                if (btnOk == null) {
462
                        btnOk = new JButton();
463
                        btnOk.setText(PluginServices.getText(this, "Ok"));
464
                        btnOk.addActionListener(new java.awt.event.ActionListener() {
465
                                public void actionPerformed(java.awt.event.ActionEvent e) {
466
                                        execute("OK");
467
                                }
468
                        });
469
                }
470
                return btnOk;
471
        }
472

    
473
        /**
474
         * This method initializes btnCancel
475
         *
476
         * @return javax.swing.JButton
477
         */
478
        private JButton getBtnCancel() {
479
                if (btnCancel == null) {
480
                        btnCancel = new JButton();
481
                        btnCancel.setText(PluginServices.getText(this, "cancel"));
482
                        btnCancel.addActionListener(new java.awt.event.ActionListener() {
483
                                public void actionPerformed(java.awt.event.ActionEvent e) {
484
                                        execute("CANCEL");
485
                                }
486
                        });
487
                }
488
                return btnCancel;
489
        }
490

    
491
        /**
492
         * This method initializes txtAbstract
493
         *
494
         * @return javax.swing.JTextArea
495
         */
496
        private JTextArea getTxtAbstract() {
497
                if (txtAbstract == null) {
498
                        txtAbstract = new JTextArea();
499
                }
500
                return txtAbstract;
501
        }
502

    
503
        /**
504
         * This method initializes scrlAbstract
505
         *
506
         * @return javax.swing.JScrollPane
507
         */
508
        private JScrollPane getScrlAbstract() {
509
                if (scrlAbstract == null) {
510
                        scrlAbstract = new JScrollPane();
511
                        scrlAbstract.setBounds(115, 27, 232, 48);
512
                        scrlAbstract.setViewportView(getTxtAbstract());
513
                }
514
                return scrlAbstract;
515
        }
516

    
517
        /**
518
         * This method initializes txtLogoURL
519
         *
520
         * @return javax.swing.JTextField
521
         */
522
        private JTextField getTxtLogoURL() {
523
                if (txtLogoURL == null) {
524
                        txtLogoURL = new JTextField();
525
                        txtLogoURL.setBounds(115, 130, 407, 20);
526
                }
527
                return txtLogoURL;
528
        }
529

    
530
        /**
531
         * This method initializes jTextField
532
         *
533
         * @return javax.swing.JTextField
534
         */
535
        private JTextField getTxtDescriptionURL() {
536
                if (txtDescriptionURL == null) {
537
                        txtDescriptionURL = new JTextField();
538
                        txtDescriptionURL.setBounds(115, 104, 232, 20);
539
                }
540
                return txtDescriptionURL;
541
        }
542

    
543
        /**
544
         * This method initializes pnlMapSize
545
         *
546
         * @return javax.swing.JPanel
547
         */
548
        private JPanel getPnlMapSize() {
549
                if (pnlMapSize == null) {
550
                        ButtonGroup group = new ButtonGroup();
551
                        lblHeight = new JLabel();
552
                        lblHeight.setText(PluginServices.getText(this, "height"));
553
                        lblHeight.setBounds(11, 79, 52, 20);
554
                        lblHeight.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
555
                        lblHeight.setEnabled(false);
556
                        lblHeight.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
557
                        lblWidth = new JLabel();
558
                        lblWidth.setText(PluginServices.getText(this, "width"));
559
                        lblWidth.setBounds(11, 56, 52, 20);
560
                        lblWidth.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
561
                        lblWidth.setEnabled(false);
562
                        lblWidth.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
563
                        pnlMapSize = new JPanel();
564
                        pnlMapSize.setLayout(null);
565
                        pnlMapSize.setBounds(351, 19, 179, 108);
566
                        pnlMapSize.setBorder(javax.swing.BorderFactory.createTitledBorder(
567
                                          null, PluginServices.getText(this, "map_size_in_pixels"),
568
                                          javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
569
                                          javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
570
                        pnlMapSize.add(getRdBtnUseViewSize(), null);
571
                        pnlMapSize.add(getRdBtnCustomSize(), null);
572
                        pnlMapSize.add(lblWidth, null);
573
                        pnlMapSize.add(lblHeight, null);
574
                        pnlMapSize.add(getTxtWidth(), null);
575
                        pnlMapSize.add(getTxtHeight(), null);
576
                        group.add(getRdBtnUseViewSize());
577
                        group.add(getRdBtnCustomSize());
578

    
579
                }
580
                return pnlMapSize;
581
        }
582

    
583
        /**
584
         * This method initializes rdBtnUseViewSize
585
         *
586
         * @return javax.swing.JRadioButton
587
         */
588
        private JRadioButton getRdBtnUseViewSize() {
589
                if (rdBtnUseViewSize == null) {
590
                        rdBtnUseViewSize = new JRadioButton();
591
                        rdBtnUseViewSize.setBounds(8, 16, 142, 20);
592
                        rdBtnUseViewSize.setText(PluginServices.getText(this, "use_view_size"));
593
                        rdBtnUseViewSize.addItemListener(new java.awt.event.ItemListener() {
594
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
595
                                        boolean b = !getRdBtnUseViewSize().isSelected();
596

    
597
                                        getTxtWidth().setEnabled(b);
598
                                        getTxtHeight().setEnabled(b);
599
                                }
600
                        });
601
                        rdBtnUseViewSize.setSelected(true);
602
                }
603
                return rdBtnUseViewSize;
604
        }
605

    
606
        /**
607
         * This method initializes jRadioButton
608
         *
609
         * @return javax.swing.JRadioButton
610
         */
611
        private JRadioButton getRdBtnCustomSize() {
612
                if (rdBtnCustomSize == null) {
613
                        rdBtnCustomSize = new JRadioButton();
614
                        rdBtnCustomSize.setBounds(8, 34, 142, 20);
615
                        rdBtnCustomSize.setText(PluginServices.getText(this, "use_custom_size"));
616
                }
617
                return rdBtnCustomSize;
618
        }
619

    
620
        /**
621
         * This method initializes txtWidth
622
         *
623
         * @return javax.swing.JTextField
624
         */
625
        private JTextField getTxtWidth() {
626
                if (txtWidth == null) {
627
                        txtWidth = new JTextField();
628
                        txtWidth.setBounds(66, 56, 105, 20);
629
                        txtWidth.setEnabled(false);
630
                        txtWidth.addKeyListener(new java.awt.event.KeyAdapter() {
631
                                public void keyTyped(java.awt.event.KeyEvent e) {
632
                                        try {
633
                                                String text = getTxtWidth().getText();
634
                                                Integer.parseInt(text);
635
                                                lastWidth = text;
636
                                        } catch (Exception ex) {
637
                                                getTxtWidth().setText(lastWidth);
638
                                        }
639
                                }
640
                        });
641
                        Dimension sz = exportableViews[getCmbViews()
642
                                                            .getSelectedIndex()]
643
                                                            .getMapContext()
644
                                                            .getViewPort()
645
                                                            .getImageSize();
646
                        lastWidth = (sz != null)? (int) sz.getWidth()+"": defaultWidth+"";
647

    
648
                        txtWidth.setText(lastWidth);
649
                }
650
                return txtWidth;
651
        }
652

    
653
        /**
654
         * This method initializes jTextField
655
         *
656
         * @return javax.swing.JTextField
657
         */
658
        private JTextField getTxtHeight() {
659
                if (txtHeight == null) {
660
                        txtHeight = new JTextField();
661
                        txtHeight.setBounds(66, 79, 105, 20);
662
                        txtHeight.setEnabled(false);
663
                        txtHeight.addKeyListener(new java.awt.event.KeyAdapter() {
664
                                public void keyTyped(java.awt.event.KeyEvent e) {
665
                                        try {
666
                                                String text = getTxtHeight().getText();
667
                                                Integer.parseInt(text);
668
                                                lastHeight = text;
669
                                        } catch (Exception ex) {
670
                                                getTxtHeight().setText(lastHeight);
671
                                        }
672
                                }
673
                        });
674
                        Dimension sz = exportableViews[getCmbViews()
675
                                                            .getSelectedIndex()]
676
                                                            .getMapContext()
677
                                                            .getViewPort()
678
                                                            .getImageSize();
679
                        lastHeight = (sz != null)? (int) sz.getHeight()+"": defaultHeight+"";
680
                        txtHeight.setText(lastHeight);
681
                }
682
                return txtHeight;
683
        }
684

    
685
        /**
686
         * This method initializes pnlContactInfo
687
         *
688
         * @return javax.swing.JPanel
689
         */
690
        private JPanel getPnlContactInfo() {
691
                if (pnlContactInfo == null) {
692
                        lblEMail = new JLabel();
693
                        lblEMail.setBounds(7, 193, 98, 20);
694
                        lblEMail.setHorizontalTextPosition(SwingConstants.RIGHT);
695
                        lblEMail.setHorizontalAlignment(SwingConstants.RIGHT);
696
                        lblEMail.setText(PluginServices.getText(this, "e-mail")+":");
697
                        lblFax = new JLabel();
698
                        lblFax.setBounds(274, 168, 57, 20);
699
                        lblFax.setHorizontalTextPosition(SwingConstants.RIGHT);
700
                        lblFax.setHorizontalAlignment(SwingConstants.RIGHT);
701
                        lblFax.setText(PluginServices.getText(this, "fax")+":");
702
                        lblPostCode = new JLabel();
703
                        lblPostCode.setBounds(7, 143, 98, 20);
704
                        lblPostCode.setHorizontalTextPosition(SwingConstants.RIGHT);
705
                        lblPostCode.setHorizontalAlignment(SwingConstants.RIGHT);
706
                        lblPostCode.setText(PluginServices.getText(this, "postcode")+":");
707
                        lblPhone = new JLabel();
708
                        lblPhone.setBounds(7, 168, 98, 20);
709
                        lblPhone.setHorizontalTextPosition(SwingConstants.RIGHT);
710
                        lblPhone.setHorizontalAlignment(SwingConstants.RIGHT);
711
                        lblPhone.setText(PluginServices.getText(this, "telephone")+":");
712
                        lblCountry = new JLabel();
713
                        lblCountry.setBounds(274, 143, 57, 20);
714
                        lblCountry.setText(PluginServices.getText(this, "country")+":");
715
                        lblCountry.setHorizontalTextPosition(SwingConstants.RIGHT);
716
                        lblCountry.setHorizontalAlignment(SwingConstants.RIGHT);
717
                        lblStateProvince = new JLabel();
718
                        lblStateProvince.setBounds(252, 119, 111, 20);
719
                        lblStateProvince.setText(PluginServices.getText(this, "state_or_province")+":");
720
                        lblStateProvince.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
721
                        lblStateProvince.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
722

    
723
                        lblCity = new JLabel();
724
                        lblCity.setBounds(7, 119, 98, 20);
725
                        lblCity.setText(PluginServices.getText(this, "city")+":");
726
                        lblCity.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
727
                        lblCity.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
728
                        lblContactPosition = new JLabel();
729
                        lblContactPosition.setBounds(6, 69, 99, 20);
730
                        lblContactPosition.setHorizontalTextPosition(SwingConstants.RIGHT);
731
                        lblContactPosition.setHorizontalAlignment(SwingConstants.RIGHT);
732
                        lblContactPosition.setText(PluginServices.getText(this, "contact_position"));
733
                        lblContactOrganization = new JLabel();
734
                        lblContactOrganization.setBounds(6, 44, 99, 20);
735
                        lblContactOrganization.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
736
                        lblContactOrganization.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
737
                        lblContactOrganization.setText(PluginServices.getText(this, "contact_organization")+":");
738
                        lblAddress = new JLabel();
739
                        lblAddress.setBounds(6, 94, 99, 20);
740
                        lblAddress.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
741
                        lblAddress.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
742
                        lblAddress.setText(PluginServices.getText(this, "address"));
743

    
744
                        lblContactPerson = new JLabel();
745
                        lblContactPerson.setText(PluginServices.getText(this, "contact_person")+":");
746
                        lblContactPerson.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
747
                        lblContactPerson.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
748
                        lblContactPerson.setBounds(6, 19, 99, 20);
749
                        pnlContactInfo = new JPanel();
750
                        pnlContactInfo.setLayout(null);
751
                        pnlContactInfo.setBorder(javax.swing.BorderFactory.createTitledBorder(
752
                                          null, PluginServices.getText(this, "contact_info"),
753
                                          javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
754
                                          javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
755
                        pnlContactInfo.setLocation(4, 158);
756
                        pnlContactInfo.setSize(527, 223);
757
                        pnlContactInfo.add(lblContactPerson, null);
758
                        pnlContactInfo.add(getTxtContactPerson(), null);
759
                        pnlContactInfo.add(lblContactOrganization, null);
760
                        pnlContactInfo.add(getTxtOrganization(), null);
761
                        pnlContactInfo.add(lblContactPosition, null);
762
                        pnlContactInfo.add(getTxtContactPosition(), null);
763
                        pnlContactInfo.add(lblAddress, null);
764
                        pnlContactInfo.add(getTxtAddress(), null);
765
                        pnlContactInfo.add(lblCity, null);
766
                        pnlContactInfo.add(getTxtCity(), null);
767
                        pnlContactInfo.add(lblStateProvince, null);
768
                        pnlContactInfo.add(getCmbCountries(), null);
769
                        pnlContactInfo.add(getTxtStateOrProvince(), null);
770
                        pnlContactInfo.add(lblPostCode, null);
771
                        pnlContactInfo.add(getTxtPostCode(), null);
772
                        pnlContactInfo.add(lblCountry, null);
773
                        pnlContactInfo.add(lblPhone, null);
774
                        pnlContactInfo.add(getTxtTelephone(), null);
775
                        pnlContactInfo.add(lblFax, null);
776
                        pnlContactInfo.add(getTxtFax(), null);
777
                        pnlContactInfo.add(lblEMail, null);
778
                        pnlContactInfo.add(getTxtEMail(), null);
779
                }
780
                return pnlContactInfo;
781
        }
782

    
783
        /**
784
         * This method initializes jTextField1
785
         *
786
         * @return javax.swing.JTextField
787
         */
788
        private JTextField getTxtKeyWords() {
789
                if (txtKeyWords == null) {
790
                        txtKeyWords = new JTextField();
791
                        txtKeyWords.setBounds(115, 79, 232, 20);
792
                }
793
                return txtKeyWords;
794
        }
795

    
796
        /**
797
         * This method initializes jTextField1
798
         *
799
         * @return javax.swing.JTextField
800
         */
801
        private JTextField getTxtContactPerson() {
802
                if (txtContactPerson == null) {
803
                        txtContactPerson = new JTextField();
804
                        txtContactPerson.setBounds(111, 19, 407, 20);
805
                }
806
                return txtContactPerson;
807
        }
808

    
809
        /**
810
         * This method initializes jTextField2
811
         *
812
         * @return javax.swing.JTextField
813
         */
814
        private JTextField getTxtOrganization() {
815
                if (txtOrganization == null) {
816
                        txtOrganization = new JTextField();
817
                        txtOrganization.setBounds(111, 44, 407, 20);
818
                }
819
                return txtOrganization;
820
        }
821

    
822
        /**
823
         * This method initializes jTextField
824
         *
825
         * @return javax.swing.JTextField
826
         */
827
        private JTextField getTxtContactPosition() {
828
                if (txtContactPosition == null) {
829
                        txtContactPosition = new JTextField();
830
                        txtContactPosition.setBounds(111, 69, 407, 20);
831
                }
832
                return txtContactPosition;
833
        }
834

    
835
        /**
836
         * This method initializes txtAddress
837
         *
838
         * @return javax.swing.JTextField
839
         */
840
        private JTextField getTxtAddress() {
841
                if (txtAddress == null) {
842
                        txtAddress = new JTextField();
843
                        txtAddress.setBounds(111, 94, 407, 20);
844
                }
845
                return txtAddress;
846
        }
847

    
848
        /**
849
         * This method initializes txtCity
850
         *
851
         * @return javax.swing.JTextField
852
         */
853
        private JTextField getTxtCity() {
854
                if (txtCity == null) {
855
                        txtCity = new JTextField();
856
                        txtCity.setBounds(111, 119, 135, 20);
857
                }
858
                return txtCity;
859
        }
860

    
861
        /**
862
         * This method initializes txtStateOrProvince
863
         *
864
         * @return javax.swing.JTextField
865
         */
866
        private JTextField getTxtStateOrProvince() {
867
                if (txtStateOrProvince == null) {
868
                        txtStateOrProvince = new JTextField();
869
                        txtStateOrProvince.setBounds(368, 119, 150, 20);
870
                }
871
                return txtStateOrProvince;
872
        }
873

    
874
        /**
875
         * This method initializes txtPostCode
876
         *
877
         * @return javax.swing.JTextField
878
         */
879
        private JTextField getTxtPostCode() {
880
                if (txtPostCode == null) {
881
                        txtPostCode = new JTextField();
882
                        txtPostCode.setBounds(111, 143, 159, 20);
883
                }
884
                return txtPostCode;
885
        }
886

    
887
        /**
888
         * This method initializes cmbCountries
889
         *
890
         * @return javax.swing.JComboBox
891
         */
892
        private JComboBox getCmbCountries() {
893
                if (cmbCountries == null) {
894
                        cmbCountries = new JComboBox();
895
                        cmbCountries.setBounds(336, 143, 182, 20);
896
                        String[] countries = PluginServices.getText(this, "countries_of_the_world").split(";");
897
                        for (int i = 0; i < countries.length; i++) {
898
                                cmbCountries.addItem(countries[i]);
899
                        }
900
                }
901
                return cmbCountries;
902
        }
903

    
904
        /**
905
         * This method initializes txtTelephone
906
         *
907
         * @return javax.swing.JTextField
908
         */
909
        private JTextField getTxtTelephone() {
910
                if (txtTelephone == null) {
911
                        txtTelephone = new JTextField();
912
                        txtTelephone.setBounds(111, 168, 159, 20);
913
                }
914
                return txtTelephone;
915
        }
916

    
917
        /**
918
         * This method initializes txtFax
919
         *
920
         * @return javax.swing.JTextField
921
         */
922
        private JTextField getTxtFax() {
923
                if (txtFax == null) {
924
                        txtFax = new JTextField();
925
                        txtFax.setBounds(336, 168, 182, 20);
926
                }
927
                return txtFax;
928
        }
929

    
930
        /**
931
         * This method initializes txtEMail
932
         *
933
         * @return javax.swing.JTextField
934
         */
935
        private JTextField getTxtEMail() {
936
                if (txtEMail == null) {
937
                        txtEMail = new JTextField();
938
                        txtEMail.setBounds(111, 193, 407, 20);
939
                }
940
                return txtEMail;
941
        }
942

    
943
        public Object getWindowModel() {
944
                return PluginServices.getText(this, "web_map_context_settings");
945
        }
946

    
947
        @SuppressWarnings({ "deprecation", "unchecked" })
948
        private void execute(String actionCommand) {
949
                if ("OK".equals(actionCommand)) {
950
                        String str = getTxtFile().getText();
951
                        if (str==null || str.equals("")) {
952
                                JOptionPane.showMessageDialog(this, PluginServices.getText(this, "must_specify_a_file"), PluginServices.getText(this, "error"), JOptionPane.ERROR_MESSAGE);
953
                                return;
954
                        }
955
                        DefaultViewDocument theView = exportableViews[getCmbViews().getSelectedIndex()];
956
                        MapContext mc = theView.getMapContext();
957
                        wmc = new WebMapContext();
958

    
959
                        // Version
960
                        wmc.fileVersion = (String) getCmbVersion().getSelectedItem();
961

    
962
                        // Web Map Context size
963
                        if (advanced) {
964
                                if (getRdBtnUseViewSize().isSelected()) {
965
                                        // View's size
966
                                        Dimension sz = null;
967
                                        if (mc.getViewPort().getImageSize()!=null) {
968
                                                sz = new Dimension(mc.getViewPort().getImageSize());
969
                                        }
970
                                        if (sz == null || (int) sz.getHeight()==0 || (int) sz.getWidth()==0) {
971
                                                // View's size is not initialized, will use default size.
972
                                                sz = new Dimension(defaultWidth, defaultHeight);
973
                                        }
974
                                        wmc.windowSize = sz;
975
                                } else {
976
                                        // User defined size
977
                                        try {
978
                                        wmc.windowSize = new Dimension(Integer.parseInt(getTxtWidth().getText()),
979
                                                                                                   Integer.parseInt(getTxtHeight().getText()));
980
                                        } catch (Exception e) {
981
                                                JOptionPane.showMessageDialog(this, PluginServices.getText(this, "invalid_dimension_values"), PluginServices.getText(this, "error"), JOptionPane.ERROR_MESSAGE);
982
                                                return;
983
                                        }
984
                                }
985
                        }
986
                        // SRS
987
                        wmc.srs = mc.getProjection().getAbrev();
988

    
989
                        // Bounding Box
990
                        if (useFullExtent) {
991
                                try {
992
                                        wmc.bBox = this.getRectable2DFromEnvelope(mc
993
                                                        .getFullEnvelope());
994
                                } catch (ReadException e) {
995
                                        NotificationManager.addError(e);
996
                                        return;
997
                                }
998
                        } else {
999
                                wmc.bBox = this.getRectable2DFromEnvelope(mc.getViewPort()
1000
                                                .getAdjustedExtent());
1001
                        }
1002

    
1003
                        // Title
1004
                        str = getTxtTitle().getText();
1005
                        if (str!=null && !str.equals("")) {
1006
                                wmc.title = str;
1007
                        } else {
1008
                                JOptionPane.showMessageDialog(this, getTxtTitle().getName()+" "+PluginServices.getText(this, "is_required"), PluginServices.getText(this, "error"), JOptionPane.ERROR_MESSAGE);
1009
                                return;
1010
                        }
1011

    
1012
                        // ID
1013
                        str = getTxtId().getText();
1014
                        if (str!=null && !str.equals("")) {
1015
                                wmc.id = str;
1016
                        } else {
1017
                                JOptionPane.showMessageDialog(this, getTxtId().getName()+" "+PluginServices.getText(this, "is_required"), PluginServices.getText(this, "error"), JOptionPane.ERROR_MESSAGE);
1018
                                return;
1019
                        }
1020

    
1021
                        wmc.xmlns = WebMapContextTags.XMLNS_VALUE;
1022
                        wmc.xmlns_xlink = WebMapContextTags.XMLNS_XLINK_VALUE;
1023
                        wmc.xmlns_xsi = WebMapContextTags.XMLNS_XSI_VALUE;
1024
                        wmc.xsi_schemaLocation = WebMapContextTags.XSI_SCHEMA_LOCATION_VALUE;
1025

    
1026
                        // Abstract
1027
                        str = getTxtAbstract().getText();
1028
                        if (str!=null && !str.equals("")) {
1029
                                wmc._abstract = str;
1030
                        }
1031

    
1032
                        // Keyword list
1033
                        str = getTxtKeyWords().getText();
1034
                        if (str!=null && !str.equals("")) {
1035
                                String[] ss = str.split("[, ;:]+"); // sequence of spaces, commas, colons or semicolons will be treated as word separator
1036
                                for (int i = 0; i < ss.length; i++) {
1037
                                        if (wmc.keywordList==null) {
1038
                                                wmc.keywordList = new ArrayList();
1039
                                        }
1040
                                        wmc.keywordList.add(ss[i]);
1041
                                }
1042
                        }
1043

    
1044
                        // Logo URL
1045
                        str = getTxtLogoURL().getText();
1046
                        if (str!=null && !str.equals("")) {
1047
                                wmc.logoURL = str;
1048
                        }
1049

    
1050
                        wmc.logoURLSize = null;                        // yet skiped
1051
                        wmc.logoURLFormat = null;                // yet skiped
1052
                        wmc.descriptionURLFormat = null;// yet skiped
1053

    
1054
                        // Description URL
1055
                        str = getTxtLogoURL().getText();
1056
                        if (str!=null && !str.equals("")) {
1057
                                wmc.descriptionURL = str;
1058
                        }
1059

    
1060
                        // Contact Person
1061
                        str = getTxtContactPerson().getText();
1062
                        if (str!=null && !str.equals("")) {
1063
                                wmc.contactPerson = str;
1064
                                wmc.contactInfo = true;
1065
                        }
1066

    
1067
                        // Contact Organization
1068
                        str = getTxtOrganization().getText();
1069
                        if (str!=null && !str.equals("")) {
1070
                                wmc.contactOrganization = str;
1071
                                wmc.contactInfo = true;
1072
                        }
1073

    
1074
                        // Contact Position
1075
                        str = getTxtContactPosition().getText();
1076
                        if (str!=null && !str.equals("")) {
1077
                                wmc.contactPosition = str;
1078
                                wmc.contactInfo = true;
1079
                        }
1080

    
1081
                        // Address
1082
                        str = getTxtAddress().getText();
1083
                        if (str!=null && !str.equals("")) {
1084
                                wmc.address = str;
1085
                                wmc.contactInfo = true;
1086
                        }
1087

    
1088
                        // City
1089
                        str = getTxtCity().getText();
1090
                        if (str!=null && !str.equals("")) {
1091
                                wmc.city = str;
1092
                                wmc.contactInfo = true;
1093
                        }
1094

    
1095
                        // State/Province
1096
                        str = getTxtStateOrProvince().getText();
1097
                        if (str!=null && !str.equals("")) {
1098
                                wmc.stateOrProvince = str;
1099
                                wmc.contactInfo = true;
1100
                        }
1101

    
1102
                        // Postcode
1103
                        str = getTxtPostCode().getText();
1104
                        if (str!=null && !str.equals("")) {
1105
                                wmc.postCode = str;
1106
                        }
1107

    
1108
                        // Country
1109
                        str = (String) getCmbCountries().getSelectedItem();
1110
                        if (str!=null && !str.equals("")) {
1111
                                wmc.country = str;
1112
                        }
1113

    
1114
                        // Telephone
1115
                        str = getTxtTelephone().getText();
1116
                        if (str!=null && !str.equals("")) {
1117
                                wmc.telephone = str;
1118
                                wmc.contactInfo = true;
1119
                        }
1120

    
1121
                        // Fax
1122
                        str = getTxtFax().getText();
1123
                        if (str!=null && !str.equals("")) {
1124
                                wmc.fax = str;
1125
                                wmc.contactInfo = true;
1126
                        }
1127

    
1128
                        // e-mail
1129
                        str = getTxtEMail().getText();
1130
                        if (str!=null && !str.equals("")) {
1131
                                wmc.email = str;
1132
                                wmc.contactInfo = true;
1133
                        }
1134

    
1135
                        ExportWebMapContextExtension exp = (ExportWebMapContextExtension)
1136
                        PluginServices.
1137
                        getExtension(ExportWebMapContextExtension.class);
1138
                        exp.execute("DO_EXPORT");
1139
                        PluginServices.getMDIManager().closeWindow(this);
1140
                } else if ("CANCEL".equals(actionCommand)) {
1141
                        PluginServices.getMDIManager().closeWindow(this);
1142
                }
1143
        }
1144

    
1145
        public String getXML() {
1146
                return wmc.toXML(exportableViews[getCmbViews().getSelectedIndex()]);
1147
        }
1148

    
1149
        public File getTargetFile() {
1150
                if (targetFile == null) {
1151
                        String fileName = getTxtFile().getText();
1152
                        if (fileName != null) {
1153
                                targetFile = new File(fileName);
1154
                        }
1155
                }
1156
                return targetFile;
1157
        }
1158

    
1159
        /**
1160
         * This method initializes cmbViews
1161
         *
1162
         * @return javax.swing.JComboBox
1163
         */
1164
        private JComboBox getCmbViews() {
1165
                if (cmbViews == null) {
1166
                        cmbViews = new JComboBox();
1167
                        cmbViews.setBounds(91, 24, 432, 21);
1168
                        cmbViews.addItemListener(new java.awt.event.ItemListener() {
1169
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
1170
                                        DefaultViewDocument theView = exportableViews[getCmbViews().getSelectedIndex()];
1171
                                        Dimension sz = theView.getMapContext().
1172
                                                                                   getViewPort().
1173
                                                                                   getImageSize();
1174
                                        if (sz == null || (int) sz.getHeight()==0 || (int) sz.getWidth()==0) {
1175
                                                sz = new Dimension(defaultWidth, defaultHeight);
1176
                                        }
1177

    
1178
                                        getTxtWidth().setText((int) sz.getWidth()+"");
1179
                                        getTxtHeight().setText((int) sz.getHeight()+"");
1180
                                        getTxtTitle().setText(theView.getName());
1181
                                }
1182
                        });
1183
                        for (int i = 0; i < exportableViews.length; i++) {
1184
                                cmbViews.addItem(exportableViews[i].getName());
1185
                        }
1186
                }
1187
                return cmbViews;
1188
        }
1189

    
1190
        /**
1191
         * This method initializes rdCurrentViewExtent
1192
         *
1193
         * @return javax.swing.JRadioButton
1194
         */
1195
        private JRadioButton getRdBtnCurrentViewExtent() {
1196
                if (rdBtnCurrentViewExtent == null) {
1197
                        rdBtnCurrentViewExtent = new JRadioButton();
1198
                        rdBtnCurrentViewExtent.setBounds(91, 146, 270, 20);
1199
                        rdBtnCurrentViewExtent.setText(PluginServices.getText(this, "defined_by_view_extent"));
1200
                        rdBtnCurrentViewExtent.addItemListener(new java.awt.event.ItemListener() {
1201
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
1202
                                        fPrefs.putBoolean("use_full_extent", !getRdBtnFullExtent().isEnabled());
1203
                                }
1204
                        });
1205
                        rdBtnCurrentViewExtent.setEnabled(!useFullExtent);
1206
                }
1207
                return rdBtnCurrentViewExtent;
1208
        }
1209

    
1210
        /**
1211
         * This method initializes rdBtnFullExtent
1212
         *
1213
         * @return javax.swing.JRadioButton
1214
         */
1215
        private JRadioButton getRdBtnFullExtent() {
1216
                if (rdBtnFullExtent == null) {
1217
                        rdBtnFullExtent = new JRadioButton();
1218
                        rdBtnFullExtent.setBounds(91, 164, 270, 20);
1219
                        rdBtnFullExtent.setText(PluginServices.getText(this, "use_full_extent"));
1220
                        rdBtnFullExtent.addItemListener(new java.awt.event.ItemListener() {
1221
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
1222
                                        boolean b = getRdBtnFullExtent().isEnabled();
1223
                                        fPrefs.putBoolean("use_full_extent", getRdBtnFullExtent().isEnabled());
1224
                                        useFullExtent = b;
1225
                                }
1226
                        });
1227
                        rdBtnFullExtent.setSelected(useFullExtent);
1228
                }
1229
                return rdBtnFullExtent;
1230
        }
1231

    
1232
        public Object getWindowProfile() {
1233
                return WindowInfo.PROPERTIES_PROFILE;
1234
        }
1235

    
1236
        private Rectangle2D.Double getRectable2DFromEnvelope(Envelope env) {
1237
                return new Rectangle2D.Double(env.getMinimum(0), env.getMinimum(1), env
1238
                                .getLength(0), env.getLength(1));
1239
        }
1240
}