Revision 1350

View differences:

org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.algorithm/org.gvsig.raster.tools.algorithm.swing/org.gvsig.raster.tools.algorithm.swing.impl/src/test/java/org/gvsig/raster/tools/algorithm/swing/impl/TestLayerDatatypePanel.java
14 14

  
15 15
	public TestLayerDatatypePanel() {
16 16
		new DefaultLibrariesInitializer().fullInitialize(true);
17
		ui = new LayerDatatypePanelImpl(null, "BYTE");
17
		ui = new LayerDatatypePanelImpl(null, "BYTE", "Este es el nombre de la capa");
18 18
		frame.getContentPane().add(ui);
19 19
		frame.setSize(w, h);
20 20
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.algorithm/org.gvsig.raster.tools.algorithm.swing/org.gvsig.raster.tools.algorithm.swing.impl/src/main/java/org/gvsig/raster/tools/algorithm/swing/impl/layerdatatype/LayerDatatypePanelImpl.java
49 49
	private JComboBox                       comboDec2Int         = null;
50 50
	private JComboBox                       comboBig2Small       = null;
51 51
	private String                          inputDatatype        = null;
52
	private String                          layerName            = null;
52 53
	private CreateNewLayerPanel             newLayerPanel        = null;
53 54
	private Object                          inputStore           = null;
54 55
	
55
	public LayerDatatypePanelImpl(Object inputStore, String inputDatatype) {
56
	public LayerDatatypePanelImpl(Object inputStore, String inputDatatype, String layerName) {
56 57
		this.inputStore = inputStore;
58
		this.layerName = layerName;
57 59
		this.inputDatatype = inputDatatype;
58 60
		init();
59 61
	}
......
67 69
		gridBagConstraints1.insets = new java.awt.Insets(0, 0, 2, 0);
68 70
		gridBagConstraints1.gridx = 0;
69 71
		gridBagConstraints1.gridy = 0;
70
		add(getInputs(), gridBagConstraints1);
72
		add(getLayerPanel(), gridBagConstraints1);
71 73
		
74
		gridBagConstraints1.gridy = 1;
75
		add(getInputsPanel(), gridBagConstraints1);
76
		
72 77
		gridBagConstraints1.insets = new java.awt.Insets(0, 2, 0, 2);
73
		gridBagConstraints1.gridy = 1;
78
		gridBagConstraints1.gridy = 2;
74 79
		add((JComponent)getCreateNewLayerPanel(), gridBagConstraints1);
75 80
		
76 81
		gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
77 82
		gridBagConstraints1.weighty = 1;
78
		gridBagConstraints1.gridy = 2;
83
		gridBagConstraints1.gridy = 3;
79 84
		add(new JPanel(), gridBagConstraints1);
80 85
	}
81 86
	
82
	private JPanel getInputs() {
87
	private JPanel getLayerPanel() {
83 88
		JPanel p = new JPanel();
89
		p.setBorder(BorderFactory.createTitledBorder("Layer"));
90
		p.setLayout(new GridBagLayout());
91
		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
92
		gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
93
		gridBagConstraints1.weightx = 1;
94
		gridBagConstraints1.insets = new java.awt.Insets(0, 0, 2, 0);
95
		
96
		gridBagConstraints1.gridx = 0;
97
		gridBagConstraints1.gridy = 0;
98
		p.add(new JLabel(layerName), gridBagConstraints1);
99
		
100
		return p;
101
	}
102
	
103
	private JPanel getInputsPanel() {
104
		JPanel p = new JPanel();
84 105
		p.setBorder(BorderFactory.createTitledBorder("Datatype"));
85 106
		p.setLayout(new GridBagLayout());
86 107
		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.algorithm/org.gvsig.raster.tools.algorithm.swing/org.gvsig.raster.tools.algorithm.swing.impl/src/main/java/org/gvsig/raster/tools/algorithm/swing/impl/DefaultAlgorithmSwingManager.java
91 91
		return new MaskThresholdPanelImpl();
92 92
	}
93 93

  
94
	public BaseAlgorithmPanel createLayerDatatypePanel(Object inputStore, String inputDatatype) {
95
		return new LayerDatatypePanelImpl(inputStore, inputDatatype);
94
	public BaseAlgorithmPanel createLayerDatatypePanel(Object inputStore, String inputDatatype, String layerName) {
95
		return new LayerDatatypePanelImpl(inputStore, inputDatatype, layerName);
96 96
	}
97 97

  
98 98
}
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.algorithm/org.gvsig.raster.tools.algorithm.swing/org.gvsig.raster.tools.algorithm.swing.api/src/main/java/org/gvsig/raster/tools/algorithm/swing/AlgorithmSwingManager.java
62 62
     */
63 63
    public MaskThresholdPanel createMaskThresholdPanel();
64 64
    
65
    public BaseAlgorithmPanel createLayerDatatypePanel(Object inputStore, String inputDatatype);
65
    public BaseAlgorithmPanel createLayerDatatypePanel(Object inputStore, String inputDatatype, String layerName);
66 66

  
67 67
}
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.algorithm/org.gvsig.raster.tools.algorithm.layerdatatype/src/main/java/org/gvsig/raster/tools/algorithm/layerdatatype/LayerDatatypeProcess.java
69 69
	private NoData            shortNoData       = null;
70 70
	private NoData            intNoData         = null;
71 71
	private NoData            floatNoData       = null;
72
	private NoData            doubleNoData      = null;
73 72
	
74 73
	public static void registerParameters() {
75 74
		RASTER_STORE1 = RasterBaseAlgorithmLibrary.registerInputParameter(RASTER_STORE1, RasterDataStore.class);
......
101 100
				store.getBandCount(), Buffer.TYPE_INT);
102 101
		floatNoData = RasterLocator.getManager().getDataStructFactory().createDefaultNoData(
103 102
				store.getBandCount(), Buffer.TYPE_FLOAT);
104
		doubleNoData = RasterLocator.getManager().getDataStructFactory().createDefaultNoData(
105
				store.getBandCount(), Buffer.TYPE_DOUBLE);
106 103
	}
