Revision 22996
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/preferencespage/SymbologyPage.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig.gui.preferencespage; |
2 | 2 |
|
3 |
import java.awt.BorderLayout; |
|
3 | 4 |
import java.awt.Color; |
4 | 5 |
import java.awt.Dimension; |
5 | 6 |
import java.awt.FlowLayout; |
6 | 7 |
import java.awt.Font; |
7 | 8 |
import java.awt.GridBagLayout; |
9 |
import java.awt.GridLayout; |
|
8 | 10 |
import java.awt.event.ActionEvent; |
9 | 11 |
import java.awt.event.ActionListener; |
10 | 12 |
import java.io.File; |
11 | 13 |
|
14 |
import javax.swing.BoxLayout; |
|
12 | 15 |
import javax.swing.ImageIcon; |
13 | 16 |
import javax.swing.JButton; |
17 |
import javax.swing.JCheckBox; |
|
14 | 18 |
import javax.swing.JLabel; |
15 | 19 |
import javax.swing.JPanel; |
16 | 20 |
import javax.swing.JSlider; |
... | ... | |
20 | 24 |
import javax.swing.event.ChangeListener; |
21 | 25 |
import javax.swing.filechooser.FileFilter; |
22 | 26 |
|
27 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
28 |
import org.gvsig.gui.beans.swing.JBlank; |
|
23 | 29 |
import org.gvsig.gui.beans.swing.JComboBoxFontSizes; |
24 | 30 |
import org.gvsig.gui.beans.swing.JComboBoxFonts; |
25 | 31 |
import org.gvsig.gui.beans.swing.JFileChooser; |
... | ... | |
27 | 33 |
import com.iver.andami.PluginServices; |
28 | 34 |
import com.iver.andami.preferences.AbstractPreferencePage; |
29 | 35 |
import com.iver.andami.preferences.StoreException; |
36 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
30 | 37 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
31 | 38 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
39 |
import com.iver.cit.gvsig.project.documents.view.legend.gui.JSymbolPreviewButton; |
|
32 | 40 |
import com.iver.utiles.StringUtilities; |
33 | 41 |
import com.iver.utiles.XMLEntity; |
34 | 42 |
|
... | ... | |
55 | 63 |
private JComboBoxFonts fonts= null; |
56 | 64 |
private JComboBoxFontSizes sizes= null; |
57 | 65 |
private ImageIcon icon=null; |
66 |
private JCheckBox aleatoryFillColor; |
|
58 | 67 |
|
59 | 68 |
|
60 | 69 |
private static final String SYMBOL_FORECOLOR_PROPERTY_NAME = "ForeColor"; |
... | ... | |
62 | 71 |
private static final String SYMBOL_FONT_TYPE_PROPERTY_NAME = "FontType"; |
63 | 72 |
private static final String SYMBOL_FONT_SIZE_PROPERTY_NAME = "FontSize"; |
64 | 73 |
private static final String SYMBOL_IMAGE_FOLDER_PROPERTY_NAME = "ImageFolder"; |
74 |
private static final String SYMBOL_ALEATORY_FORECOLOR = "AleatoryForeColor"; |
|
75 |
private static final String SYMBOL_ALEATORY_FILLCOLOR = "AleatoryFillColor"; |
|
65 | 76 |
|
66 | 77 |
|
67 | 78 |
|
... | ... | |
83 | 94 |
xml.putProperty(SYMBOL_FORECOLOR_PROPERTY_NAME, |
84 | 95 |
StringUtilities.color2String(foreColor)); |
85 | 96 |
|
97 |
|
|
86 | 98 |
xml.putProperty(SYMBOL_FILLCOLOR_PROPERTY_NAME, |
87 | 99 |
StringUtilities.color2String(fillColor)); |
100 |
xml.putProperty(SYMBOL_ALEATORY_FILLCOLOR,aleatoryFillColor.isSelected()); |
|
88 | 101 |
|
89 | 102 |
propertyName = SYMBOL_IMAGE_FOLDER_PROPERTY_NAME; |
90 | 103 |
path = txtProjectsFolder.getText(); |
... | ... | |
177 | 190 |
panelStarted=true; |
178 | 191 |
addComponent(new JLabel(" ")); |
179 | 192 |
|
180 |
JPanel selectionDefaultColorPanel = new JPanel();
|
|
193 |
GridBagLayoutPanel selectionDefaultColorPanel = new GridBagLayoutPanel();
|
|
181 | 194 |
selectionDefaultColorPanel.setBorder(new TitledBorder(PluginServices.getText(this, "default_color"))); |
182 | 195 |
selectionDefaultColorPanel.setLayout(new GridBagLayout()); |
183 | 196 |
selectionDefaultColorPanel.add(new JLabel(PluginServices.getText(this,"fill"))); |
... | ... | |
185 | 198 |
|
186 | 199 |
selectionDefaultColorPanel.add(new JLabel(PluginServices.getText(this,"alpha"))); |
187 | 200 |
selectionDefaultColorPanel.add(jsDefaultSelectionAlpha = new JSlider(0,255)); |
201 |
selectionDefaultColorPanel.add(new JBlank(50,50)); |
|
188 | 202 |
|
189 | 203 |
jsDefaultSelectionAlpha.setPreferredSize(new Dimension(100,30)); |
190 | 204 |
jsDefaultSelectionAlpha.addChangeListener(new ChangeListener(){ |
191 | 205 |
public void stateChanged(ChangeEvent e) { |
192 | 206 |
defaultColor.setAlpha(((JSlider)e.getSource()).getValue()); |
193 | 207 |
}}); |
194 |
|
|
208 |
addComponent(new JLabel(" ")); |
|
195 | 209 |
addComponent(selectionDefaultColorPanel); |
196 | 210 |
|
197 |
JPanel selectionFillColor = new JPanel();
|
|
211 |
GridBagLayoutPanel selectionFillColor = new GridBagLayoutPanel();
|
|
198 | 212 |
selectionFillColor.setBorder(new TitledBorder(PluginServices.getText(this, "default_fill_color"))); |
199 | 213 |
selectionFillColor.setLayout(new GridBagLayout()); |
200 | 214 |
selectionFillColor.add(new JLabel(PluginServices.getText(this,"fill"))); |
... | ... | |
209 | 223 |
defaultFillColor.setAlpha(((JSlider)e.getSource()).getValue()); |
210 | 224 |
}}); |
211 | 225 |
|
226 |
selectionFillColor.add(new JBlank(50,50)); |
|
227 |
selectionFillColor.add(aleatoryFillColor = new JCheckBox()); |
|
228 |
selectionFillColor.add(new JLabel(" " + PluginServices.getText(this,"aleatory"))); |
|
229 |
|
|
230 |
|
|
231 |
aleatoryFillColor.addActionListener(new ActionListener(){ |
|
232 |
|
|
233 |
public void actionPerformed(ActionEvent e) { |
|
234 |
if(e.getSource() == aleatoryFillColor){ |
|
235 |
defaultFillColor.setEnabled(!aleatoryFillColor.isSelected()); |
|
236 |
jsFillSelelctionAlpha.setEnabled(!aleatoryFillColor.isSelected()); |
|
237 |
} |
|
238 |
} |
|
239 |
|
|
240 |
}); |
|
241 |
|
|
212 | 242 |
addComponent(new JLabel(" ")); |
213 | 243 |
addComponent(selectionFillColor); |
214 | 244 |
|
... | ... | |
286 | 316 |
PluginServices ps = PluginServices.getPluginServices(this); |
287 | 317 |
XMLEntity xml = ps.getPersistentXML(); |
288 | 318 |
|
319 |
|
|
289 | 320 |
//Default Color |
290 | 321 |
if (xml.contains(SYMBOL_FORECOLOR_PROPERTY_NAME)) { |
291 | 322 |
Color color=StringUtilities.string2Color(xml.getStringProperty(SYMBOL_FORECOLOR_PROPERTY_NAME)); |
292 | 323 |
defaultColor.setColor(color); |
293 | 324 |
defaultColor.setAlpha(color.getAlpha()); |
294 | 325 |
jsDefaultSelectionAlpha.setValue(color.getAlpha()); |
326 |
SymbologyFactory.DefaultSymbolColor = color; |
|
295 | 327 |
}else{ |
296 | 328 |
Color color=SymbologyFactory.FactoryDefaultSymbolColor; |
297 | 329 |
defaultColor.setColor(color); |
298 | 330 |
defaultColor.setAlpha(color.getAlpha()); |
299 | 331 |
jsDefaultSelectionAlpha.setValue(color.getAlpha()); |
332 |
SymbologyFactory.DefaultSymbolColor = color; |
|
300 | 333 |
} |
301 | 334 |
|
335 |
if(xml.contains(SYMBOL_ALEATORY_FILLCOLOR)){ |
|
336 |
aleatoryFillColor.setSelected(xml.getBooleanProperty(SYMBOL_ALEATORY_FILLCOLOR)); |
|
337 |
SymbologyFactory.DefaultAleatoryFillColor = aleatoryFillColor.isSelected(); |
|
338 |
}else{ |
|
339 |
aleatoryFillColor.setSelected(SymbologyFactory.FactoryDefaultAleatoryFillColor); |
|
340 |
SymbologyFactory.DefaultAleatoryFillColor = aleatoryFillColor.isSelected(); |
|
341 |
} |
|
342 |
|
|
302 | 343 |
//Fill Color |
303 | 344 |
if (xml.contains(SYMBOL_FILLCOLOR_PROPERTY_NAME)) { |
304 | 345 |
Color color=StringUtilities.string2Color(xml.getStringProperty(SYMBOL_FILLCOLOR_PROPERTY_NAME)); |
305 | 346 |
defaultFillColor.setColor(color); |
306 | 347 |
defaultFillColor.setAlpha(color.getAlpha()); |
307 | 348 |
jsFillSelelctionAlpha.setValue(color.getAlpha()); |
349 |
SymbologyFactory.DefaultFillSymbolColor = color; |
|
308 | 350 |
}else{ |
309 | 351 |
Color color=SymbologyFactory.FactoryDefaultFillSymbolColor; |
310 | 352 |
defaultFillColor.setColor(color); |
311 | 353 |
defaultFillColor.setAlpha(color.getAlpha()); |
312 | 354 |
jsFillSelelctionAlpha.setValue(color.getAlpha()); |
355 |
SymbologyFactory.DefaultFillSymbolColor = color; |
|
313 | 356 |
} |
314 | 357 |
|
358 |
defaultFillColor.setEnabled(!aleatoryFillColor.isSelected()); |
|
359 |
jsFillSelelctionAlpha.setEnabled(!aleatoryFillColor.isSelected()); |
|
360 |
|
|
315 | 361 |
//Path |
316 | 362 |
if (xml.contains(SYMBOL_IMAGE_FOLDER_PROPERTY_NAME)) { |
317 | 363 |
String path=xml.getStringProperty(SYMBOL_IMAGE_FOLDER_PROPERTY_NAME); |
318 | 364 |
txtProjectsFolder.setText(path); |
365 |
SymbologyFactory.SymbolLibraryPath = path; |
|
319 | 366 |
}else{ |
320 | 367 |
txtProjectsFolder.setText(SymbologyFactory.FactorySymbolLibraryPath); |
368 |
SymbologyFactory.SymbolLibraryPath = SymbologyFactory.FactorySymbolLibraryPath; |
|
321 | 369 |
} |
322 | 370 |
|
323 | 371 |
//Font Size |
... | ... | |
338 | 386 |
int size =SymbologyFactory.FactoryDefaultTextFont.getSize(); |
339 | 387 |
sizes.setSelectedItem(size); |
340 | 388 |
} |
341 |
|
|
389 |
SymbologyFactory.DefaultTextFont = new Font(fonts.getFont().getName(),fonts.getFont().getStyle(),(Integer) sizes.getSelectedItem()); |
|
342 | 390 |
} |
343 | 391 |
|
344 | 392 |
public void initializeDefaults() { |
... | ... | |
351 | 399 |
fonts.setSelectedItem(SymbologyFactory.FactoryDefaultTextFont.getFamily()); |
352 | 400 |
sizes.setSelectedItem(SymbologyFactory.FactoryDefaultTextFont.getSize()); |
353 | 401 |
txtProjectsFolder.setText(SymbologyFactory.FactorySymbolLibraryPath); |
402 |
|
|
403 |
aleatoryFillColor.setSelected(SymbologyFactory.FactoryDefaultAleatoryFillColor); |
|
354 | 404 |
} |
355 | 405 |
|
356 | 406 |
public boolean isValueChanged() { |
... | ... | |
365 | 415 |
} |
366 | 416 |
|
367 | 417 |
private void setPropertiesFromPanel(){ |
418 |
|
|
368 | 419 |
if(defaultColor.getColor()!=null){ |
369 | 420 |
Color color = defaultColor.getColor(); |
370 | 421 |
color = new Color(color.getRed(),color.getGreen(),color.getBlue(),jsDefaultSelectionAlpha.getValue()); |
371 | 422 |
SymbologyFactory.DefaultSymbolColor = color; |
372 | 423 |
} |
373 | 424 |
|
425 |
if(aleatoryFillColor != null){ |
|
426 |
SymbologyFactory.DefaultAleatoryFillColor = aleatoryFillColor.isSelected(); |
|
427 |
} |
|
374 | 428 |
//Fill Color |
375 | 429 |
if (defaultFillColor.getColor() != null) { |
376 | 430 |
Color color = defaultFillColor.getColor(); |
Also available in: Unified diff