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 / EditingPage.java @ 40557
History | View | Annotate | Download (14.5 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: EditingPage.java 36005 2011-08-08 11:15:31Z jpiera $
|
27 |
* $Log$
|
28 |
* Revision 1.4 2007-09-19 16:01:06 jaume
|
29 |
* removed unnecessary imports
|
30 |
*
|
31 |
* Revision 1.3 2007/05/02 16:55:13 caballero
|
32 |
* Editing colors
|
33 |
*
|
34 |
* Revision 1.1.2.2 2007/05/02 15:49:56 caballero
|
35 |
* Editing colors
|
36 |
*
|
37 |
* Revision 1.1.2.1 2007/05/02 07:50:56 caballero
|
38 |
* Editing colors
|
39 |
*
|
40 |
* Revision 1.4.4.9 2007/02/16 10:30:36 caballero
|
41 |
* factor 0 incorrecto
|
42 |
*
|
43 |
* Revision 1.4.4.8 2006/11/22 01:45:47 luisw2
|
44 |
* Recuperados cambios de la RC2 que normalizan la gesti?n de CRSs
|
45 |
*
|
46 |
* Revision 1.4.4.7 2006/11/15 00:08:09 jjdelcerro
|
47 |
* *** empty log message ***
|
48 |
*
|
49 |
* Revision 1.21 2006/11/08 10:57:55 jaume
|
50 |
* remove unecessary imports
|
51 |
*
|
52 |
* Revision 1.20 2006/10/25 08:34:06 jmvivo
|
53 |
* LLamado al PluginServices.getText para las unidades de medida del los combo
|
54 |
*
|
55 |
* Revision 1.19 2006/10/04 07:23:31 jaume
|
56 |
* refactored ambiguous methods and field names and added some more features for preference pages
|
57 |
*
|
58 |
* Revision 1.18 2006/10/03 09:52:38 jaume
|
59 |
* restores to meters
|
60 |
*
|
61 |
* Revision 1.17 2006/10/03 09:19:12 jaume
|
62 |
* *** empty log message ***
|
63 |
*
|
64 |
* Revision 1.16 2006/10/03 07:26:08 jaume
|
65 |
* *** empty log message ***
|
66 |
*
|
67 |
* Revision 1.15 2006/10/02 15:30:29 jaume
|
68 |
* *** empty log message ***
|
69 |
*
|
70 |
* Revision 1.14 2006/10/02 13:52:34 jaume
|
71 |
* organize impots
|
72 |
*
|
73 |
* Revision 1.13 2006/10/02 13:38:23 jaume
|
74 |
* *** empty log message ***
|
75 |
*
|
76 |
* Revision 1.12 2006/10/02 11:49:23 jaume
|
77 |
* *** empty log message ***
|
78 |
*
|
79 |
* Revision 1.11 2006/09/28 12:04:21 jaume
|
80 |
* default selection color now configurable
|
81 |
*
|
82 |
* Revision 1.10 2006/09/25 10:17:15 caballero
|
83 |
* Projection
|
84 |
*
|
85 |
* Revision 1.9 2006/09/15 10:41:30 caballero
|
86 |
* extensibilidad de documentos
|
87 |
*
|
88 |
* Revision 1.8 2006/09/14 15:43:48 jaume
|
89 |
* *** empty log message ***
|
90 |
*
|
91 |
* Revision 1.7 2006/09/14 15:42:38 jaume
|
92 |
* *** empty log message ***
|
93 |
*
|
94 |
* Revision 1.6 2006/09/14 06:57:18 jaume
|
95 |
* *** empty log message ***
|
96 |
*
|
97 |
* Revision 1.5 2006/09/12 15:56:50 jaume
|
98 |
* Default Projection now customizable
|
99 |
*
|
100 |
* Revision 1.4 2006/08/29 07:21:08 cesar
|
101 |
* Rename com.iver.cit.gvsig.fmap.Fmap class to com.iver.cit.gvsig.fmap.MapContext
|
102 |
*
|
103 |
* Revision 1.3 2006/08/22 12:30:59 jaume
|
104 |
* *** empty log message ***
|
105 |
*
|
106 |
* Revision 1.2 2006/08/22 07:36:04 jaume
|
107 |
* *** empty log message ***
|
108 |
*
|
109 |
* Revision 1.1 2006/08/04 11:41:05 caballero
|
110 |
* poder especificar el zoom a aplicar en las vistas
|
111 |
*
|
112 |
* Revision 1.3 2006/07/31 10:02:31 jaume
|
113 |
* *** empty log message ***
|
114 |
*
|
115 |
* Revision 1.2 2006/06/13 07:43:08 fjp
|
116 |
* Ajustes sobre los cuadros de dialogos de preferencias
|
117 |
*
|
118 |
* Revision 1.1 2006/06/12 16:04:28 caballero
|
119 |
* Preferencias
|
120 |
*
|
121 |
* Revision 1.11 2006/06/06 10:26:31 jaume
|
122 |
* *** empty log message ***
|
123 |
*
|
124 |
* Revision 1.10 2006/06/05 17:07:17 jaume
|
125 |
* *** empty log message ***
|
126 |
*
|
127 |
* Revision 1.9 2006/06/05 17:00:44 jaume
|
128 |
* *** empty log message ***
|
129 |
*
|
130 |
* Revision 1.8 2006/06/05 16:57:59 jaume
|
131 |
* *** empty log message ***
|
132 |
*
|
133 |
* Revision 1.7 2006/06/05 14:45:06 jaume
|
134 |
* *** empty log message ***
|
135 |
*
|
136 |
* Revision 1.6 2006/06/05 11:00:09 jaume
|
137 |
* *** empty log message ***
|
138 |
*
|
139 |
* Revision 1.5 2006/06/05 10:39:02 jaume
|
140 |
* *** empty log message ***
|
141 |
*
|
142 |
* Revision 1.4 2006/06/05 10:13:40 jaume
|
143 |
* *** empty log message ***
|
144 |
*
|
145 |
* Revision 1.3 2006/06/05 10:06:08 jaume
|
146 |
* *** empty log message ***
|
147 |
*
|
148 |
* Revision 1.2 2006/06/05 09:51:56 jaume
|
149 |
* *** empty log message ***
|
150 |
*
|
151 |
* Revision 1.1 2006/06/02 10:50:18 jaume
|
152 |
* *** empty log message ***
|
153 |
*
|
154 |
*
|
155 |
*/
|
156 |
package org.gvsig.editing.gui.preferences; |
157 |
|
158 |
import java.awt.Color; |
159 |
import java.awt.Dimension; |
160 |
import java.awt.GridBagLayout; |
161 |
|
162 |
import javax.swing.ImageIcon; |
163 |
import javax.swing.JLabel; |
164 |
import javax.swing.JPanel; |
165 |
import javax.swing.JSlider; |
166 |
import javax.swing.border.TitledBorder; |
167 |
import javax.swing.event.ChangeEvent; |
168 |
import javax.swing.event.ChangeListener; |
169 |
|
170 |
import org.gvsig.andami.IconThemeHelper; |
171 |
import org.gvsig.andami.PluginServices; |
172 |
import org.gvsig.andami.PluginsLocator; |
173 |
import org.gvsig.andami.PluginsManager; |
174 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
175 |
import org.gvsig.andami.preferences.StoreException; |
176 |
import org.gvsig.app.gui.panels.ColorChooserPanel; |
177 |
import org.gvsig.editing.CADExtension; |
178 |
import org.gvsig.fmap.geom.Geometry; |
179 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
180 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
181 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
182 |
import org.gvsig.fmap.mapcontrol.MapControlLocator; |
183 |
import org.gvsig.fmap.mapcontrol.MapControlManager; |
184 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol; |
185 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol; |
186 |
import org.gvsig.tools.dynobject.DynObject; |
187 |
|
188 |
|
189 |
|
190 |
/**
|
191 |
* Editing configuration page.
|
192 |
* <b><b>
|
193 |
* Here the user can establish what settings wants to use by default regarding to
|
194 |
* editing.
|
195 |
*
|
196 |
*
|
197 |
* @author Vicente Caballero Navarro
|
198 |
*/
|
199 |
public class EditingPage extends AbstractPreferencePage { |
200 |
private static final long serialVersionUID = -6126280933781398092L; |
201 |
|
202 |
public static String DEFAULT_HANDLER_SYMBOL = "default_editing_handler_symbol"; |
203 |
public static String DEFAULT_AXIS_REFERENCES_SYMBOL = "default_editing_axis_references_symbol"; |
204 |
public static String DEFAULT_RECTANGLE_SELECTION_SYMBOL = "default_editing_rectangle_selection_symbol"; |
205 |
|
206 |
protected String id; |
207 |
private ImageIcon icon; |
208 |
private ColorChooserPanel jccDefaultAxisReferencesColor;
|
209 |
private ColorChooserPanel jccDefaultGeometrySelectionColor;
|
210 |
private ColorChooserPanel jccDefaultHandlerColor;
|
211 |
|
212 |
private boolean panelStarted = false; |
213 |
private JSlider jsDefaultAxisReferencesAlpha; |
214 |
private JSlider jsDefaultGeometrySelectionAlpha; |
215 |
private JSlider jsDefaultHandlerAlpha; |
216 |
|
217 |
private SymbolManager symbolManager = MapContextLocator.getSymbolManager();
|
218 |
private MapControlManager mapControlManager = MapControlLocator.getMapControlManager();
|
219 |
|
220 |
/**
|
221 |
* Creates a new panel containing View preferences settings.
|
222 |
*
|
223 |
*/
|
224 |
public EditingPage() {
|
225 |
super();
|
226 |
id = this.getClass().getName();
|
227 |
icon = IconThemeHelper.getImageIcon("edition-properties");
|
228 |
} |
229 |
|
230 |
public void initializeValues() { |
231 |
if (!panelStarted) getPanel();
|
232 |
|
233 |
//The values has beed retrieved in the CADExtension.
|
234 |
|
235 |
// Default axis references color
|
236 |
ISymbol axisReferenceSymbol = mapControlManager.getAxisReferenceSymbol(); |
237 |
jccDefaultAxisReferencesColor.setColor(axisReferenceSymbol.getColor()); |
238 |
jccDefaultAxisReferencesColor.setAlpha(axisReferenceSymbol.getColor().getAlpha()); |
239 |
jsDefaultAxisReferencesAlpha.setValue(axisReferenceSymbol.getColor().getAlpha()); |
240 |
|
241 |
// Default geometry selection color
|
242 |
ISymbol geometrySelectionSymbol = mapControlManager.getGeometrySelectionSymbol(); |
243 |
jccDefaultGeometrySelectionColor.setColor(geometrySelectionSymbol.getColor()); |
244 |
jccDefaultGeometrySelectionColor.setAlpha(geometrySelectionSymbol.getColor().getAlpha()); |
245 |
jsDefaultGeometrySelectionAlpha.setValue(geometrySelectionSymbol.getColor().getAlpha()); |
246 |
|
247 |
// Default handler color
|
248 |
ISymbol handlerSymbol = mapControlManager.getHandlerSymbol(); |
249 |
jccDefaultHandlerColor.setColor(((IFillSymbol)handlerSymbol).getColor()); |
250 |
jccDefaultHandlerColor.setAlpha(((IFillSymbol)handlerSymbol).getColor().getAlpha()); |
251 |
jsDefaultHandlerAlpha.setValue(geometrySelectionSymbol.getColor().getAlpha()); |
252 |
|
253 |
} |
254 |
|
255 |
public String getID() { |
256 |
return id;
|
257 |
} |
258 |
|
259 |
public String getTitle() { |
260 |
return PluginServices.getText(this, "editing"); |
261 |
} |
262 |
|
263 |
public JPanel getPanel() { |
264 |
if (panelStarted) return this; |
265 |
panelStarted = true;
|
266 |
|
267 |
// just a separator
|
268 |
addComponent(new JLabel(" ")); |
269 |
|
270 |
addComponent(new JLabel(PluginServices.getText(this,"change_the_editing_colors"))); |
271 |
|
272 |
|
273 |
// default selection color chooser
|
274 |
JPanel modifyPanel = new JPanel(); |
275 |
modifyPanel.setBorder(new TitledBorder(PluginServices.getText(this, "options.editing.default_axis_references_color"))); |
276 |
modifyPanel.setLayout(new GridBagLayout()); |
277 |
modifyPanel.add(new JLabel(PluginServices.getText(this,"fill"))); |
278 |
modifyPanel.add(jccDefaultAxisReferencesColor = new ColorChooserPanel());
|
279 |
|
280 |
// JPanel alphaModifyPanel= new JPanel();
|
281 |
modifyPanel.add(new JLabel(PluginServices.getText(this,"alpha"))); |
282 |
modifyPanel.add(jsDefaultAxisReferencesAlpha = new JSlider(0,255)); |
283 |
jsDefaultAxisReferencesAlpha.setPreferredSize(new Dimension(100,30)); |
284 |
|
285 |
jsDefaultAxisReferencesAlpha.addChangeListener(new ChangeListener(){ |
286 |
public void stateChanged(ChangeEvent e) { |
287 |
jccDefaultAxisReferencesColor.setAlpha(((JSlider)e.getSource()).getValue());
|
288 |
|
289 |
}}); |
290 |
|
291 |
addComponent(modifyPanel); |
292 |
addComponent(new JLabel(" ")); |
293 |
|
294 |
// default drawing color chooser
|
295 |
JPanel drawingPanel = new JPanel(); |
296 |
drawingPanel.setBorder(new TitledBorder(PluginServices.getText(this, "options.editing.default_rectangle_selection_color"))); |
297 |
drawingPanel.setLayout(new GridBagLayout()); |
298 |
drawingPanel.add(new JLabel(PluginServices.getText(this,"fill"))); |
299 |
drawingPanel.add(jccDefaultGeometrySelectionColor = new ColorChooserPanel());
|
300 |
|
301 |
// JPanel alphaDrawingPanel= new JPanel();
|
302 |
drawingPanel.add(new JLabel(PluginServices.getText(this,"alpha"))); |
303 |
drawingPanel.add(jsDefaultGeometrySelectionAlpha = new JSlider(0,255)); |
304 |
jsDefaultGeometrySelectionAlpha.setPreferredSize(new Dimension(100,30)); |
305 |
|
306 |
jsDefaultGeometrySelectionAlpha.addChangeListener(new ChangeListener(){ |
307 |
public void stateChanged(ChangeEvent e) { |
308 |
jccDefaultGeometrySelectionColor.setAlpha(((JSlider)e.getSource()).getValue());
|
309 |
}}); |
310 |
|
311 |
addComponent(drawingPanel); |
312 |
addComponent(new JLabel(" ")); |
313 |
|
314 |
// default selection color chooser
|
315 |
JPanel handlerPanel = new JPanel(); |
316 |
handlerPanel.setBorder(new TitledBorder(PluginServices.getText(this, "options.editing.default_handler_color"))); |
317 |
handlerPanel.setLayout(new GridBagLayout()); |
318 |
handlerPanel.add(new JLabel(PluginServices.getText(this,"fill"))); |
319 |
handlerPanel.add(jccDefaultHandlerColor = new ColorChooserPanel());
|
320 |
|
321 |
handlerPanel.add(new JLabel(PluginServices.getText(this,"alpha"))); |
322 |
handlerPanel.add(jsDefaultHandlerAlpha = new JSlider(0,255)); |
323 |
jsDefaultHandlerAlpha.setPreferredSize(new Dimension(100,30)); |
324 |
|
325 |
jsDefaultHandlerAlpha.addChangeListener(new ChangeListener(){ |
326 |
public void stateChanged(ChangeEvent e) { |
327 |
jccDefaultHandlerColor.setAlpha(((JSlider)e.getSource()).getValue());
|
328 |
}}); |
329 |
|
330 |
addComponent(handlerPanel); |
331 |
addComponent(new JLabel(" ")); |
332 |
|
333 |
initializeValues(); |
334 |
return this; |
335 |
} |
336 |
|
337 |
public void storeValues() throws StoreException { |
338 |
Color axisReferencesColor, geometrySelectionColor, handlerColor, handlerOutLineColor;
|
339 |
axisReferencesColor = jccDefaultAxisReferencesColor.getColor(); |
340 |
geometrySelectionColor = jccDefaultGeometrySelectionColor.getColor(); |
341 |
handlerColor = jccDefaultHandlerColor.getColor(); |
342 |
|
343 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
344 |
DynObject dynObject = pluginsManager.getPlugin(CADExtension.class).getPluginProperties(); |
345 |
|
346 |
//Symbol for the AxisReferences
|
347 |
ISymbol axisReferencesSymbol = |
348 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, axisReferencesColor); |
349 |
if (axisReferencesSymbol instanceof IFillSymbol){ |
350 |
((IFillSymbol)axisReferencesSymbol).setFillColor(axisReferencesColor); |
351 |
} |
352 |
mapControlManager.setAxisReferenceSymbol(axisReferencesSymbol); |
353 |
dynObject.setDynValue(DEFAULT_AXIS_REFERENCES_SYMBOL, axisReferencesSymbol); |
354 |
|
355 |
//Symbol for the geometry used in the edition selection
|
356 |
ISymbol geometrySelectionSymbol = |
357 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, geometrySelectionColor); |
358 |
if (geometrySelectionSymbol instanceof IFillSymbol){ |
359 |
((IFillSymbol)geometrySelectionSymbol).setFillColor(geometrySelectionColor); |
360 |
} |
361 |
if (geometrySelectionSymbol instanceof ILineSymbol){ |
362 |
((ILineSymbol)geometrySelectionSymbol).setLineColor(geometrySelectionColor); |
363 |
} |
364 |
mapControlManager.setGeometrySelectionSymbol(geometrySelectionSymbol); |
365 |
dynObject.setDynValue(DEFAULT_RECTANGLE_SELECTION_SYMBOL, geometrySelectionSymbol); |
366 |
|
367 |
//Symbol for the handlers
|
368 |
ISymbol handlerSymbol = |
369 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, handlerColor); |
370 |
if (axisReferencesSymbol instanceof IFillSymbol){ |
371 |
((IFillSymbol)handlerSymbol).setFillColor(handlerColor); |
372 |
} |
373 |
mapControlManager.setHandlerSymbol(handlerSymbol); |
374 |
dynObject.setDynValue(DEFAULT_HANDLER_SYMBOL, handlerSymbol); |
375 |
} |
376 |
|
377 |
public void initializeDefaults() { |
378 |
jccDefaultAxisReferencesColor.setColor(new Color(100, 100, 100, 100)); |
379 |
jsDefaultAxisReferencesAlpha.setValue(100);
|
380 |
|
381 |
jccDefaultGeometrySelectionColor.setColor(new Color(255, 0,0, 100)); |
382 |
jsDefaultGeometrySelectionAlpha.setValue(100);
|
383 |
|
384 |
jccDefaultHandlerColor.setColor(new Color(255, 0,0, 100)); |
385 |
jsDefaultHandlerAlpha.setValue(100);
|
386 |
} |
387 |
|
388 |
public ImageIcon getIcon() { |
389 |
return icon;
|
390 |
} |
391 |
|
392 |
public boolean isValueChanged() { |
393 |
return super.hasChanged(); |
394 |
} |
395 |
|
396 |
public void setChangesApplied() { |
397 |
setChanged(false);
|
398 |
} |
399 |
} |