Revision 2356

View differences:

org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/alg_with_preview_template/sources/app/ProjectTemplatePreview.java
3 3
import java.awt.Graphics2D;
4 4
import java.awt.geom.Rectangle2D;
5 5
import java.awt.image.BufferedImage;
6
import java.io.File;
6 7
import java.util.ArrayList;
7 8
import java.util.HashMap;
8 9
import java.util.List;
......
135 136
			return null;
136 137
		}
137 138
		task.addParam(ProjectTemplateProcess.RASTER_STORE, inputLyr.getDataStore());
138
		task.addParam(ProjectTemplateProcess.TEST_EXTENT, ext);
139
		task.addParam(ProjectTemplateProcess.TEST_WIDTH, w);
140
		task.addParam(ProjectTemplateProcess.TEST_HEIGHT, h);
139
		task.addParam(ProjectTemplateProcess.PREVIEW, true);
140
		task.addParam(ProjectTemplateProcess.WINDOW, ext);
141
		task.addParam(ProjectTemplateProcess.OUTPUT_WIDTH, w);
142
		task.addParam(ProjectTemplateProcess.OUTPUT_HEIGHT, h);
141 143
		//......
142 144
		
143 145
		task.init();
......
204 206
		return new Rectangle2D.Double();
205 207
	}
206 208

  
207
	public void addParams(DataProcess task, ProjectTemplateData data, String path) {
209
	public void addParams(DataProcess task, String path, String fileName) {
210
		if(!fileName.matches("([*]\\.[???])")) {
211
			fileName += ".tif";
212
		}
213
		
208 214
		task.addParam(ProjectTemplateProcess.RASTER_STORE, inputLyr.getDataStore());
209 215
		//......
210
		task.addParam(ProjectTemplateProcess.PATH, path);
216
		task.addParam(ProjectTemplateProcess.PATH, path + File.separator + fileName);
211 217
	}
212 218
}
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/alg_with_preview_template/sources/app/ProjectTemplateWindow.java
42 42
    		redimPreview(panel, preview);
43 43

  
44 44
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this);
45
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).addActionListener(this);
45
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setVisible(false);
46
        //getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).addActionListener(this);
46 47
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this);
47 48
        
48 49
        info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE);
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/alg_with_preview_template/sources/app/ProjectTemplateExtension.java
1 1
package org.gvsig.raster.projecttemplate.app;
2 2

  
3
import java.awt.Component;
4 3
import java.awt.event.ActionEvent;
5 4
import java.awt.event.ActionListener;
5
import java.io.File;
6 6
import java.util.ArrayList;
7
import java.util.HashMap;
7 8
import java.util.List;
8 9

  
9 10
import javax.swing.JComponent;
10
import javax.swing.JOptionPane;
11 11
import javax.swing.JPanel;
12 12

  
13 13
import org.gvsig.andami.IconThemeHelper;
......
21 21
import org.gvsig.fmap.mapcontext.layers.FLayer;
22 22
import org.gvsig.fmap.mapcontext.layers.FLayers;
23 23
import org.gvsig.fmap.mapcontrol.MapControl;
24
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
24 25
import org.gvsig.i18n.Messages;
26
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary;
27
import org.gvsig.raster.algorithm.process.DataProcess;
28
import org.gvsig.raster.algorithm.process.IProcessActions;
29
import org.gvsig.raster.algorithm.process.ProcessException;
25 30
import org.gvsig.raster.fmap.layers.FLyrRaster;
31
import org.gvsig.raster.mainplugin.RasterMainPluginUtils;
26 32
import org.gvsig.raster.projecttemplate.swing.ProjectTemplatePanel;
27 33
import org.gvsig.raster.projecttemplate.swing.ProjectTemplateSwingLocator;
34
import org.gvsig.raster.projecttemplate.algorithm.ProjectTemplateProcess;
28 35
import org.gvsig.raster.swing.RasterSwingLibrary;
29 36
import org.gvsig.raster.swing.RasterSwingLocator;
30 37
import org.gvsig.raster.swing.newlayer.CreateNewLayerPanel;
31 38
import org.gvsig.raster.swing.newlayer.FileNameManagement;
32 39
import org.gvsig.raster.swing.preview.PreviewPanel;
40
import org.gvsig.raster.util.RasterNotLoadException;
33 41
import org.gvsig.tools.ToolsLocator;
34 42
import org.gvsig.tools.extensionpoint.ExtensionPoint;
35 43
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
......
37 45
import org.slf4j.LoggerFactory;
38 46

  
39 47

  
40
public class ProjectTemplateExtension extends Extension implements ActionListener {
48
public class ProjectTemplateExtension extends Extension implements ActionListener, IProcessActions {
41 49
	private int                      windowWidth         = 600;
42 50
	private int                      windowHeight        = 350;
43 51
	private IWindow                  window              = null;
......
173 181
    private CreateNewLayerPanel getNewLayerPanel() {
174 182
    	if(newLayerPanel == null)
175 183
    		 newLayerPanel = RasterSwingLocator.getSwingManager().createNewLayerPanel(
176
    				 new FileNameManagementImpl(),
177 184
    				 Messages.getText("create_output_layer"));
178 185
    	return newLayerPanel;
179 186
    }
......
211 218
    }
212 219

  
213 220
	public void actionPerformed(ActionEvent e) {
214
		
221
		if(window != null && 
222
			(e.getSource() == ((ProjectTemplateWindow)window).getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT) ||
223
			e.getSource() == ((ProjectTemplateWindow)window).getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY))) {
224
				DataProcess task = null;
225
				try {
226
					task = RasterBaseAlgorithmLibrary.getManager().createRasterTask("ProjectTemplateProcess");
227
				} catch (ProcessException e1) {
228
					RasterSwingLibrary.messageBoxError("error_processing_layer", null, e1);
229
				}
230
				task.setActions(this);
231
				getDataSourcePreview().addParams(task, 
232
						getNewLayerPanel().getDirectorySelected(), 
233
						getNewLayerPanel().getFileSelected());
234
				task.start();
235
				return;
236
		}
