Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / extensions / DielmoOpenLidar / src / com / dielmo / gvsig / lidar / extensions / Lidar_Preferences.java @ 25419

History | View | Annotate | Download (4.67 KB)

1
/* DielmoOpenLiDAR
2
 *
3
 * Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures  
4
 * and Transports Department 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
 * For more information, contact:
22
 *
23
 * DIELMO 3D S.L.
24
 * Plaza Vicente Andr?s Estell?s 1 Bajo E
25
 * 46950 Xirivella, Valencia
26
 * SPAIN
27
 *   
28
 * +34 963137212
29
 * dielmo@dielmo.com
30
 * www.dielmo.com
31
 * 
32
 * or
33
 * 
34
 * Generalitat Valenciana
35
 * Conselleria d'Infraestructures i Transport
36
 * Av. Blasco Ib??ez, 50
37
 * 46010 VALENCIA
38
 * SPAIN
39
 *
40
 * +34 963862235
41
 * gvsig@gva.es
42
 * www.gvsig.gva.es
43
 */
44

    
45
/*
46
 * AUTHORS (In addition to DIELMO and CIT):
47
 *  
48
 */
49

    
50
package com.dielmo.gvsig.lidar.extensions;
51

    
52

    
53
import java.awt.event.ActionEvent;
54
import java.awt.event.ActionListener;
55
import java.io.File;
56

    
57
import javax.swing.ImageIcon;
58
import javax.swing.JFileChooser;
59
import javax.swing.JLabel;
60
import javax.swing.JPanel;
61
import javax.swing.JTextField;
62

    
63
import org.gvsig.gui.beans.swing.JButton;
64

    
65
import com.iver.andami.PluginServices;
66
import com.iver.andami.preferences.AbstractPreferencePage;
67
import com.iver.andami.preferences.StoreException;
68
import com.iver.utiles.GenericFileFilter;
69

    
70

    
71
/**
72
 *  Default configuration page.
73
 *  <b><b>
74
 *  Here the user can establish what settings wants to use by default LiDAR preferences.
75
 *
76
 *
77
 * @author Oscar Garcia
78
 */
79
public class Lidar_Preferences extends AbstractPreferencePage {
80

    
81
        
82
        private static final long serialVersionUID = 1L;
83
        protected String id;
84
        private ImageIcon icon;
85
        private JTextField txtDefaultText;
86
        private JButton btnExaminar;
87
        private JTextField sizePixelContainer;
88
        private static boolean panelStarted = false;
89

    
90
        /**
91
         * Creates a new panel containing View preferences settings.
92
         *
93
         */
94
        public Lidar_Preferences() {
95
                super();
96
                id = this.getClass().getName();
97
                icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/LiDAR_Properties.png"));
98
        }
99

    
100
        public void initializeValues() {
101
                if (!panelStarted) 
102
                        getPanel();
103

    
104
                LiDAR_Mapping map = new LiDAR_Mapping();
105
                String legend = map.getPathLegend();
106
                int size = map.getSizePixel();
107
                
108
                txtDefaultText.setText(legend);        
109
                sizePixelContainer.setText((new Integer(size)).toString());
110
        }
111

    
112
        public String getID() {
113
                return id;
114
        }
115

    
116
        public String getTitle() {
117
                return PluginServices.getText(this, "LiDAR_preferences");
118
        }
119

    
120
        public JPanel getPanel() {
121
                if (panelStarted) 
122
                        return this;
123
                
124
                panelStarted = true;
125

    
126
                // just a separator
127
                addComponent(new JLabel(" "));
128

    
129
                txtDefaultText = new JTextField(30);
130
                btnExaminar = new JButton("...");
131
                btnExaminar.addActionListener(new ActionListener() {
132
                        public void actionPerformed(ActionEvent e) {
133
                                JFileChooser fileChooser = new JFileChooser();
134
                                fileChooser.addChoosableFileFilter(new GenericFileFilter("gvl",
135
                                                PluginServices.getText(this, "tipo_de_leyenda")));
136
                                File file;
137
                                
138
                                int result = fileChooser.showOpenDialog(btnExaminar);
139

    
140
                if (result == JFileChooser.APPROVE_OPTION && (file = fileChooser.getSelectedFile()) != null) {
141
                        txtDefaultText.setText(file.getAbsolutePath());
142
                }
143
                        }
144
                });
145
                
146
                sizePixelContainer = new JTextField(30);
147
                
148
                addComponent(new JLabel(PluginServices.getText(this,"PreferedLiDAR_Legend")));
149
                addComponent(txtDefaultText, btnExaminar);
150
                
151
                addComponent(new JLabel(PluginServices.getText(this,"PreferedLiDAR_PixelSize")));
152
                addComponent(sizePixelContainer);
153
        
154
                // just a separator
155
                addComponent(new JLabel(" "));
156

    
157
                initializeValues();
158
                return this;
159
        }
160

    
161
        public void storeValues() throws StoreException {
162
                String PreferLiDARLegend=txtDefaultText.getText();
163
                LiDAR_Mapping.storeValuesLegend(PreferLiDARLegend);
164
                
165
                String sizePixel=sizePixelContainer.getText();
166
                LiDAR_Mapping.storeValuesSizePixel(Integer.parseInt(sizePixel));
167
        }
168

    
169
        public void initializeDefaults() {
170
                txtDefaultText.setText("");
171
                sizePixelContainer.setText("");
172
        }
173

    
174
        public ImageIcon getIcon() {
175
                return icon;
176
        }
177

    
178
        public boolean isValueChanged() {
179
                return super.hasChanged();
180
        }
181

    
182
        public void setChangesApplied() {
183
                setChanged(false);
184
        }
185
}