Revision 17511 trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/gui/preferences/panels/PreferenceLoadLayer.java

View differences:

PreferenceLoadLayer.java
41 41
import org.gvsig.raster.gui.preferences.combocolortable.PaintItem;
42 42
import org.gvsig.raster.gui.preferences.combocolortable.PreferenceColorTableIconPainter;
43 43
import org.gvsig.raster.util.PanelBase;
44

  
44
/**
45
 *
46
 * @version 14/12/2007
47
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
48
 */
45 49
public class PreferenceLoadLayer extends PanelBase implements ActionListener {
46
	JComboBox      comboBoxColorTable    = null;
47
	JRadioButton   radioButtonRealce     = null;
48
	JRadioButton   radioButtonColorTable = null;
50
	private JComboBox    comboBoxColorTable    = null;
51
	private JRadioButton radioButtonRealce     = null;
52
	private JRadioButton radioButtonColorTable = null;
53
	private JLabel       labelLoadLayer        = null;
54
	private ButtonGroup  buttonGroup           = new ButtonGroup();
49 55

  
50 56
	private String palettesPath = System.getProperty("user.home") +
51 57
		File.separator +
......
58 64
	}
59 65

  
60 66
	private void translate() {
67
		getPanel().setBorder(BorderFactory.createTitledBorder(getText(this, "carga_capas")));
68
		getLabelLoadLayer().setText(getText(this, "loadlayer_aplicar") + ":");
69
		getRadioButtonRealce().setText(getText(this, "realce"));
70
		getRadioButtonColorTable().setText(getText(this, "tabla_color"));
71
	}
61 72

  
62
	}
63 73
	private void initialize() {
64 74
		GridBagConstraints gridBagConstraints;
65
		ButtonGroup buttonGroup;
66
		JLabel jLabel9;
67
		buttonGroup = new ButtonGroup();
68
		jLabel9 = new JLabel();
69
		radioButtonRealce = new JRadioButton();
70
		radioButtonColorTable = new JRadioButton();
71 75

  
72 76
		getPanel().setLayout(new GridBagLayout());
73 77

  
74
		getPanel().setBorder(BorderFactory.createTitledBorder("Carga de capas"));
75
		jLabel9.setText("Al cargar una imagen no RGB, aplicarle:");
76
		jLabel9.setToolTipText("Al cargar una imagen No RGB");
77 78
		gridBagConstraints = new GridBagConstraints();
78 79
		gridBagConstraints.gridx = 0;
79 80
		gridBagConstraints.gridy = 0;
......
81 82
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
82 83
		gridBagConstraints.anchor = GridBagConstraints.WEST;
83 84
		gridBagConstraints.insets = new Insets(5, 5, 2, 5);
84
		getPanel().add(jLabel9, gridBagConstraints);
85
		getPanel().add(getLabelLoadLayer(), gridBagConstraints);
85 86

  
86
		buttonGroup.add(radioButtonRealce);
87
		radioButtonRealce.addActionListener(this);
88
		radioButtonRealce.setSelected(true);
89
		radioButtonRealce.setActionCommand("realce");
90
		radioButtonRealce.setText("Realce");
91
		radioButtonRealce.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
92
		radioButtonRealce.setMargin(new Insets(0, 0, 0, 0));
93 87
		gridBagConstraints = new GridBagConstraints();
94 88
		gridBagConstraints.gridx = 0;
95 89
		gridBagConstraints.gridy = 1;
96 90
		gridBagConstraints.gridwidth = 2;
97 91
		gridBagConstraints.anchor = GridBagConstraints.WEST;
98 92
		gridBagConstraints.insets = new Insets(2, 5, 2, 5);
99
		getPanel().add(radioButtonRealce, gridBagConstraints);
93
		getPanel().add(getRadioButtonRealce(), gridBagConstraints);
100 94

  
101
		buttonGroup.add(radioButtonColorTable);
102
		radioButtonColorTable.addActionListener(this);
103
		radioButtonColorTable.setText("Tabla de color");
104
		radioButtonRealce.setActionCommand("colortable");
105
		radioButtonColorTable.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
106
		radioButtonColorTable.setMargin(new Insets(0, 0, 0, 0));
107 95
		gridBagConstraints = new GridBagConstraints();
108 96
		gridBagConstraints.gridx = 0;
109 97
		gridBagConstraints.gridy = 2;
110 98
		gridBagConstraints.anchor = GridBagConstraints.WEST;
111 99
		gridBagConstraints.insets = new Insets(2, 5, 5, 2);
112
		getPanel().add(radioButtonColorTable, gridBagConstraints);
100
		getPanel().add(getRadioButtonColorTable(), gridBagConstraints);
113 101

  
114 102
		gridBagConstraints = new GridBagConstraints();
115 103
		gridBagConstraints.gridx = 1;
......
120 108
		getPanel().add(getComboBoxColorTable(), gridBagConstraints);
121 109
	}
