Revision 1336

View differences:

org.gvsig.raster.tilecache/tags/buildNumber_29/org.gvsig.raster.tilecache/Readme.txt
1

  
2
Packages
3
---------
4
org.gvsig.raster.tilecache            core                 lin      x86
5
                                      core                 win      x86
6
*org.gvsig.raster.gdal                 formats              all      all
7
*org.gvsig.raster.app.tools            tools                all      all
8
*org.gvsig.raster.ermapper             formats              lin      x86
9
*                                      formats              win      x86
10
*org.gvsig.raster.lizardtech           formats              lin      x86
11
*                                      formats              win      x86
12
*org.gvsig.raster.netcdf               formats              all      all
13
*org.gvsig.raster.wms                  services             all      all
14
*org.gvsig.raster.wcs                  services             all      all
15
*org.gvsig.raster.wmts                 services             all      all
16
org.gvsig.raster.timesupport          services/formats     all      all  (not finished)
17
org.gvsig.raster.postgis              formats              all      all  (not finished)
18
                                     
0 19

  
org.gvsig.raster.tilecache/tags/buildNumber_29/org.gvsig.raster.tilecache/distribution/distribution.xml
1
<assembly>
2
</assembly>
0 3

  
org.gvsig.raster.tilecache/tags/buildNumber_29/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.app/src/main/java/org/gvsig/raster/tilecache/app/TileCachePreferences.java
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.tilecache.app;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27

  
28
import javax.swing.ImageIcon;
29
import javax.swing.JPanel;
30
import javax.swing.JScrollPane;
31
import javax.swing.border.EmptyBorder;
32

  
33
import org.gvsig.andami.IconThemeHelper;
34
import org.gvsig.andami.preferences.AbstractPreferencePage;
35
import org.gvsig.andami.preferences.StoreException;
36

  
37
/**
38
 * Preferences for tile cache
39
 * @author Nacho Brodin (nachobrodin@gmail.com
40
 */
41
public class TileCachePreferences extends AbstractPreferencePage {
42
	private static final long         serialVersionUID = -1689657253810393874L;
43

  
44
	protected static String           id        = TileCachePreferences.class.getName();
45
	private ImageIcon                 icon;
46

  
47
	private TileCachePreferencesPanel tilecache = null;
48

  
49
	/**
50
	 * Constructor de la clase RasterPreferences
51
	 */
52
	public TileCachePreferences() {
53
		super();
54
		icon = IconThemeHelper.getImageIcon("pref-tilecache-icon");
55
		initialize();
56
	}
57

  
58
	/**
59
	 * Inicializacion del panel de preferencias.
60
	 */
61
	private void initialize() {
62
		setTitle("Frame");
63

  
64
		GridBagConstraints gridBagConstraints;
65

  
66
		JScrollPane scrollPane = new JScrollPane();
67

  
68
		scrollPane.getVerticalScrollBar().setUnitIncrement(20);
69

  
70
		JPanel panel = new JPanel();
71

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

  
74
		gridBagConstraints = new GridBagConstraints();
75
		gridBagConstraints.gridx = 0;
76
		gridBagConstraints.gridy = 0;
77
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
78
		panel.add(getPreferenceTileCache(), gridBagConstraints);
79

  
80
		gridBagConstraints = new GridBagConstraints();
81
		gridBagConstraints.gridx = 0;
82
		gridBagConstraints.gridy = 7;
83
		gridBagConstraints.weightx = 1.0;
84
		gridBagConstraints.weighty = 1.0;
85
		panel.add(new JPanel(), gridBagConstraints);
86

  
87
		panel.setBorder(new EmptyBorder(5, 5, 5, 5));
88

  
89
		scrollPane.setViewportView(panel);
90

  
91
		setLayout(new BorderLayout());
92
		add(scrollPane, BorderLayout.CENTER);
93
	}
94

  
95
	/**
96
	 * Gets a tile cache configuration panel
97
	 * @return
98
	 */
99
	private TileCachePreferencesPanel getPreferenceTileCache() {
100
		if (tilecache == null) {
101
			tilecache = new TileCachePreferencesPanel();
102
		}
103
		return tilecache;
104
	}
105

  
106
	/*
107
	 * (non-Javadoc)
108
	 * @see com.iver.andami.preferences.IPreference#initializeValues()
109
	 */
110
	public void initializeValues() {
111
		getPreferenceTileCache().initializeValues();
112
	}
113

  
114
	/*
115
	 * (non-Javadoc)
116
	 * @see com.iver.andami.preferences.AbstractPreferencePage#storeValues()
117
	 */
118
	public void storeValues() throws StoreException {
119
		getPreferenceTileCache().storeValues();
120
	}
121

  
122
	/*
123
	 * (non-Javadoc)
124
	 * @see com.iver.andami.preferences.IPreference#initializeDefaults()
125
	 */
126
	public void initializeDefaults() {
127
		getPreferenceTileCache().initializeDefaults();
128
	}
129

  
130
	/*
131
	 * (non-Javadoc)
132
	 * @see com.iver.andami.preferences.AbstractPreferencePage#isResizeable()
133
	 */
134
	public boolean isResizeable() {
135
		return true;
136
	}
137

  
138
	/*
139
	 * (non-Javadoc)
140
	 * @see com.iver.andami.preferences.IPreference#getID()
141
	 */
142
	public String getID() {
143
		return id;
144
	}
145

  
146
	/*
147
	 * (non-Javadoc)
148
	 * @see com.iver.andami.preferences.IPreference#getIcon()
149
	 */
150
	public ImageIcon getIcon() {
151
		return icon;
152
	}
153

  
154
	/*
155
	 * (non-Javadoc)
156
	 * @see com.iver.andami.preferences.IPreference#getPanel()
157
	 */
158
	public JPanel getPanel() {
159
		return this;
160
	}
161

  
162
	/*
163
	 * (non-Javadoc)
164
	 * @see com.iver.andami.preferences.IPreference#getTitle()
165
	 */
166
	public String getTitle() {
167
		return "Tile Cache";
168
	}
169

  
170
	/*
171
	 * (non-Javadoc)
172
	 * @see com.iver.andami.preferences.IPreference#isValueChanged()
173
	 */
174
	public boolean isValueChanged() {
175
		return true;
176
	}
177

  
178
	public void setChangesApplied() {}
179
}
0 180

  
org.gvsig.raster.tilecache/tags/buildNumber_29/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.app/src/main/java/org/gvsig/raster/tilecache/app/TileCachePreferencesPanel.java
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.tilecache.app;
23

  
24
import java.awt.Color;
25
import java.awt.Dimension;
26
import java.awt.GridBagConstraints;
27
import java.awt.GridBagLayout;
28
import java.awt.Insets;
29
import java.awt.event.ActionEvent;
30
import java.awt.event.ActionListener;
31
import java.io.File;
32
import java.text.NumberFormat;
33

  
34
import javax.swing.BorderFactory;
35
import javax.swing.DefaultComboBoxModel;
36
import javax.swing.JButton;
37
import javax.swing.JComboBox;
38
import javax.swing.JFormattedTextField;
39
import javax.swing.JLabel;
40
import javax.swing.JTextField;
41
import javax.swing.SwingConstants;
42
import javax.swing.text.DefaultFormatterFactory;
43
import javax.swing.text.NumberFormatter;
44

  
45
import org.gvsig.andami.PluginServices;
46
import org.gvsig.andami.preferences.DlgPreferences;
47
import org.gvsig.andami.ui.mdiManager.IWindow;
48
import org.gvsig.fmap.dal.coverage.RasterLibrary;
49
import org.gvsig.raster.cache.tile.TileCacheLibrary;
50
import org.gvsig.raster.util.BasePanel;
51
/**
52
 * This class provides a panel for tile cache configuration
53
 * 
54
 * @author Nacho Brodin (nachobrodin@gmail.com)
55
 */