107 104

  
108 105
	public void process() throws ProcessInterruptedException {
109 106
		long t1 = new java.util.Date().getTime();
110 107
		insertLineLog(Messages.getText("layer_datatype"));
111
		int result = 1;
112 108
		try {
113 109
			if (store == null)
114 110
				throw new LayerDatatypeException("intput_not_valid");
......
134 130
			}
135 131
			double v = 0;
136 132
			
137
			for (int row = 0; row < buf.getHeight(); row++) {
138
				for (int col = 0; col < buf.getWidth(); col++) {
139
					for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
140
						switch (inDataType) {
141
						case Buffer.TYPE_BYTE:
142
							
143
							break;
144
						case Buffer.TYPE_SHORT:
145

  
146
							break;
147
						case Buffer.TYPE_INT:
148

  
149
							break;
150
						case Buffer.TYPE_FLOAT:
133
			
134
			switch (inDataType) {
135
			case Buffer.TYPE_BYTE:
136
				for (int row = 0; row < buf.getHeight(); row++) {
137
					for (int col = 0; col < buf.getWidth(); col++) {
138
						for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
139
							writePixelFromByte(row, col, iBand, sourceBuffer.getElemByte(row, col, iBand), buf);
140
						}
141
					}
142
					percent = (int)((row * 100) / buf.getHeight());
143
				}
144
				break;
145
			case Buffer.TYPE_SHORT:
146
				for (int row = 0; row < buf.getHeight(); row++) {
147
					for (int col = 0; col < buf.getWidth(); col++) {
148
						for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
149
							writePixelFromShort(row, col, iBand, sourceBuffer.getElemShort(row, col, iBand), buf);
150
						}
151
					}
152
					percent = (int)((row * 100) / buf.getHeight());
153
				}
154
				break;
155
			case Buffer.TYPE_INT:
156
				for (int row = 0; row < buf.getHeight(); row++) {
157
					for (int col = 0; col < buf.getWidth(); col++) {
158
						for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
159
							writePixelFromInt(row, col, iBand, sourceBuffer.getElemInt(row, col, iBand), buf);
160
						}
161
					}
162
					percent = (int)((row * 100) / buf.getHeight());
163
				}
164
				break;
165
			case Buffer.TYPE_FLOAT:
166
				for (int row = 0; row < buf.getHeight(); row++) {
167
					for (int col = 0; col < buf.getWidth(); col++) {
168
						for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
151 169
							v = getDecimalValue(sourceBuffer.getElemFloat(row, col, iBand), inDataType);
152
							break;
153
						case Buffer.TYPE_DOUBLE:
170
							writePixelFromDouble(row, col, iBand, v, buf);
171
						}
172
					}
173
					percent = (int)((row * 100) / buf.getHeight());
174
				}
175
				break;
176
			case Buffer.TYPE_DOUBLE:
177
				for (int row = 0; row < buf.getHeight(); row++) {
178
					for (int col = 0; col < buf.getWidth(); col++) {
179
						for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
154 180
							v = getDecimalValue(sourceBuffer.getElemDouble(row, col, iBand), inDataType);
155
							break;
181
							writePixelFromDouble(row, col, iBand, v, buf);
156 182
						}
157
						
158 183
					}
184
					percent = (int)((row * 100) / buf.getHeight());
159 185
				}
