gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / raster / gui / preference / panel / PreferenceGeneral.java @ 2123
History | View | Annotate | Download (8.04 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
package org.gvsig.raster.tools.app.basic.raster.gui.preference.panel; |
23 |
|
24 |
import java.awt.GridBagConstraints; |
25 |
import java.awt.GridBagLayout; |
26 |
import java.awt.Insets; |
27 |
|
28 |
import javax.swing.BorderFactory; |
29 |
import javax.swing.DefaultComboBoxModel; |
30 |
import javax.swing.JCheckBox; |
31 |
import javax.swing.JComboBox; |
32 |
import javax.swing.JLabel; |
33 |
|
34 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
35 |
import org.gvsig.raster.mainplugin.config.Configuration; |
36 |
import org.gvsig.raster.util.BasePanel; |
37 |
/**
|
38 |
* Clase para la configuracion general de Raster. Aqui tenemos todas las variables
|
39 |
* que no tienen una secci?n en concreto.
|
40 |
*
|
41 |
* @version 12/12/2007
|
42 |
* @author BorSanZa - Borja S?nchez Zamorano
|
43 |
*/
|
44 |
public class PreferenceGeneral extends BasePanel { |
45 |
private static final long serialVersionUID = 1L; |
46 |
private JCheckBox checkBoxPreview = null; |
47 |
private JCheckBox checkBoxCoordinates = null; |
48 |
private JLabel labelNumClases = null; |
49 |
private JComboBox comboBoxNumClases = null; |
50 |
private JCheckBox checkBoxProjection = null; |
51 |
|
52 |
/**
|
53 |
*Inicializa componentes gr?ficos y traduce
|
54 |
*/
|
55 |
public PreferenceGeneral() {
|
56 |
init(); |
57 |
translate(); |
58 |
} |
59 |
|
60 |
/**
|
61 |
* Todas las traducciones de esta clase.
|
62 |
*/
|
63 |
protected void translate() { |
64 |
setBorder(BorderFactory.createTitledBorder(getText(this, "general"))); |
65 |
getCheckBoxPreview().setText(getText(this, "previsualizar_automaticamente_raster")); |
66 |
getCheckBoxPreview().setToolTipText(getCheckBoxPreview().getText()); |
67 |
getLabelNumClases().setText(getText(this, "num_clases") + ":"); |
68 |
getCheckBoxCoordinates().setText(getText(this, "pedir_coordenadas_georreferenciacion")); |
69 |
getCheckBoxProjection().setText(getText(this, "ask_for_projection")); |
70 |
} |
71 |
|
72 |
protected void init() { |
73 |
GridBagConstraints gridBagConstraints;
|
74 |
|
75 |
setLayout(new GridBagLayout()); |
76 |
|
77 |
gridBagConstraints = new GridBagConstraints(); |
78 |
gridBagConstraints.gridx = 0;
|
79 |
gridBagConstraints.gridy = 0;
|
80 |
gridBagConstraints.gridwidth = 2;
|
81 |
gridBagConstraints.fill = GridBagConstraints.BOTH;
|
82 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
83 |
gridBagConstraints.weighty = 1.0;
|
84 |
gridBagConstraints.insets = new Insets(5, 5, 2, 5); |
85 |
add(getCheckBoxPreview(), gridBagConstraints); |
86 |
|
87 |
gridBagConstraints = new GridBagConstraints(); |
88 |
gridBagConstraints.gridx = 0;
|
89 |
gridBagConstraints.gridy = 1;
|
90 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
91 |
gridBagConstraints.insets = new Insets(2, 5, 2, 2); |
92 |
add(getLabelNumClases(), gridBagConstraints); |
93 |
|
94 |
gridBagConstraints = new GridBagConstraints(); |
95 |
gridBagConstraints.gridx = 1;
|
96 |
gridBagConstraints.gridy = 1;
|
97 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
98 |
gridBagConstraints.weightx = 1.0;
|
99 |
gridBagConstraints.insets = new Insets(2, 2, 2, 5); |
100 |
add(getComboBoxNumClases(), gridBagConstraints); |
101 |
|
102 |
gridBagConstraints = new GridBagConstraints(); |
103 |
gridBagConstraints.gridx = 0;
|
104 |
gridBagConstraints.gridy = 2;
|
105 |
gridBagConstraints.gridwidth = 2;
|
106 |
gridBagConstraints.fill = GridBagConstraints.BOTH;
|
107 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
108 |
gridBagConstraints.weighty = 1.0;
|
109 |
gridBagConstraints.insets = new Insets(2, 5, 5, 5); |
110 |
add(getCheckBoxCoordinates(), gridBagConstraints); |
111 |
|
112 |
gridBagConstraints = new GridBagConstraints(); |
113 |
gridBagConstraints.gridx = 0;
|
114 |
gridBagConstraints.gridy = 3;
|
115 |
gridBagConstraints.gridwidth = 2;
|
116 |
gridBagConstraints.fill = GridBagConstraints.BOTH;
|
117 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
118 |
gridBagConstraints.insets = new Insets(2, 5, 5, 5); |
119 |
add(getCheckBoxProjection(), gridBagConstraints); |
120 |
} |
121 |
|
122 |
private JCheckBox getCheckBoxPreview() { |
123 |
if (checkBoxPreview == null) { |
124 |
checkBoxPreview = new JCheckBox(); |
125 |
checkBoxPreview.setMargin(new Insets(0, 0, 0, 0)); |
126 |
} |
127 |
return checkBoxPreview;
|
128 |
} |
129 |
|
130 |
private JLabel getLabelNumClases() { |
131 |
if (labelNumClases == null) { |
132 |
labelNumClases = new JLabel(); |
133 |
} |
134 |
return labelNumClases;
|
135 |
} |
136 |
|
137 |
private JComboBox getComboBoxNumClases() { |
138 |
if (comboBoxNumClases == null) { |
139 |
comboBoxNumClases = new JComboBox(); |
140 |
comboBoxNumClases.setModel(new DefaultComboBoxModel(new String[] { "32", "64", "128", "256" })); |
141 |
} |
142 |
return comboBoxNumClases;
|
143 |
} |
144 |
|
145 |
private JCheckBox getCheckBoxCoordinates() { |
146 |
if (checkBoxCoordinates == null) { |
147 |
checkBoxCoordinates = new JCheckBox(); |
148 |
checkBoxCoordinates.setMargin(new Insets(0, 0, 0, 0)); |
149 |
} |
150 |
return checkBoxCoordinates;
|
151 |
} |
152 |
|
153 |
/**
|
154 |
* Obtiene el checkbox que indica si se se muestran las opciones de proyecci?n
|
155 |
* en la carga de un raster o no. Si se marca no, se aplicar?n siempre las opciones
|
156 |
* por defecto.
|
157 |
* @return JCheckBox
|
158 |
*/
|
159 |
private JCheckBox getCheckBoxProjection() { |
160 |
if (checkBoxProjection == null) { |
161 |
checkBoxProjection = new JCheckBox(); |
162 |
checkBoxProjection.setMargin(new Insets(0, 0, 0, 0)); |
163 |
} |
164 |
return checkBoxProjection;
|
165 |
} |
166 |
|
167 |
/**
|
168 |
* Establece los valodres por defecto
|
169 |
*/
|
170 |
public void initializeDefaults() { |
171 |
getCheckBoxCoordinates().setSelected(((Boolean) Configuration.getDefaultValue("general_ask_coordinates")).booleanValue()); |
172 |
getCheckBoxProjection().setSelected(((Boolean) Configuration.getDefaultValue("general_ask_projection")).booleanValue()); |
173 |
getCheckBoxPreview().setSelected(((Boolean)Configuration.getDefaultValue("general_auto_preview")).booleanValue()); |
174 |
Integer defaultNumberOfClasses = (Integer) Configuration.getDefaultValue("general_defaultNumberOfClasses"); |
175 |
for (int i = 0; i < getComboBoxNumClases().getItemCount(); i++) { |
176 |
if (getComboBoxNumClases().getItemAt(i).toString().equals(defaultNumberOfClasses.toString())) {
|
177 |
getComboBoxNumClases().setSelectedIndex(i); |
178 |
break;
|
179 |
} |
180 |
} |
181 |
} |
182 |
|
183 |
/**
|
184 |
* Establece los valores que han sido definidas por el usuario
|
185 |
*/
|
186 |
public void initializeValues() { |
187 |
getCheckBoxCoordinates().setSelected(Configuration.getValue("general_ask_coordinates", Boolean.valueOf(false)).booleanValue()); |
188 |
getCheckBoxProjection().setSelected(Configuration.getValue("general_ask_projection", Boolean.valueOf(true)).booleanValue()); |
189 |
getCheckBoxPreview().setSelected(Configuration.getValue("general_auto_preview", Boolean.valueOf(true)).booleanValue()); |
190 |
Integer defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)); |
191 |
for (int i = 0; i < getComboBoxNumClases().getItemCount(); i++) { |
192 |
if (getComboBoxNumClases().getItemAt(i).toString().equals(defaultNumberOfClasses.toString())) {
|
193 |
getComboBoxNumClases().setSelectedIndex(i); |
194 |
break;
|
195 |
} |
196 |
} |
197 |
} |
198 |
|
199 |
/**
|
200 |
* Guarda los valores que han sido definidas por el usuario
|
201 |
*/
|
202 |
public void storeValues() { |
203 |
Configuration.setValue("general_ask_coordinates", Boolean.valueOf(getCheckBoxCoordinates().isSelected())); |
204 |
Configuration.setValue("general_auto_preview", Boolean.valueOf(getCheckBoxPreview().isSelected())); |
205 |
int nClasses = Integer.valueOf(getComboBoxNumClases().getSelectedItem().toString()); |
206 |
Configuration.setValue("general_defaultNumberOfClasses", nClasses); |
207 |
RasterLibrary.defaultNumberOfClasses = nClasses; |
208 |
Configuration.setValue("general_ask_projection", Boolean.valueOf(getCheckBoxProjection().isSelected())); |
209 |
} |
210 |
} |