root / trunk / extensions / extRasterTools-SE / src / org / gvsig / raster / gui / preferences / panels / PreferenceGeneral.java @ 17491
History | View | Annotate | Download (6.32 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.fmap.raster.util.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 |
|
45 |
public PreferenceGeneral() {
|
46 |
initialize(); |
47 |
translate(); |
48 |
} |
49 |
|
50 |
private void translate() { |
51 |
getPanel().setBorder(BorderFactory.createTitledBorder(getText(this, "general"))); |
52 |
getCheckBoxPreview().setText(getText(this, "previsualizar_automaticamente_raster")); |
53 |
getCheckBoxPreview().setToolTipText(getCheckBoxPreview().getText()); |
54 |
getLabelNumClases().setText(getText(this, "num_clases") + ":"); |
55 |
getCheckBoxCoordinates().setText(getText(this, "pedir_coordenadas_georreferenciacion")); |
56 |
} |
57 |
|
58 |
private void initialize() { |
59 |
GridBagConstraints gridBagConstraints;
|
60 |
|
61 |
getPanel().setLayout(new GridBagLayout()); |
62 |
|
63 |
gridBagConstraints = new GridBagConstraints(); |
64 |
gridBagConstraints.gridx = 0;
|
65 |
gridBagConstraints.gridy = 0;
|
66 |
gridBagConstraints.gridwidth = 2;
|
67 |
gridBagConstraints.fill = GridBagConstraints.BOTH;
|
68 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
69 |
gridBagConstraints.weighty = 1.0;
|
70 |
gridBagConstraints.insets = new Insets(5, 5, 2, 5); |
71 |
getPanel().add(getCheckBoxPreview(), gridBagConstraints); |
72 |
|
73 |
gridBagConstraints = new GridBagConstraints(); |
74 |
gridBagConstraints.gridx = 0;
|
75 |
gridBagConstraints.gridy = 1;
|
76 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
77 |
gridBagConstraints.insets = new Insets(2, 5, 2, 2); |
78 |
getPanel().add(getLabelNumClases(), gridBagConstraints); |
79 |
|
80 |
gridBagConstraints = new GridBagConstraints(); |
81 |
gridBagConstraints.gridx = 1;
|
82 |
gridBagConstraints.gridy = 1;
|
83 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
84 |
gridBagConstraints.weightx = 1.0;
|
85 |
gridBagConstraints.insets = new Insets(2, 2, 2, 5); |
86 |
getPanel().add(getComboBoxNumClases(), gridBagConstraints); |
87 |
|
88 |
gridBagConstraints = new GridBagConstraints(); |
89 |
gridBagConstraints.gridx = 0;
|
90 |
gridBagConstraints.gridy = 2;
|
91 |
gridBagConstraints.gridwidth = 2;
|
92 |
gridBagConstraints.fill = GridBagConstraints.BOTH;
|
93 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
94 |
gridBagConstraints.weighty = 1.0;
|
95 |
gridBagConstraints.insets = new Insets(2, 5, 5, 5); |
96 |
getPanel().add(getCheckBoxCoordinates(), gridBagConstraints); |
97 |
} |
98 |
|
99 |
private JCheckBox getCheckBoxPreview() { |
100 |
if (checkBoxPreview == null) { |
101 |
checkBoxPreview = new JCheckBox(); |
102 |
checkBoxPreview.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
103 |
checkBoxPreview.setMargin(new Insets(0, 0, 0, 0)); |
104 |
} |
105 |
return checkBoxPreview;
|
106 |
} |
107 |
|
108 |
private JLabel getLabelNumClases() { |
109 |
if (labelNumClases == null) { |
110 |
labelNumClases = new JLabel(); |
111 |
} |
112 |
return labelNumClases;
|
113 |
} |
114 |
|
115 |
private JComboBox getComboBoxNumClases() { |
116 |
if (comboBoxNumClases == null) { |
117 |
comboBoxNumClases = new JComboBox(); |
118 |
comboBoxNumClases.setModel(new DefaultComboBoxModel(new String[] { "32", "64", "128", "256" })); |
119 |
} |
120 |
return comboBoxNumClases;
|
121 |
} |
122 |
|
123 |
private JCheckBox getCheckBoxCoordinates() { |
124 |
if (checkBoxCoordinates == null) { |
125 |
checkBoxCoordinates = new JCheckBox(); |
126 |
checkBoxCoordinates.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
127 |
checkBoxCoordinates.setMargin(new Insets(0, 0, 0, 0)); |
128 |
} |
129 |
return checkBoxCoordinates;
|
130 |
} |
131 |
|
132 |
public void initializeDefaults() { |
133 |
getCheckBoxCoordinates().setSelected(((Boolean) Configuration.getDefaultValue("general_ask_coordinates")).booleanValue()); |
134 |
getCheckBoxPreview().setSelected(((Boolean)Configuration.getDefaultValue("general_auto_preview")).booleanValue()); |
135 |
Integer defaultNumberOfClasses = (Integer) Configuration.getDefaultValue("general_defaultNumberOfClasses"); |
136 |
for (int i = 0; i < getComboBoxNumClases().getItemCount(); i++) { |
137 |
if (getComboBoxNumClases().getItemAt(i).toString().equals(defaultNumberOfClasses.toString())) {
|
138 |
getComboBoxNumClases().setSelectedIndex(i); |
139 |
break;
|
140 |
} |
141 |
} |
142 |
} |
143 |
|
144 |
public void initializeValues() { |
145 |
getCheckBoxCoordinates().setSelected(Configuration.getValue("general_ask_coordinates", Boolean.valueOf(false)).booleanValue()); |
146 |
getCheckBoxPreview().setSelected(Configuration.getValue("general_auto_preview", Boolean.valueOf(true)).booleanValue()); |
147 |
Integer defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)); |
148 |
for (int i = 0; i < getComboBoxNumClases().getItemCount(); i++) { |
149 |
if (getComboBoxNumClases().getItemAt(i).toString().equals(defaultNumberOfClasses.toString())) {
|
150 |
getComboBoxNumClases().setSelectedIndex(i); |
151 |
break;
|
152 |
} |
153 |
} |
154 |
} |
155 |
|
156 |
public void storeValues() { |
157 |
Configuration.setValue("general_ask_coordinates", Boolean.valueOf(getCheckBoxCoordinates().isSelected())); |
158 |
Configuration.setValue("general_auto_preview", Boolean.valueOf(getCheckBoxPreview().isSelected())); |
159 |
Configuration.setValue("general_defaultNumberOfClasses", Integer.valueOf(getComboBoxNumClases().getSelectedItem().toString())); |
160 |
} |
161 |
} |