svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / preferencespage / CartographicSupportPage.java @ 28368
History | View | Annotate | Download (4.33 KB)
1 | 18623 | jdominguez | package com.iver.cit.gvsig.gui.preferencespage; |
---|---|---|---|
2 | |||
3 | 23704 | vcaballero | import java.awt.Color; |
4 | import java.awt.Font; |
||
5 | |||
6 | 18623 | jdominguez | import javax.swing.ImageIcon; |
7 | import javax.swing.JPanel; |
||
8 | import javax.swing.JSeparator; |
||
9 | |||
10 | import com.iver.andami.PluginServices; |
||
11 | import com.iver.andami.preferences.AbstractPreferencePage; |
||
12 | import com.iver.andami.preferences.StoreException; |
||
13 | import com.iver.cit.gvsig.fmap.core.CartographicSupport; |
||
14 | import com.iver.cit.gvsig.fmap.core.CartographicSupportToolkit; |
||
15 | 23704 | vcaballero | import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
16 | 18623 | jdominguez | import com.iver.cit.gvsig.gui.JComboBoxUnits; |
17 | import com.iver.cit.gvsig.gui.styling.JComboBoxUnitsReferenceSystem; |
||
18 | 23704 | vcaballero | import com.iver.utiles.StringUtilities; |
19 | 18623 | jdominguez | import com.iver.utiles.XMLEntity; |
20 | |||
21 | /**
|
||
22 | *
|
||
23 | * @author jaume dominguez faus - jaume.dominguez@iver.es
|
||
24 | */
|
||
25 | public class CartographicSupportPage extends AbstractPreferencePage { |
||
26 | private static final String DefaultMeasureUnitKey = "DefaultMeasureUnitKey"; |
||
27 | private static final String DefaultUnitReferenceSystemKey = "DefaultUnitReferenceSystemKey"; |
||
28 | private JComboBoxUnits cmbUnits;
|
||
29 | private JComboBoxUnitsReferenceSystem cmbReferenceSystem;
|
||
30 | 23704 | vcaballero | |
31 | 18623 | jdominguez | public CartographicSupportPage() {
|
32 | super();
|
||
33 | initialize(); |
||
34 | } |
||
35 | 23704 | vcaballero | |
36 | 18623 | jdominguez | private void initialize() { |
37 | addComponent(PluginServices.getText(this, "default_measure_units"), |
||
38 | cmbUnits = new JComboBoxUnits(true)); |
||
39 | addComponent(PluginServices.getText(this, "default_measure_units_reference_system"), |
||
40 | cmbReferenceSystem = new JComboBoxUnitsReferenceSystem());
|
||
41 | addComponent(new JSeparator(JSeparator.HORIZONTAL)); |
||
42 | } |
||
43 | |||
44 | // pending of a proposed refactor, don't erase
|
||
45 | 23704 | vcaballero | public void persistPreferences() throws StoreException { |
46 | PluginServices ps = PluginServices.getPluginServices(this);
|
||
47 | XMLEntity xml = ps.getPersistentXML(); |
||
48 | xml.putProperty(DefaultMeasureUnitKey, cmbUnits.getSelectedUnitIndex()); |
||
49 | xml.putProperty(DefaultUnitReferenceSystemKey, cmbReferenceSystem.getSelectedIndex()); |
||
50 | } |
||
51 | 18623 | jdominguez | |
52 | @Override
|
||
53 | public void setChangesApplied() { |
||
54 | setChanged(false);
|
||
55 | } |
||
56 | |||
57 | public void applyValuesFromPersistence() throws StoreException { |
||
58 | PluginServices ps = PluginServices.getPluginServices(this);
|
||
59 | XMLEntity xml = ps.getPersistentXML(); |
||
60 | if (xml.contains(DefaultMeasureUnitKey))
|
||
61 | CartographicSupportToolkit.DefaultMeasureUnit = xml.getIntProperty(DefaultMeasureUnitKey); |
||
62 | if (xml.contains(DefaultUnitReferenceSystemKey))
|
||
63 | CartographicSupportToolkit.DefaultReferenceSystem = xml.getIntProperty(DefaultUnitReferenceSystemKey); |
||
64 | } |
||
65 | |||
66 | public String getID() { |
||
67 | return getClass().getName();
|
||
68 | } |
||
69 | |||
70 | public ImageIcon getIcon() { |
||
71 | // TODO Auto-generated method stub
|
||
72 | return null; |
||
73 | } |
||
74 | |||
75 | public JPanel getPanel() { |
||
76 | return this; |
||
77 | } |
||
78 | |||
79 | public String getTitle() { |
||
80 | return PluginServices.getText(this, "cartographic_support"); |
||
81 | } |
||
82 | |||
83 | // pending of a refactoring do not delete (swap commented lines)
|
||
84 | // public void initializeComponents() {
|
||
85 | public void initializeValues() { |
||
86 | 23704 | vcaballero | |
87 | PluginServices ps = PluginServices.getPluginServices(this);
|
||
88 | XMLEntity xml = ps.getPersistentXML(); |
||
89 | |||
90 | if (xml.contains(DefaultMeasureUnitKey)) {
|
||
91 | cmbUnits.setSelectedUnitIndex(xml.getIntProperty(DefaultMeasureUnitKey)); |
||
92 | CartographicSupportToolkit.DefaultMeasureUnit = xml.getIntProperty(DefaultMeasureUnitKey); |
||
93 | }else{
|
||
94 | CartographicSupportToolkit.DefaultMeasureUnit = -1; // pixel |
||
95 | } |
||
96 | |||
97 | if (xml.contains(DefaultUnitReferenceSystemKey)) {
|
||
98 | cmbReferenceSystem.setSelectedIndex(xml.getIntProperty(DefaultUnitReferenceSystemKey)); |
||
99 | CartographicSupportToolkit.DefaultReferenceSystem = xml.getIntProperty(DefaultUnitReferenceSystemKey); |
||
100 | }else{
|
||
101 | CartographicSupportToolkit.DefaultReferenceSystem = CartographicSupport.WORLD; |
||
102 | } |
||
103 | |||
104 | 18623 | jdominguez | } |
105 | |||
106 | public void initializeDefaults() { |
||
107 | CartographicSupportToolkit.DefaultMeasureUnit = -1; // pixel |
||
108 | CartographicSupportToolkit.DefaultReferenceSystem = CartographicSupport.WORLD; |
||
109 | initializeValues(); |
||
110 | // pending of a refactoring do not delete (swap commented lines)
|
||
111 | // initializeComponents();
|
||
112 | } |
||
113 | 23704 | vcaballero | |
114 | 18623 | jdominguez | // pending of a refactoring, following method would be removed
|
115 | @Override
|
||
116 | public void storeValues() throws StoreException { |
||
117 | 23704 | vcaballero | setPropertiesFromPanel(); |
118 | persistPreferences(); |
||
119 | 18623 | jdominguez | } |
120 | |||
121 | public boolean isValueChanged() { |
||
122 | return super.hasChanged(); |
||
123 | } |
||
124 | |||
125 | 23704 | vcaballero | private void setPropertiesFromPanel(){ |
126 | |||
127 | if(cmbReferenceSystem.getSelectedItem()!=null) |
||
128 | CartographicSupportToolkit.DefaultReferenceSystem = cmbReferenceSystem.getSelectedIndex(); |
||
129 | CartographicSupportToolkit.DefaultMeasureUnit = cmbUnits.getSelectedUnitIndex(); |
||
130 | } |
||
131 | |||
132 | 18623 | jdominguez | } |