root / trunk / extensions / extRasterTools-SE / src / org / gvsig / raster / gui / preferences / panels / PreferenceOverviews.java @ 17491
History | View | Annotate | Download (8.31 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.addo.Jaddo; |
32 |
import org.gvsig.fmap.raster.util.Configuration; |
33 |
import org.gvsig.raster.util.PanelBase; |
34 |
|
35 |
public class PreferenceOverviews extends PanelBase { |
36 |
private JCheckBox jCheckBoxAsk = null; |
37 |
private JComboBox comboBoxRate = null; |
38 |
private JComboBox comboBoxNumber = null; |
39 |
private JComboBox comboBoxAlgorithm = null; |
40 |
private JLabel labelNumber = null; |
41 |
private JLabel labelRate = null; |
42 |
private JLabel labelAlgorithm = null; |
43 |
|
44 |
public PreferenceOverviews() {
|
45 |
initialize(); |
46 |
translate(); |
47 |
} |
48 |
|
49 |
private void translate() { |
50 |
getPanel().setBorder(BorderFactory.createTitledBorder(getText(this, "overviews"))); |
51 |
getLabelNumber().setText(getText(this, "num_overviews") + ":"); |
52 |
getLabelRate().setText(getText(this, "proporcion_overviews") + ":"); |
53 |
getLabelAlgorithm().setText(getText(this, "algorithm") + ":"); |
54 |
getCheckBoxAsk().setText(getText(this, "generacion_overviews")); |
55 |
getCheckBoxAsk().setToolTipText(getCheckBoxAsk().getText()); |
56 |
getComboAlgorithm().setModel(new DefaultComboBoxModel(new String[] { getText(this, "vecino_cercano"), getText(this, "media"), getText(this, "media_phase") })); |
57 |
} |
58 |
|
59 |
private void initialize() { |
60 |
GridBagConstraints gridBagConstraints;
|
61 |
|
62 |
getPanel().setLayout(new GridBagLayout()); |
63 |
|
64 |
gridBagConstraints = new GridBagConstraints(); |
65 |
gridBagConstraints.gridwidth = 2;
|
66 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
67 |
gridBagConstraints.weightx = 1.0;
|
68 |
gridBagConstraints.insets = new Insets(5, 5, 2, 5); |
69 |
getPanel().add(getCheckBoxAsk(), gridBagConstraints); |
70 |
|
71 |
gridBagConstraints = new GridBagConstraints(); |
72 |
gridBagConstraints.gridx = 0;
|
73 |
gridBagConstraints.gridy = 1;
|
74 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
75 |
gridBagConstraints.insets = new Insets(2, 5, 2, 2); |
76 |
getPanel().add(getLabelNumber(), gridBagConstraints); |
77 |
|
78 |
gridBagConstraints = new GridBagConstraints(); |
79 |
gridBagConstraints.gridx = 1;
|
80 |
gridBagConstraints.gridy = 1;
|
81 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
82 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
83 |
gridBagConstraints.weightx = 1.0;
|
84 |
gridBagConstraints.insets = new Insets(2, 2, 2, 5); |
85 |
getPanel().add(getComboNumber(), gridBagConstraints); |
86 |
|
87 |
gridBagConstraints = new GridBagConstraints(); |
88 |
gridBagConstraints.gridx = 0;
|
89 |
gridBagConstraints.gridy = 2;
|
90 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
91 |
gridBagConstraints.insets = new Insets(2, 5, 2, 2); |
92 |
getPanel().add(getLabelRate(), gridBagConstraints); |
93 |
|
94 |
gridBagConstraints = new GridBagConstraints(); |
95 |
gridBagConstraints.gridx = 1;
|
96 |
gridBagConstraints.gridy = 2;
|
97 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
98 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
99 |
gridBagConstraints.insets = new Insets(2, 2, 2, 5); |
100 |
getPanel().add(getComboRate(), gridBagConstraints); |
101 |
|
102 |
gridBagConstraints = new GridBagConstraints(); |
103 |
gridBagConstraints.gridx = 0;
|
104 |
gridBagConstraints.gridy = 3;
|
105 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
106 |
gridBagConstraints.insets = new Insets(2, 5, 5, 2); |
107 |
getPanel().add(getLabelAlgorithm(), gridBagConstraints); |
108 |
|
109 |
gridBagConstraints = new GridBagConstraints(); |
110 |
gridBagConstraints.gridx = 1;
|
111 |
gridBagConstraints.gridy = 3;
|
112 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
113 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
114 |
gridBagConstraints.insets = new Insets(2, 2, 5, 5); |
115 |
getPanel().add(getComboAlgorithm(), gridBagConstraints); |
116 |
} |
117 |
|
118 |
private JLabel getLabelAlgorithm() { |
119 |
if (labelAlgorithm == null) |
120 |
labelAlgorithm = new JLabel(); |
121 |
return labelAlgorithm;
|
122 |
} |
123 |
|
124 |
private JLabel getLabelRate() { |
125 |
if (labelRate == null) |
126 |
labelRate = new JLabel(); |
127 |
return labelRate;
|
128 |
} |
129 |
|
130 |
private JLabel getLabelNumber() { |
131 |
if (labelNumber == null) |
132 |
labelNumber = new JLabel(); |
133 |
return labelNumber;
|
134 |
} |
135 |
|
136 |
private JCheckBox getCheckBoxAsk() { |
137 |
if (jCheckBoxAsk == null) { |
138 |
jCheckBoxAsk = new JCheckBox(); |
139 |
jCheckBoxAsk.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
140 |
jCheckBoxAsk.setMargin(new Insets(0, 0, 0, 0)); |
141 |
} |
142 |
return jCheckBoxAsk;
|
143 |
} |
144 |
|
145 |
private JComboBox getComboRate() { |
146 |
if (comboBoxRate == null) { |
147 |
comboBoxRate = new JComboBox(); |
148 |
comboBoxRate.setModel(new DefaultComboBoxModel(new String[] { "/2", "/3" })); |
149 |
} |
150 |
return comboBoxRate;
|
151 |
} |
152 |
|
153 |
private JComboBox getComboNumber() { |
154 |
if (comboBoxNumber == null) { |
155 |
comboBoxNumber = new JComboBox(); |
156 |
comboBoxNumber.setModel(new DefaultComboBoxModel(new String[] { "2", "3", "4" })); |
157 |
} |
158 |
return comboBoxNumber;
|
159 |
} |
160 |
|
161 |
private JComboBox getComboAlgorithm() { |
162 |
if (comboBoxAlgorithm == null) |
163 |
comboBoxAlgorithm = new JComboBox(); |
164 |
return comboBoxAlgorithm;
|
165 |
} |
166 |
|
167 |
public void initializeDefaults() { |
168 |
int pos = 0; |
169 |
getCheckBoxAsk().setSelected(((Boolean) Configuration.getDefaultValue("overviews_ask_before_loading")).booleanValue()); |
170 |
|
171 |
pos = ((Integer) Configuration.getDefaultValue("overviews_number")).intValue() - 2; |
172 |
if ((pos < 0) || (pos >= getComboNumber().getItemCount())) |
173 |
pos = 2;
|
174 |
getComboNumber().setSelectedIndex(pos); |
175 |
|
176 |
pos = ((Integer) Configuration.getDefaultValue("overviews_rate")).intValue() - 2; |
177 |
if ((pos < 0) || (pos >= getComboRate().getItemCount())) |
178 |
pos = 0;
|
179 |
getComboRate().setSelectedIndex(pos); |
180 |
|
181 |
pos = ((Integer) Configuration.getDefaultValue("overviews_resampling_algorithm")).intValue(); |
182 |
int type = 1; |
183 |
switch (pos) {
|
184 |
case Jaddo.NEAREST:
|
185 |
type = 0;
|
186 |
break;
|
187 |
case Jaddo.AVERAGE_MAGPHASE:
|
188 |
type = 2;
|
189 |
break;
|
190 |
} |
191 |
getComboAlgorithm().setSelectedIndex(type); |
192 |
} |
193 |
|
194 |
public void initializeValues() { |
195 |
int pos = 0; |
196 |
getCheckBoxAsk().setSelected(Configuration.getValue("overviews_ask_before_loading", Boolean.FALSE).booleanValue()); |
197 |
|
198 |
pos = Configuration.getValue("overviews_number", Integer.valueOf(4)).intValue() - 2; |
199 |
if ((pos < 0) || (pos >= getComboNumber().getItemCount())) |
200 |
pos = 2;
|
201 |
getComboNumber().setSelectedIndex(pos); |
202 |
|
203 |
pos = Configuration.getValue("overviews_rate", Integer.valueOf(2)).intValue() - 2; |
204 |
if ((pos < 0) || (pos >= getComboRate().getItemCount())) |
205 |
pos = 0;
|
206 |
getComboRate().setSelectedIndex(pos); |
207 |
|
208 |
pos = Configuration.getValue("overviews_resampling_algorithm", Integer.valueOf(Jaddo.AVERAGE)).intValue(); |
209 |
int type = 1; |
210 |
switch (pos) {
|
211 |
case Jaddo.NEAREST:
|
212 |
type = 0;
|
213 |
break;
|
214 |
case Jaddo.AVERAGE_MAGPHASE:
|
215 |
type = 2;
|
216 |
break;
|
217 |
} |
218 |
getComboAlgorithm().setSelectedIndex(type); |
219 |
} |
220 |
|
221 |
public void storeValues() { |
222 |
Configuration.setValue("overviews_ask_before_loading", Boolean.valueOf(getCheckBoxAsk().isSelected())); |
223 |
if (getComboRate().getSelectedIndex() > -1) |
224 |
Configuration.setValue("overviews_rate", Integer.valueOf(getComboRate().getSelectedIndex() + 2)); |
225 |
if (getComboNumber().getSelectedIndex() > -1) |
226 |
Configuration.setValue("overviews_number", Integer.valueOf(getComboNumber().getSelectedIndex() + 2)); |
227 |
|
228 |
int type = Jaddo.AVERAGE;
|
229 |
switch (getComboAlgorithm().getSelectedIndex()) {
|
230 |
case 0: |
231 |
type = Jaddo.NEAREST; |
232 |
break;
|
233 |
case 2: |
234 |
type = Jaddo.AVERAGE_MAGPHASE; |
235 |
break;
|
236 |
} |
237 |
Configuration.setValue("overviews_resampling_algorithm", Integer.valueOf(type)); |
238 |
} |
239 |
} |