Revision 2355 org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.algorithm/src/main/java/org/gvsig/raster/algorithm/process/ProcessParamsManagement.java

View differences:

ProcessParamsManagement.java
54 54
	 * Input parameter: Force to this bounding box. If is defined, then ROI_EPSG is not taken into account
55 55
	 */
56 56
	public static String                WINDOW                             = "WINDOW";
57
	/**
58
	 * Input parameter: Force to this width in pixels in the output buffer
59
	 */
60
	public static String                OUTPUT_WIDTH                       = "OUTPUT_WIDTH";
61
	/**
62
	 * Input parameter: Force to this height in pixels in the output buffer
63
	 */
64
	public static String                OUTPUT_HEIGHT                      = "OUTPUT_HEIGHT";
65
	/**
66
	 * Input parameter: The output of this algorithm is for previews. It usually implies that the buffer will be
67
	 * send as output parameter, the buffer will be RGB and the input buffer will be to read and write
68
	 */
69
	public static String                PREVIEW                            = "PREVIEW";
57 70
	
58 71
	//************************
59 72
	//Global output parameters
......
76 89
	public static final String          REGISTER_OUTPUT_PARAMETERS_LABEL   = "RasterProcessOutputParam";
77 90
	
78 91
	private Extent                      outputWindow                       = null;
92
	private int                         outputWidth                        = 0;
93
	private int                         outputHeight                       = 0;
79 94
	private String                      roiEPSG                            = null;
95
	private boolean                     preview                            = false;
96
	private boolean                     globalParametersLoaded             = false;
80 97

  
81 98
	protected Hashtable<String, Object> inputParameters                    = new Hashtable<String, Object>();
82 99
	protected HashMap<String, Object>   outputParameters                   = new HashMap<String, Object>();
......
110 127
		ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
111 128
		ExtensionPoint point = extensionPoints.add(REGISTER_INPUT_PARAMETERS_LABEL + "_" + processLabel);
112 129
		if(!point.has(ROI_EPSG))
113
			point.append(ROI_EPSG, "", Long.class);
130
			point.append(ROI_EPSG, "", String.class);
114 131
		if(!point.has(WINDOW))
115
			point.append(WINDOW, "", DataProcess.class);
132
			point.append(WINDOW, "", Extent.class);
133
		if(!point.has(OUTPUT_HEIGHT))
134
			point.append(OUTPUT_HEIGHT, "", Integer.class);
135
		if(!point.has(OUTPUT_WIDTH))
136
			point.append(OUTPUT_WIDTH, "", Integer.class);
137
		if(!point.has(PREVIEW))
138
			point.append(PREVIEW, "", Boolean.class);
116 139
	}
117 140
	
118 141
	public static void registerGlobalOutputParameters(String parameterLabel, Class<?> parameterClass, String processLabel) {
......
216 239
	 * @return parameter
217 240
	 */
218 241
	public Object getParam(String key) {
242
		loadGlobalParameters();
219 243
		return inputParameters.get(key);
220 244
	}
221 245
	
......
225 249
	 * @return parameter
226 250
	 */
227 251
	public String getStringParam(String key) {
252
		loadGlobalParameters();
228 253
		Object value = inputParameters.get(key);
229 254
		return (value != null && value instanceof String) ? (String)value : null;
230 255
	}
......
235 260
	 * @return parameter
236 261
	 */
237 262
	public byte getByteParam(String name) {
263
		loadGlobalParameters();
238 264
		Object value = inputParameters.get(name);
239 265
		return (value != null && value instanceof Byte) ? ((Byte)value).byteValue() : 0;
240 266
	}
......
245 271
	 * @return parameter
246 272
	 */
247 273
	public float getFloatParam(String name) {
274
		loadGlobalParameters();
248 275
		Object value = inputParameters.get(name);
249 276
		return (value != null && value instanceof Float) ? ((Float)value).floatValue() : 0F;
250 277
	}
......
255 282
	 * @return parameter
256 283
	 */
257 284
	public double getDoubleParam(String name) {
285
		loadGlobalParameters();
258 286
		Object value = inputParameters.get(name);
259 287
		return (value != null && value instanceof Double) ? ((Double)value).doubleValue() : 0D;
260 288
	}
......
265 293
	 * @return parameter
266 294
	 */
267 295
	public int getIntParam(String name) {
296
		loadGlobalParameters();
268 297
		Object value = inputParameters.get(name);
269 298
		return (value != null && value instanceof Integer) ? ((Integer)value).intValue() : 0;
270 299
	}
......
275 304
	 * @return parameter
276 305
	 */
277 306
	public boolean getBooleanParam(String name) {
307
		loadGlobalParameters();
278 308
		Object value = inputParameters.get(name);
279 309
		return (value != null && value instanceof Boolean) ? ((Boolean)value).booleanValue() : false;
280 310
	}
......
285 315
	 * @return parameter
286 316
	 */
287 317
	public int[] getIntArrayParam(String name) {
318
		loadGlobalParameters();
288 319
		Object value = inputParameters.get(name);
289 320
		return (value != null && value instanceof int[]) ? ((int[])value) : null;
290 321
	}
......
295 326
	 * @return parameter
296 327
	 */
297 328
	public double[] getDoubleArrayParam(String name) {
329
		loadGlobalParameters();
298 330
		Object value = inputParameters.get(name);
299 331
		return (value != null && value instanceof double[]) ? ((double[])value) : null;
300 332
	}
......
305 337
	 * @return parameter
306 338
	 */
307 339
	public Extent getExtentParam(String name) {
340
		loadGlobalParameters();
308 341
		Object value = inputParameters.get(name);
309 342
		return (value != null && value instanceof Extent) ? ((Extent)value) : null;
310 343
	}
......
326 359
	}
327 360
	
328 361
	/**
362
	 * Gets the width in pixels of the output
363
	 * @return
364
	 */
365
	protected int getOutputWidth() {
366
		return outputWidth;
367
	}
368
	
369
	/**
370
	 * Gets the height in pixels of the output
371
	 * @return
372
	 */
373
	protected int getOutputHeight() {
374
		return outputHeight;
375
	}
376
	
377
	/**
378
	 * Returns true if the output will be rescaled
379
	 * @return
380
	 */
381
	protected boolean isOutputRescaled() {
382
		return (outputWidth != 0 || outputHeight != 0);
383
	}
384
	
385
	/**
386
	 * Returns true if the output of this algorithm is for previews. It usually implies that the buffer will be
387
	 * send as output parameter, the buffer will be RGB and the input buffer will be to read and write.
388
	 * @return
389
	 */
390
	protected boolean isForPreviews() {
391
		return preview;
392
	}
393
	
394
	/**
329 395
	 * Loads global parameters defined in this class
330 396
	 */
331 397
	protected void loadGlobalParameters() {
398
		if(globalParametersLoaded)
399
			return;
400
		globalParametersLoaded = true;
332 401
		roiEPSG = getStringParam(ROI_EPSG);
333 402
		outputWindow = getParam(WINDOW) != null ? (Extent)getParam(WINDOW) : null;
403
		outputWidth = getIntParam(OUTPUT_WIDTH);
404
		outputHeight = getIntParam(OUTPUT_HEIGHT);
405
		preview = getBooleanParam(PREVIEW);
334 406
	}
335 407
}

Also available in: Unified diff