56
public class TileCachePreferencesPanel extends BasePanel implements ActionListener {
57
	protected static final long serialVersionUID      = 1L;
58
	private static int          TILE_SIZE_WMS         = 1024;              
59
	private JLabel              labelWarning          = null;
60
	private JLabel              labelCacheSize        = null;
61
	private JLabel              labelLevels           = null;
62
	private JLabel              labelStruct           = null;
63
	private JLabel              labelTileSize         = null;
64
	private JLabel              labelWMSTileSize      = null;
65
	private JLabel              labelPath             = null;
66
	private JFormattedTextField textFieldCacheSize    = null;
67
	private JFormattedTextField textFieldLevels       = null;
68
	private JFormattedTextField textFieldTileSize     = null;
69
	private JFormattedTextField textFieldWMSTileSize  = null;
70
	private JTextField          textFieldPath         = null;
71
	private JComboBox           comboBoxStruct        = null;
72
	private JButton             buttonRemove          = null;
73

  
74
	/**
75
	 *Inicializa componentes gr?ficos y traduce
76
	 */
77
	public TileCachePreferencesPanel() {
78
		init();
79
		translate();
80
	}
81

  
82
	/**
83
	 * Define todas las traducciones de PreferenceCache
84
	 */
85
	protected void translate() {
86
		setBorder(BorderFactory.createTitledBorder(getText(this, "tilecache")));
87
		getLabelWarning().setText(getText(this, "preference_cache_warning"));
88
		getLabelCacheSize().setText(getText(this, "tamanyo_max_tilecache") + ":");
89
		getLabelLevels().setText(getText(this, "res_levels") + ":");
90
		getLabelTileSize().setText(getText(this, "tilesize") + ":");
91
		getLabelWMSTileSize().setText("WMS/WCS " + getText(this, "tilesize") + ":");
92
		getLabelStruct().setText(getText(this, "tilecache_struct") + ":");
93
		getButtonRemove().setText(getText(this, "remove_cache"));
94
		getLabelPath().setText(getText(this, "path_tilecache"));
95
	}
96

  
97
	protected void init() {
98
		GridBagConstraints gridBagConstraints;
99

  
100
		setLayout(new GridBagLayout());
101

  
102
		gridBagConstraints = new GridBagConstraints();
103
		gridBagConstraints.gridwidth = 2;
104
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
105
		gridBagConstraints.weightx = 1.0;
106
		gridBagConstraints.insets = new Insets(5, 5, 2, 5);
107
		add(getLabelWarning(), gridBagConstraints);
108

  
109
		gridBagConstraints = new GridBagConstraints();
110
		gridBagConstraints.gridx = 0;
111
		gridBagConstraints.gridy = 1;
112
		gridBagConstraints.anchor = GridBagConstraints.EAST;
113
		gridBagConstraints.insets = new Insets(2, 5, 2, 2);
114
		add(getLabelCacheSize(), gridBagConstraints);
115
		
116
		gridBagConstraints = new GridBagConstraints();
117
		gridBagConstraints.gridx = 0;
118
		gridBagConstraints.gridy = 2;
119
		gridBagConstraints.anchor = GridBagConstraints.EAST;
120
		gridBagConstraints.insets = new Insets(2, 5, 2, 2);
121
		add(getLabelLevels(), gridBagConstraints);
122
		
123
		gridBagConstraints = new GridBagConstraints();
124
		gridBagConstraints.gridx = 0;
125
		gridBagConstraints.gridy = 3;
126
		gridBagConstraints.anchor = GridBagConstraints.EAST;
127
		gridBagConstraints.insets = new Insets(2, 5, 2, 2);
128
		add(getLabelTileSize(), gridBagConstraints);
129
		
130
		gridBagConstraints = new GridBagConstraints();
131
		gridBagConstraints.gridx = 0;
132
		gridBagConstraints.gridy = 4;
133
		gridBagConstraints.anchor = GridBagConstraints.EAST;
134
		gridBagConstraints.insets = new Insets(2, 5, 2, 2);
135
		add(getLabelWMSTileSize(), gridBagConstraints);
136
		
137
		gridBagConstraints = new GridBagConstraints();
138
		gridBagConstraints.gridx = 0;
139
		gridBagConstraints.gridy = 5;
140
		gridBagConstraints.anchor = GridBagConstraints.EAST;
141
		gridBagConstraints.insets = new Insets(2, 5, 2, 2);
142
		add(getLabelStruct(), gridBagConstraints);
143
		
144
		gridBagConstraints = new GridBagConstraints();
145
		gridBagConstraints.gridx = 0;
146
		gridBagConstraints.gridy = 6;
147
		gridBagConstraints.gridwidth = 2;
148
		gridBagConstraints.anchor = GridBagConstraints.WEST;
149
		gridBagConstraints.insets = new Insets(2, 5, 2, 2);
150
		add(getButtonRemove(), gridBagConstraints);
151
		
152
		gridBagConstraints = new GridBagConstraints();
153
		gridBagConstraints.gridx = 0;
154
		gridBagConstraints.gridy = 7;
155
		gridBagConstraints.anchor = GridBagConstraints.EAST;
156
		gridBagConstraints.insets = new Insets(2, 5, 2, 2);
157
		add(getLabelPath(), gridBagConstraints);
158

  
159
		gridBagConstraints = new GridBagConstraints();
160
		gridBagConstraints.gridx = 1;
161
		gridBagConstraints.gridy = 1;
162
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
163
		gridBagConstraints.anchor = GridBagConstraints.WEST;
164
		gridBagConstraints.insets = new Insets(2, 2, 2, 5);
165
		add(getTextFieldCacheSize(), gridBagConstraints);
166
		
167
		gridBagConstraints = new GridBagConstraints();
168
		gridBagConstraints.gridx = 1;
169
		gridBagConstraints.gridy = 2;
170
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
171
		gridBagConstraints.anchor = GridBagConstraints.WEST;
172
		gridBagConstraints.insets = new Insets(2, 2, 2, 5);
173
		add(getTextFieldLevels(), gridBagConstraints);
174
		
175
		gridBagConstraints = new GridBagConstraints();
176
		gridBagConstraints.gridx = 1;
177
		gridBagConstraints.gridy = 3;
178
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
179
		gridBagConstraints.anchor = GridBagConstraints.WEST;
180
		gridBagConstraints.insets = new Insets(2, 2, 2, 5);
181
		add(getTextFieldTileSize(), gridBagConstraints);
182
		
183
		gridBagConstraints = new GridBagConstraints();
184
		gridBagConstraints.gridx = 1;
185
		gridBagConstraints.gridy = 4;
186
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
187
		gridBagConstraints.anchor = GridBagConstraints.WEST;
188
		gridBagConstraints.insets = new Insets(2, 2, 2, 5);
189
		add(getTextFieldWMSTileSize(), gridBagConstraints);
190
		
191
		gridBagConstraints = new GridBagConstraints();
192
		gridBagConstraints.gridx = 1;
193
		gridBagConstraints.gridy = 5;
194
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
195
		gridBagConstraints.anchor = GridBagConstraints.WEST;
196
		gridBagConstraints.insets = new Insets(2, 2, 2, 5);
197
		add(getComboBoxStruct(), gridBagConstraints);
198
		
199
		gridBagConstraints = new GridBagConstraints();
200
		gridBagConstraints.gridx = 1;
201
		gridBagConstraints.gridy = 7;
202
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
203
		gridBagConstraints.anchor = GridBagConstraints.WEST;
204
		gridBagConstraints.insets = new Insets(2, 2, 2, 5);
205
		add(getTextFieldPath(), gridBagConstraints);
206
		
207
	}
208

  
209
	private JLabel getLabelWarning() {
210
		if (labelWarning == null) {
211
			labelWarning = new JLabel();
212
			labelWarning.setForeground(new Color(255, 0, 0));
213
			labelWarning.setHorizontalAlignment(SwingConstants.CENTER);
214
			labelWarning.setPreferredSize(new Dimension(0, 32));
215
		}
216
		return labelWarning;
217
	}
218

  
219
	private JButton getButtonRemove() {
220
		if(buttonRemove == null) {
221
			buttonRemove = new JButton();
222
			buttonRemove.addActionListener(this);
223
		}
224
		return buttonRemove;
225
	}
226
	
227
	private JComboBox getComboBoxStruct() {
228
		if (comboBoxStruct == null) {
229
			comboBoxStruct = new JComboBox();
230
			comboBoxStruct.setModel(new DefaultComboBoxModel(new String[] { "FLATX" }));
231
		}
232
		return comboBoxStruct;
233
	}
234
	
235
	private JTextField getTextFieldPath() {
236
		if (textFieldPath == null) {
237
			textFieldPath = new JTextField();
238
		}
239
		return textFieldPath;
240
	}
241
	
242
	private JFormattedTextField getTextFieldCacheSize() {
243
		if (textFieldCacheSize == null) {
244
			NumberFormat integerFormat = NumberFormat.getNumberInstance();
245
			integerFormat.setParseIntegerOnly(true);
246
			textFieldCacheSize = new JFormattedTextField(new DefaultFormatterFactory(
247
					new NumberFormatter(integerFormat),
248
					new NumberFormatter(integerFormat),
249
					new NumberFormatter(integerFormat)));
250
		}
251
		return textFieldCacheSize;
252
	}
253
	
254
	private JFormattedTextField getTextFieldTileSize() {
255
		if (textFieldTileSize == null) {
256
			NumberFormat integerFormat = NumberFormat.getNumberInstance();
257
			integerFormat.setParseIntegerOnly(true);
258
			textFieldTileSize = new JFormattedTextField(new DefaultFormatterFactory(
259
					new NumberFormatter(integerFormat),
260
					new NumberFormatter(integerFormat),
261
					new NumberFormatter(integerFormat)));
262
		}
263
		return textFieldTileSize;
264
	}
265
	
266
	private JFormattedTextField getTextFieldWMSTileSize() {
267
		if (textFieldWMSTileSize == null) {
268
			NumberFormat integerFormat = NumberFormat.getNumberInstance();
269
			integerFormat.setParseIntegerOnly(true);
270
			textFieldWMSTileSize = new JFormattedTextField(new DefaultFormatterFactory(
271
					new NumberFormatter(integerFormat),
272
					new NumberFormatter(integerFormat),
273
					new NumberFormatter(integerFormat)));
274
		}
275
		return textFieldWMSTileSize;
276
	}
277
	
278
	private JFormattedTextField getTextFieldLevels() {
279
		if (textFieldLevels == null) {
280
			NumberFormat integerFormat = NumberFormat.getNumberInstance();
281
			integerFormat.setParseIntegerOnly(true);
282
			textFieldLevels = new JFormattedTextField(new DefaultFormatterFactory(
283
					new NumberFormatter(integerFormat),
284
					new NumberFormatter(integerFormat),
285
					new NumberFormatter(integerFormat)));
286
		}
287
		return textFieldLevels;
288
	}
289

  
290
	private JLabel getLabelPath() {
291
		if (labelPath == null)
292
			labelPath = new JLabel();
293
		return labelPath;
294
	}
295
	
296
	private JLabel getLabelCacheSize() {
297
		if (labelCacheSize == null)
298
			labelCacheSize = new JLabel();
299
		return labelCacheSize;
300
	}
301
	
302
	private JLabel getLabelLevels() {
303
		if (labelLevels == null)
304
			labelLevels = new JLabel();
305
		return labelLevels;
306
	}
307
	
308
	private JLabel getLabelStruct() {
309
		if (labelStruct == null)
310
			labelStruct = new JLabel();
311
		return labelStruct;
312
	}
313
	
314
	private JLabel getLabelTileSize() {
315
		if (labelTileSize == null)
316
			labelTileSize = new JLabel();
317
		return labelTileSize;
318
	}
319
	
320
	private JLabel getLabelWMSTileSize() {
321
		if (labelWMSTileSize == null)
322
			labelWMSTileSize = new JLabel();
323
		return labelWMSTileSize;
324
	}
325

  
326
	/**
327
	 * Establece los valores por defecto de la Cache
328
	 */
329
	public void initializeDefaults() {
330
		getTextFieldCacheSize().setValue(Configuration.getDefaultValue("tilecache_size"));
331
		getTextFieldTileSize().setValue(Configuration.getDefaultValue("tilesize"));
332
		getTextFieldWMSTileSize().setValue(Configuration.getDefaultValue("tilesizewms"));
333
		getTextFieldLevels().setValue(Configuration.getDefaultValue("tile_levels"));
334
		getTextFieldPath().setText(Configuration.getDefaultValue("path_tilecache").toString());
335
		String struct = (String) Configuration.getDefaultValue("cache_struct");
336
		if(struct != null) {
337
			for (int i = 0; i < getComboBoxStruct().getItemCount(); i++)
338
				if (getComboBoxStruct().getItemAt(i).toString().equals(struct.toString())) {
339
					getComboBoxStruct().setSelectedIndex(i);
340
					break;
341
				}
342
		}
343
	}
344

  
345
	/**
346
	 * Establece los valores que ha definido el usuario de la Cache
347
	 */
348
	public void initializeValues() {
349
		getTextFieldCacheSize().setValue(Configuration.getValue("tilecache_size", Integer.valueOf(TileCacheLibrary.MAX_CACHE_SIZE)));
350
		getTextFieldTileSize().setValue(Configuration.getValue("tilesize", Integer.valueOf(TileCacheLibrary.DEFAULT_TILEWIDTH)));
351
		getTextFieldWMSTileSize().setValue(Configuration.getValue("tilesizewms", TILE_SIZE_WMS));
352
		getTextFieldLevels().setValue(Configuration.getValue("tile_levels", Integer.valueOf(TileCacheLibrary.DEFAULT_LEVELS)));
353
		getTextFieldPath().setText(Configuration.getValue("path_tilecache", RasterLibrary.pathTileCache));
354
		String struct = Configuration.getValue("cache_struct", TileCacheLibrary.DEFAULT_STRUCTURE);
355
		if(struct != null) {
356
			for (int i = 0; i < getComboBoxStruct().getItemCount(); i++)
357
				if (getComboBoxStruct().getItemAt(i).toString().equals(struct.toString())) {
358
					getComboBoxStruct().setSelectedIndex(i);
359
					break;
360
				}
361
		}
362
	}
363

  
364
	/**
365
	 * Guarda los valores de la cache establecidos por el usuario
366
	 */
367
	public void storeValues() {
368
		Integer tilecachesize = null;
369
		try {
370
			String s = getTextFieldCacheSize().getText().replaceAll(",", "");
371
			tilecachesize = new Integer(s);
372
			Configuration.setValue("tilecache_size", tilecachesize);
373
		} catch (NumberFormatException e)  {
374
			
375
		}
376
		
377
		Integer tilesize = null;
378
		try {
379
			String s = getTextFieldTileSize().getText().replaceAll(",", "");
380
			tilesize = new Integer(s);
381
			Configuration.setValue("tilesize", tilesize);
382
		} catch (NumberFormatException e)  {
383
			
384
		}
385
		
386
		Integer tilesizewms = null;
387
		try {
388
			String s = getTextFieldWMSTileSize().getText().replaceAll(",", "");
389
			tilesizewms = new Integer(s);
390
			Configuration.setValue("tilesizewms", tilesizewms);
391
		} catch (NumberFormatException e)  {
392
			
393
		}
394
		
395
		Integer tilelevels = null;
396
		try {
397
			String s = getTextFieldLevels().getText().replaceAll(",", "");
398
			tilelevels = new Integer(s);
399
			Configuration.setValue("tile_levels", tilelevels);
400
		} catch (NumberFormatException e)  {
401
			
402
		}
403
		
404
		Configuration.setValue("cache_struct", getComboBoxStruct().getSelectedItem() != null ? getComboBoxStruct().getSelectedItem().toString() : TileCacheLibrary.DEFAULT_STRUCTURE);
405
		Configuration.setValue("path_tilecache", getTextFieldPath().getText());
406
	}
407

  
408
	public void actionPerformed(ActionEvent e) {
409
		String path = getTextFieldPath().getText();
410
		IWindow parent = PluginServices.getMDIManager().getActiveWindow();
411
		IWindow[] wList = PluginServices.getMDIManager().getAllWindows();
412
		for (int i = 0; i < wList.length; i++) {
413
			if(wList[i] instanceof DlgPreferences)
414
				parent = wList[i];
415
		}
416
		
417
		if(CacheExtension.messageBoxYesOrNot(PluginServices.getText(this, "remove_directory") + "<BR>" + path, parent)) {
418
			File f = new File(path);
419
			if(f.exists()) {
420
				if(!deleteDirectory(f)) {
421
					CacheExtension.messageBoxError("open_files", parent);
422
				}
423
			}else
424
				CacheExtension.messageBoxError("path_not_exists", parent);
425
		}
426
	}
427

  
428
	public boolean deleteDirectory(File directory) {  
429
		File[] files = directory.listFiles();  
430
		for(int i = 0; i < files.length; i++) {  
431
			if(files[i].isDirectory()) {  
432
				this.deleteDirectory(files[i]);  
433
			} else {  
434
				files[i].delete();  
435
			}  
436
		}  
437
		return directory.delete();  
438
	}  
439
}
0 440

  
org.gvsig.raster.tilecache/tags/buildNumber_29/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.app/src/main/java/org/gvsig/raster/tilecache/app/Configuration.java
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.tilecache.app;
23

  
24
import java.util.ArrayList;
25
import java.util.HashMap;
26
import java.util.Iterator;
27

  
28
import org.gvsig.andami.PluginServices;
29
import org.gvsig.raster.fmap.layers.IConfiguration;
30
import org.gvsig.utils.XMLEntity;
31

  
32
/**
33
 * La clase <code>Configuration</code> sirve para poder leer y escribir valores en el entorno
34
 * de raster a nivel de configuraci?n. Para leer o escribir hay que usar los
35
 * metodos getValue y setValue, estos metodos lanzan eventos en el caso de
36
 * cambiar el valor que habia establecido. Forma de uso:<p>
37
 *
38
 * En la lectura es recomendable pasar un valor por defecto en el get, para que
39
 * si no existe o si existe pero no corresponde el tipo de datos devolvera el
40
 * valor por defecto<p>
41
 *
42
 * <code>Boolean valor = Configuration.getValue("valorBooleano", Boolean.valueOf(true));</code><p>
43
 *
44
 * <code>Configuration.setValue("valorBooleano", Boolean.valueOf(false));</code><p>
45
 *
46
 * Solo se pueden usar los siguientes tipos de datos:<br>
47
 *  - <b>Boolean</b>, <b>Double</b>, <b>Float</b>, <b>Integer</b>, <b>Long</b>
48
 *  y <b>String</b>.<p>
49
 *
50
 * Otra funcionalidad que tiene, es que puedes agregar un manejador de eventos
51
 * para controlar los cambios de las variables y actuar en consecuencia si cambia
52
 * la que deseas.
53
 *
54
 * @version 07/12/2007
55
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
56
 */