186
				break;
160 187
			}
161 188
			
162
			if(result != 0) {
163
				if (incrementableTask != null) {
164
					incrementableTask.processFinalize();
165
					setProgressActive(false);
166
				}
167
				messageBoxError("transformation_not_possible", this);
168
				return;
169
			}
170

  
189
			super.exportRaster(filename, 
190
					buf, 
191
					sourceBuffer.getStore().getCellSize(), 
192
					sourceBuffer.getStore().getExtent().getULX(), 
193
					sourceBuffer.getStore().getExtent().getULY());
194
			
171 195
			long t2 = new java.util.Date().getTime();
172 196
			milis = t2 - t1;
173 197
			
......
213 237
	private void writePixelFromShort(int row, int col, int band, short value, Buffer dst) {
214 238
		switch (dst.getDataType()) {
215 239
		case Buffer.TYPE_BYTE: 
240
			dst.setElem(row, col, band, (byte)value);
216 241
			if(value > Byte.MAX_VALUE) {
217 242
				switch (big2smal) {
218
				case 0:dst.setElem(row, col, band, (byte)value);break;
219 243
				case 1:dst.setElem(row, col, band, Byte.MAX_VALUE);break;
220 244
				case 2:dst.setElem(row, col, band, (Byte)byteNoData.getValue());break;
221 245
				}
222
			}
246
			} 
223 247
			break;
224 248
		case Buffer.TYPE_SHORT: dst.setElem(row, col, band, value);break;
225 249
		case Buffer.TYPE_INT: dst.setElem(row, col, band, (int)value);break;
......
231 255
	private void writePixelFromInt(int row, int col, int band, int value, Buffer dst) {
232 256
		switch (dst.getDataType()) {
233 257
		case Buffer.TYPE_BYTE: 
258
			dst.setElem(row, col, band, (byte)value);
234 259
			if(value > Byte.MAX_VALUE) {
235 260
				switch (big2smal) {
236
				case 0:dst.setElem(row, col, band, (byte)value);break;
237 261
				case 1:dst.setElem(row, col, band, Byte.MAX_VALUE);break;
238 262
				case 2:dst.setElem(row, col, band, (Byte)byteNoData.getValue());break;
239 263
				}
240 264
			}
241 265
			break;
242 266
		case Buffer.TYPE_SHORT:
267
			dst.setElem(row, col, band, (short)value);
243 268
			if(value > Short.MAX_VALUE) {
244 269
				switch (big2smal) {
245
				case 0:dst.setElem(row, col, band, (short)value);break;
246 270
				case 1:dst.setElem(row, col, band, Short.MAX_VALUE);break;
247 271
				case 2:dst.setElem(row, col, band, (Short)shortNoData.getValue());break;
248 272
				}
......
254 278
		}
255 279
	}
256 280
	
281
	private void writePixelFromDouble(int row, int col, int band, double value, Buffer dst) {
282
		switch (dst.getDataType()) {
283
		case Buffer.TYPE_BYTE: 
284
			dst.setElem(row, col, band, (byte)value);
285
			if(value > Byte.MAX_VALUE) {
286
				switch (big2smal) {
287
				case 1:dst.setElem(row, col, band, Byte.MAX_VALUE);break;
288
				case 2:dst.setElem(row, col, band, (Byte)byteNoData.getValue());break;
289
				}
290
			}
291
			break;
292
		case Buffer.TYPE_SHORT:
293
			dst.setElem(row, col, band, (short)value);
294
			if(value > Short.MAX_VALUE) {
295
				switch (big2smal) {
296
				case 1:dst.setElem(row, col, band, Short.MAX_VALUE);break;
297
				case 2:dst.setElem(row, col, band, (Short)shortNoData.getValue());break;
298
				}
299
			}
300
			break;
301
		case Buffer.TYPE_INT:
302
			dst.setElem(row, col, band, (int)value);
303
			if(value > Integer.MAX_VALUE) {
304
				switch (big2smal) {
305
				case 1:dst.setElem(row, col, band, Integer.MAX_VALUE);break;
306
				case 2:dst.setElem(row, col, band, (Integer)intNoData.getValue());break;
307
				}
308
			}
309
			break;
310
		case Buffer.TYPE_FLOAT:
311
			dst.setElem(row, col, band, (float)value);
312
			if(value > Float.MAX_VALUE) {
313
				switch (big2smal) {
314
				case 1:dst.setElem(row, col, band, Float.MAX_VALUE);break;
315
				case 2:dst.setElem(row, col, band, (Float)floatNoData.getValue());break;
316
				}
317
			}
318
			break;
319
		case Buffer.TYPE_DOUBLE: dst.setElem(row, col, band, (double)value);break;
320
		}
321
	}
322
	
257 323
	/*
258 324
	 * (non-Javadoc)
259 325
	 * @see org.gvsig.raster.tools.app.basic.raster.process.RasterProcess#getResult()
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.algorithm/org.gvsig.raster.tools.algorithm.maskthreshold/src/main/java/org/gvsig/raster/tools/algorithm/maskthreshold/MaskthresholdProcess.java
207 207
	 * @see org.gvsig.rastertools.RasterProcess#init()
208 208
	 */
209 209
	public void init() {
210
		inputStore = getParam(RASTER_STORE1) != null ? (RasterDataStore)getParam(RASTER_STORE1) : null; //M
210
		inputStore = getParam(RASTER_STORE1) != null ? (RasterDataStore)getParam(RASTER_STORE1) : null;
211 211
		operationStore = getParam(RASTER_STORE2) != null ? (RasterDataStore)getParam(RASTER_STORE2) : null; //Default Null
212 212
		outputStore = getParam(RASTER_STORE3) != null ? (RasterDataStore)getParam(RASTER_STORE3) : null; //Default Null
213 213
		
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.algorithm/pom.xml
99 99
        <module>org.gvsig.raster.tools.algorithm.base</module>
100 100
        <module>org.gvsig.raster.tools.algorithm.reproject</module>
101 101
        <module>org.gvsig.raster.tools.algorithm.maskthreshold</module>
102
        <module>org.gvsig.raster.tools.algorithm.layerdatatype</module>
102 103
    </modules>
103 104
</project>
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/MainWindow.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2011-2012 Prodevelop S.L
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 */
21
package org.gvsig.raster.tools.app.basic;
22

  
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27

  
28
import javax.swing.JComponent;
29

  
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.andami.ui.mdiManager.WindowInfo;
33
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
34
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
35

  
36

  
37
/**
38
 * Basic frame for a gvSIG <code>IWindow</code> object. This frame adds buttons 
39
 * of Cancel, Accept and others.
40
 * 
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 */
43
public class MainWindow extends DefaultButtonsPanel implements IWindow, ActionListener {
44
    
45
    private static final long  serialVersionUID = -4401123724140025094L;
46
    private ActionListener     listener         = null;
47
    private WindowInfo         info             = null;
48

  
49
    private Object profile = WindowInfo.EDITOR_PROFILE;
50

  
51
    public MainWindow(JComponent panel, JComponent preview, String title, int w, int h, ActionListener actionListener) {
52
    	this.listener = actionListener;
53
    	
54
    	setLayout(new GridBagLayout());
55
		GridBagConstraints gbc = new GridBagConstraints();
56
		gbc.fill = GridBagConstraints.BOTH;
57
		gbc.weightx = 1;
58
		gbc.weighty = 1;
59
		add(panel, gbc);
60
		
61
		if(preview != null) {
62
			gbc.anchor = GridBagConstraints.NORTH;
63
			gbc.fill = GridBagConstraints.NONE;
64
			gbc.weightx = 0;
65
			gbc.weighty = 0;
66
			gbc.gridx = 1;
67
			add(preview, gbc);
68
		}
69

  
70
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this);
71
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).addActionListener(this);
72
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this);
73
        
74
        info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE);
75
        info.setTitle(title);
76
        info.setWidth(w);
77
        info.setHeight(h);
78
    }