215 237
	}
216 238
	
239
	@SuppressWarnings("unchecked")
240
	public void end(Object params) {
241
		if(params instanceof HashMap<?, ?>) {
242
			HashMap<String, Object>  map = (HashMap<String, Object>) params;
243
			String fName = (String)map.get(ProjectTemplateProcess.FILENAME);
244
			long milis = (Long)map.get(ProjectTemplateProcess.TIME);
245
			processFinalize(fName, milis);
246
			RasterSwingLocator.getSwingManager().showSummaryProcessDialog(fName, milis);
247
		}
248
	}
249
	
250
	private void processFinalize(String fileName, long milis) {
251
		if (!new File(fileName).exists())
252
			return;
253

  
254
		String viewName = getViewName();
255
		if(viewName != null) {
256
			if (RasterSwingLibrary.messageBoxYesOrNot("cargar_toc", this)) {
257
				try {
258
					RasterMainPluginUtils.loadLayer(viewName, fileName, null);
259
				} catch (RasterNotLoadException e) {
260
					RasterSwingLibrary.messageBoxError("error_load_layer", null, e);
261
				}
262
			}
263
		}
264
	}
265
	
266
	private String getViewName() {
267
		FLyrRaster lyrRaster = getSelectedLayer();
268
		IWindow[] w = PluginServices.getMDIManager().getAllWindows();
269
		for (int i = 0; i < w.length; i++) {
270
			if(w[i] instanceof AbstractViewPanel) {
271
				FLayers lyrs = ((AbstractViewPanel)w[i]).getMapControl().getMapContext().getLayers();
272
				for (int j = 0; j < lyrs.getLayersCount(); j++) {
273
					FLayer lyr = lyrs.getLayer(j);
274
					if(lyrRaster == lyr) {
275
						return PluginServices.getMDIManager().getWindowInfo((AbstractViewPanel) w[i]).getTitle();
276
					}
277
				}
278
			}
279
		}
280
		return null;
281
	}
282

  
283
	public void interrupted() {
284

  
285
	}
286

  
287
	public void updateProgress(int current, int total) {
288

  
289
	}
290
	
