Revision 544 org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.spatialjoin/src/main/java/org/gvsig/geoprocess/algorithm/spatialjoin/SpatialJoinParametersPanel.java

View differences:

SpatialJoinParametersPanel.java
74 74
	private TableContainer                   table              = null;
75 75
	private OutputChannelSelectionPanel      outputChannelSelectionPanel;
76 76
	private JPanel                           outputPanel;
77
	
77

  
78 78
	public SpatialJoinParametersPanel() {
79 79
		super();
80 80
	}
......
88 88
		GridBagLayout gbl = new GridBagLayout();
89 89
		this.setLayout(gbl);
90 90
		this.setBorder(BorderFactory.createLineBorder(Color.gray));
91
		
91

  
92 92
		GridBagConstraints gbc = new GridBagConstraints();
93 93
		gbc.fill = GridBagConstraints.HORIZONTAL;
94 94
		gbc.weightx = 1.0;
......
96 96
		gbc.gridy = 0;
97 97
		gbc.insets = new Insets(0, 0, 8, 0);
98 98
		this.add(getComboPanel(GeoProcessLocator.getGeoProcessManager().getTranslation("input_layers"), getLayers1Combo()), gbc);
99
		
99

  
100 100
		gbc.gridy = 1;
101 101
		this.add(getComboPanel(GeoProcessLocator.getGeoProcessManager().getTranslation("input_layers_join"), getLayers2Combo()), gbc);
102
		
102

  
103 103
		gbc.gridy = 2;
104 104
		this.add(getSelectionInputCheck(), gbc);
105
		
105

  
106 106
		gbc.gridy = 3;
107 107
		this.add(getSelectionOverlayCheck(), gbc);
108
		
108

  
109 109
		gbc.gridy = 4;
110 110
		this.add(getNearestCheck(), gbc);
111
		
111

  
112 112
		gbc.gridy = 5;
113 113
		this.add(new JLabel(GeoProcessLocator.getGeoProcessManager().getTranslation("summary_function")), gbc);
114
		
114

  
115 115
		gbc.gridy = 6;
116 116
		gbc.fill = GridBagConstraints.BOTH;
117 117
		gbc.insets = new Insets(0, 0, 12, 0);
......
126 126
		initTable();
127 127
		getRadioButtonTable().setVisible(false);
128 128
	}
129
	
129

  
130 130
	/**
131 131
	 * Gets the output panel (SEXTANTE)
132 132
	 * @return
......
147 147
		}
148 148
		return outputPanel;
149 149
	}
150
	
150

  
151 151
	/**
152 152
	 * Gets the output panel (DAL)
153 153
	 * @return
......
159 159
		}
160 160
		return output;
161 161
	}
162
	
162

  
163 163
	/**
164
	 * Gets a new JPanel with the text and JComboBox 
164
	 * Gets a new JPanel with the text and JComboBox
165 165
	 * @param text
166 166
	 * @param combo
167 167
	 * @return
......
188 188
		panel.add(combo, gbc);
189 189
		return panel;
190 190
	}
191
	
191

  
192 192
	/**
193 193
	 * Gets a ComboBox
194 194
	 * @return
......
203 203
		}
204 204
		return layersCombo;
205 205
	}
206
	
206

  
207 207
	/**
208 208
	 * Gets a ComboBox
209 209
	 * @return
......
218 218
		}
219 219
		return layersJoinCombo;
220 220
	}
221
	
221

  
222 222
	/**
223 223
	 * Gets a CheckBox
224 224
	 * @return
......
229 229
		}
230 230
		return selectionInput;
231 231
	}
232
	
232

  
233 233
	/**
234 234
	 * Gets a CheckBox
235 235
	 * @return
......
240 240
		}
241 241
		return selectionOverlay;
242 242
	}
243
	
243

  
244 244
	/**
245 245
	 * Gets a CheckBox
246 246
	 * @return
......
267 267
		}
268 268
		return table;
269 269
	}
270
	
270

  
271 271
	//------------------------------------------------------------
272
	
272

  
273 273
	public void actionPerformed(ActionEvent e) {
274 274
		if(e.getSource() == getNearestCheck()) {
275 275
			if(!getNearestCheck().isSelected())
......
277 277
			else
278 278
				getRadioButtonTable().setVisible(false);
279 279
		}
280
		
280

  
281 281
		if(e.getSource() ==  getLayers2Combo()) {
282 282
			initTable();
283
			
283

  
284 284
			//If the second layer has not numerical fields only the nearest method can be applied
285 285
			IVectorLayer lyr = getSelectedVectorLayer2();
286 286
			Class[] types = lyr.getFieldTypes();
287 287
			boolean hasNumericField = false;
288 288
			for (int i = 0; i < types.length; i++) {
289
				if(types[i] == Integer.class 
290
						|| types[i] == Double.class 
291
						|| types[i] == Float.class 
289
				if(types[i] == Integer.class
290
						|| types[i] == Double.class
291
						|| types[i] == Float.class
292 292
						|| types[i] == Short.class) {
293 293
					hasNumericField = true;
294 294
					break;
295 295
				}
296 296
			}
297
			if(!hasNumericField)
297
			if(!hasNumericField){
298 298
				getNearestCheck().setSelected(true);
299
			}
299 300
		}
300 301
	}
301
	
302

  
302 303
	/**
303 304
	 * Adds to the table one entry for each field
304 305
	 */