79

  
80
    public WindowInfo getWindowInfo() {
81
        return info;
82
    }
83

  
84
    public Object getWindowProfile() {
85
        return profile;
86
    }
87

  
88
    public void actionPerformed(ActionEvent e) {
89
    	if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) {
90
    		listener.actionPerformed(e);
91
    		PluginServices.getMDIManager().closeWindow(this);
92
    	}
93
    	
94
    	if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY)) {
95
    		listener.actionPerformed(e);
96
    	}
97
    	
98
    	if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL)) {
99
    		PluginServices.getMDIManager().closeWindow(this);
100
    	}
101
    }
102
}
0 103

  
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/colortable/ui/ColorTablePanel.java
334 334
		}catch (Exception e) {
335 335
			throw new ColorTableException(ColorTableException.MESSAGE_NOTLOADED);
336 336
		}
337
		getPreviewBasePanel().refreshPreview();
338 337
	}
339 338

  
340 339
	/**
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/layerdatatype/MainWindow.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2011-2012 Prodevelop S.L
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 */
21
package org.gvsig.raster.tools.app.basic.tool.layerdatatype;
22

  
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27

  
28
import javax.swing.JComponent;
29

  
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.andami.ui.mdiManager.WindowInfo;
33
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
34
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
35

  
36

  
37
/**
38
 * @author Nacho Brodin (nachobrodin@gmail.com)
39
 */
