Statistics
| Revision:

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

History | View | Annotate | Download (6.64 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 38564 2012-07-16 11:19:13Z jjdelcerro $
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.IconThemeHelper;
122
import org.gvsig.andami.PluginServices;
123
import org.gvsig.andami.preferences.AbstractPreferencePage;
124
import org.gvsig.andami.preferences.StoreException;
125
import org.gvsig.fmap.geom.GeometryLocator;
126
import org.gvsig.fmap.geom.GeometryManager;
127
import org.gvsig.fmap.geom.util.Converter;
128

    
129

    
130

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

    
139
        private ImageIcon icon;
140

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

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

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

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

    
184
                geomManager.setFlatness(flatness);
185
        }
186

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

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

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

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

    
208
                geomManager.setFlatness(flatness);
209

    
210
        }
211

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

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

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

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