57
public class Configuration implements IConfiguration {
58
	static private Configuration singleton              = new Configuration();
59
	private ArrayList<ConfigurationListener>            
60
	                             actionCommandListeners = new ArrayList<ConfigurationListener>();
61
	private XMLEntity            xml                    = null;
62
	private HashMap<String, Object>
63
	                             hashMap                = new HashMap<String, Object>();
64

  
65
	/**
66
	 * Constructor privado. Nos aseguramos de que nadie pueda crear una instancia
67
	 * desde fuera, la configuraci?n es ?nica para todos.
68
	 */
69
	private Configuration() {
70
		try {
71
			PluginServices ps = PluginServices.getPluginServices("org.gvsig.raster.tilecache.app");
72
			xml = ps.getPersistentXML();
73
		} catch (NullPointerException e) {
74
			//No est? inicializado Configuration
75
			xml = new XMLEntity();
76
		}
77
	}
78

  
79
	/**
80
	 * Devuelve un valor Boolean para el key especificado
81
	 * @param key
82
	 * @param defaultValue
83
	 * @return
84
	 */
85
	static public Boolean getValue(String key, Boolean defaultValue) {
86
		singleton.saveDefaultValue(key, defaultValue);
87
		try {
88
			return Boolean.valueOf(getXMLEntity().getStringProperty(key));
89
		} catch (Exception e) {
90
		}
91
		try {
92
			getXMLEntity().putProperty(key, defaultValue.booleanValue());
93
		} catch(NullPointerException e) {
94
			//No est? inicializada la configuraci?n. Devuelve el default
95
		}
96
		return defaultValue;
97
	}
98

  
99
	/**
100
	 * Devuelve un valor Double para el key especificado
101
	 * @param key
102
	 * @param defaultValue
103
	 * @return
104
	 */
105
	static public Double getValue(String key, Double defaultValue) {
106
		singleton.saveDefaultValue(key, defaultValue);
107
		try {
108
			return Double.valueOf(getXMLEntity().getStringProperty(key));
109
		} catch (Exception e) {
110
		}
111
		getXMLEntity().putProperty(key, defaultValue.doubleValue());
112
		return defaultValue;
113
	}
114

  
115
	/**
116
	 * Devuelve un valor Float para el key especificado
117
	 * @param key
118
	 * @param defaultValue
119
	 * @return
120
	 */
121
	static public Float getValue(String key, Float defaultValue) {
122
		singleton.saveDefaultValue(key, defaultValue);
123
		try {
124
			return Float.valueOf(getXMLEntity().getStringProperty(key));
125
		} catch (Exception e) {
126
		}
127
		getXMLEntity().putProperty(key, defaultValue.floatValue());
128
		return defaultValue;
129
	}
130

  
131
	/**
132
	 * Devuelve un valor Integer para el key especificado
133
	 * @param key
134
	 * @param defaultValue
135
	 * @return
136
	 */
137
	static public Integer getValue(String key, Integer defaultValue) {
138
		singleton.saveDefaultValue(key, defaultValue);
139
		try {
140
			return Integer.valueOf(getXMLEntity().getStringProperty(key));
141
		} catch (Exception e) {
142
		}
143
		getXMLEntity().putProperty(key, defaultValue.intValue());
144
		return defaultValue;
145
	}
146

  
147
	/**
148
	 * Devuelve un valor Long para el key especificado
149
	 * @param key
150
	 * @param defaultValue
151
	 * @return
152
	 */
153
	static public Long getValue(String key, Long defaultValue) {
154
		singleton.saveDefaultValue(key, defaultValue);
155
		try {
156
			return Long.valueOf(getXMLEntity().getStringProperty(key));
157
		} catch (Exception e) {
158
		}
159
		getXMLEntity().putProperty(key, defaultValue.longValue());
160
		return defaultValue;
161
	}
162

  
163
	/**
164
	 * Devuelve un valor String para el key especificado
165
	 * @param key
166
	 * @param defaultValue
167
	 * @return
168
	 */
169
	static public String getValue(String key, String defaultValue) {
170
		singleton.saveDefaultValue(key, defaultValue);
171
		try {
172
			return getXMLEntity().getStringProperty(key);
173
		} catch (Exception e) {
174
		}
175
		getXMLEntity().putProperty(key, defaultValue);
176
		return defaultValue;
177
	}
178

  
179
	/**
180
	 * Guarda el valor por defecto en caso de que no exista
181
	 * @param key
182
	 * @param defaultValue
183
	 */
184
	private void saveDefaultValue(String key, Object defaultValue) {
185
		if (hashMap.get(key) == null)
186
			hashMap.put(key, defaultValue);
187
	}
188

  
189
	/**
190
	 * Devuelve el valor por defecto de un key
191
	 * @param key
192
	 * @return
193
	 */
194
	static public Object getDefaultValue(String key) {
195
		return singleton.hashMap.get(key);
196
	}
197

  
198
	/**
199
	 * Guarda en la configuracion el Objeto pasado por parametro asociado a dicho
200
	 * key
201
	 * @param key
202
	 * @param value
203
	 */
204
	private void putProperty(String key, Object value) {
205
		if (Integer.class.isInstance(value)) {
206
			getXMLEntity().putProperty(key, ((Integer) value).intValue());
207
			return;
208
		}
209
		if (Double.class.isInstance(value)) {
210
			getXMLEntity().putProperty(key, ((Double) value).doubleValue());
211
			return;
212
		}
213
		if (Float.class.isInstance(value)) {
214
			getXMLEntity().putProperty(key, ((Float) value).floatValue());
215
			return;
216
		}
217
		if (Boolean.class.isInstance(value)) {
218
			getXMLEntity().putProperty(key, ((Boolean) value).booleanValue());
219
			return;
220
		}
221
		if (Long.class.isInstance(value)) {
222
			getXMLEntity().putProperty(key, ((Long) value).longValue());
223
			return;
224
		}
225
		if (String.class.isInstance(value)) {
226
			getXMLEntity().putProperty(key, (String) value);
227
			return;
228
		}
229
		getXMLEntity().putProperty(key, value);
230
	}
231

  
232
	/**
233
	 * Establece un valor en la configuracion
234
	 * @param uri
235
	 * @param value
236
	 */
237
	static public void setValue(String key, Object value) {
238
		if (value == null) {
239
			getXMLEntity().remove(key);
240
			singleton.callConfigurationChanged(key, value);
241
			return;
242
		}
243

  
244
		String oldValue = getValue(key, value.toString());
245

  
246
		singleton.putProperty(key, value);
247

  
248
		if (!oldValue.equals(value.toString()))
249
			singleton.callConfigurationChanged(key, value);
250
	}
251

  
252
	/**
253
	 * A?adir un listener a la lista de eventos
254
	 * @param listener
255
	 */
256
	static public void addValueChangedListener(ConfigurationListener listener) {
257
		if (!singleton.actionCommandListeners.contains(listener))
258
			singleton.actionCommandListeners.add(listener);
259
	}
260

  
261
	/**
262
	 * Borrar un listener de la lista de eventos
263
	 * @param listener
264
	 */
265
	static public void removeValueChangedListener(ConfigurationListener listener) {
266
		singleton.actionCommandListeners.remove(listener);
267
	}
268

  
269
	/**
270
	 * Invocar a los eventos asociados al componente
271
	 */
272
	private void callConfigurationChanged(String key, Object value) {
273
		Iterator<ConfigurationListener> iterator = actionCommandListeners.iterator();
274
		while (iterator.hasNext()) {
275
			ConfigurationListener listener = iterator.next();
276
			listener.actionConfigurationChanged(new ConfigurationEvent(this, key, value));
277
		}
278
	}
279

  
280
	/**
281
	 * Devuelve una instancia unica al XMLEntity de Configuration
282
	 * @return
283
	 */
284
	static private XMLEntity getXMLEntity() {
285
		return singleton.xml;
286
	}
287
	
288
	/**
289
	 * Devuelve una instancia al unico objeto de configuraci?n que puede existir.
290
	 * @return
291
	 */
292
	static public Configuration getSingleton() {
293
		return singleton;
294
	}
295

  
296
	/*
297
	 * (non-Javadoc)
298
	 * @see org.gvsig.fmap.raster.conf.IConfiguration#getValueBoolean(java.lang.String, java.lang.Boolean)
299
	 */
300
	public Boolean getValueBoolean(String name, Boolean defaultValue) {
301
		return Configuration.getValue(name, defaultValue);
302
	}
303

  
304
	/*
305
	 * (non-Javadoc)
306
	 * @see org.gvsig.fmap.raster.conf.IConfiguration#getValueString(java.lang.String, java.lang.String)
307
	 */
308
	public String getValueString(String name, String defaultValue) {
309
		return Configuration.getValue(name, defaultValue);
310
	}
311

  
312
	/*
313
	 * (non-Javadoc)
314
	 * @see org.gvsig.fmap.raster.conf.IConfiguration#getValueDouble(java.lang.String, java.lang.Double)
315
	 */
316
	public Double getValueDouble(String name, Double defaultValue) {
317
		return Configuration.getValue(name, defaultValue);
318
	}
319

  
320
	/*
321
	 * (non-Javadoc)
322
	 * @see org.gvsig.fmap.raster.conf.IConfiguration#getValueFloat(java.lang.String, java.lang.Float)
323
	 */
324
	public Float getValueFloat(String name, Float defaultValue) {
325
		return Configuration.getValue(name, defaultValue);
326
	}
327

  
328
	/*
329
	 * (non-Javadoc)
330
	 * @see org.gvsig.fmap.raster.conf.IConfiguration#getValueInteger(java.lang.String, java.lang.Integer)
331
	 */
332
	public Integer getValueInteger(String name, Integer defaultValue) {
333
		return Configuration.getValue(name, defaultValue);
334
	}
335

  
336
	/*
337
	 * (non-Javadoc)
338
	 * @see org.gvsig.fmap.raster.conf.IConfiguration#getValueLong(java.lang.String, java.lang.Long)
339
	 */
340
	public Long getValueLong(String name, Long defaultValue) {
341
		return Configuration.getValue(name, defaultValue);
342
	}
343
}
0 344

  
org.gvsig.raster.tilecache/tags/buildNumber_29/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.app/src/main/java/org/gvsig/raster/tilecache/app/ConfigurationEvent.java
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.tilecache.app;
23

  
24
import java.util.EventObject;
25
/**
26
 * Estado del evento de configuraci?n para las preferencias de Raster.
27
 * 
28
 * @version 26/02/2008
29
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
30
 */