217 291
	public class FileNameManagementImpl implements FileNameManagement {
218 292
		private FileUtils fileUtils = RasterLocator.getManager().getFileUtils();
219 293
		
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/alg_with_preview_template/sources/algorithm/ProjectTemplateProcess.java
1 1
package org.gvsig.raster.projecttemplate.algorithm;
2 2

  
3
import java.util.HashMap;
4 3
import java.util.List;
5 4

  
6
import javax.swing.SwingUtilities;
7

  
8 5
import java.awt.geom.Rectangle2D;
9 6

  
10 7
import org.gvsig.fmap.dal.coverage.RasterLocator;
11 8
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
12 9
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
13 10
import org.gvsig.fmap.dal.coverage.exception.CloneException;
14
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
15 11
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
12
import org.gvsig.fmap.dal.coverage.exception.QueryException;
16 13
import org.gvsig.fmap.dal.coverage.exception.ROIException;
17
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
18 14
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
19 15
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
20 16
import org.gvsig.i18n.Messages;
21
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary;
22 17
import org.gvsig.raster.algorithm.process.DataProcess;
23 18
import org.gvsig.raster.roi.ROI;
19
import org.gvsig.raster.algorithm.process.ProcessException;
24 20

  
25 21
/**
26 22
 * Process 
......
30 26
	public static String      BUFFER            = "RasterStore";
31 27
	public static String      PATH              = "Path";
32 28
	public static String      FILENAME          = "FileName";
33
	public static String      EXPORT            = "Export";
34 29
	
35
	public static String      TEST              = "Test";
36
	public static String      TEST_EXTENT       = "TestExtent";
37
	public static String      TEST_WIDTH        = "TestWidth";
38
	public static String      TEST_HEIGHT       = "TestHeight";
39
	
40
	private boolean           test              = false;
41 30
	private RasterDataStore   store             = null;
42 31
	private String            filename          = null;
43
	private boolean           export            = true;
44 32
	private List<ROI>         rois              = null;
45
	private Extent            extentResult      = null;
46 33
	
47
	private Extent            testExtent        = null;
48
	private int               testWidth         = 0;
49
	private int               testHeight        = 0;
50
	
51
	/**
52
	 * This buffer is just to test
53
	 */
54
	private Buffer            bufferForTest     = null;
55
	
56 34
	public static void registerParameters() {
57 35
		registerInputParameter(RASTER_STORE, RasterDataStore.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
58 36
		registerInputParameter(PATH, String.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
59
		registerInputParameter(EXPORT, Boolean.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
60
		registerInputParameter(TEST, Boolean.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
61
		registerInputParameter(TEST_EXTENT, Extent.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
62
		registerInputParameter(TEST_WIDTH, Integer.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
63
		registerInputParameter(TEST_HEIGHT, Integer.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
64 37
		
65 38
		registerOutputParameter(FILENAME, String.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
66 39
	}
......
68 41
	public void init() {
69 42
		store = getParam(RASTER_STORE) != null ? (RasterDataStore)getParam(RASTER_STORE) : null;
70 43
		filename = getStringParam(PATH);
71
		export = getBooleanParam(EXPORT);
72
		
73
		test = getBooleanParam(TEST);
74
		testExtent = getParam(TEST_EXTENT) != null ? (Extent)getParam(TEST_EXTENT) : null;
75
		testWidth = getIntParam(TEST_WIDTH);
76
		testHeight = getIntParam(TEST_HEIGHT);
77 44
	}
78 45

  
79
	public void process() throws ProcessInterruptedException {
46
	public void process() throws ProcessInterruptedException, ProcessException {
80 47
		insertLineLog(Messages.getText("..."));
81 48
		try {
82 49
			if (store == null)
......
93 60
			try {
94 61
				store = ((RasterDataStore)store).cloneDataStore();
95 62
			} catch (CloneException e) {
96
				new ProjectTemplateException("Error cloning the input DataStore", e);
63
				new ProcessException("Error cloning the input DataStore", e);
97 64
			}
98 65
			
99
			extentResult = getExtentResult(getOutputWindow(), rois, store);
100
			Rectangle2D sourcePxBBox = getSourcePxBox(extentResult, store);
101
			double cellSize = store.getCellSize();
102
			
103 66
			RasterQuery query = RasterLocator.getManager().createQuery();
104
			query.setAllDrawableBands();
105
			query.setAreaOfInterest(testExtent, testWidth, testHeight);
67
			
68
			Extent windowExtent = getExtentResult(getOutputWindow(), null, store);
69
			Rectangle2D sourcePxBBox = null;
70
			if(isOutputRescaled()) {
71
				sourcePxBBox = new Rectangle2D.Double(0, 0, getOutputWidth(), getOutputHeight());
72
				query.setSupersamplingOption(true);
73
			} else {
74
				sourcePxBBox = getSourcePxBox(windowExtent, store);
75
				query.setSupersamplingOption(false);
76
			}
77
			double cellSize = windowExtent.width() / sourcePxBBox.getWidth();
78
			
79
			if(isForPreviews()) {
80
				query.setReadOnly(false);
81
				query.forceRGBRequest();
82
				query.setDrawableBands(store.getRender().getRenderColorInterpretation().buildRenderBands());
83
			} else {
84
				query.setAllDrawableBands();
85
				query.setReadOnly(true);
86
			}
87
			
88
			query.setAreaOfInterest(windowExtent, (int)sourcePxBBox.getWidth(), (int)sourcePxBBox.getHeight());
106 89
			Buffer sourceBuffer = null;
107 90
			try {
108 91
				sourceBuffer = store.query(query);
109
				sourceBuffer.setDataExtent(testExtent.toRectangle2D());
110
			} catch (org.gvsig.fmap.dal.coverage.exception.QueryException e) {
111
				throw new ProjectTemplateException("");
92
				sourceBuffer.setDataExtent(windowExtent.toRectangle2D());
93
			} catch (QueryException e) {
94
				throw new ProcessException("Error reading data", e);
112 95
			} 
113
			bufferForTest = sourceBuffer;
114 96
			
115 97
			//////////////////////////
116
			//TODO:PROCESS!!
117
			
118 98
			//int inDataType = store.getDataType()[0];
119
			//Buffer buf = RasterLocator.getManager().createBuffer(
99
			//Buffer outputBuffer = RasterLocator.getManager().createBuffer(
120 100
			//		inDataType, 
121 101
			//		(int)store.getWidth(), 
122 102
			//		(int)store.getHeight(), 
123 103
			//		store.getBandCount(), 
124 104
			//		true);
125
			//updatePercent(row, buf.getHeight());
105
			//...
106
			//TODO:PROCESS!!
107
			//...
108
			//updatePercent(row, outputBuffer.getHeight());
126 109
			//////////////////////////
127 110
			
128
			/*if(export) {
111
			if(!isForPreviews()) {
129 112
				super.exportRaster(filename, 
130
						buf, 
131
						cellSize, 
132
						windowExtent.getULX(), 
133
						windowExtent.getULY());
134
			}*/
113
						sourceBuffer, 
114
						store.getColorInterpretation(),
115
						windowExtent,
116
						store.getNoDataValue(),
117
						store.getProjection());
118
				addOutputValue(FILENAME, filename);
119
			} else {
120
				addOutputValue(BUFFER, sourceBuffer);
121
			}
135 122
			
136
			addOutputValue(FILENAME, filename);
137
			addOutputValue(BUFFER, bufferForTest);
138 123
		} catch (ProjectTemplateException e) {
139 124
			if (incrementableTask != null)
140 125
				incrementableTask.processFinalize();
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/alg_template/pom/app.client_provider
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.raster.projecttemplate.app.client</artifactId>
6
	<packaging>jar</packaging>
7
	<name></name>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.raster.projecttemplate.app</artifactId>
11
		<version>2.0.0-SNAPSHOT</version>
12
	</parent>
13
	<description></description>
14
	<dependencies>
15
		<dependency>
16
			<groupId>org.gvsig</groupId>
17
			<artifactId>org.gvsig.raster.projecttemplate.lib.api</artifactId>
18
			<scope>compile</scope>
19
		</dependency>
20
		<dependency>
21
			<groupId>org.gvsig</groupId>
22
			<artifactId>org.gvsig.raster.projecttemplate.lib.impl</artifactId>
23
			<scope>runtime</scope>
24
		</dependency>
25
		<dependency>
26
			<groupId>org.gvsig</groupId>
27
			<artifactId>org.gvsig.raster.projecttemplate.swing.api</artifactId>
28
			<scope>compile</scope>
29
		</dependency>
30
		<dependency>
31
			<groupId>org.gvsig</groupId>
32
			<artifactId>org.gvsig.raster.projecttemplate.swing.impl</artifactId>
33
			<scope>runtime</scope>
34
		</dependency>
35
		<dependency>
36
			<groupId>org.gvsig</groupId>
37
			<artifactId>org.gvsig.app.mainplugin</artifactId>
38
			<scope>compile</scope>
39
		</dependency>
40
		<dependency>
41
			<groupId>org.gvsig</groupId>
42
			<artifactId>org.gvsig.raster.lib.api</artifactId>
43
			<scope>compile</scope>
44
		</dependency>
45
		<dependency>
46
			<groupId>org.gvsig</groupId>
47
			<artifactId>org.gvsig.raster.lib.impl</artifactId>
48
			<scope>runtime</scope>
49
		</dependency>
50
		<dependency>
51
			<groupId>org.gvsig</groupId>
52
			<artifactId>org.gvsig.raster.fmap</artifactId>
53
			<scope>compile</scope>
54
		</dependency>
55
		<dependency>
56
			<groupId>org.gvsig</groupId>
57
			<artifactId>org.gvsig.fmap.control</artifactId>
58
			<scope>compile</scope>
59
		</dependency>
60
		<dependency>
61
			<groupId>org.gvsig</groupId>
62
			<artifactId>org.gvsig.utils</artifactId>
63
			<scope>compile</scope>
64
		</dependency>
65
		<dependency>
66
			<groupId>org.gvsig</groupId>
67
			<artifactId>org.gvsig.ui</artifactId>
68
			<scope>compile</scope>
69
		</dependency>
70
        <dependency>
71
			<groupId>org.gvsig</groupId>
72
			<artifactId>org.gvsig.raster.mainplugin</artifactId>
73
            <scope>compile</scope>
74
		</dependency>
75
		<dependency> 
76
			<groupId>org.gvsig</groupId> 
77
			<artifactId>org.gvsig.symbology.lib.api</artifactId> 
78
			<scope>compile</scope> 
79
		</dependency>
80
		<dependency>
81
			<groupId>org.gvsig</groupId>
82
			<artifactId>org.gvsig.symbology.lib.impl</artifactId>
83
			<scope>compile</scope>
84
		</dependency>
85
		<dependency>
86
			<groupId>org.gvsig</groupId>
87
			<artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
88
			<scope>compile</scope>
89
		</dependency>
90
		
91
		
92
		<dependency>
93
            <groupId>org.gvsig</groupId>
94
            <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
95
            <scope>compile</scope>
96
        </dependency>
97
        <dependency>
98
            <groupId>org.gvsig</groupId>
99
            <artifactId>org.gvsig.fmap.mapcontext.impl</artifactId>
100
            <scope>runtime</scope>
101
        </dependency>
102
        <dependency>
103
            <groupId>org.gvsig</groupId>
104
            <artifactId>org.gvsig.fmap.mapcontext.operation</artifactId>
105
            <scope>runtime</scope>
106
        </dependency>
107
		<dependency>
108
            <groupId>org.gvsig</groupId>
109
            <artifactId>org.gvsig.projection.api</artifactId>
110
            <scope>compile</scope>
111
        </dependency>
112
        <dependency>
113
            <groupId>org.gvsig</groupId>
114
            <artifactId>org.gvsig.projection.cresques.impl</artifactId>
115
            <scope>runtime</scope>
116
        </dependency>
117
        <dependency>
118
            <groupId>org.gvsig</groupId>
119
            <artifactId>org.gvsig.compat.api</artifactId>
120
            <scope>compile</scope>
121
        </dependency>
122
        <dependency>
123
            <groupId>org.gvsig</groupId>
124
            <artifactId>org.gvsig.compat.se</artifactId>
125
            <scope>compile</scope>
126
        </dependency>
127
        <dependency>
128
            <groupId>org.gvsig</groupId>
129
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
130
            <scope>compile</scope>
131
        </dependency>
132
        <dependency>
133
            <groupId>org.gvsig</groupId>
134
            <artifactId>org.gvsig.fmap.dal.impl</artifactId>
135
            <scope>compile</scope>
136
        </dependency>
137
        <dependency>
138
            <groupId>org.gvsig</groupId>
139
            <artifactId>org.gvsig.fmap.dal.file.lib</artifactId>
140
            <scope>compile</scope>
141
        </dependency>
142
        <dependency>
143
            <groupId>org.gvsig</groupId>
144
            <artifactId>org.gvsig.fmap.dal.spi</artifactId>
145
            <scope>compile</scope>
146
        </dependency>
147
        <dependency>
148
            <groupId>org.gvsig</groupId>
149
            <artifactId>org.gvsig.fmap.geometry.api</artifactId>
150
            <scope>compile</scope>
151
        </dependency>
152
        <dependency>
153
            <groupId>org.gvsig</groupId>
154
            <artifactId>org.gvsig.fmap.geometry.impl</artifactId>
155
            <scope>runtime</scope>
156
        </dependency>
157
        <dependency>
158
            <groupId>org.gvsig</groupId>
159
            <artifactId>org.gvsig.fmap.geometry.operation</artifactId>
160
            <scope>runtime</scope>
161
        </dependency>
162
	</dependencies>
163

  
164
	<properties>
165
		<gvsig.package.info.state>devel</gvsig.package.info.state>
166
		<gvsig.package.info.dependencies>required: org.gvsig.raster.tilecache.app -ge 2, required: org.gvsig.raster.tools.app.basic -ge 2</gvsig.package.info.dependencies>
167
		<gvsig.package.info.baseDownloadURL>http://devel.gvsig.org/download/projects/Raster/pool/org.gvsig.raster.projecttemplate.app.projecttemplateclient</gvsig.package.info.baseDownloadURL>
168
		<gvsig.package.info.categories>Raster</gvsig.package.info.categories>
169
	</properties>
170
</project>
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/alg_template/pom/base_provider.xml
98 98
				<version>2.1.0-SNAPSHOT</version>
99 99
			</dependency>
100 100
			<dependency>
101
			    <groupId>org.gvsig</groupId>
102
			    <artifactId>org.gvsig.raster.mainplugin</artifactId>
103
                <version>2.2.0-SNAPSHOT</version>
104
		    </dependency>
105
			<dependency>
101 106
				<groupId>org.gvsig</groupId>
102 107
				<artifactId>org.gvsig.raster.algorithm</artifactId>
103 108
				<version>2.1.0-SNAPSHOT</version>
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/alg_template/sources/algorithm/ProjectTemplateProcess.java
1 1
package org.gvsig.raster.projecttemplate.algorithm;
2 2

  
3
import java.awt.geom.Rectangle2D;
4
import java.util.HashMap;
5 3
import java.util.List;
6 4

  
7
import javax.swing.SwingUtilities;
5
import java.awt.geom.Rectangle2D;
8 6

  
9
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
10 7
import org.gvsig.fmap.dal.coverage.RasterLocator;
11 8
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
9
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
12 10
import org.gvsig.fmap.dal.coverage.exception.CloneException;
13
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
14 11
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
12
import org.gvsig.fmap.dal.coverage.exception.QueryException;
15 13
import org.gvsig.fmap.dal.coverage.exception.ROIException;
16
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
17 14
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
18 15
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
19 16
import org.gvsig.i18n.Messages;
20
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary;
21 17
import org.gvsig.raster.algorithm.process.DataProcess;
22 18
import org.gvsig.raster.roi.ROI;
19
import org.gvsig.raster.algorithm.process.ProcessException;
23 20

  
24 21
/**
25 22
 * Process 
26 23
 */
27 24
public class ProjectTemplateProcess extends DataProcess {
28 25
	public static String      RASTER_STORE      = "RasterStore";
26
	public static String      BUFFER            = "RasterStore";
29 27
	public static String      PATH              = "Path";
30 28
	public static String      FILENAME          = "FileName";
31
	public static String      EXPORT            = "Export";
32 29
	
33
	public static String      TEST              = "Test";
34
	public static String      TEST_EXTENT       = "TestExtent";
35
	public static String      TEST_WIDTH        = "TestWidth";
36
	public static String      TEST_HEIGHT       = "TestHeight";
37
	
38
	private boolean           test              = false;
39 30
	private RasterDataStore   store             = null;
40 31
	private String            filename          = null;
41
	private boolean           export            = true;
42 32
	private List<ROI>         rois              = null;
43
	private Extent            extentResult      = null;
44 33
	
45
	private Extent            testExtent        = null;
46
	private int               testWidth         = 0;
47
	private int               testHeight        = 0;
48
	
49 34
	public static void registerParameters() {
50 35
		registerInputParameter(RASTER_STORE, RasterDataStore.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
51 36
		registerInputParameter(PATH, String.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
37
		
52 38
		registerOutputParameter(FILENAME, String.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
53
		registerInputParameter(EXPORT, Boolean.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
54
		registerInputParameter(TEST, Boolean.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
55
		registerInputParameter(TEST_EXTENT, Extent.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
56
		registerInputParameter(TEST_WIDTH, Integer.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
57
		registerInputParameter(TEST_HEIGHT, Integer.class, ProjectTemplateAlgorithmLibrary.PROCESS_LABEL);
58 39
	}
59 40
	
60 41
	public void init() {
61 42
		store = getParam(RASTER_STORE) != null ? (RasterDataStore)getParam(RASTER_STORE) : null;
62 43
		filename = getStringParam(PATH);
63
		export = getBooleanParam(EXPORT);
64
		
65
		test = getBooleanParam(TEST);
66
		testExtent = getParam(TEST_EXTENT) != null ? (Extent)getParam(TEST_EXTENT) : null;
67
		testWidth = getIntParam(TEST_WIDTH);
68
		testHeight = getIntParam(TEST_HEIGHT);
69 44
	}
70 45

  
71
	public void process() throws ProcessInterruptedException {
46
	public void process() throws ProcessInterruptedException, ProcessException {
72 47
		insertLineLog(Messages.getText("..."));
73 48
		try {
74 49
			if (store == null)
......
85 60
			try {
86 61
				store = ((RasterDataStore)store).cloneDataStore();
87 62
			} catch (CloneException e) {
88
				new ProjectTemplateException("Error cloning the input DataStore", e);
63
				new ProcessException("Error cloning the input DataStore", e);
89 64
			}
90 65
			
91
			extentResult = getExtentResult(getOutputWindow(), rois, store);
92
			Rectangle2D sourcePxBBox = getSourcePxBox(extentResult, store);
93
			double cellSize = store.getCellSize();
94
			
95
			Extent windowExtent = store.getExtent();
96
			int w = (int)store.getWidth();
97
			int h = (int)store.getHeight();
98
			cellSize = store.getCellSize();
99
			
100
			int inDataType = store.getDataType()[0];
101
			Buffer buf = RasterLocator.getManager().createBuffer(
102
					inDataType, 
103
					(int)store.getWidth(), 
104
					(int)store.getHeight(), 
105
					store.getBandCount(), 
106
					true);
107
			
108 66
			RasterQuery query = RasterLocator.getManager().createQuery();
109 67
			
110
			if(extent != null) {
111
				windowExtent = extent;
112
				w = outputWidth;
113
				h = outputHeight;
114
				cellSize = windowExtent.width() / w;
68
			Extent windowExtent = getExtentResult(getOutputWindow(), null, store);
69
			Rectangle2D sourcePxBBox = null;
70
			if(isOutputRescaled()) {
71
				sourcePxBBox = new Rectangle2D.Double(0, 0, getOutputWidth(), getOutputHeight());
115 72
				query.setSupersamplingOption(true);
116 73
			} else {
74
				sourcePxBBox = getSourcePxBox(windowExtent, store);
117 75
				query.setSupersamplingOption(false);
118 76
			}
119

  
120
			if(test) {
121
				query.setReadOnly(false);
122
				query.forceRGBRequest();
123
				query.setDrawableBands(store.getRender().getRenderColorInterpretation().buildRenderBands());
124
			} else {
125
				query.setAllDrawableBands();
126
				query.setReadOnly(true);
127
			}
77
			double cellSize = windowExtent.width() / sourcePxBBox.getWidth();
128 78
			
129
			query.setAreaOfInterest();
79
			query.setAllDrawableBands();
80
			query.setReadOnly(true);
81
			query.setAreaOfInterest(windowExtent, (int)sourcePxBBox.getWidth(), (int)sourcePxBBox.getHeight());
130 82
			Buffer sourceBuffer = null;
131 83
			try {
132 84
				sourceBuffer = store.query(query);
133 85
				sourceBuffer.setDataExtent(windowExtent.toRectangle2D());
134
			} catch (org.gvsig.fmap.dal.coverage.exception.QueryException e) {
135
				throw new ProjectTemplateException("");
86
			} catch (QueryException e) {
87
				throw new ProcessException("Error reading data", e);
136 88
			} 
137
			
138
			
89

  
139 90
			//////////////////////////
91
			//int inDataType = store.getDataType()[0];
92
			//Buffer outputBuffer = RasterLocator.getManager().createBuffer(
93
			//		inDataType, 
94
			//		(int)store.getWidth(), 
95
			//		(int)store.getHeight(), 
96
			//		store.getBandCount(), 
97
			//		true);
98
			//...
140 99
			//TODO:PROCESS!!
141
			
142
			//updatePercent(row, buf.getHeight());
143
			
144
			/*if(export) {
100
			//...
101
			//updatePercent(row, outputBuffer.getHeight());
102
			//////////////////////////
103

  
145 104
			super.exportRaster(filename, 
146
					buf, 
147
					cellSize, 
148
					windowExtent.getULX(), 
149
					windowExtent.getULY());
150
			}*/
151
			
105
					sourceBuffer, 
106
					store.getColorInterpretation(),
107
					windowExtent,
108
					store.getNoDataValue(),
109
					store.getProjection());
152 110
			addOutputValue(FILENAME, filename);
153 111
		} catch (ProjectTemplateException e) {
154 112
			if (incrementableTask != null)
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/alg_template/sources/io/ProjectTemplateServerExplorer.java
12 12
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
13 13
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
14 14
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
15
import org.gvsig.raster.myprojectname.io.MyProjectNameDataParameters;
16
import org.gvsig.raster.myprojectname.io.MyProjectNameProvider;
15
import org.gvsig.raster.projecttemplate.io.ProjectTemplateDataParameters;
16
import org.gvsig.raster.projecttemplate.io.ProjectTemplateProvider;
17 17

  
18 18
 @SuppressWarnings("unchecked")
19 19
public class ProjectTemplateServerExplorer implements DataServerExplorerProvider {
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/providerproject.xml
91 91
	  </replace>
92 92
	  <move file="pom.xml" todir="${dirplugin}" overwrite="yes"/>
93 93
	  	
94
	  <copy file="${pom}/app.client" tofile="pom.xml" overwrite="yes"/>
94
	  <copy file="${pom}/app.client_provider" tofile="pom.xml" overwrite="yes"/>
95 95
	   	<replace file="pom.xml" value="${project}">
96 96
	   	  <replacefilter token="${tokenin1}"/>
97 97
	   	</replace>
org.gvsig.raster.tools/trunk/templates/rasterTaskProjectTemplate/toolbox_template/sources/ProjectTemplateSextanteAlgorithm.java
8 8
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary;
9 9
import org.gvsig.raster.algorithm.process.ProcessException;
10 10
import org.gvsig.raster.algorithm.process.DataProcess;
11
import org.gvsig.raster.algorithm.process.ProcessParamsManagement;
11 12
import org.gvsig.raster.fmap.layers.FLyrRaster;
12 13
import org.gvsig.raster.projecttemplate.algorithm.ProjectTemplateProcess;
13 14

  
......
69 70
    	task.addParam(ProjectTemplateProcess.PATH, fileName);
70 71
		task.addParam(ProjectTemplateProcess.RASTER_STORE, lyrRaster.getDataStore());
71 72
		//TODO:Add parameters
72
		task.addParam(ProjectTemplateProcess.EXPORT, true);
73
		task.addParam(ProjectTemplateProcess.TEST_EXTENT, bbox);
74
		task.addParam(ProjectTemplateProcess.TEST_WIDTH, ext.getNX());
75
		task.addParam(ProjectTemplateProcess.TEST_HEIGHT, ext.getNY());
73
		task.addParam(ProjectTemplateProcess.WINDOW, bbox);
74
		task.addParam(ProjectTemplateProcess.OUTPUT_WIDTH, ext.getNX());
75
		task.addParam(ProjectTemplateProcess.OUTPUT_HEIGHT, ext.getNY());
76 76
		
77 77
		try {
78 78
			task.execute();
org.gvsig.raster.roimask/trunk/org.gvsig.raster.roimask/org.gvsig.raster.roimask.algorithm/src/main/java/org/gvsig/raster/roimask/algorithm/ROIMaskProcess.java
30 30
	public static String      ALPHA             = "Alpha";
31 31
	public static String      ALPHA_BAND        = "AlphaBand";
32 32
	public static String      NODATA            = "NoData";
33
	public static String      EXPORT            = "Export";
34 33
	
35
	public static String      TEST              = "Test";
36
	public static String      EXTENT            = "Extent";
37
	public static String      OUTPUT_WIDTH      = "OutputWidth";
38
	public static String      OUTPUT_HEIGHT     = "OutputHeight";
39
	
40 34
	private RasterDataStore   store             = null;
41 35
	private String            filename          = null;
42 36
	
43 37
	private ROI[]             rois              = null;  
44 38
	private boolean           inverse           = false;
45
	private boolean           export            = true;
46 39
	private int               alpha             = 0;
47 40
	private NoData            nodata            = null;
48 41
	
......
58 51
		registerInputParameter(INVERSE, Boolean.class, ROIMaskAlgorithmLibrary.PROCESS_LABEL);
59 52
		registerInputParameter(ALPHA, Integer.class, ROIMaskAlgorithmLibrary.PROCESS_LABEL);
60 53
		registerInputParameter(NODATA, NoData.class, ROIMaskAlgorithmLibrary.PROCESS_LABEL);
61
		registerInputParameter(EXPORT, Boolean.class, ROIMaskAlgorithmLibrary.PROCESS_LABEL);
62 54
		
63 55
		registerOutputParameter(FILENAME, String.class, ROIMaskAlgorithmLibrary.PROCESS_LABEL);
64 56
		registerOutputParameter(ALPHA_BAND, Buffer.class, ROIMaskAlgorithmLibrary.PROCESS_LABEL);
......
69 61
		store = getParam(RASTER_STORE1) != null ? (RasterDataStore)getParam(RASTER_STORE1) : null;
70 62
		filename = getStringParam(PATH);
71 63
		inverse = getBooleanParam(INVERSE);
72
		export = getBooleanParam(EXPORT);
73 64
		alpha = getIntParam(ALPHA);
74 65
		
75 66
		nodata = getParam(NODATA) != null ? (NoData)getParam(NODATA) : null;
......
138 129
				}
139 130
			} 
140 131
			
141
			if(export) {
132
			if(!isForPreviews()) {
142 133
				super.exportRaster(filename, 
143 134
						bufferForTest, 
144 135
						ci,
145 136
						windowExtent,
146 137
						nodata,
147 138
						store.getProjection());
139
				addOutputValue(FILENAME, filename);
140
			} else {
141
				addOutputValue(BUFFER, bufferForTest);
148 142
			}
149

  
150
			addOutputValue(FILENAME, filename);
151
			addOutputValue(BUFFER, bufferForTest);
143
				
152 144
			addOutputValue(ALPHA_BAND, ouputAlphaBandNumber);
153 145
		} catch (ROIMaskException e) {
154 146
			if (incrementableTask != null)
org.gvsig.raster.roimask/trunk/org.gvsig.raster.roimask/org.gvsig.raster.roimask.toolbox.algorithm/src/main/java/org/gvsig/raster/roimask/ROIMaskSextanteAlgorithm.java
85 85
		task.addParam(ROIMaskProcess.ALPHA, alpha);
86 86
		task.addParam(ROIMaskProcess.INVERSE, inverse);
87 87
		task.addParam(ROIMaskProcess.NODATA, lyrRaster.getNoDataValue());
88
		task.addParam(ROIMaskProcess.EXPORT, true);
89
		task.addParam(ROIMaskProcess.EXTENT, bbox);
88
		task.addParam(ROIMaskProcess.WINDOW, bbox);
90 89
		task.addParam(ROIMaskProcess.OUTPUT_WIDTH, ext.getNX());
91 90
		task.addParam(ROIMaskProcess.OUTPUT_HEIGHT, ext.getNY());
92 91
		
org.gvsig.raster.roimask/trunk/org.gvsig.raster.roimask/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/java/org/gvsig/raster/roimask/app/ROIMaskPreview.java
145 145
			task.addParam(ROIMaskProcess.ALPHA, data.getAlpha());
146 146
			task.addParam(ROIMaskProcess.INVERSE, data.isInverse());
147 147
			task.addParam(ROIMaskProcess.NODATA, getNoDataSelected());
148
			task.addParam(ROIMaskProcess.EXPORT, false);
149 148
		} catch (ProcessException e1) {
150 149
			logger.debug("Error creating task", e1);
151 150
			return null;
......
252 251
		task.addParam(ROIMaskProcess.ALPHA, data.getAlpha());
253 252
		task.addParam(ROIMaskProcess.INVERSE, data.isInverse());
254 253
		task.addParam(ROIMaskProcess.NODATA, getNoDataSelected());
255
		task.addParam(ROIMaskProcess.EXPORT, true);
256 254
	}
257 255
}

Also available in: Unified diff