122 110

  
111
	public JRadioButton getRadioButtonRealce() {
112
		if (radioButtonRealce == null) {
113
			radioButtonRealce = new JRadioButton();
114
			buttonGroup.add(radioButtonRealce);
115
			radioButtonRealce.addActionListener(this);
116
			radioButtonRealce.setSelected(true);
117
			radioButtonRealce.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
118
			radioButtonRealce.setMargin(new Insets(0, 0, 0, 0));
119
		}
120
		return radioButtonRealce;
121
	}
122

  
123
	public JRadioButton getRadioButtonColorTable() {
124
		if (radioButtonColorTable == null) {
125
			radioButtonColorTable = new JRadioButton();
126
			buttonGroup.add(radioButtonColorTable);
127
			radioButtonColorTable.addActionListener(this);
128
			radioButtonColorTable.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
129
			radioButtonColorTable.setMargin(new Insets(0, 0, 0, 0));
130
		}
131
		return radioButtonColorTable;
132
	}
133

  
134
	public JLabel getLabelLoadLayer() {
135
		if (labelLoadLayer == null) {
136
			labelLoadLayer = new JLabel();
137
		}
138
		return labelLoadLayer;
139
	}
140

  
123 141
	public JComboBox getComboBoxColorTable() {
124 142
		if (comboBoxColorTable == null) {
125 143
			comboBoxColorTable = new JComboBox();
......
162 180
	}
163 181

  
164 182
	public void initializeDefaults() {
165
		radioButtonRealce.setSelected(true);
183
		getRadioButtonRealce().setSelected(true);
166 184
		setColorTableEnabled(false);
185
		selectComboName("Default");
167 186
	}
168 187

  
169
	public void initializeValues() {
170
		String colorTable = Configuration.getValue("loadlayer_usecolortable", (String) null);
171
		boolean finded = false;
172
		if (colorTable != null) {
173
			radioButtonColorTable.setSelected(true);
174
			setColorTableEnabled(true);
175

  
188
	private boolean selectComboName(String name) {
189
		if (name != null) {
176 190
			for (int i=0; i<getComboBoxColorTable().getItemCount(); i++) {
177
				if (((String) ((ArrayList) getComboBoxColorTable().getItemAt(i)).get(0)).equals(colorTable)) {
191
				if (((String) ((ArrayList) getComboBoxColorTable().getItemAt(i)).get(0)).equals(name)) {
178 192
					getComboBoxColorTable().setSelectedIndex(i);
179
					finded = true;
180
					break;
193
					return true;
181 194
				}
182 195
			}
183 196
		}
197
		return false;
198
	}
184 199

  
200
	public void initializeValues() {
201
		String colorTable = Configuration.getValue("loadlayer_usecolortable", (String) null);
202

  
203
		boolean finded = selectComboName(colorTable);
204

  
185 205
		if (finded == false) {
186
			radioButtonRealce.setSelected(true);
206
			getRadioButtonRealce().setSelected(true);
187 207
			setColorTableEnabled(false);
188 208
			Configuration.setValue("loadlayer_usecolortable", (String) null);
209
			selectComboName("Default");
210
		} else {
211
			getRadioButtonColorTable().setSelected(true);
212
			setColorTableEnabled(true);
189 213
		}
190 214
	}
191 215

  
192 216
	public void storeValues() {
193
		if (radioButtonColorTable.isSelected())
217
		if (getRadioButtonColorTable().isSelected())
194 218
			Configuration.setValue("loadlayer_usecolortable", (String) ((ArrayList) getComboBoxColorTable().getSelectedItem()).get(0));
195 219
		else
196 220
			Configuration.setValue("loadlayer_usecolortable", null);
197 221
	}
198 222

  
199 223
	public void actionPerformed(ActionEvent e) {
200
		if (radioButtonColorTable.isSelected()) {
224
		if (getRadioButtonColorTable().isSelected()) {
201 225
			setColorTableEnabled(true);
202 226
		} else {
203 227
			setColorTableEnabled(false);

Also available in: Unified diff