31
public class ConfigurationEvent extends EventObject {
32
	private static final long serialVersionUID = 7016236098872059L;
33
	private String key;
34
	private Object value;
35

  
36
	/**
37
	 * Constructor de un ConfigurationEvent
38
	 * @param source
39
	 * @param key
40
	 * @param value
41
	 */
42
	public ConfigurationEvent(Object source, String key, Object value) {
43
		super(source);
44
		this.key = key;
45
		this.value = value;
46
	}
47

  
48
	/**
49
	 * @return the key
50
	 */
51
	public String getKey() {
52
		return key;
53
	}
54

  
55
	/**
56
	 * @return the value
57
	 */
58
	public Object getValue() {
59
		return value;
60
	}
61
}
0 62

  
org.gvsig.raster.tilecache/tags/buildNumber_29/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.app/src/main/java/org/gvsig/raster/tilecache/app/ConfigurationListener.java
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.tilecache.app;
23

  
24
import java.util.EventListener;
25

  
26
public interface ConfigurationListener extends EventListener {
27
	/**
28
	 * Evento que se dispara cuando cambia un valor de configuracion.
29
	 * @param e
30
	 */
31
	public void actionConfigurationChanged(ConfigurationEvent e);
32
}
0 33

  
org.gvsig.raster.tilecache/tags/buildNumber_29/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.app/src/main/java/org/gvsig/raster/tilecache/app/CacheExtension.java
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.tilecache.app;
23

  
24
import java.awt.Component;
25
import java.util.prefs.Preferences;
26

  
27
import javax.swing.JOptionPane;
28

  
29
import org.gvsig.about.AboutManager;
30
import org.gvsig.about.AboutParticipant;
31
import org.gvsig.andami.IconThemeHelper;
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.andami.plugins.Extension;
34
import org.gvsig.app.ApplicationLocator;
35
import org.gvsig.app.ApplicationManager;
36
import org.gvsig.app.project.documents.view.toc.ITocItem;
37
import org.gvsig.fmap.dal.coverage.RasterLibrary;
38
import org.gvsig.fmap.mapcontext.layers.FLayer;
39
import org.gvsig.raster.cache.tile.TileCache;
40
import org.gvsig.raster.cache.tile.TileCacheLibrary;
41
import org.gvsig.raster.cache.tile.TileCacheLocator;
42
import org.gvsig.tools.ToolsLocator;
43
import org.gvsig.tools.extensionpoint.ExtensionPoint;
44
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
45

  
46

  
47
/**
48
 * Tile cache extension for gvSIG
49
 * 
50
 * @author Nacho Brodin (nachobrodin@gmail.com)
51
 */
