Revision 1306 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/maskthreshold/MaskThresholdDataImpl.java

View differences:

MaskThresholdDataImpl.java
21 21
*/
22 22
package org.gvsig.raster.tools.algorithm.swing.impl.maskthreshold;
23 23

  
24
import org.gvsig.raster.tools.algorithm.swing.maskthreshold.MaskThresholdData;
25

  
24 26
/**
25 27
 * Data model for the mask threshold user interface
26 28
 * @author Nacho Brodin (nachobrodin@gmail.com)
27 29
 */
28
public class MaskThresholdDataImpl {
30
public class MaskThresholdDataImpl implements MaskThresholdData {
29 31
	private MaskThresholdPanelImpl panel = null;
30 32
	
31 33
	public MaskThresholdDataImpl(MaskThresholdPanelImpl panel) {
......
33 35
	}
34 36
	
35 37
	public Object getInputLayer() {
36
		return panel.getLayerSelection().getInputLayerCombo().getSelectedItem();
38
		Object obj = panel.getLayerSelection().getInputLayerCombo()
39
			.getSelectedItem();
40
		if(obj == null)
41
			return panel.getLayerSelection().getInputLayerCombo().getItemAt(0);
42
		else
43
			return obj;
37 44
	}
38 45
	
39 46
	public int getBandInputLayer() {
40
		return panel.getLayerSelection().getBandsSelectorCombo().getSelectedIndex();
47
		return panel.getLayerSelection().getBandsSelectorCombo()
48
			.getSelectedIndex() - 1;
41 49
	}
42 50
	
43 51
	public int getOperation() {
44
		return panel.getOperationMaskThresholdPanel().getComboText().getCombo().getSelectedIndex();
52
		return panel.getOperationMaskThresholdPanel().getComboText()
53
			.getCombo().getSelectedIndex();
45 54
	}
46 55
	
47 56
	public int getOperationMethod() {
48
		return panel.getOperationMaskThresholdPanel().getLayerRadio().isSelected() ? 1 : 0;
57
		return panel.getOperationMaskThresholdPanel().getLayerRadio()
58
			.isSelected() ? 1 : 0;
49 59
	}
50 60
	
51 61
	public double getThresholdValue() {
......
58 68
	}
59 69
	
60 70
	public Object getOperationLayer() {
61
		return panel.getOperationMaskThresholdPanel().getLayerSelection()
62
			.getInputLayerCombo().getSelectedIndex();
71
		Object obj = panel.getOperationMaskThresholdPanel().getLayerSelection()
72
			.getInputLayerCombo().getSelectedItem();
73
		if(obj == null)
74
			return panel.getOperationMaskThresholdPanel().getLayerSelection()
75
				.getInputLayerCombo().getItemAt(0);
76
		else
77
			return obj;
63 78
	}
64 79
	
65 80
	public int getBandOperationLayer() {
66 81
		return panel.getOperationMaskThresholdPanel().getLayerSelection()
67
			.getBandsSelectorCombo().getSelectedIndex();
82
			.getBandsSelectorCombo().getSelectedIndex() - 1;
68 83
	}
69 84
	
70 85
	public Object getOutputInputLayer() {
71
		return panel.getOutputMaskThresholdPanel().getLayerSelection()
86
		Object obj = panel.getOutputMaskThresholdPanel().getLayerSelection()
72 87
			.getInputLayerCombo().getSelectedItem();
88
		if(obj == null)
89
			return panel.getOutputMaskThresholdPanel().getLayerSelection()
90
				.getInputLayerCombo().getItemAt(0);
91
		else
92
			return obj;
73 93
	}
74 94
	
75 95
	public int getBandOutputLayer() {
76 96
		return panel.getOutputMaskThresholdPanel().getLayerSelection()
77
			.getBandsSelectorCombo().getSelectedIndex();
97
			.getBandsSelectorCombo().getSelectedIndex() - 1;
78 98
	}
79 99
	
80 100
    public int getMethodOutput() {

Also available in: Unified diff