40
public class MainWindow extends DefaultButtonsPanel implements IWindow, ActionListener {
41
    
42
    private static final long  serialVersionUID = -4401123724140025094L;
43
    private ActionListener     listener         = null;
44
    private WindowInfo         info             = null;
45

  
46
    private Object profile = WindowInfo.EDITOR_PROFILE;
47

  
48
    public MainWindow(JComponent panel, JComponent preview, String title, int w, int h, ActionListener actionListener) {
49
    	this.listener = actionListener;
50
    	
51
    	setLayout(new GridBagLayout());
52
		GridBagConstraints gbc = new GridBagConstraints();
53
		gbc.fill = GridBagConstraints.BOTH;
54
		gbc.weightx = 1;
55
		gbc.weighty = 1;
56
		add(panel, gbc);
57
		
58
		if(preview != null) {
59
			gbc.anchor = GridBagConstraints.NORTH;
60
			gbc.fill = GridBagConstraints.NONE;
61
			gbc.weightx = 0;
62
			gbc.weighty = 0;
63
			gbc.gridx = 1;
64
			add(preview, gbc);
65
		}
66

  
67
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this);
68
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).addActionListener(this);
69
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this);
70
        
71
        info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE);
72
        info.setTitle(title);
73
        info.setWidth(w);
74
        info.setHeight(h);
75
    }
76

  
77
    public WindowInfo getWindowInfo() {
78
        return info;
79
    }
80

  
81
    public Object getWindowProfile() {
82
        return profile;
83
    }
84

  
85
    public void actionPerformed(ActionEvent e) {
86
    	if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) {
87
    		listener.actionPerformed(e);
88
    		PluginServices.getMDIManager().closeWindow(this);
89
    	}
90
    	
91
    	if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY)) {
92
    		listener.actionPerformed(e);
93
    	}
94
    	
95
    	if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL)) {
96
    		PluginServices.getMDIManager().closeWindow(this);
97
    	}
98
    }
99
}
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/layerdatatype/LayerDatatypeTocMenuEntry.java
22 22
package org.gvsig.raster.tools.app.basic.tool.layerdatatype;
23 23

  
24 24
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionListener;
25 26

  
26 27
import javax.swing.Icon;
27 28

  
......
38 39
import org.gvsig.raster.tools.algorithm.base.process.RasterProcess;
39 40
import org.gvsig.raster.tools.algorithm.swing.AlgorithmSwingLocator;
40 41
import org.gvsig.raster.tools.algorithm.swing.BaseAlgorithmPanel;
42
import org.gvsig.raster.tools.app.basic.MainWindow;
41 43
import org.gvsig.raster.tools.app.basic.RasterToolsUtil;
42 44
import org.gvsig.raster.tools.app.basic.raster.gui.IGenericToolBarMenuItem;
43 45

  
......
46 48
 *