52
public class CacheExtension extends Extension implements ConfigurationListener {
53

  
54
	/*
55
	 * (non-Javadoc)
56
	 * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
57
	 */
58
	public void execute(String actionCommand) {
59
		
60
	}
61

  
62
	private void addAboutInfo() {
63
        ApplicationManager application = ApplicationLocator.getManager();
64
        
65
        AboutManager about = application.getAbout();
66
        about.addDeveloper("PRODEVELOP", getClass().getClassLoader()
67
            .getResource("about/tilecache-about.html"), 2);
68

  
69
        AboutParticipant participant = about.getDeveloper("PRODEVELOP");
70
        participant.addContribution(
71
            "Cach? de teselas",
72
            "Cach? de teselas para fuentes de datos r?ster y remotas", 
73
            2011,1,1, 
74
            2011,1,30
75
        );      
76
    }
77

  
78
	/*
79
	 * (non-Javadoc)
80
	 * @see com.iver.andami.plugins.IExtension#initialize()
81
	 */
82
	public void initialize() {
83
		IconThemeHelper.registerIcon(null, "pref-tilecache-icon", this);
84
		
85
		Configuration.addValueChangedListener(this);
86
		Preferences prefs = Preferences.userRoot().node("gvsig.foldering");
87
		prefs.put("DataFolder", System.getProperty("user.home"));
88
		
89
		ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
90
		ExtensionPoint point = extensionPoints.add("AplicationPreferences");
91
		point.append("TileCachePreferences", "", TileCachePreferences.class);
92
		
93
		TileCacheLibrary.DEFAULT_TILEWIDTH = Configuration.getValue("tilesize", Integer.valueOf(TileCacheLibrary.DEFAULT_TILEWIDTH));
94
		TileCacheLibrary.DEFAULT_TILEHEIGHT = TileCacheLibrary.DEFAULT_TILEWIDTH;
95
		
96
		TileCacheLibrary.ALTERNATIVE_TILESIZE = Configuration.getValue("tilesizewms", Integer.valueOf(TileCacheLibrary.ALTERNATIVE_TILESIZE));
97
	}
98
	
99
	/*
100
	 * (non-Javadoc)
101
	 * @see com.iver.andami.plugins.IExtension#isEnabled()
102
	 */
103
	public boolean isEnabled() {
104
		return false;
105
	}
106

  
107
	public boolean isVisible() {
108
		return false;
109
	}
110

  
111
	/*
112
	 * (non-Javadoc)
113
	 * @see org.gvsig.raster.util.ConfigurationListener#actionConfigurationChanged(org.gvsig.raster.util.ConfigurationEvent)
114
	 */
115
	public void actionConfigurationChanged(ConfigurationEvent e) {
116

  
117
		if (e.getKey().equals("path_tilecache")) {
118
			if(e.getValue() instanceof String) {
119
				String value = (String)e.getValue();
120
				if(value != null && value.compareTo("") != 0) {
121
					RasterLibrary.pathTileCache =  (String)e.getValue();
122
					TileCache tc = TileCacheLocator.getManager().getTileCache(RasterLibrary.pathTileCache);
123
					tc.updateBaseDirectory(RasterLibrary.pathTileCache);
124
				}
125
			}
126
			return;
127
		}
128
		
129
		if (e.getKey().equals("tile_levels")) {
130
			if(e.getValue() instanceof String)
131
				try {
132
					TileCacheLibrary.DEFAULT_LEVELS = new Integer((String) e
133
							.getValue()).intValue();
134
				} catch (NumberFormatException exc) {
135
					//Valor por defecto en la cache
136
				}
137
			if(e.getValue() instanceof Integer)
138
				TileCacheLibrary.DEFAULT_LEVELS = ((Integer) e.getValue()).intValue();
139
			return;
140
		}
141
		
142
		if (e.getKey().equals("tilesize")) {
143
			if(e.getValue() instanceof String) {
144
				try {
145
					String text = (String) e.getValue();
146
					text = text.replaceAll("\\.", "");
147
					text = text.replaceAll(",", "\\.");
148
					TileCacheLibrary.DEFAULT_TILEWIDTH = new Integer(text).intValue();
149
					TileCacheLibrary.DEFAULT_TILEHEIGHT = TileCacheLibrary.DEFAULT_TILEWIDTH;
150
				} catch (NumberFormatException exc) {
151
					//Valor por defecto en la cache
152
				}
153
			}
154
			if(e.getValue() instanceof Integer) {
155
				TileCacheLibrary.DEFAULT_TILEWIDTH = ((Integer) e.getValue()).intValue();
156
				TileCacheLibrary.DEFAULT_TILEHEIGHT = TileCacheLibrary.DEFAULT_TILEWIDTH;
157
			}
158
			return;
159
		}
160
		
161
		if (e.getKey().equals("tilesizewms")) {
162
			if(e.getValue() instanceof String) {
163
				try {
164
					String text = (String) e.getValue();
165
					text = text.replaceAll("\\.", "");
166
					text = text.replaceAll(",", "\\.");
167
					TileCacheLibrary.ALTERNATIVE_TILESIZE = new Integer(text).intValue();
168
				} catch (NumberFormatException exc) {
169
					//Valor por defecto en la cache
170
				}
171
			}
172
			if(e.getValue() instanceof Integer) {
173
				TileCacheLibrary.ALTERNATIVE_TILESIZE = ((Integer) e.getValue()).intValue();
174
			}
175
			return;
176
		}
177
		
178
		if (e.getKey().equals("tilecache_size")) {
179
			if(e.getValue() instanceof String)
180
				try {
181
					String text = (String) e.getValue();
182
					text = text.replaceAll("\\.", "");
183
					text = text.replaceAll(",", "\\.");
184
					TileCacheLibrary.MAX_CACHE_SIZE = new Integer((String) e
185
							.getValue()).intValue();
186
				} catch (NumberFormatException exc) {
187
					//Valor por defecto en la cache
188
				}
189
			if(e.getValue() instanceof Integer)
190
				TileCacheLibrary.MAX_CACHE_SIZE = ((Integer) e.getValue()).intValue();
191
			return;
192
		}
193
		
194
		if (e.getKey().equals("cache_struct")) {
195
			if(e.getValue() instanceof String)
196
				TileCacheLibrary.DEFAULT_STRUCTURE = (String)e.getValue();
197
			return;
198
		}
199
	}
200

  
201
	/*
202
	 * (non-Javadoc)
203
	 * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
204
	 */
205
	public void execute(ITocItem item, FLayer[] selectedItems) {
206

  
207
	}
208

  
209
	public void postInitialize() {
210
		super.postInitialize();
211
	//		storeLibrary.postInitialize();
212
		addAboutInfo();
213
	}
214
	
215
	/**
216
	 * Shows an error dialog with a text and a accept button 
217
	 * @param msg Message to show in the dialog
218
	 * @param parentWindow Parent window
219
	 */
220
	public static void messageBoxError(String msg, Object parentWindow){
221
		String string = PluginServices.getText(parentWindow, "accept");
222
		Object[] options = {string};
223
		JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(),
224
					"<html>" + PluginServices.getText(parentWindow, msg).replaceAll("\n", "<br>") + "</html>",
225
					PluginServices.getText(parentWindow, "confirmacion"),
226
					JOptionPane.OK_OPTION,
227
					JOptionPane.ERROR_MESSAGE,
228
					null,
229
					options,
230
					string);
231
	}
