Revision 17491

View differences:

trunk/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/util/Configuration.java
19 19
package org.gvsig.fmap.raster.util;
20 20

  
21 21
import java.util.ArrayList;
22
import java.util.EventObject;
22
import java.util.HashMap;
23 23
import java.util.Iterator;
24 24

  
25
import org.gvsig.raster.util.ConfigurationListener;
26 25

  
27 26
import com.iver.andami.PluginServices;
28 27
import com.iver.utiles.XMLEntity;
......
55 54
	static private Configuration singleton              = new Configuration();
56 55
	private ArrayList            actionCommandListeners = new ArrayList();
57 56
	private XMLEntity            xml                    = null;
57
	private HashMap              hashMap                = new HashMap();
58 58

  
59 59
	/**
60 60
	 * Constructor privado. Nos aseguramos de que nadie pueda crear una instancia
......
72 72
	 * @return
73 73
	 */
74 74
	static public Boolean getValue(String key, Boolean defaultValue) {
75
		if (singleton.hashMap.get(key) == null)
76
			singleton.hashMap.put(key, defaultValue);
75 77
		try {
76 78
			return Boolean.valueOf(getXMLEntity().getStringProperty(key));
77 79
		} catch (Exception e) {
......
87 89
	 * @return
88 90
	 */
89 91
	static public Double getValue(String key, Double defaultValue) {
92
		if (singleton.hashMap.get(key) == null)
93
			singleton.hashMap.put(key, defaultValue);
90 94
		try {
91 95
			return Double.valueOf(getXMLEntity().getStringProperty(key));
92 96
		} catch (Exception e) {
......
102 106
	 * @return
103 107
	 */
104 108
	static public Float getValue(String key, Float defaultValue) {
109
		if (singleton.hashMap.get(key) == null)
110
			singleton.hashMap.put(key, defaultValue);
105 111
		try {
106 112
			return Float.valueOf(getXMLEntity().getStringProperty(key));
107 113
		} catch (Exception e) {
......
117 123
	 * @return
118 124
	 */
119 125
	static public Integer getValue(String key, Integer defaultValue) {
126
		if (singleton.hashMap.get(key) == null)
127
			singleton.hashMap.put(key, defaultValue);
120 128
		try {
121 129
			return Integer.valueOf(getXMLEntity().getStringProperty(key));
122 130
		} catch (Exception e) {
......
132 140
	 * @return
133 141
	 */
134 142
	static public Long getValue(String key, Long defaultValue) {
143
		if (singleton.hashMap.get(key) == null)
144
			singleton.hashMap.put(key, defaultValue);
135 145
		try {
136 146
			return Long.valueOf(getXMLEntity().getStringProperty(key));
137 147
		} catch (Exception e) {
......
147 157
	 * @return
148 158
	 */
149 159
	static public String getValue(String key, String defaultValue) {
160
		if (singleton.hashMap.get(key) == null)
161
			singleton.hashMap.put(key, defaultValue);
150 162
		try {
151 163
			return getXMLEntity().getStringProperty(key);
152 164
		} catch (Exception e) {
......
156 168
	}
157 169

  
158 170
	/**
171
	 * Devuelve el valor por defecto de un key
172
	 * @param key
173
	 * @return
174
	 */
175
	static public Object getDefaultValue(String key) {
176
		return singleton.hashMap.get(key);
177
	}
178

  
179
	/**
159 180
	 * Guarda en la configuracion el Objeto pasado por parametro asociado a dicho
160 181
	 * key
161 182
	 * @param key
......
197 218
	static public void setValue(String key, Object value) {
198 219
		if (value == null) {
199 220
			getXMLEntity().remove(key);
200
			singleton.callConfigurationChanged();
221
			singleton.callConfigurationChanged(key, value);
201 222
			return;
202 223
		}
203 224

  
......
205 226

  
206 227
		singleton.putProperty(key, value);
207 228

  
208
		if (!oldValue.equals(value))
209
			singleton.callConfigurationChanged();
229
		if (!oldValue.equals(value.toString()))
230
			singleton.callConfigurationChanged(key, value);
210 231
	}
211 232

  
212 233
	/**
......
229 250
	/**
230 251
	 * Invocar a los eventos asociados al componente
231 252
	 */
232
	private void callConfigurationChanged() {
253
	private void callConfigurationChanged(String key, Object value) {
233 254
		Iterator iterator = actionCommandListeners.iterator();
234 255
		while (iterator.hasNext()) {
235 256
			ConfigurationListener listener = (ConfigurationListener) iterator.next();
236
			listener.actionConfigurationChanged(new EventObject(this));
257
			listener.actionConfigurationChanged(new ConfigurationEvent(this, key, value));
237 258
		}
238 259
	}
239 260

  
trunk/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/util/ConfigurationEvent.java
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.fmap.raster.util;
20

  
21
import java.util.EventObject;
22

  
23
public class ConfigurationEvent extends EventObject {
24
	private String key;
25
	private Object value;
26

  
27
	public ConfigurationEvent(Object source, String key, Object value) {
28
		super(source);
29
		this.key = key;
30
		this.value = value;
31
	}
32

  
33
	/**
34
	 * @return the key
35
	 */
36
	public String getKey() {
37
		return key;
38
	}
39

  
40
	/**
41
	 * @return the value
42
	 */
43
	public Object getValue() {
44
		return value;
45
	}
46
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/util/ConfigurationListener.java
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.fmap.raster.util;
20

  
21
import java.util.EventListener;
22
import java.util.EventObject;
23

  
24
public interface ConfigurationListener extends EventListener {
25
	/**
26
	 * Evento que se dispara cuando cambia un valor de configuracion.
27
	 * @param e
28
	 */
29
	public void actionConfigurationChanged(ConfigurationEvent e);
30
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/gui/preferences/RasterPreferences.java
21 21
import java.awt.BorderLayout;
22 22
import java.awt.GridBagConstraints;
23 23
import java.awt.GridBagLayout;
24
import java.awt.Insets;
25 24

  
26
import javax.swing.BorderFactory;
27
import javax.swing.ButtonGroup;
28
import javax.swing.DefaultComboBoxModel;
29 25
import javax.swing.ImageIcon;
30
import javax.swing.JButton;
31
import javax.swing.JCheckBox;
32
import javax.swing.JComboBox;
33
import javax.swing.JLabel;
34 26
import javax.swing.JPanel;
35
import javax.swing.JRadioButton;
36 27
import javax.swing.JScrollPane;
37
import javax.swing.JTextField;
28
import javax.swing.border.EmptyBorder;
38 29

  
39 30
import org.gvsig.raster.gui.preferences.panels.PreferenceCache;
31
import org.gvsig.raster.gui.preferences.panels.PreferenceGeneral;
32
import org.gvsig.raster.gui.preferences.panels.PreferenceLoadLayer;
40 33
import org.gvsig.raster.gui.preferences.panels.PreferenceNoData;
41 34
import org.gvsig.raster.gui.preferences.panels.PreferenceOverviews;
35
import org.gvsig.raster.gui.preferences.panels.PreferenceTemporal;
42 36

  
43 37
import com.iver.andami.PluginServices;
44 38
import com.iver.andami.preferences.AbstractPreferencePage;
......
57 51
	private PreferenceNoData    noData           = null;
58 52
	private PreferenceOverviews overviews        = null;
59 53
	private PreferenceCache     cache            = null;
54
	private PreferenceTemporal  temporal         = null;
55
	private PreferenceGeneral   general          = null;
56
	private PreferenceLoadLayer loadLayer        = null;
60 57

  
61 58
	public RasterPreferences() {
62 59
		super();
......
65 62
	}
66 63

  
67 64
	private void initialize() {
68
		ButtonGroup buttonGroup1;
69
		JScrollPane jScrollPane1;
65
		setTitle("Frame");
66

  
70 67
		GridBagConstraints gridBagConstraints;
71
		JButton jButton1;
72
		JCheckBox jCheckBox4;
73
		JCheckBox jCheckBox5;
74
		JCheckBox jCheckBox6;
75
		JComboBox jComboBox2;
76
		JComboBox jComboBox3;
77
		JLabel jLabel6;
78
		JLabel jLabel8;
79
		JLabel jLabel9;
80
		JPanel jPanel2;
81
		JPanel jPanel4;
82
		JPanel jPanel5;
83
		JPanel jPanel6;
84
		JPanel jPanel7;
85
		JRadioButton jRadioButton1;
86
		JRadioButton jRadioButton2;
87
		JTextField jTextField4;
88 68

  
89
		buttonGroup1 = new ButtonGroup();
90
		jScrollPane1 = new javax.swing.JScrollPane();
69
		JScrollPane scrollPane = new JScrollPane();
91 70

  
92
		jScrollPane1.getVerticalScrollBar().setUnitIncrement(20);
71
		scrollPane.getVerticalScrollBar().setUnitIncrement(20);
93 72

  
94
		jPanel5 = new JPanel();
95
		jPanel6 = new JPanel();
96
		jPanel2 = new JPanel();
97
		jLabel6 = new JLabel();
98
		jTextField4 = new JTextField();
99
		jButton1 = new JButton();
100
		jPanel4 = new JPanel();
101
		jCheckBox4 = new JCheckBox();
102
		jCheckBox5 = new JCheckBox();
103
		jLabel8 = new JLabel();
104
		jComboBox2 = new JComboBox();
105
		jCheckBox6 = new JCheckBox();
106
		jPanel7 = new JPanel();
107
		jLabel9 = new JLabel();
108
		jRadioButton1 = new JRadioButton();
109
		jRadioButton2 = new JRadioButton();
110
		jComboBox3 = new JComboBox();
73
		JPanel panel = new JPanel();
111 74

  
112
		setTitle("Frame");
113
		jPanel5.setLayout(new GridBagLayout());
75
		panel.setLayout(new GridBagLayout());
114 76

  
115 77
		gridBagConstraints = new GridBagConstraints();
116 78
		gridBagConstraints.gridx = 0;
117
		gridBagConstraints.gridy = 6;
118
		gridBagConstraints.weightx = 1.0;
119
		gridBagConstraints.weighty = 1.0;
120
		jPanel5.add(jPanel6, gridBagConstraints);
121

  
122
		gridBagConstraints = new GridBagConstraints();
123
		gridBagConstraints.gridx = 0;
124
		gridBagConstraints.gridy = 5;
79
		gridBagConstraints.gridy = 0;
125 80
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
126
		jPanel5.add(getPreferenceCache().getPanel(), gridBagConstraints);
81
		panel.add(getPreferenceGeneral().getPanel(), gridBagConstraints);
127 82

  
128
		jPanel2.setLayout(new GridBagLayout());
129

  
130
		jPanel2.setBorder(BorderFactory.createTitledBorder("Rutas"));
131
		jLabel6.setText("Temporales:");
132 83
		gridBagConstraints = new GridBagConstraints();
133
		gridBagConstraints.insets = new Insets(5, 5, 5, 2);
134
		jPanel2.add(jLabel6, gridBagConstraints);
135

  
136
		gridBagConstraints = new GridBagConstraints();
137
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
138
		gridBagConstraints.weightx = 1.0;
139
		gridBagConstraints.insets = new Insets(5, 2, 5, 2);
140
		jPanel2.add(jTextField4, gridBagConstraints);
141

  
142
		jButton1.setText("Abrir");
143
		gridBagConstraints = new GridBagConstraints();
144
		gridBagConstraints.insets = new Insets(5, 2, 5, 5);
145
		jPanel2.add(jButton1, gridBagConstraints);
146

  
147
		gridBagConstraints = new GridBagConstraints();
148 84
		gridBagConstraints.gridx = 0;
149
		gridBagConstraints.gridy = 3;
85
		gridBagConstraints.gridy = 1;
150 86
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
151
		jPanel5.add(jPanel2, gridBagConstraints);
87
		panel.add(getPreferenceLoadLayer().getPanel(), gridBagConstraints);
152 88

  
153 89
		gridBagConstraints = new GridBagConstraints();
154 90
		gridBagConstraints.gridx = 0;
155 91
		gridBagConstraints.gridy = 2;
156 92
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
157
		jPanel5.add(getPreferenceNoData().getPanel(), gridBagConstraints);
93
		panel.add(getPreferenceNoData().getPanel(), gridBagConstraints);
158 94

  
159
		jPanel4.setLayout(new GridBagLayout());
160

  
161
		jPanel4.setBorder(BorderFactory.createTitledBorder("General"));
162

  
163
		jCheckBox4.setText("Generar estad\u00edsticas al cargar el raster");
164
		jCheckBox4.setToolTipText("Generar estad\u00edsticas al cargar el raster");
165
		jCheckBox4.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
166
		jCheckBox4.setMargin(new Insets(0, 0, 0, 0));
167 95
		gridBagConstraints = new GridBagConstraints();
168 96
		gridBagConstraints.gridx = 0;
169
		gridBagConstraints.gridy = 0;
170
		gridBagConstraints.gridwidth = 2;
171
		gridBagConstraints.fill = GridBagConstraints.BOTH;
172
		gridBagConstraints.anchor = GridBagConstraints.WEST;
173
		gridBagConstraints.weighty = 1.0;
174
		gridBagConstraints.insets = new Insets(2, 5, 2, 5);
175
		jPanel4.add(jCheckBox4, gridBagConstraints);
176

  
177
		jCheckBox5.setText("Previsualizar autom\u00e1ticamente al cambiar las propiedades de raster");
178
		jCheckBox5.setToolTipText("Previsualizar autom\u00e1ticamente al cambiar las propiedades de raster");
179
		jCheckBox5.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
180
		jCheckBox5.setMargin(new Insets(0, 0, 0, 0));
181
		gridBagConstraints = new GridBagConstraints();
182
		gridBagConstraints.gridx = 0;
183
		gridBagConstraints.gridy = 1;
184
		gridBagConstraints.gridwidth = 2;
185
		gridBagConstraints.fill = GridBagConstraints.BOTH;
186
		gridBagConstraints.anchor = GridBagConstraints.WEST;
187
		gridBagConstraints.weighty = 1.0;
188
		gridBagConstraints.insets = new Insets(2, 5, 2, 5);
189
		jPanel4.add(jCheckBox5, gridBagConstraints);
190

  
191
		jLabel8.setText("N\u00ba de clases:");
192
		gridBagConstraints = new GridBagConstraints();
193
		gridBagConstraints.gridx = 0;
194
		gridBagConstraints.gridy = 2;
195
		gridBagConstraints.anchor = GridBagConstraints.EAST;
196
		gridBagConstraints.insets = new Insets(2, 5, 2, 2);
197
		jPanel4.add(jLabel8, gridBagConstraints);
198

  
199
		jComboBox2.setModel(new DefaultComboBoxModel(new String[] { "32", "64", "128", "256" }));
200
		gridBagConstraints = new GridBagConstraints();
201
		gridBagConstraints.gridx = 1;
202
		gridBagConstraints.gridy = 2;
203
		gridBagConstraints.anchor = GridBagConstraints.WEST;
204
		gridBagConstraints.weightx = 1.0;
205
		gridBagConstraints.insets = new Insets(2, 2, 2, 5);
206
		jPanel4.add(jComboBox2, gridBagConstraints);
207

  
208
		jCheckBox6.setText("Pedir las coordenadas de georreferenciaci\u00f3n al cargar un raster que no lo tengo");
209
		jCheckBox6.setToolTipText("Pedir las coordenadas de georreferenciaci\u00f3n al cargar un raster que no lo tengo");
210
		jCheckBox6.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
211
		jCheckBox6.setMargin(new Insets(0, 0, 0, 0));
212
		gridBagConstraints = new GridBagConstraints();
213
		gridBagConstraints.gridx = 0;
214 97
		gridBagConstraints.gridy = 3;
215
		gridBagConstraints.gridwidth = 2;
216 98
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
217
		gridBagConstraints.anchor = GridBagConstraints.WEST;
218
		gridBagConstraints.insets = new Insets(2, 5, 5, 5);
219
		jPanel4.add(jCheckBox6, gridBagConstraints);
99
		panel.add(getPreferenceTemporal().getPanel(), gridBagConstraints);
220 100

  
221 101
		gridBagConstraints = new GridBagConstraints();
222 102
		gridBagConstraints.gridx = 0;
223
		gridBagConstraints.gridy = 0;
103
		gridBagConstraints.gridy = 4;
224 104
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
225
		jPanel5.add(jPanel4, gridBagConstraints);
105
		panel.add(getPreferenceOverviews().getPanel(), gridBagConstraints);
226 106

  
227
		jPanel7.setLayout(new GridBagLayout());
228

  
229
		jPanel7.setBorder(BorderFactory.createTitledBorder("Carga de capas"));
230
		jLabel9.setText("Al cargar una imagen no RGB, aplicarle:");
231
		jLabel9.setToolTipText("Al cargar una imagen No RGB");
232 107
		gridBagConstraints = new GridBagConstraints();
233 108
		gridBagConstraints.gridx = 0;
234
		gridBagConstraints.gridy = 0;
235
		gridBagConstraints.gridwidth = 2;
109
		gridBagConstraints.gridy = 5;
236 110
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
237
		gridBagConstraints.anchor = GridBagConstraints.WEST;
238
		gridBagConstraints.insets = new Insets(5, 5, 2, 5);
239
		jPanel7.add(jLabel9, gridBagConstraints);
111
		panel.add(getPreferenceCache().getPanel(), gridBagConstraints);
240 112

  
241
		buttonGroup1.add(jRadioButton1);
242
		jRadioButton1.setSelected(true);
243
		jRadioButton1.setText("Realce");
244
		jRadioButton1.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
245
		jRadioButton1.setMargin(new Insets(0, 0, 0, 0));
246 113
		gridBagConstraints = new GridBagConstraints();
247 114
		gridBagConstraints.gridx = 0;
248
		gridBagConstraints.gridy = 1;
249
		gridBagConstraints.gridwidth = 2;
250
		gridBagConstraints.anchor = GridBagConstraints.WEST;
251
		gridBagConstraints.insets = new Insets(2, 5, 2, 5);
252
		jPanel7.add(jRadioButton1, gridBagConstraints);
253

  
254
		buttonGroup1.add(jRadioButton2);
255
		jRadioButton2.setText("Tabla de color");
256
		jRadioButton2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
257
		jRadioButton2.setMargin(new Insets(0, 0, 0, 0));
258
		gridBagConstraints = new GridBagConstraints();
259
		gridBagConstraints.gridx = 0;
260
		gridBagConstraints.gridy = 2;
261
		gridBagConstraints.anchor = GridBagConstraints.WEST;
262
		gridBagConstraints.insets = new Insets(2, 5, 5, 2);
263
		jPanel7.add(jRadioButton2, gridBagConstraints);
264

  
265
		gridBagConstraints = new GridBagConstraints();
266
		gridBagConstraints.gridx = 1;
267
		gridBagConstraints.gridy = 2;
268
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
115
		gridBagConstraints.gridy = 6;
269 116
		gridBagConstraints.weightx = 1.0;
270
		gridBagConstraints.insets = new Insets(2, 2, 5, 5);
271
		jPanel7.add(jComboBox3, gridBagConstraints);
117
		gridBagConstraints.weighty = 1.0;
118
		panel.add(new JPanel(), gridBagConstraints);
272 119

  
273
		gridBagConstraints = new GridBagConstraints();
274
		gridBagConstraints.gridx = 0;
275
		gridBagConstraints.gridy = 1;
276
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
277
		jPanel5.add(jPanel7, gridBagConstraints);
120
		panel.setBorder(new EmptyBorder(5, 5, 5, 5));
278 121

  
279
		gridBagConstraints = new GridBagConstraints();
280
		gridBagConstraints.gridx = 0;
281
		gridBagConstraints.gridy = 4;
282
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
283
		jPanel5.add(getPreferenceOverviews().getPanel(), gridBagConstraints);
122
		scrollPane.setViewportView(panel);
284 123

  
285
		jScrollPane1.setViewportView(jPanel5);
286

  
287
		this.setLayout(new BorderLayout());
288
		this.add(jScrollPane1, BorderLayout.CENTER);
124
		setLayout(new BorderLayout());
125
		add(scrollPane, BorderLayout.CENTER);
289 126
	}
290 127

  
291 128
	private PreferenceNoData getPreferenceNoData() {
......
295 132
		return noData;
296 133
	}
297 134

  
135
	private PreferenceGeneral getPreferenceGeneral() {
136
		if (general == null) {
137
			general = new PreferenceGeneral();
138
		}
139
		return general;
140
	}
141

  
298 142
	private PreferenceOverviews getPreferenceOverviews() {
299 143
		if (overviews == null) {
300 144
			overviews = new PreferenceOverviews();
......
309 153
		return cache;
310 154
	}
311 155

  
156
	private PreferenceTemporal getPreferenceTemporal() {
157
		if (temporal == null) {
158
			temporal = new PreferenceTemporal();
159
		}
160
		return temporal;
161
	}
162

  
163
	private PreferenceLoadLayer getPreferenceLoadLayer() {
164
		if (loadLayer == null) {
165
			loadLayer = new PreferenceLoadLayer();
166
		}
167
		return loadLayer;
168
	}
169

  
312 170
	/*
313 171
	 * (non-Javadoc)
314 172
	 * @see com.iver.andami.preferences.IPreference#initializeValues()
......
317 175
		getPreferenceNoData().initializeValues();
318 176
		getPreferenceOverviews().initializeValues();
319 177
		getPreferenceCache().initializeValues();
178
		getPreferenceTemporal().initializeValues();
179
		getPreferenceGeneral().initializeValues();
180
		getPreferenceLoadLayer().initializeValues();
320 181
	}
321 182

  
322 183
	/*
......
327 188
		getPreferenceNoData().storeValues();
328 189
		getPreferenceOverviews().storeValues();
329 190
		getPreferenceCache().storeValues();
191
		getPreferenceTemporal().storeValues();
192
		getPreferenceGeneral().storeValues();
193
		getPreferenceLoadLayer().storeValues();
330 194
	}
331 195

  
332 196
	/*
......
337 201
		getPreferenceNoData().initializeDefaults();
338 202
		getPreferenceOverviews().initializeDefaults();
339 203
		getPreferenceCache().initializeDefaults();
204
		getPreferenceTemporal().initializeDefaults();
205
		getPreferenceGeneral().initializeDefaults();
206
		getPreferenceLoadLayer().initializeDefaults();
340 207
	}
341 208

  
342 209
	/*
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/gui/preferences/panels/PreferenceLoadLayer.java
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.Component;
22
import java.awt.GridBagConstraints;
23
import java.awt.GridBagLayout;
24
import java.awt.Insets;
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27
import java.io.File;
28
import java.util.ArrayList;
29

  
30
import javax.swing.BorderFactory;
31
import javax.swing.ButtonGroup;
32
import javax.swing.JComboBox;
33
import javax.swing.JLabel;
34
import javax.swing.JList;
35
import javax.swing.JRadioButton;
36
import javax.swing.ListCellRenderer;
37

  
38
import org.gvsig.fmap.raster.util.Configuration;
39
import org.gvsig.raster.datastruct.ColorTable;
40
import org.gvsig.raster.datastruct.serializer.ColorTableLibraryPersistence;
41
import org.gvsig.raster.gui.preferences.combocolortable.PaintItem;
42
import org.gvsig.raster.gui.preferences.combocolortable.PreferenceColorTableIconPainter;
43
import org.gvsig.raster.util.PanelBase;
44

  
45
public class PreferenceLoadLayer extends PanelBase implements ActionListener {
46
	JComboBox      comboBoxColorTable    = null;
47
	JRadioButton   radioButtonRealce     = null;
48
	JRadioButton   radioButtonColorTable = null;
49

  
50
	private String palettesPath = System.getProperty("user.home") +
51
		File.separator +
52
		"gvSIG" + // PluginServices.getArguments()[0] +
53
		File.separator + "colortable";
54

  
55
	public PreferenceLoadLayer() {
56
		initialize();
57
		translate();
58
	}
59

  
60
	private void translate() {
61

  
62
	}
63
	private void initialize() {
64
		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

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

  
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
		gridBagConstraints = new GridBagConstraints();
78
		gridBagConstraints.gridx = 0;
79
		gridBagConstraints.gridy = 0;
80
		gridBagConstraints.gridwidth = 2;
81
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
82
		gridBagConstraints.anchor = GridBagConstraints.WEST;
83
		gridBagConstraints.insets = new Insets(5, 5, 2, 5);
84
		getPanel().add(jLabel9, gridBagConstraints);
85

  
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
		gridBagConstraints = new GridBagConstraints();
94
		gridBagConstraints.gridx = 0;
95
		gridBagConstraints.gridy = 1;
96
		gridBagConstraints.gridwidth = 2;
97
		gridBagConstraints.anchor = GridBagConstraints.WEST;
98
		gridBagConstraints.insets = new Insets(2, 5, 2, 5);
99
		getPanel().add(radioButtonRealce, gridBagConstraints);
100

  
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
		gridBagConstraints = new GridBagConstraints();
108
		gridBagConstraints.gridx = 0;
109
		gridBagConstraints.gridy = 2;
110
		gridBagConstraints.anchor = GridBagConstraints.WEST;
111
		gridBagConstraints.insets = new Insets(2, 5, 5, 2);
112
		getPanel().add(radioButtonColorTable, gridBagConstraints);
113

  
114
		gridBagConstraints = new GridBagConstraints();
115
		gridBagConstraints.gridx = 1;
116
		gridBagConstraints.gridy = 2;
117
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
118
		gridBagConstraints.weightx = 1.0;
119
		gridBagConstraints.insets = new Insets(2, 2, 5, 5);
120
		getPanel().add(getComboBoxColorTable(), gridBagConstraints);
121
	}
122

  
123
	public JComboBox getComboBoxColorTable() {
124
		if (comboBoxColorTable == null) {
125
			comboBoxColorTable = new JComboBox();
126

  
127
			ArrayList fileList = ColorTableLibraryPersistence.getPaletteFileList(palettesPath);
128

  
129
			for (int i = 0; i < fileList.size(); i++) {
130
				ArrayList paletteItems = new ArrayList();
131
				String paletteName = ColorTableLibraryPersistence.loadPalette(palettesPath, (String) fileList.get(i), paletteItems);
132

  
133
				if (paletteItems.size() <= 0)
134
					continue;
135

  
136
				ColorTable colorTable = new ColorTable();
137
				colorTable.setName(paletteName);
138
				colorTable.createPaletteFromColorItems(paletteItems, true);
139
				colorTable.setInterpolated(true);
140

  
141
				ArrayList array = new ArrayList();
142
				array.add(paletteName);
143
				array.add(new PreferenceColorTableIconPainter(colorTable));
144

  
145
				comboBoxColorTable.addItem(array);
146
			}
147

  
148
			comboBoxColorTable.setRenderer(new ListCellRenderer() {
149
				public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
150
					ArrayList array = (ArrayList) value;
151

  
152
					PaintItem paintItem = new PaintItem((String) array.get(0), (PreferenceColorTableIconPainter) array.get(1), isSelected);
153
					return paintItem;
154
				}
155
			});
156
		}
157
		return comboBoxColorTable;
158
	}
159

  
160
	private void setColorTableEnabled(boolean enabled) {
161
		getComboBoxColorTable().setEnabled(enabled);
162
	}
163

  
164
	public void initializeDefaults() {
165
		radioButtonRealce.setSelected(true);
166
		setColorTableEnabled(false);
167
	}
168

  
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

  
176
			for (int i=0; i<getComboBoxColorTable().getItemCount(); i++) {
177
				if (((String) ((ArrayList) getComboBoxColorTable().getItemAt(i)).get(0)).equals(colorTable)) {
178
					getComboBoxColorTable().setSelectedIndex(i);
179
					finded = true;
180
					break;
181
				}
182
			}
183
		}
184

  
185
		if (finded == false) {
186
			radioButtonRealce.setSelected(true);
187
			setColorTableEnabled(false);
188
			Configuration.setValue("loadlayer_usecolortable", (String) null);
189
		}
190
	}
191

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

  
199
	public void actionPerformed(ActionEvent e) {
200
		if (radioButtonColorTable.isSelected()) {
201
			setColorTableEnabled(true);
202
		} else {
203
			setColorTableEnabled(false);
204
		}
205
	}
206
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/gui/preferences/panels/PreferenceGeneral.java
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
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/gui/preferences/panels/PreferenceCache.java
219 219
	}
220 220

  
221 221
	public void initializeDefaults() {
222
		getTextFieldCacheSize().setValue(Long.valueOf(RasterLibrary.cacheSize));
223
		getTextFieldPageSize().setValue(Double.valueOf(RasterLibrary.pageSize));
224
		getTextFieldPagsPerGroup().setValue(Integer.valueOf(RasterLibrary.pagsPerGroup));
222
		getTextFieldCacheSize().setValue((Long) Configuration.getDefaultValue("cache_size"));
223
		getTextFieldPageSize().setValue((Double) Configuration.getDefaultValue("cache_pagesize"));
224
		getTextFieldPagsPerGroup().setValue((Integer) Configuration.getDefaultValue("cache_pagspergroup"));
225 225

  
226
		Integer blockHeight = (Integer) Configuration.getDefaultValue("cache_blockheight");
226 227
		for (int i = 0; i < getComboBoxBlockHeight().getItemCount(); i++) {
227
			if (getComboBoxBlockHeight().getItemAt(i).toString().equals(Integer.valueOf(RasterLibrary.blockHeight).toString())) {
228
			if (getComboBoxBlockHeight().getItemAt(i).toString().equals(blockHeight.toString())) {
228 229
				getComboBoxBlockHeight().setSelectedIndex(i);
229 230
				break;
230 231
			}
......
251 252
		Configuration.setValue("cache_pagspergroup", getTextFieldPagsPerGroup().getText());
252 253
		Configuration.setValue("cache_blockheight", getComboBoxBlockHeight().getSelectedItem().toString());
253 254
	}
254
}

255
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/gui/preferences/panels/PreferenceTemporal.java
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.Dimension;
22
import java.awt.GridBagConstraints;
23
import java.awt.GridBagLayout;
24
import java.awt.Insets;
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27
import java.io.File;
28

  
29
import javax.swing.BorderFactory;
30
import javax.swing.JButton;
31
import javax.swing.JLabel;
32
import javax.swing.JTextField;
33

  
34
import org.gvsig.fmap.raster.util.Configuration;
35
import org.gvsig.gui.beans.swing.JFileChooser;
36
import org.gvsig.raster.RasterLibrary;
37
import org.gvsig.raster.util.PanelBase;
38

  
39
import com.iver.andami.PluginServices;
40
/**
41
 *
42
 * @version 12/12/2007
43
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
44
 */
45
public class PreferenceTemporal extends PanelBase implements ActionListener {
46
	private JLabel     labelTemporales    = null;
47
	private JButton    buttonOpen         = null;
48
	private JTextField textFieldDirectory = null;
49

  
50
	public PreferenceTemporal() {
51
		initialize();
52
		translate();
53
	}
54

  
55
	private void translate() {
56
		getPanel().setBorder(BorderFactory.createTitledBorder(getText(this, "rutas")));
57
		getLabelTemporales().setText(getText(this, "temporales") + ":");
58
		getButtonOpen().setText(getText(this, "seleccionar_directorio"));
59
	}
60

  
61
	private void initialize() {
62
		GridBagConstraints gridBagConstraints;
63

  
64
		getPanel().setLayout(new GridBagLayout());
65

  
66
		gridBagConstraints = new GridBagConstraints();
67
		gridBagConstraints.insets = new Insets(5, 5, 5, 2);
68
		getPanel().add(getLabelTemporales(), gridBagConstraints);
69

  
70
		gridBagConstraints = new GridBagConstraints();
71
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
72
		gridBagConstraints.weightx = 1.0;
73
		gridBagConstraints.insets = new Insets(5, 2, 5, 2);
74
		getPanel().add(getTextFieldDirectory(), gridBagConstraints);
75

  
76
		gridBagConstraints = new GridBagConstraints();
77
		gridBagConstraints.insets = new Insets(5, 2, 5, 5);
78
		getPanel().add(getButtonOpen(), gridBagConstraints);
79
	}
80

  
81
	private JLabel getLabelTemporales() {
82
		if (labelTemporales == null) {
83
			labelTemporales = new JLabel();
84
		}
85
		return labelTemporales;
86
	}
87

  
88
	private JButton getButtonOpen() {
89
		if (buttonOpen == null) {
90
			buttonOpen = new JButton();
91
			buttonOpen.addActionListener(this);
92
		}
93
		return buttonOpen;
94
	}
95

  
96
	private JTextField getTextFieldDirectory() {
97
		if (textFieldDirectory == null) {
98
			textFieldDirectory = new JTextField();
99
			textFieldDirectory.setEditable(false);
100
			textFieldDirectory.setPreferredSize(new Dimension(0, textFieldDirectory.getPreferredSize().height));
101
		}
102
		return textFieldDirectory;
103
	}
104

  
105

  
106
	public void initializeDefaults() {
107
		File file = new File((String) Configuration.getDefaultValue("path_temp_cache_directory"));
108
		if (!file.exists())
109
			file.mkdir();
110
		getTextFieldDirectory().setText(file.getAbsolutePath());
111
	}
112

  
113
	public void initializeValues() {
114
		File file = new File(Configuration.getValue("path_temp_cache_directory", RasterLibrary.tempCacheDirectoryPath));
115
		if (!file.exists())
116
			file.mkdir();
117
		getTextFieldDirectory().setText(file.getAbsolutePath());
118
	}
119

  
120
	public void storeValues() {
121
		Configuration.setValue("path_temp_cache_directory", getTextFieldDirectory().getText());
122
	}
123

  
124
	public void actionPerformed(ActionEvent e) {
125
		JFileChooser chooser = new JFileChooser(this.getClass().getName(), new File(getTextFieldDirectory().getText()));
126
		chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
127
		chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_directorio"));
128

  
129
		if (chooser.showOpenDialog(getPanel()) == JFileChooser.APPROVE_OPTION)
130
			getTextFieldDirectory().setText(chooser.getSelectedFile().getAbsolutePath());
131

  
132
		JFileChooser.setLastPath(this.getClass().getName(), new File(getTextFieldDirectory().getText()));
133
	}
134
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/gui/preferences/panels/PreferenceNoData.java
43 43
public class PreferenceNoData extends PanelBase implements ActionListener {
44 44
	private static final long serialVersionUID = -8964531984609056094L;
45 45
	private JCheckBox           jCheckBoxNoDataEnabled = null;
46
	private JCheckBox           jCheckBoxTransparent   = null;
47 46
	private JLabel              jLabelGeneralValue     = null;
48 47
	private JFormattedTextField textFieldGeneralValue  = null;
49 48

  
......
56 55
		getPanel().setBorder(BorderFactory.createTitledBorder(getText(this, "nodata")));
57 56
		getCheckBoxNoDataEnabled().setText(getText(this, "activar_uso_nodata"));
58 57
		getCheckBoxNoDataEnabled().setToolTipText(getText(this, "activar_uso_nodata"));
59
		getCheckBoxTransparent().setText(getText(this, "transparente"));
60 58
		getLabelGeneralValue().setText(getText(this, "valor_general") + ":");
61 59
	}
62 60

  
......
88 86
		gridBagConstraints.weightx = 1.0;
89 87
		gridBagConstraints.insets = new Insets(2, 2, 2, 5);
90 88
		getPanel().add(getTextFieldGeneralValue(), gridBagConstraints);
91

  
92
		posy++;
93
		gridBagConstraints = new GridBagConstraints();
94
		gridBagConstraints.gridx = 0;
95
		gridBagConstraints.gridy = posy;
96
		gridBagConstraints.gridwidth = 2;
97
		gridBagConstraints.anchor = GridBagConstraints.WEST;
98
		gridBagConstraints.insets = new Insets(2, 5, 5, 5);
99
		getPanel().add(getCheckBoxTransparent(), gridBagConstraints);
100 89
	}
101 90

  
102 91
	private JFormattedTextField getTextFieldGeneralValue() {
......
123 112
		return jCheckBoxNoDataEnabled;
124 113
	}
125 114

  
126
	private JCheckBox getCheckBoxTransparent() {
127
		if (jCheckBoxTransparent == null) {
128
			jCheckBoxTransparent = new JCheckBox();
129
			jCheckBoxTransparent.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
130
			jCheckBoxTransparent.setMargin(new Insets(0, 0, 0, 0));
131
		}
132
		return jCheckBoxTransparent;
133
	}
134

  
135 115
	private JLabel getLabelGeneralValue() {
136 116
		if (jLabelGeneralValue == null) {
137 117
			jLabelGeneralValue = new JLabel();
......
141 121

  
142 122
	private void setNoDataEnabled(boolean enabled) {
143 123
		getLabelGeneralValue().setEnabled(enabled);
144
		getCheckBoxTransparent().setEnabled(enabled);
145 124
		getTextFieldGeneralValue().setEnabled(enabled);
146 125
	}
147 126

  
148 127
	public void initializeDefaults() {
149
		Boolean enabled = Boolean.valueOf(RasterLibrary.noDataEnabled);
128
		Boolean enabled = (Boolean) Configuration.getDefaultValue("nodata_enabled");
150 129
		getCheckBoxNoDataEnabled().setSelected(enabled.booleanValue());
151 130
		setNoDataEnabled(enabled.booleanValue());
152
		getTextFieldGeneralValue().setValue(Double.valueOf(RasterLibrary.noDataValue));
153

  
154
		enabled = Boolean.valueOf(RasterLibrary.noDataTransparent);
155
		getCheckBoxTransparent().setSelected(enabled.booleanValue());
131
		getTextFieldGeneralValue().setValue((Double) Configuration.getDefaultValue("nodata_value"));
156 132
	}
157 133

  
158 134
	public void initializeValues() {
......
160 136
		getCheckBoxNoDataEnabled().setSelected(enabled.booleanValue());
161 137
		setNoDataEnabled(enabled.booleanValue());
162 138
		getTextFieldGeneralValue().setValue(Configuration.getValue("nodata_value", Double.valueOf(RasterLibrary.noDataValue)));
163

  
164
		enabled = Configuration.getValue("nodata_transparent", Boolean.valueOf(RasterLibrary.noDataTransparent));
165
		getCheckBoxTransparent().setSelected(enabled.booleanValue());
166 139
	}
167 140

  
168 141
	public void storeValues() {
......
171 144
			Configuration.setValue("nodata_value", Double.valueOf(getTextFieldGeneralValue().getText()));
172 145
		} catch (NumberFormatException e) {
173 146
		}
174
		Configuration.setValue("nodata_transparent", Boolean.valueOf(getCheckBoxTransparent().isSelected()));
175 147
	}
176 148

  
177 149
	public void actionPerformed(ActionEvent e) {
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/gui/preferences/panels/PreferenceOverviews.java
165 165
	}
166 166

  
167 167
	public void initializeDefaults() {
168
		getCheckBoxAsk().setSelected(false);
169
		getComboNumber().setSelectedIndex(2);
170
		getComboRate().setSelectedIndex(0);
171
		getComboAlgorithm().setSelectedIndex(1);
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);
172 192
	}
173 193

  
174 194
	public void initializeValues() {
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/gui/preferences/combocolortable/PaintItem.java
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.combocolortable;
20

  
21
import java.awt.Color;
22
import java.awt.Component;
23
import java.awt.Dimension;
24
import java.awt.FontMetrics;
25
import java.awt.GradientPaint;
26
import java.awt.Graphics;
27
import java.awt.Graphics2D;
28
import java.awt.Rectangle;
29
/**
30
 *
31
 * @version 17/04/2007
32
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
33
 */
34
public class PaintItem extends Component {
35
	private static final long serialVersionUID = -6448740563809113949L;
36
	private boolean isSelected = false;
37
	private String name = "";
38
	private PreferenceColorTableIconPainter colorTablePaint = null;
39

  
40
	public PaintItem(String name, PreferenceColorTableIconPainter colorTablePaint, boolean isSelected) {
41
		this.name = name;
42
		this.colorTablePaint = colorTablePaint;
43
		this.isSelected = isSelected;
44

  
45
		setSize(getWidth(), 19);
46
		setPreferredSize(new Dimension(getWidth(), 19));
47
	}
48

  
49
	public void paint(Graphics g) {
50
		Graphics2D g2 = (Graphics2D) g;
51
		if (isSelected) {
52
			Color color1 = new Color(89, 153, 229);
53
			Color color2 = new Color(31, 92, 207);
54
			g2.setPaint(new GradientPaint(0, 1, color1, 0, getHeight() - 1, color2, false));
55
			g2.fillRect(0, 1, getWidth(), getHeight() - 1);
56
			g2.setColor(new Color(61, 123, 218));
57
			g2.drawLine(0, 0, getWidth(), 0);
58
			g2.setColor(Color.white);
59
		} else {
60
			g2.setColor(Color.white);
61
			g2.fillRect(0, 0, getWidth(), getHeight());
62
			g2.setColor(Color.black);
63
		}
64

  
65
		Rectangle bounds = getBounds();
66

  
67
		FontMetrics fm = g2.getFontMetrics();
68
		int upper = (bounds.height + fm.getHeight()) / 2 - fm.getDescent();
69

  
70
		g2.setClip(bounds.x, 0, bounds.width, bounds.height);
71
		g2.drawString(name, bounds.width - 146, upper);
72

  
73
		g2.setClip(bounds.x, 0, bounds.width - 150, bounds.height);
74

  
75
		colorTablePaint.paint((Graphics2D) g2, isSelected);
76
	}
77
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/gui/preferences/combocolortable/PreferenceColorTableIconPainter.java
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.combocolortable;
20

  
21
import java.awt.Color;
22
import java.awt.Graphics2D;
23
import java.awt.Rectangle;
24
import java.util.ArrayList;
25

  
26
import org.gvsig.gui.beans.listview.IIconPaint;
27
import org.gvsig.raster.datastruct.ColorItem;
28
import org.gvsig.raster.datastruct.ColorTable;
29
/**
30
 * Clase para dibujar los iconos del ListViewComponent del panel de color. Se
31
 * puede indicar si la paleta esta seleccionada y si se dibuja con
32
 * interpolaciones.
33
 * 
34
 * @version 29/06/2007
35
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
36
 */
37
public class PreferenceColorTableIconPainter implements IIconPaint {
38
	private ColorTable colorTable;
39

  
40
	/**
41
	 * Construye un ColorTablePaint con una tabla de color pasada por parametro
42
	 * @param colorTable
43
	 */
44
	public PreferenceColorTableIconPainter(ColorTable colorTable) {
45
		this.colorTable = colorTable;
46
	}
47

  
48
	/**
49
	 * Define si los valores estan interpolados o no entre si
50
	 * @param value
51
	 */
52
	public void setInterpolated(boolean value) {
53
		colorTable.setInterpolated(value);
54
	}
55

  
56
	/**
57
	 * Obtiene el array de los colores de la paleta de color
58
	 * @return
59
	 */
60
	public ArrayList getColorItems() {
61
		return colorTable.getColorItems();
62
	}
63

  
64
	/**
65
	 * Obtiene el ColorTable
66
	 * @return
67
	 */
68
	public ColorTable getColorTable() {
69
		return colorTable;
70
	}
71

  
72
	/**
73
	 * Especificar los colores de la tabla de color, definiendo si estan los
74
	 * valores interpolados y si la paleta se comprimira o no.
75
	 * @param value
76
	 * @param interpolated
77
	 * @param compress
78
	 */
79
	public void setColorItems(ArrayList value, boolean interpolated, boolean compress) {
80
		colorTable.createPaletteFromColorItems(value, compress);
81
		setInterpolated(interpolated);
82
	}
83

  
84
	/**
85
	 * Metodo de pintado de la tabla de color
86
	 * @param g
87
	 * @param isSelected
88
	 */
89
	public void paint(Graphics2D g, boolean isSelected) {
90
		Rectangle area = g.getClipBounds();
91

  
92
		int x1 = area.x;
93
		int x2 = area.x + area.width - 1;
94

  
95
		Color bgColor = new Color(224, 224, 224);
96
		for (int i = 0; (i * 4) <= area.width; i++) {
97
			for (int j = 0; (j * 4) <= area.height; j++) {
98
				if ((i + j) % 2 == 0)
99
					g.setColor(Color.white);
100
				else
101
					g.setColor(bgColor);
102
				g.fillRect(area.x + 1 + i * 4, area.y + 1 + j * 4, 4, 4);
103
			}
104
		}		
105
		
106
		if (colorTable.getColorItems().size() >= 1) {
107
			double min = ((ColorItem) colorTable.getColorItems().get(0)).getValue();
108
			double max = ((ColorItem) colorTable.getColorItems().get(colorTable.getColorItems().size() - 1)).getValue();
109
			for (int i = area.x; i < (area.x + area.width); i++) {
110
				double pos = min + (((max - min) * (i - area.x)) / (area.width - 2));
111

  
112
				byte[] col3 = colorTable.getRGBAByBand(pos);
113
				g.setColor(new Color(col3[0] & 0xff, col3[1] & 0xff, col3[2] & 0xff, col3[3] & 0xff));
114
				g.drawLine(i, area.y, i, area.y + area.height);
115
			}
116
		} else {
117
			g.setColor(new Color(224, 224, 224));
118
			g.fillRect(x1, area.y, x2 - x1, area.height - 1);
119
		}
120
		if (isSelected)
121
			g.setColor(Color.black);
122
		else
123
			g.setColor(new Color(96, 96, 96));
124
		g.drawRect(x1, area.y, x2 - x1, area.height - 1);
125
	}	
126
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/util/ConfigurationListener.java
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.util;
20

  
21
import java.util.EventListener;
22
import java.util.EventObject;
23

  
24
public interface ConfigurationListener extends EventListener {
25
	/**
26
	 * Evento que se dispara cuando cambia un valor de configuracion.
27
	 * @param e
28
	 */
29
	public void actionConfigurationChanged(EventObject e);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff