Revision 19516 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/enhanced/ui/SelectorsPanel.java

View differences:

SelectorsPanel.java
18 18
 */
19 19
package org.gvsig.rastertools.enhanced.ui;
20 20

  
21
import java.awt.FlowLayout;
22 21
import java.awt.GridBagConstraints;
23 22
import java.awt.GridBagLayout;
24 23
import java.awt.Insets;
25 24
import java.util.ArrayList;
26 25

  
26
import javax.swing.BorderFactory;
27 27
import javax.swing.JLabel;
28 28
import javax.swing.JPanel;
29
import javax.swing.border.TitledBorder;
29 30

  
30 31
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
31 32
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation;
32 33

  
33 34
import com.iver.utiles.swing.JComboBox;
34

  
35 35
/**
36 36
 * Panel con las selecci?n de opciones.
37 37
 * 
......
39 39
 * @author Nacho Brodin nachobrodin@gmail.com
40 40
 */
41 41
public class SelectorsPanel extends JPanel {
42
	private static final long     serialVersionUID     = 1L;
42
	private static final long serialVersionUID = 3453973982901626644L;
43
	private JComboBox enhancedType         = null;
44
	private JComboBox histogramType        = null;
45
	private JComboBox drawType             = null;
46
	private JComboBox band                 = null;
47
	private JComboBox sourcesMatchingPanel = null;
43 48
	
44
	private JComboBox             enhancedType         = null;
45
	private JComboBox             histogramType        = null;
46
	private JComboBox             drawType             = null;
47
	private JComboBox             band                 = null;
48
	
49
	private JPanel                enhancedTypePanel    = null;
50
	private JPanel                histogramTypePanel   = null;
51
	private JPanel                drawTypePanel        = null;
52
	private JPanel                bandPanel            = null;
53
	private JComboBox             sourcesMatchingPanel = null;
54
	
55 49
	/**
56 50
	 * Crea una instancia del panel GraphicsPanel
57 51
	 */
......
63 57
	 * Inicializaci?n de los controles gr?ficos.
64 58
	 */
65 59
	private void init(FLyrRasterSE lyr, ArrayList list) {
60
		GridBagConstraints gridBagConstraints = null;
61

  
62
		setBorder(BorderFactory.createTitledBorder(null, null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
63

  
66 64
		setLayout(new GridBagLayout());
67
		GridBagConstraints gbc = new GridBagConstraints();
68
		gbc.weightx = 1;
69
		gbc.insets = new Insets(0, 0, 0, 5);
70 65
		
71
		gbc.fill = GridBagConstraints.HORIZONTAL;
72
		gbc.anchor = GridBagConstraints.WEST;
73
		setBorder(javax.swing.BorderFactory.createTitledBorder(null, null, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
66
		gridBagConstraints = new GridBagConstraints();
67
		gridBagConstraints.gridx = 0;
68
		gridBagConstraints.gridy = 0;
69
		gridBagConstraints.anchor = GridBagConstraints.EAST;
70
		gridBagConstraints.weightx = 1.0;
71
		gridBagConstraints.insets = new Insets(5, 5, 2, 2);
72
		add(new JLabel("operation"), gridBagConstraints);
73

  
74
		gridBagConstraints = new GridBagConstraints();
75
		gridBagConstraints.gridx = 1;
76
		gridBagConstraints.gridy = 0;
77
		gridBagConstraints.insets = new Insets(5, 2, 2, 2);
78
		gridBagConstraints.anchor = GridBagConstraints.WEST;
79
		add(getEnhancedType(), gridBagConstraints);
74 80
		
75
		gbc.gridx = 0;
76
		gbc.gridy = 0;
77
		add(getEnhancedTypePanel(), gbc);
78
		gbc.gridx = 0;
79
		gbc.gridy = 1;
80
		add(getBandPanel(lyr), gbc);		
81
		gbc.gridx = 1;
82
		gbc.gridy = 0;
83
		//Quitar si se a?ade el tipo
84
		gbc.gridheight = 2;
85
		add(getDrawTypePanel(), gbc);
86
		//gbc.gridx = 1;
87
		//gbc.gridy = 1;
88
		//add(getHistogramTypePanel(), gbc);
89
		gbc.gridx = 0;
90
		gbc.gridy = 2;
91
		gbc.gridwidth = 2;
92
		gbc.insets = new Insets(2, 0, 0, 5);
93
		add(getSourcesMatchingPanel(list), gbc);
81
		gridBagConstraints = new GridBagConstraints();
82
		gridBagConstraints.gridx = 0;
83
		gridBagConstraints.gridy = 1;
84
		gridBagConstraints.anchor = GridBagConstraints.EAST;
85
		gridBagConstraints.weightx = 1.0;
86
		gridBagConstraints.insets = new Insets(2, 5, 2, 2);
87
		add(new JLabel("band"), gridBagConstraints);
88

  
89
		gridBagConstraints = new GridBagConstraints();
90
		gridBagConstraints.gridx = 1;
91
		gridBagConstraints.gridy = 1;
92
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
93
		gridBagConstraints.anchor = GridBagConstraints.WEST;
94
		add(getBand(lyr), gridBagConstraints);
95
		
96
		gridBagConstraints = new GridBagConstraints();
97
		gridBagConstraints.gridx = 2;
98
		gridBagConstraints.gridy = 0;
99
		gridBagConstraints.anchor = GridBagConstraints.EAST;
100
		gridBagConstraints.weightx = 1.0;
101
		gridBagConstraints.insets = new Insets(5, 2, 2, 2);
102
		add(new JLabel("drawing_type"), gridBagConstraints);
103

  
104
		gridBagConstraints = new GridBagConstraints();
105
		gridBagConstraints.gridx = 3;
106
		gridBagConstraints.gridy = 0;
107
		gridBagConstraints.insets = new Insets(5, 2, 2, 5);
108
		gridBagConstraints.anchor = GridBagConstraints.WEST;
109
		add(getDrawType(), gridBagConstraints);
110
		
111
		gridBagConstraints = new GridBagConstraints();
112
		gridBagConstraints.gridx = 2;
113
		gridBagConstraints.gridy = 1;
114
		gridBagConstraints.anchor = GridBagConstraints.EAST;
115
		gridBagConstraints.weightx = 1.0;
116
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
117
		add(new JLabel("histogram_type"), gridBagConstraints);
118

  
119
		gridBagConstraints = new GridBagConstraints();
120
		gridBagConstraints.gridx = 3;
121
		gridBagConstraints.gridy = 1;
122
		gridBagConstraints.insets = new Insets(2, 2, 2, 5);
123
		gridBagConstraints.anchor = GridBagConstraints.WEST;
124
		add(getHistogramType(), gridBagConstraints);
125
		
126
		gridBagConstraints = new GridBagConstraints();
127
		gridBagConstraints.gridx = 0;
128
		gridBagConstraints.gridy = 2;
129
		gridBagConstraints.gridwidth = 4;
130
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
131
		gridBagConstraints.anchor = GridBagConstraints.NORTH;
132
		gridBagConstraints.weighty = 1.0;
133
		gridBagConstraints.insets = new Insets(2, 5, 5, 5);
134
		add(getSourcesMatchingPanel(list), gridBagConstraints);
94 135
	}
95 136
	
96 137
	/**
......
99 140
	 * @return JPanel
100 141
	 */
101 142
	public JComboBox getSourcesMatchingPanel(ArrayList list) {
102
		if(sourcesMatchingPanel == null) {
143
		if (sourcesMatchingPanel == null) {
103 144
			sourcesMatchingPanel = new JComboBox();
104
			for (int i = 0; i < list.size(); i++) 
105
				sourcesMatchingPanel.addItem(((FLyrRasterSE)list.get(i)).getName());	
145
			for (int i = 0; i < list.size(); i++)
146
				sourcesMatchingPanel.addItem(((FLyrRasterSE) list.get(i)).getName());
106 147
		}
107 148
		return sourcesMatchingPanel;
108 149
	}
109 150
	
110 151
	/**
111
	 * Obtiene el panel con el tipo de histograma
112
	 * @return JPanel
113
	 */
114
	protected JPanel getHistogramTypePanel() {
115
		if(histogramTypePanel == null) {
116
			FlowLayout l = new FlowLayout();
117
			l.setAlignment(FlowLayout.RIGHT);
118
			l.setHgap(0);
119
			l.setVgap(1);
120
			histogramTypePanel = new JPanel(l);
121
			histogramTypePanel.add(new JLabel("histogram_type"));
122
			histogramTypePanel.add(getHistogramType());
123
		}
124
		return histogramTypePanel;
125
	}
126

  
127
	/**
128 152
	 * Obtiene el tipo de histograma
129 153
	 * @return JComboBox
130 154
	 */
131 155
	public JComboBox getHistogramType() {
132
		if(histogramType == null) {
156
		if (histogramType == null) {
133 157
			histogramType = new JComboBox();
134 158
			histogramType.addItem("Standard");
135 159
			histogramType.addItem("Cumulative");
160
			histogramType.addItem("Logarithmic");
161
			histogramType.addItem("Cumulative Logarithmic");
136 162
		}
137 163
		return histogramType;
138 164
	}
139 165
	
140 166
	/**
141
	 * Obtiene el panel con el tipo de dibujado de histograma (lineas, barras, ...)
142
	 * @return JComboBox
143
	 */
144
	private JPanel getDrawTypePanel() {
145
		if(drawTypePanel == null) {
146
			FlowLayout l = new FlowLayout();
147
			l.setAlignment(FlowLayout.RIGHT);
148
			l.setHgap(0);
149
			l.setVgap(1);
150
			drawTypePanel = new JPanel(l);
151
			drawTypePanel.add(new JLabel("drawing_type"));
152
			drawTypePanel.add(getDrawType());
153
		}
154
		return drawTypePanel;
155
	}
156

  
157
	/**
158 167
	 * Obtiene el tipo de dibujado de histograma (lineas, barras, ...)
159 168
	 * @return JComboBox
160 169
	 */
161 170
	public JComboBox getDrawType() {
162
		if(drawType == null) {
171
		if (drawType == null) {
163 172
			drawType = new JComboBox();
164 173
			drawType.addItem("Line");
165 174
			drawType.addItem("Fill");
......
168 177
	}
169 178
	
170 179
	/**
171
	 * Obtiene el panel con la banda que representa el histograma
172
	 * @return JComboBox
173
	 */
174
	private JPanel getBandPanel(FLyrRasterSE lyr) {
175
		if(bandPanel == null) {
176
			FlowLayout l = new FlowLayout();
177
			l.setAlignment(FlowLayout.RIGHT);
178
			l.setHgap(0);
179
			l.setVgap(1);
180
			bandPanel = new JPanel(l);
181
			bandPanel.add(new JLabel("band"));
182
			bandPanel.add(getBand(lyr));
183
		}
184
		return bandPanel;
185
	}
186

  
187
	/**
188 180
	 * Obtiene la banda que representa el histograma
189 181
	 * @return JComboBox
190 182
	 */
191 183
	public JComboBox getBand(FLyrRasterSE lyr) {
192
		if(band == null) {
184
		if (band == null) {
193 185
			band = new JComboBox();
194
			if(lyr.getBandCount() == 1)
186
			if (lyr.getBandCount() == 1)
195 187
				band.addItem(DatasetColorInterpretation.GRAY_BAND);
196 188
			else {
197 189
				band.addItem(DatasetColorInterpretation.RED_BAND);
......
203 195
	}
204 196

  
205 197
	/**
206
	 * Obtiene el panel con el tipo de funci?n a aplicar (ecualizaci?n, realce lineal, ...)
207
	 * @return JComboBox
208
	 */
209
	private JPanel getEnhancedTypePanel() {
210
		if(enhancedTypePanel == null) {
211
			FlowLayout l = new FlowLayout();
212
			l.setAlignment(FlowLayout.RIGHT);
213
			l.setHgap(0);
214
			l.setVgap(1);
215
			enhancedTypePanel = new JPanel(l);
216
			enhancedTypePanel.add(new JLabel("operation"));
217
			enhancedTypePanel.add(getEnhancedType());
218
		}
219
		return enhancedTypePanel;
220
	}
221
	
222
	/**
223 198
	 * Obtiene el tipo de funci?n a aplicar (ecualizaci?n, realce lineal, ...)
224 199
	 * @return JComboBox
225 200
	 */
226 201
	public JComboBox getEnhancedType() {
227
		if(enhancedType == null) {
202
		if (enhancedType == null) {
228 203
			enhancedType = new JComboBox();
229 204
			enhancedType.addItem("Lineal");
230 205
			enhancedType.addItem("Gaussian");
......
236 211
		}
237 212
		return enhancedType;
238 213
	}
239

  
240
}
241

  
214
}

Also available in: Unified diff