305 306
	private void initTable() {
306 307
		try {
307 308
			getRadioButtonTable().removeAllRows();
308
			if(getSelectedVectorLayer() == null)
309
			if(getSelectedVectorLayer2() == null)
309 310
				return;
310
			Class<?>[] types = getSelectedVectorLayer().getFieldTypes();
311
			for (int i = 0; i < getSelectedVectorLayer().getFieldCount(); i++) {
311
			Class<?>[] types = getSelectedVectorLayer2().getFieldTypes();
312
			for (int i = 0; i < getSelectedVectorLayer2().getFieldCount(); i++) {
312 313
				if(Number.class.isAssignableFrom(types[i])) {
313
					addTableRow(getSelectedVectorLayer().getFieldName(i));
314
					addTableRow(getSelectedVectorLayer2().getFieldName(i));
314 315
				}
315 316
			}
316 317
		} catch (NotInitializeException e) {
......
322 323
	 * A?ade una banda a la tabla bandas de la imagen asignandole un nombre y
323 324
	 * valor a los checkbox
324 325
	 * @param bandName Nombre de la banda
325
	 * @throws NotInitializeException 
326
	 * @throws NotInitializeException
326 327
	 */
327 328
	private void addTableRow(String fieldName) throws NotInitializeException {
328
		Object[] row = {	new Boolean(false), 
329
							new Boolean(false), 
330
							new Boolean(false), 
331
							new Boolean(false), 
329
		Object[] row = {	new Boolean(false),
330
							new Boolean(false),
331
							new Boolean(false),
332
							new Boolean(false),
332 333
							fieldName };
333 334
		getRadioButtonTable().addRow(row);
334 335
	}
335
	
336

  
336 337
	@Override
337 338
	public void assignParameters() {
338 339
		try {
......
343 344
			params.getParameter(SpatialJoinAlgorithm.SELECTGEOM_OVERLAY).setParameterValue(getSelectionOverlayCheck().isSelected());
344 345
			params.getParameter(SpatialJoinAlgorithm.NEAREST).setParameterValue(getNearestCheck().isSelected());
345 346
			params.getParameter(SpatialJoinAlgorithm.FUNCTION_LIST).setParameterValue(getValues());
346
			
347

  
347 348
			OutputObjectsSet ooSet = m_Algorithm.getOutputObjects();
348 349
			Output out = ooSet.getOutput(SpatialJoinAlgorithm.RESULT);
349
			
350

  
350 351
			//Reponer estas l?neas para cambiar el panel de salida y comentar la siguiente
351 352
			//AlgorithmOutputPanel fsp = getAlgorithmOutputPanel();
352 353
			//out.setOutputChannel(new CompositeSourceOutputChannel(fsp.getOutputParameters()));
......
358 359

  
359 360
	@Override
360 361
	public void setOutputValue(String arg0, String arg1) {
361
		
362

  
362 363
	}
363 364

  
364 365
	@Override
365 366
	public void setParameterValue(String arg0, String arg1) {
366
		
367

  
367 368
	}
368
	
369

  
369 370
	/**
370 371
	 * Gets the input layer list
371 372
	 * @return
......
378 379
			oad[i] = new ObjectAndDescription(layers[i].getName(), layers[i]);
379 380
		return oad;
380 381
	}
381
	
382

  
382 383
	/**
383 384
	 * Gets the selected vector layer in the JComboBox
384 385
	 * @return
......
388 389
			return (IVectorLayer)((ObjectAndDescription)layersCombo.getSelectedItem()).getObject();
389 390
		return null;
390 391
	}
391
	
392

  
392 393
	/**
393 394
	 * Gets the selected vector layer in the JComboBox
394 395
	 * @return
......
398 399
			return (IVectorLayer)((ObjectAndDescription)layersJoinCombo.getSelectedItem()).getObject();
399 400
		return null;
400 401
	}
401
	
402

  
402 403
	/**
403 404
	 * Gets the field list of the selected layer
404 405
	 * @return
......
406 407
	public String[] getFieldList() {
407 408
		IVectorLayer layer = getSelectedVectorLayer2();
408 409
		String[] data = new String[layer.getFieldCount()];
409
		for (int i = 0; i < layer.getFieldCount(); i++) 
410
		for (int i = 0; i < layer.getFieldCount(); i++)
410 411
			data[i] = layer.getFieldName(i);
411 412
		return data;
412 413
	}
413
	
414

  
414 415
	/**
415 416
	 * Formats the content of the table
416 417
	 * @return
......
428 429
		} catch (NotInitializeException e) {
429 430
			Sextante.addErrorToLog(e);
430 431
		}
432
    	if (str.isEmpty()) {
433
    		return str;
434
    	}
431 435
    	return str.substring(0, str.length() - 1);
432 436
    }
433 437

  

Also available in: Unified diff