gvsig-raster / org.gvsig.raster.tools / branches / org.gvsig.raster.tools_proyeccion_al_vuelo / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / raster / gui / preference / panel / PreferenceGeneral.java @ 5472
History | View | Annotate | Download (5.63 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 JLabel labelNumClases = null; |
48 |
private JComboBox comboBoxNumClases = null; |
49 |
|
50 |
/**
|
51 |
*Inicializa componentes gr?ficos y traduce
|
52 |
*/
|
53 |
public PreferenceGeneral() {
|
54 |
init(); |
55 |
translate(); |
56 |
} |
57 |
|
58 |
/**
|
59 |
* Todas las traducciones de esta clase.
|
60 |
*/
|
61 |
protected void translate() { |
62 |
setBorder(BorderFactory.createTitledBorder(getText(this, "general"))); |
63 |
getCheckBoxPreview().setText(getText(this, "previsualizar_automaticamente_raster")); |
64 |
getCheckBoxPreview().setToolTipText(getCheckBoxPreview().getText()); |
65 |
getLabelNumClases().setText(getText(this, "num_clases") + ":"); |
66 |
} |
67 |
|
68 |
protected void init() { |
69 |
GridBagConstraints gridBagConstraints;
|
70 |
|
71 |
setLayout(new GridBagLayout()); |
72 |
|
73 |
gridBagConstraints = new GridBagConstraints(); |
74 |
gridBagConstraints.gridx = 0;
|
75 |
gridBagConstraints.gridy = 0;
|
76 |
gridBagConstraints.gridwidth = 2;
|
77 |
gridBagConstraints.fill = GridBagConstraints.BOTH;
|
78 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
79 |
gridBagConstraints.weighty = 1.0;
|
80 |
gridBagConstraints.insets = new Insets(5, 5, 2, 5); |
81 |
add(getCheckBoxPreview(), gridBagConstraints); |
82 |
|
83 |
gridBagConstraints = new GridBagConstraints(); |
84 |
gridBagConstraints.gridx = 0;
|
85 |
gridBagConstraints.gridy = 1;
|
86 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
87 |
gridBagConstraints.insets = new Insets(2, 5, 2, 2); |
88 |
add(getLabelNumClases(), gridBagConstraints); |
89 |
|
90 |
gridBagConstraints = new GridBagConstraints(); |
91 |
gridBagConstraints.gridx = 1;
|
92 |
gridBagConstraints.gridy = 1;
|
93 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
94 |
gridBagConstraints.weightx = 1.0;
|
95 |
gridBagConstraints.insets = new Insets(2, 2, 2, 5); |
96 |
add(getComboBoxNumClases(), gridBagConstraints); |
97 |
} |
98 |
|
99 |
private JCheckBox getCheckBoxPreview() { |
100 |
if (checkBoxPreview == null) { |
101 |
checkBoxPreview = new JCheckBox(); |
102 |
checkBoxPreview.setMargin(new Insets(0, 0, 0, 0)); |
103 |
} |
104 |
return checkBoxPreview;
|
105 |
} |
106 |
|
107 |
private JLabel getLabelNumClases() { |
108 |
if (labelNumClases == null) { |
109 |
labelNumClases = new JLabel(); |
110 |
} |
111 |
return labelNumClases;
|
112 |
} |
113 |
|
114 |
private JComboBox getComboBoxNumClases() { |
115 |
if (comboBoxNumClases == null) { |
116 |
comboBoxNumClases = new JComboBox(); |
117 |
comboBoxNumClases.setModel(new DefaultComboBoxModel(new String[] { "32", "64", "128", "256" })); |
118 |
} |
119 |
return comboBoxNumClases;
|
120 |
} |
121 |
|
122 |
/**
|
123 |
* Establece los valodres por defecto
|
124 |
*/
|
125 |
public void initializeDefaults() { |
126 |
getCheckBoxPreview().setSelected(((Boolean)Configuration.getDefaultValue("general_auto_preview")).booleanValue()); |
127 |
Integer defaultNumberOfClasses = (Integer) Configuration.getDefaultValue("general_defaultNumberOfClasses"); |
128 |
for (int i = 0; i < getComboBoxNumClases().getItemCount(); i++) { |
129 |
if (getComboBoxNumClases().getItemAt(i).toString().equals(defaultNumberOfClasses.toString())) {
|
130 |
getComboBoxNumClases().setSelectedIndex(i); |
131 |
break;
|
132 |
} |
133 |
} |
134 |
} |
135 |
|
136 |
/**
|
137 |
* Establece los valores que han sido definidas por el usuario
|
138 |
*/
|
139 |
public void initializeValues() { |
140 |
getCheckBoxPreview().setSelected(Configuration.getValue("general_auto_preview", Boolean.valueOf(true)).booleanValue()); |
141 |
Integer defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)); |
142 |
for (int i = 0; i < getComboBoxNumClases().getItemCount(); i++) { |
143 |
if (getComboBoxNumClases().getItemAt(i).toString().equals(defaultNumberOfClasses.toString())) {
|
144 |
getComboBoxNumClases().setSelectedIndex(i); |
145 |
break;
|
146 |
} |
147 |
} |
148 |
} |
149 |
|
150 |
/**
|
151 |
* Guarda los valores que han sido definidas por el usuario
|
152 |
*/
|
153 |
public void storeValues() { |
154 |
Configuration.setValue("general_auto_preview", Boolean.valueOf(getCheckBoxPreview().isSelected())); |
155 |
int nClasses = Integer.valueOf(getComboBoxNumClases().getSelectedItem().toString()); |
156 |
Configuration.setValue("general_defaultNumberOfClasses", nClasses); |
157 |
RasterLibrary.defaultNumberOfClasses = nClasses; |
158 |
} |
159 |
} |