Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / raster / gui / preferences / panels / PreferenceGeneral.java @ 20043

History | View | Annotate | Download (7.44 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.raster.gui.preferences.panels;
20

    
21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
23
import java.awt.Insets;
24

    
25
import javax.swing.BorderFactory;
26
import javax.swing.DefaultComboBoxModel;
27
import javax.swing.JCheckBox;
28
import javax.swing.JComboBox;
29
import javax.swing.JLabel;
30

    
31
import org.gvsig.raster.Configuration;
32
import org.gvsig.raster.RasterLibrary;
33
import org.gvsig.raster.util.PanelBase;
34
/**
35
 *
36
 * @version 12/12/2007
37
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
38
 */
39
public class PreferenceGeneral extends PanelBase {
40
        private JCheckBox checkBoxPreview     = null;
41
        private JCheckBox checkBoxCoordinates = null;
42
        private JLabel    labelNumClases      = null;
43
        private JComboBox comboBoxNumClases   = null;
44
        private JCheckBox checkBoxProjection  = null;
45

    
46
        public PreferenceGeneral() {
47
                initialize();
48
                translate();
49
        }
50

    
51
        private void translate() {
52
                getPanel().setBorder(BorderFactory.createTitledBorder(getText(this, "general")));
53
                getCheckBoxPreview().setText(getText(this, "previsualizar_automaticamente_raster"));
54
                getCheckBoxPreview().setToolTipText(getCheckBoxPreview().getText());
55
                getLabelNumClases().setText(getText(this, "num_clases") + ":");
56
                getCheckBoxCoordinates().setText(getText(this, "pedir_coordenadas_georreferenciacion"));
57
                getCheckBoxProjection().setText(getText(this, "ask_for_projection"));
58
        }
59

    
60
        private void initialize() {
61
                GridBagConstraints gridBagConstraints;
62

    
63
                getPanel().setLayout(new GridBagLayout());
64

    
65
                gridBagConstraints = new GridBagConstraints();
66
                gridBagConstraints.gridx = 0;
67
                gridBagConstraints.gridy = 0;
68
                gridBagConstraints.gridwidth = 2;
69
                gridBagConstraints.fill = GridBagConstraints.BOTH;
70
                gridBagConstraints.anchor = GridBagConstraints.WEST;
71
                gridBagConstraints.weighty = 1.0;
72
                gridBagConstraints.insets = new Insets(5, 5, 2, 5);
73
                getPanel().add(getCheckBoxPreview(), gridBagConstraints);
74

    
75
                gridBagConstraints = new GridBagConstraints();
76
                gridBagConstraints.gridx = 0;
77
                gridBagConstraints.gridy = 1;
78
                gridBagConstraints.anchor = GridBagConstraints.EAST;
79
                gridBagConstraints.insets = new Insets(2, 5, 2, 2);
80
                getPanel().add(getLabelNumClases(), gridBagConstraints);
81

    
82
                gridBagConstraints = new GridBagConstraints();
83
                gridBagConstraints.gridx = 1;
84
                gridBagConstraints.gridy = 1;
85
                gridBagConstraints.anchor = GridBagConstraints.WEST;
86
                gridBagConstraints.weightx = 1.0;
87
                gridBagConstraints.insets = new Insets(2, 2, 2, 5);
88
                getPanel().add(getComboBoxNumClases(), gridBagConstraints);
89

    
90
                gridBagConstraints = new GridBagConstraints();
91
                gridBagConstraints.gridx = 0;
92
                gridBagConstraints.gridy = 2;
93
                gridBagConstraints.gridwidth = 2;
94
                gridBagConstraints.fill = GridBagConstraints.BOTH;
95
                gridBagConstraints.anchor = GridBagConstraints.WEST;
96
                gridBagConstraints.weighty = 1.0;
97
                gridBagConstraints.insets = new Insets(2, 5, 5, 5);
98
                getPanel().add(getCheckBoxCoordinates(), gridBagConstraints);
99
                
100
                gridBagConstraints = new GridBagConstraints();
101
                gridBagConstraints.gridx = 0;
102
                gridBagConstraints.gridy = 3;
103
                gridBagConstraints.gridwidth = 2;
104
                gridBagConstraints.fill = GridBagConstraints.BOTH;
105
                gridBagConstraints.anchor = GridBagConstraints.WEST;
106
                gridBagConstraints.insets = new Insets(2, 5, 5, 5);
107
                getPanel().add(getCheckBoxProjection(), gridBagConstraints);
108
        }
109

    
110
        private JCheckBox getCheckBoxPreview() {
111
                if (checkBoxPreview == null) {
112
                        checkBoxPreview = new JCheckBox();
113
                        checkBoxPreview.setMargin(new Insets(0, 0, 0, 0));
114
                }
115
                return checkBoxPreview;
116
        }
117

    
118
        private JLabel getLabelNumClases() {
119
                if (labelNumClases == null) {
120
                        labelNumClases = new JLabel();
121
                }
122
                return labelNumClases;
123
        }
124

    
125
        private JComboBox getComboBoxNumClases() {
126
                if (comboBoxNumClases == null) {
127
                        comboBoxNumClases = new JComboBox();
128
                        comboBoxNumClases.setModel(new DefaultComboBoxModel(new String[] { "32", "64", "128", "256" }));
129
                }
130
                return comboBoxNumClases;
131
        }
132

    
133
        private JCheckBox getCheckBoxCoordinates() {
134
                if (checkBoxCoordinates == null) {
135
                        checkBoxCoordinates = new JCheckBox();
136
                        checkBoxCoordinates.setMargin(new Insets(0, 0, 0, 0));
137
                }
138
                return checkBoxCoordinates;
139
        }
140
        
141
        /**
142
         * Obtiene el checkbox que indica si se se muestran las opciones de proyecci?n
143
         * en la carga de un raster o no. Si se marca no, se aplicar?n siempre las opciones
144
         * por defecto.
145
         * @return JCheckBox
146
         */
147
        private JCheckBox getCheckBoxProjection() {
148
                if (checkBoxProjection == null) {
149
                        checkBoxProjection = new JCheckBox();
150
                        checkBoxProjection.setMargin(new Insets(0, 0, 0, 0));
151
                }
152
                return checkBoxProjection;
153
        }
154

    
155
        public void initializeDefaults() {
156
                getCheckBoxCoordinates().setSelected(((Boolean) Configuration.getDefaultValue("general_ask_coordinates")).booleanValue());
157
                getCheckBoxProjection().setSelected(((Boolean) Configuration.getDefaultValue("general_ask_projection")).booleanValue());
158
                getCheckBoxPreview().setSelected(((Boolean)Configuration.getDefaultValue("general_auto_preview")).booleanValue());
159
                Integer defaultNumberOfClasses = (Integer) Configuration.getDefaultValue("general_defaultNumberOfClasses");
160
                for (int i = 0; i < getComboBoxNumClases().getItemCount(); i++) {
161
                        if (getComboBoxNumClases().getItemAt(i).toString().equals(defaultNumberOfClasses.toString())) {
162
                                getComboBoxNumClases().setSelectedIndex(i);
163
                                break;
164
                        }
165
                }
166
        }
167

    
168
        public void initializeValues() {
169
                getCheckBoxCoordinates().setSelected(Configuration.getValue("general_ask_coordinates", Boolean.valueOf(false)).booleanValue());
170
                getCheckBoxProjection().setSelected(Configuration.getValue("general_ask_projection", Boolean.valueOf(true)).booleanValue());
171
                getCheckBoxPreview().setSelected(Configuration.getValue("general_auto_preview", Boolean.valueOf(true)).booleanValue());
172
                Integer defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses));
173
                for (int i = 0; i < getComboBoxNumClases().getItemCount(); i++) {
174
                        if (getComboBoxNumClases().getItemAt(i).toString().equals(defaultNumberOfClasses.toString())) {
175
                                getComboBoxNumClases().setSelectedIndex(i);
176
                                break;
177
                        }
178
                }
179
        }
180

    
181
        public void storeValues() {
182
                Configuration.setValue("general_ask_coordinates", Boolean.valueOf(getCheckBoxCoordinates().isSelected()));
183
                Configuration.setValue("general_auto_preview", Boolean.valueOf(getCheckBoxPreview().isSelected()));
184
                Configuration.setValue("general_defaultNumberOfClasses", Integer.valueOf(getComboBoxNumClases().getSelectedItem().toString()));
185
                Configuration.setValue("general_ask_projection", Boolean.valueOf(getCheckBoxProjection().isSelected()));
186
        }
187
}