232
	
233
	/**
234
	 * Shows an error dialog with a text and a YesOrNot button 
235
	 * @param msg Message to show in the dialog.
236
	 * @param parentWindow Parent window
237
	 * @return Selected button by the button. Returns true if the user has selected Yes
238
	 * and false if he has selected No. 
239
	 */
240
	public static boolean messageBoxYesOrNot(String msg, Object parentWindow){
241
		String string1 = PluginServices.getText(parentWindow, "yes");
242
		String string2 = PluginServices.getText(parentWindow, "no");
243
		Object[] options = {string1, string2};
244
		int n = JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(),
245
					"<html>" + PluginServices.getText(parentWindow, msg).replaceAll("\n", "<br>") + "</html>",
246
					PluginServices.getText(parentWindow, "confirmacion"),
247
					JOptionPane.YES_NO_OPTION,
248
					JOptionPane.QUESTION_MESSAGE,
249
					null,
250
					options,
251
					string1);
252
		if (n == JOptionPane.YES_OPTION)
253
			return true;
254
		else
255
			return false;
256
	}
257
}
0 258

  
org.gvsig.raster.tilecache/tags/buildNumber_29/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.app/src/main/resources/text.properties
1
WMTSLayer=Capa WMTS
2
select_info_formats=Seleccionar formatos de texto (Info)
3
wmts_properties=Propiedades WMTS
4
wmts_cant_connect=No ha sido posible realizar la conexi\u00f3n con el WMTS
5
wmts_not_queryable=Este servidor no acepta peticiones de este tipo
6
wmts_server_error=Error del servidor WMTS
7
wmts_transparency=Transparencia
8
WMTSLayer=Capa WMTS
9
fit_WMTS_layer=Ajustar capa WMTS
0 10

  
org.gvsig.raster.tilecache/tags/buildNumber_29/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.app/src/main/resources/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<depends plugin-name="org.gvsig.app" />
4
	<libraries library-dir="lib"/>
5
	<resourceBundle name="text"/>
6
	<extensions>
7
		<extension class-name="org.gvsig.raster.tilecache.app.CacheExtension"
8
			description="Tile Cache support"
9
			active="true"
10
			priority="1">
11
		</extension>
12
	</extensions>
13
</plugin-config>
0 14

  
org.gvsig.raster.tilecache/tags/buildNumber_29/org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.app/src/main/resources/install/install.xml
1
<project name="org.gvsig.plugin1" default="main" basedir=".">
2
	<target name="main" depends="copy_files, link1, link2"/>
3
    <target name="copy_files">
4
    	<copy todir="${gvsig_dir}">
5
    		<fileset dir="./files" includes="**"/>
6
		</copy>
7
	</target>
8
	<target name="link1" depends="gdal-properties" if="gdal.link1">
9
	  <exec executable="ln" >
10
      <arg value="-s"/>
11
      <arg value="${gdal.so}"/>
12
      <arg value="${gdal.link1}"/>
13
	  </exec>
14
	</target>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff