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