svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / gui / preferences / FlatnessPage.java @ 40557
History | View | Annotate | Download (7.05 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/* CVS MESSAGES:
|
25 |
*
|
26 |
* $Id: FlatnessPage.java 39611 2013-01-21 12:24:59Z jldominguez $
|
27 |
* $Log$
|
28 |
* Revision 1.4 2006-09-06 15:29:59 caballero
|
29 |
* initialize flatness
|
30 |
*
|
31 |
* Revision 1.3 2006/08/22 12:27:53 jaume
|
32 |
* improved performances when saving
|
33 |
*
|
34 |
* Revision 1.2 2006/08/22 07:37:32 jaume
|
35 |
* *** empty log message ***
|
36 |
*
|
37 |
* Revision 1.1 2006/08/10 08:18:35 caballero
|
38 |
* configurar grid
|
39 |
*
|
40 |
* Revision 1.1 2006/08/04 11:41:05 caballero
|
41 |
* poder especificar el zoom a aplicar en las vistas
|
42 |
*
|
43 |
* Revision 1.3 2006/07/31 10:02:31 jaume
|
44 |
* *** empty log message ***
|
45 |
*
|
46 |
* Revision 1.2 2006/06/13 07:43:08 fjp
|
47 |
* Ajustes sobre los cuadros de dialogos de preferencias
|
48 |
*
|
49 |
* Revision 1.1 2006/06/12 16:04:28 caballero
|
50 |
* Preferencias
|
51 |
*
|
52 |
* Revision 1.11 2006/06/06 10:26:31 jaume
|
53 |
* *** empty log message ***
|
54 |
*
|
55 |
* Revision 1.10 2006/06/05 17:07:17 jaume
|
56 |
* *** empty log message ***
|
57 |
*
|
58 |
* Revision 1.9 2006/06/05 17:00:44 jaume
|
59 |
* *** empty log message ***
|
60 |
*
|
61 |
* Revision 1.8 2006/06/05 16:57:59 jaume
|
62 |
* *** empty log message ***
|
63 |
*
|
64 |
* Revision 1.7 2006/06/05 14:45:06 jaume
|
65 |
* *** empty log message ***
|
66 |
*
|
67 |
* Revision 1.6 2006/06/05 11:00:09 jaume
|
68 |
* *** empty log message ***
|
69 |
*
|
70 |
* Revision 1.5 2006/06/05 10:39:02 jaume
|
71 |
* *** empty log message ***
|
72 |
*
|
73 |
* Revision 1.4 2006/06/05 10:13:40 jaume
|
74 |
* *** empty log message ***
|
75 |
*
|
76 |
* Revision 1.3 2006/06/05 10:06:08 jaume
|
77 |
* *** empty log message ***
|
78 |
*
|
79 |
* Revision 1.2 2006/06/05 09:51:56 jaume
|
80 |
* *** empty log message ***
|
81 |
*
|
82 |
* Revision 1.1 2006/06/02 10:50:18 jaume
|
83 |
* *** empty log message ***
|
84 |
*
|
85 |
*
|
86 |
*/
|
87 |
package org.gvsig.editing.gui.preferences; |
88 |
|
89 |
import java.awt.BorderLayout; |
90 |
import java.awt.GridBagConstraints; |
91 |
import java.awt.GridBagLayout; |
92 |
import java.awt.Insets; |
93 |
import java.awt.event.KeyEvent; |
94 |
import java.awt.event.KeyListener; |
95 |
import java.util.prefs.Preferences; |
96 |
|
97 |
import javax.swing.ImageIcon; |
98 |
import javax.swing.JLabel; |
99 |
import javax.swing.JPanel; |
100 |
import javax.swing.JTextArea; |
101 |
import javax.swing.JTextField; |
102 |
import javax.swing.border.EmptyBorder; |
103 |
|
104 |
import org.apache.batik.ext.swing.GridBagConstants; |
105 |
|
106 |
import org.gvsig.andami.IconThemeHelper; |
107 |
import org.gvsig.andami.PluginServices; |
108 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
109 |
import org.gvsig.andami.preferences.StoreException; |
110 |
import org.gvsig.fmap.geom.GeometryLocator; |
111 |
import org.gvsig.fmap.geom.GeometryManager; |
112 |
|
113 |
|
114 |
|
115 |
public class FlatnessPage extends AbstractPreferencePage implements KeyListener { |
116 |
|
117 |
private static Preferences prefs = Preferences.userRoot().node( "cadtooladapter" ); |
118 |
private JTextArea jTextArea = null; |
119 |
private JTextField txtFlatness; |
120 |
private JPanel northPanel = null; |
121 |
private boolean valChanged = false; |
122 |
|
123 |
private GeometryManager geomManager = GeometryLocator.getGeometryManager();
|
124 |
|
125 |
private ImageIcon icon; |
126 |
|
127 |
public FlatnessPage() {
|
128 |
super();
|
129 |
icon = IconThemeHelper.getImageIcon("preferences-layer-modify-flatness");
|
130 |
setLayout(new BorderLayout()); |
131 |
add(getNorthPanel(), BorderLayout.NORTH);
|
132 |
} |
133 |
|
134 |
public JPanel getNorthPanel(){ |
135 |
if (northPanel == null){ |
136 |
northPanel = new JPanel(); |
137 |
northPanel.setLayout(new GridBagLayout()); |
138 |
northPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); |
139 |
|
140 |
GridBagConstraints constraints = new GridBagConstraints(); |
141 |
constraints.gridx = 0;
|
142 |
constraints.gridy = 0;
|
143 |
constraints.fill = GridBagConstants.HORIZONTAL; |
144 |
constraints.weightx = 1.0;
|
145 |
constraints.gridwidth = 2;
|
146 |
constraints.insets = new Insets(0, 0, 5, 0); |
147 |
northPanel.add(getJTextArea(), constraints); |
148 |
|
149 |
constraints = new GridBagConstraints(); |
150 |
constraints.gridx = 0;
|
151 |
constraints.gridy = 1;
|
152 |
northPanel.add(new JLabel(PluginServices.getText(this, "densityfication") + ":"), constraints); |
153 |
|
154 |
txtFlatness = new JTextField("", 15); |
155 |
txtFlatness.addKeyListener(this);
|
156 |
constraints = new GridBagConstraints(); |
157 |
constraints.gridx = 1;
|
158 |
constraints.gridy = 1;
|
159 |
constraints.fill = GridBagConstants.HORIZONTAL; |
160 |
constraints.weightx = 1.0;
|
161 |
northPanel.add(txtFlatness, constraints); |
162 |
} |
163 |
return northPanel;
|
164 |
} |
165 |
|
166 |
public void initializeValues() { |
167 |
double flatness = geomManager.getFlatness();
|
168 |
|
169 |
txtFlatness.setText(String.valueOf(flatness));
|
170 |
|
171 |
geomManager.setFlatness(flatness); |
172 |
} |
173 |
|
174 |
public String getID() { |
175 |
return this.getClass().getName(); |
176 |
} |
177 |
|
178 |
public String getTitle() { |
179 |
return PluginServices.getText(this, "Flatness"); |
180 |
} |
181 |
|
182 |
public JPanel getPanel() { |
183 |
return this; |
184 |
} |
185 |
|
186 |
public void storeValues() throws StoreException { |
187 |
double flatness;
|
188 |
try{
|
189 |
flatness=Double.parseDouble(txtFlatness.getText());
|
190 |
}catch (Exception e) { |
191 |
throw new StoreException(PluginServices.getText(this,"minimum_size_of_line_incorrect")); |
192 |
} |
193 |
prefs.putDouble("flatness", flatness);
|
194 |
|
195 |
geomManager.setFlatness(flatness); |
196 |
|
197 |
} |
198 |
|
199 |
public void initializeDefaults() { |
200 |
txtFlatness.setText(String.valueOf(geomManager.getFlatness()));
|
201 |
} |
202 |
|
203 |
public ImageIcon getIcon() { |
204 |
return icon;
|
205 |
} |
206 |
/**
|
207 |
* This method initializes jTextArea
|
208 |
*
|
209 |
* @return javax.swing.JTextArea
|
210 |
*/
|
211 |
private JTextArea getJTextArea() { |
212 |
if (jTextArea == null) { |
213 |
jTextArea = new JTextArea(); |
214 |
jTextArea.setBounds(new java.awt.Rectangle(13,7,285,57)); |
215 |
jTextArea.setForeground(java.awt.Color.black); |
216 |
jTextArea.setBackground(java.awt.SystemColor.control); |
217 |
jTextArea.setRows(3);
|
218 |
jTextArea.setWrapStyleWord(true);
|
219 |
jTextArea.setLineWrap(true);
|
220 |
jTextArea.setEditable(false);
|
221 |
jTextArea.setText(PluginServices.getText(this,"specifies_the_minimum_size_of_the_lines_that_will_form_the_curves")); |
222 |
} |
223 |
return jTextArea;
|
224 |
} |
225 |
|
226 |
public boolean isValueChanged() { |
227 |
return valChanged;
|
228 |
} |
229 |
|
230 |
public void setChangesApplied() { |
231 |
setChanged(false);
|
232 |
} |
233 |
|
234 |
/*
|
235 |
* (non-Javadoc)
|
236 |
* @see org.gvsig.andami.preferences.AbstractPreferencePage#isResizeable()
|
237 |
*/
|
238 |
public boolean isResizeable() { |
239 |
return true; |
240 |
} |
241 |
|
242 |
/* (non-Javadoc)
|
243 |
* @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
|
244 |
*/
|
245 |
public void keyTyped(KeyEvent e) { |
246 |
valChanged = true;
|
247 |
} |
248 |
|
249 |
/* (non-Javadoc)
|
250 |
* @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
|
251 |
*/
|
252 |
public void keyPressed(KeyEvent e) { |
253 |
valChanged = true;
|
254 |
} |
255 |
|
256 |
/* (non-Javadoc)
|
257 |
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
|
258 |
*/
|
259 |
public void keyReleased(KeyEvent e) { |
260 |
} |
261 |
|
262 |
|
263 |
} |