Statistics
| Revision:

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

History | View | Annotate | Download (37.4 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.i18n.Messages;
57
import org.gvsig.raster.wms.app.wmsclient.wmc.ExportWebMapContextExtension;
58
import org.gvsig.raster.wms.app.wmsclient.wmc.ImportWebMapContextExtension;
59
import org.gvsig.raster.wms.app.wmsclient.wmc.WebMapContext;
60
import org.gvsig.raster.wms.app.wmsclient.wmc.WebMapContextTags;
61

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

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

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

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

    
159
                switchPanels();
160
        }
161

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

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

    
175
                }
176

    
177
                this.setSize(sz);
178

    
179

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

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

    
191
        public WindowInfo getWindowInfo() {
192

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

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

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

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

    
331
                return buttonsPanel;
332
        }
333

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

    
348
                }
349
                return cmbVersion;
350
        }
351

    
352

    
353

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

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

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

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

    
387
                                        fc = null;
388
                                }
389
                        });
390
                        btnBrowseFileSystem.setText(Messages.getText("browse"));
391
                }
392
                return btnBrowseFileSystem;
393
        }
394

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

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

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

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

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

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

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

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

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

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

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

    
580
                }
581
                return pnlMapSize;
582
        }
583

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
944
        public Object getWindowModel() {
945
                return Messages.getText("web_map_context_settings");
946
        }
947

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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