Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extEditing / src / org / gvsig / editing / gui / preferences / FlatnessPage.java @ 30372

History | View | Annotate | Download (6.58 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

    
42
/* CVS MESSAGES:
43
*
44
* $Id: FlatnessPage.java 30372 2009-08-11 06:59:42Z jpiera $
45
* $Log$
46
* Revision 1.4  2006-09-06 15:29:59  caballero
47
* initialize flatness
48
*
49
* Revision 1.3  2006/08/22 12:27:53  jaume
50
* improved performances when saving
51
*
52
* Revision 1.2  2006/08/22 07:37:32  jaume
53
* *** empty log message ***
54
*
55
* Revision 1.1  2006/08/10 08:18:35  caballero
56
* configurar grid
57
*
58
* Revision 1.1  2006/08/04 11:41:05  caballero
59
* poder especificar el zoom a aplicar en las vistas
60
*
61
* Revision 1.3  2006/07/31 10:02:31  jaume
62
* *** empty log message ***
63
*
64
* Revision 1.2  2006/06/13 07:43:08  fjp
65
* Ajustes sobre los cuadros de dialogos de preferencias
66
*
67
* Revision 1.1  2006/06/12 16:04:28  caballero
68
* Preferencias
69
*
70
* Revision 1.11  2006/06/06 10:26:31  jaume
71
* *** empty log message ***
72
*
73
* Revision 1.10  2006/06/05 17:07:17  jaume
74
* *** empty log message ***
75
*
76
* Revision 1.9  2006/06/05 17:00:44  jaume
77
* *** empty log message ***
78
*
79
* Revision 1.8  2006/06/05 16:57:59  jaume
80
* *** empty log message ***
81
*
82
* Revision 1.7  2006/06/05 14:45:06  jaume
83
* *** empty log message ***
84
*
85
* Revision 1.6  2006/06/05 11:00:09  jaume
86
* *** empty log message ***
87
*
88
* Revision 1.5  2006/06/05 10:39:02  jaume
89
* *** empty log message ***
90
*
91
* Revision 1.4  2006/06/05 10:13:40  jaume
92
* *** empty log message ***
93
*
94
* Revision 1.3  2006/06/05 10:06:08  jaume
95
* *** empty log message ***
96
*
97
* Revision 1.2  2006/06/05 09:51:56  jaume
98
* *** empty log message ***
99
*
100
* Revision 1.1  2006/06/02 10:50:18  jaume
101
* *** empty log message ***
102
*
103
*
104
*/
105
package org.gvsig.editing.gui.preferences;
106

    
107
import java.awt.BorderLayout;
108
import java.awt.GridBagConstraints;
109
import java.awt.GridBagLayout;
110
import java.awt.Insets;
111
import java.util.prefs.Preferences;
112

    
113
import javax.swing.ImageIcon;
114
import javax.swing.JLabel;
115
import javax.swing.JPanel;
116
import javax.swing.JTextArea;
117
import javax.swing.JTextField;
118
import javax.swing.border.EmptyBorder;
119

    
120
import org.apache.batik.ext.swing.GridBagConstants;
121
import org.gvsig.andami.PluginServices;
122
import org.gvsig.andami.preferences.AbstractPreferencePage;
123
import org.gvsig.andami.preferences.StoreException;
124
import org.gvsig.fmap.geom.GeometryLocator;
125
import org.gvsig.fmap.geom.GeometryManager;
126
import org.gvsig.fmap.geom.util.Converter;
127

    
128

    
129

    
130
public class FlatnessPage extends AbstractPreferencePage {
131
        private static Preferences prefs = Preferences.userRoot().node( "cadtooladapter" );
132
        private JTextArea jTextArea = null;
133
        private JTextField txtFlatness;
134
        private JPanel northPanel = null;
135
        
136
        private GeometryManager geomManager = GeometryLocator.getGeometryManager();
137

    
138
        private ImageIcon icon;
139

    
140
        public FlatnessPage() {
141
                super();
142
                icon = PluginServices.getIconTheme().get("flatness-icon");
143
                setLayout(new BorderLayout());
144
                add(getNorthPanel(), BorderLayout.NORTH);
145
        }
146
        
147
        public JPanel getNorthPanel(){
148
                if (northPanel == null){
149
                        northPanel = new JPanel();
150
                        northPanel.setLayout(new GridBagLayout());
151
                        northPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
152
                        
153
                        GridBagConstraints constraints = new GridBagConstraints();
154
                        constraints.gridx = 0;
155
                        constraints.gridy = 0;
156
                        constraints.fill = GridBagConstants.HORIZONTAL;
157
                        constraints.weightx = 1.0;
158
                        constraints.gridwidth = 2;
159
                        constraints.insets = new Insets(0, 0, 5, 0);
160
                        northPanel.add(getJTextArea(), constraints);
161

    
162
                        constraints = new GridBagConstraints();
163
                        constraints.gridx = 0;
164
                        constraints.gridy = 1;
165
                        northPanel.add(new JLabel(PluginServices.getText(this, "densityfication") + ":"), constraints);
166
                                
167
                        txtFlatness = new JTextField("", 15);
168
                        constraints = new GridBagConstraints();
169
                        constraints.gridx = 1;
170
                        constraints.gridy = 1;
171
                        constraints.fill = GridBagConstants.HORIZONTAL;
172
                        constraints.weightx = 1.0;                        
173
                        northPanel.add(txtFlatness, constraints);                                
174
                }
175
                return northPanel;
176
        }
177

    
178
        public void initializeValues() {
179
                double flatness = geomManager.getFlatness();
180

    
181
                txtFlatness.setText(String.valueOf(flatness));
182

    
183
                geomManager.setFlatness(flatness);
184
        }
185

    
186
        public String getID() {
187
                return this.getClass().getName();
188
        }
189

    
190
        public String getTitle() {
191
                return PluginServices.getText(this, "Flatness");
192
        }
193

    
194
        public JPanel getPanel() {
195
                return this;
196
        }
197

    
198
        public void storeValues() throws StoreException {
199
                double flatness;
200
                try{
201
                        flatness=Double.parseDouble(txtFlatness.getText());
202
                }catch (Exception e) {
203
                        throw new StoreException(PluginServices.getText(this,"minimum_size_of_line_incorrect"));
204
                }
205
                prefs.putDouble("flatness", flatness);
206

    
207
                geomManager.setFlatness(flatness);
208

    
209
        }
210

    
211
        public void initializeDefaults() {
212
                txtFlatness.setText(String.valueOf(geomManager.getFlatness()));
213
        }
214

    
215
        public ImageIcon getIcon() {
216
                return icon;
217
        }
218
        /**
219
         * This method initializes jTextArea
220
         *
221
         * @return javax.swing.JTextArea
222
         */
223
        private JTextArea getJTextArea() {
224
                if (jTextArea == null) {
225
                        jTextArea = new JTextArea();
226
                        jTextArea.setBounds(new java.awt.Rectangle(13,7,285,57));
227
                        jTextArea.setForeground(java.awt.Color.black);
228
                        jTextArea.setBackground(java.awt.SystemColor.control);
229
                        jTextArea.setRows(3);
230
                        jTextArea.setWrapStyleWord(true);
231
                        jTextArea.setLineWrap(true);
232
                        jTextArea.setEditable(false);
233
                        jTextArea.setText(PluginServices.getText(this,"specifies_the_minimum_size_of_the_lines_that_will_form_the_curves"));
234
                }
235
                return jTextArea;
236
        }
237

    
238
        public boolean isValueChanged() {
239
                return super.hasChanged();
240
        }
241

    
242
        public void setChangesApplied() {
243
                setChanged(false);
244
        }
245
        
246
        /*
247
         * (non-Javadoc)
248
         * @see org.gvsig.andami.preferences.AbstractPreferencePage#isResizeable()
249
         */
250
        public boolean isResizeable() {
251
                return true;
252
        }
253
        
254
        
255
}