47 49
 * @author Nacho Brodin (nachobrodin@gmail.com)
48 50
 */
49
public class LayerDatatypeTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem {
51
public class LayerDatatypeTocMenuEntry extends AbstractTocContextMenuAction 
52
	implements IGenericToolBarMenuItem, ActionListener {
50 53
	static private LayerDatatypeTocMenuEntry       singleton              = null;
51
	private MainWindow                          window                 = null;
52
	private BaseAlgorithmPanel                  panel                  = null;
53
	private FLyrRaster                          inputLayer             = null;
54
	private MainWindow                             window                 = null;
55
	private BaseAlgorithmPanel                     panel                  = null;
56
	private FLyrRaster                             inputLayer             = null;
54 57
	
55 58
	/**
56
	 * Nadie puede crear una instancia a esta clase ?nica, hay que usar el
57
	 * getSingleton()
59
	 * Nobody can instantiate this object. It's necessary to use getSingleton method
58 60
	 */
59 61
	private LayerDatatypeTocMenuEntry() {}
60 62

  
61 63
	/**
62
	 * Devuelve un objeto unico a dicha clase
64
	 * Gets a unique instance of this class
63 65
	 * @return
64 66
	 */
65
	static public LayerDatatypeTocMenuEntry getSingleton() {
67
	public static LayerDatatypeTocMenuEntry getSingleton() {
66 68
		if (singleton == null)
67 69
			singleton = new LayerDatatypeTocMenuEntry();
68 70
		return singleton;
......
148 150
		
149 151
		panel = AlgorithmSwingLocator.getSwingManager().createLayerDatatypePanel(
150 152
				inputLayer.getDataStore(), 
151
				getDataType(inputLayer));
153
				getDataType(inputLayer),
154
				inputLayer.getName());
152 155
		window = new MainWindow(panel.getComponent(), 
153 156
				null, 
154 157
				Messages.getText("change_datatype"), 
155
				320, 290, 
156
				null);
158
				350, 290, 
159
				this);
157 160
		
158 161
		RasterToolsUtil.addWindow(window);
159 162
	}
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/layerdatatype/ProcessEndActions.java
30 30
import org.gvsig.fmap.dal.DataManager;
31 31
import org.gvsig.fmap.dal.DataStore;
32 32
import org.gvsig.fmap.dal.DataStoreParameters;
33
import org.gvsig.fmap.dal.coverage.RasterLocator;
34
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
35
import org.gvsig.fmap.dal.coverage.util.ProviderServices;
33 36
import org.gvsig.fmap.dal.exception.InitializeException;
34 37
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
35 38
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
......
129 132

  
130 133
		try {
131 134
			DataManager dataManager = DALLocator.getDataManager();
132
			DataStoreParameters storeParameters = dataManager.createStoreParameters("Shape");
133
			storeParameters.setDynValue("CRS", theView.getProjection());
134
			storeParameters.setDynValue("shpfile", fileName);
135 135
			
136
			ProviderServices provServ = RasterLocator.getManager().getProviderServices();
137
			RasterDataParameters storeParameters = provServ.createParameters(fileName);
138
			storeParameters.setURI(fileName);
139
			
136 140
			MapContextManager mcm = MapContextLocator.getMapContextManager();
137 141
			
138 142
			DataStore dataStore = null;
......
159 163

  
160 164
		} catch (LoadLayerException e) {
161 165
			throw new RasterNotLoadException("Error al cargar la capa.");
162
		} catch (InitializeException e) {
163
			throw new RasterNotLoadException("Error creating parameters.");
164
		} catch (ProviderNotRegisteredException e) {
165
			throw new RasterNotLoadException("Error creating parameters.");
166
		}
166
		} 
167 167
		theView.getMapControl().getMapContext().invalidate();
168 168
		theView.getMapControl().getMapContext().endAtomicEvent();
169 169
	}

Also available in: Unified diff