Revision 12154 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/EnhancedWithTrimPanel.java

View differences:

EnhancedWithTrimPanel.java
16 16
 * along with this program; if not, write to the Free Software
17 17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18 18
 */
19

  
20 19
package org.gvsig.rastertools.properties.panels;
21 20

  
22 21
import java.awt.BorderLayout;
......
34 33
import org.gvsig.gui.beans.slidertext.SliderTextContainer;
35 34

  
36 35
import com.iver.andami.PluginServices;
37

  
38

  
39 36
/**
40
 * Panel para los controles de brillo y contrase .
37
 * Panel para los controles de brillo y contraste.
41 38
 * 
42 39
 * @author Nacho Brodin (nachobrodin@gmail.com)
43 40
 */
44
public class EnhancedWithTrimPanel extends JPanel implements ActionListener{
45
	final private static long 			serialVersionUID = 0;
46
	public static final int				LINEAR = 0;
47
	private TrimPanel trimPanel = null;
48
	private SelectorPanel selectorPanel = null;
49
	private JCheckBox	active = null;
50
	
41
public class EnhancedWithTrimPanel extends JPanel implements ActionListener {
42
	private static final long serialVersionUID = 9023137365069951866L;
43
	public static final int   LINEAR           = 0;
44
	private TrimPanel         trimPanel        = null;
45
	private SelectorPanel     selectorPanel    = null;
46
	private JCheckBox         active           = null;
47

  
51 48
	/**
52 49
	 * Panel con los controles de eliminar extremos, recorte de colas y slider
53 50
	 * con el porcentaje de recorte.
54 51
	 * 
55 52
	 * @author Nacho Brodin (nachobrodin@gmail.com)
56
	 *
57 53
	 */
58
	class TrimPanel extends JPanel implements ActionListener{
59
		final private static long 		serialVersionUID = 0;
60
		private SliderTextContainer 	trimSlider = null;
61
		private JCheckBox				remove = null;
62
		private JCheckBox				trimCheck = null;
63
		private JPanel					pCheck = null;
64
		
54
	class TrimPanel extends JPanel implements ActionListener {
55
		private static final long   serialVersionUID = -6435560458161006843L;
56
		private SliderTextContainer trimSlider       = null;
57
		private JCheckBox           remove           = null;
58
		private JCheckBox           trimCheck        = null;
59
		private JPanel              pCheck           = null;
60

  
65 61
		/**
66 62
		 * Contructor
67 63
		 */
68
		public TrimPanel(){
64
		public TrimPanel() {
69 65
			trimSlider = new SliderTextContainer(0, 100, 50);
70 66
			trimSlider.setDecimal(true);
71 67
			trimSlider.setBorder("");
72 68
			init();
73 69
			getTrim().addActionListener(this);
74 70
		}
75
		
76
		private void init(){
71

  
72
		private void init() {
77 73
			setBorder(javax.swing.BorderFactory.createTitledBorder(null, null, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
78 74
			this.setLayout(new BorderLayout());
79
			this.add(getPCheck(), BorderLayout.NORTH );
75
			this.add(getPCheck(), BorderLayout.NORTH);
80 76
			this.add(trimSlider, BorderLayout.CENTER);
81 77
		}
82
	
78

  
83 79
		/**
84 80
		 * Obtiene el control con el slider de recorte de colas
85 81
		 * @return SliderTextContainer
86 82
		 */
87
		public SliderTextContainer getTrimSlider(){
88
			if(trimSlider == null)
83
		public SliderTextContainer getTrimSlider() {
84
			if (trimSlider == null)
89 85
				trimSlider = new SliderTextContainer(0, 100, 50);
90 86
			return trimSlider;
91 87
		}
92
		
93
		public JPanel getPCheck(){
94
			if(pCheck == null){
88

  
89
		public JPanel getPCheck() {
90
			if (pCheck == null) {
95 91
				pCheck = new JPanel();
96 92
				pCheck.setLayout(new GridBagLayout());
97 93
				GridBagConstraints gbc = new GridBagConstraints();
......
100 96
				gbc.gridx = 0;
101 97
				gbc.gridy = 0;
102 98
				gbc.weightx = 8;
103
				
99

  
104 100
				GridBagConstraints gbc1 = new GridBagConstraints();
105 101
				gbc1.insets = new Insets(9, 0, 9, 0);
106 102
				gbc1.gridx = 0;
107 103
				gbc1.gridy = 1;
108 104
				gbc1.anchor = GridBagConstraints.WEST;
109 105
				gbc1.weightx = 8;
110
				
106

  
111 107
				pCheck.add(getRemove(), gbc);
112 108
				pCheck.add(getTrim(), gbc1);
113 109
			}
114 110
			return pCheck;
115 111
		}
116
		
112

  
117 113
		/**
118 114
		 * Obtiene el check de eliminar extremos
119 115
		 * @return
120 116
		 */
121
		public JCheckBox getRemove(){
122
			if(remove == null)
117
		public JCheckBox getRemove() {
118
			if (remove == null)
123 119
				remove = new JCheckBox(PluginServices.getText(this, "eliminar_extremos"));
124 120
			return remove;
125 121
		}
126
		
122

  
127 123
		/**
128 124
		 * Obtiene el check de recorte de colas
129 125
		 * @return
130 126
		 */
131
		public JCheckBox getTrim(){
132
			if(trimCheck == null)
127
		public JCheckBox getTrim() {
128
			if (trimCheck == null)
133 129
				trimCheck = new JCheckBox(PluginServices.getText(this, "recorte_colas"));
134 130
			return trimCheck;
135 131
		}
136
		
132

  
137 133
		/**
138 134
		 * Activa o desactiva el control
139 135
		 * @param enable true activa y false desactiva los controles del panel
140 136
		 */
141
		public void setControlEnabled(boolean enabled){
142
			if(enabled && getTrim().isSelected())
137
		public void setControlEnabled(boolean enabled) {
138
			if (enabled && getTrim().isSelected())
143 139
				trimSlider.setControlEnabled(true);
144 140
			else
145 141
				trimSlider.setControlEnabled(false);
146 142
			remove.setEnabled(enabled);
147 143
			trimCheck.setEnabled(enabled);
148 144
		}
149
		
145

  
150 146
		/**
151 147
		 * Maneja eventos de activar y desactivar el panel
152 148
		 */
153 149
		public void actionPerformed(ActionEvent e) {
154
			if(e.getSource() == getTrim())
150
			if (e.getSource() == getTrim())
155 151
				trimSlider.setControlEnabled(getTrim().isSelected());
156
			
157 152
		}
158 153
	}
159
	
154

  
160 155
	/**
161 156
	 * Panel con los controles de selecci?n para el tipo de filtro
162 157
	 * de realce.
163 158
	 * 
164 159
	 * @author Nacho Brodin (nachobrodin@gmail.com)
165
	 *
166 160
	 */
167
	class SelectorPanel extends JPanel{
168
		final private static long 	serialVersionUID = 0;
169
		private JRadioButton  		rb = null;
170
		
161
	class SelectorPanel extends JPanel {
162
		private static final long serialVersionUID = 9036702518290091787L;
163
		private JRadioButton rb = null;
164

  
171 165
		/**
172 166
		 * Constructor
173 167
		 */
174
		public SelectorPanel(){
168
		public SelectorPanel() {
175 169
			setLayout(new GridLayout(1, 1));
176
			//setBorder(javax.swing.BorderFactory.createTitledBorder(null, null, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
177 170
			add(getLineal());
178 171
		}
179
		
172

  
180 173
		/**
181 174
		 * Obtiene el radio button de selecci?n de filtro lineal
182 175
		 * @return JRadioButton
183 176
		 */
184
		private JRadioButton getLineal(){
185
			if(rb == null){
177
		private JRadioButton getLineal() {
178
			if (rb == null) {
186 179
				rb = new JRadioButton(PluginServices.getText(this, "lineal_directo"));
187 180
				rb.setSelected(true);
188 181
			}
189 182
			return rb;
190 183
		}
191
		
184

  
192 185
		/**
193 186
		 * Activa o desactiva el control
194 187
		 * @param enable true activa y false desactiva los controles del panel
195 188
		 */
196
		public void setControlEnabled(boolean enabled){
189
		public void setControlEnabled(boolean enabled) {
197 190
			rb.setEnabled(enabled);
198 191
		}
199
		
200 192
	}
201
	
193

  
202 194
	/**
203 195
	 * Contructor
204 196
	 */
205
	public EnhancedWithTrimPanel(){
197
	public EnhancedWithTrimPanel() {
206 198
		super();
207 199
		trimPanel = new TrimPanel();
208 200
		selectorPanel = new SelectorPanel();
209 201
		initialize();
210 202
	}
211
	
203

  
212 204
	private void initialize() {
213 205
		setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "realce"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
214 206
		setLayout(new BorderLayout());
......
217 209
		add(trimPanel, BorderLayout.SOUTH);
218 210
		getActive().addActionListener(this);
219 211
	}
220
	
212

  
221 213
	/**
222 214
	 * Obtiene el check de activar
223 215
	 * @return
224 216
	 */
225
	public JCheckBox getActive(){
226
		if(active == null){
217
	public JCheckBox getActive() {
218
		if (active == null) {
227 219
			active = new JCheckBox(PluginServices.getText(this, "activar"));
228 220
			active.setSelected(false);
229 221
			this.setControlEnabled(false);
230 222
		}
231 223
		return active;
232 224
	}
233
	
225

  
234 226
	/**
235 227
	 * Activa o desactiva el control
236 228
	 * @param enable true activa y false desactiva los controles del panel
237 229
	 */
238
	public void setControlEnabled(boolean enabled){
230
	public void setControlEnabled(boolean enabled) {
239 231
		getActive().setSelected(enabled);
240 232
		trimPanel.setControlEnabled(enabled);
241 233
		selectorPanel.setControlEnabled(enabled);
242 234
	}
243
	
235

  
244 236
	/**
245 237
	 * Maneja eventos de activar y desactivar el panel
246 238
	 */
247 239
	public void actionPerformed(ActionEvent e) {
248
		if(e.getSource() == getActive()){
249
			if(getActive().isSelected())
240
		if (e.getSource() == getActive()) {
241
			if (getActive().isSelected())
250 242
				setControlEnabled(true);
251 243
			else
252 244
				setControlEnabled(false);
253 245
		}
254 246
	}
255
	
247

  
256 248
	/**
257 249
	 * Obtiene el valor de selecci?n del check de eliminar extremos
258 250
	 * @return boolean, true si est? seleccionado y false si no lo est?. 
259 251
	 */
260
	public boolean isRemoveEndsSelected(){
252
	public boolean isRemoveEndsSelected() {
261 253
		return trimPanel.getRemove().isSelected();
262 254
	}
263
	
255

  
264 256
	/**
265 257
	 * Obtiene el valor de selecci?n del check de recorte de colas.
266
	 * @return boolean, true si est? seleccionado y false si no lo est?. 
258
	 * @return boolean, true si est? seleccionado y false si no lo est?.
267 259
	 */
268
	public boolean isTailTrimCheckSelected(){
260
	public boolean isTailTrimCheckSelected() {
269 261
		return trimPanel.getTrim().isSelected();
270 262
	}
271
	
263

  
272 264
	/**
273 265
	 * Obtiene el valor de recorte de colas seleccionado en el slider
274 266
	 * @return double
275 267
	 */
276
	public double getTrimValue(){
268
	public double getTrimValue() {
277 269
		return trimPanel.getTrimSlider().getValue();
278 270
	}
279
	
271

  
280 272
	/**
281 273
	 * Activa o desactiva el checkbox de recorte de colas
282 274
	 * @param active true si deseamos activarlo y false para desactivarlo
283 275
	 */
284
	public void setTailTrimCheckActive(boolean active){
276
	public void setTailTrimCheckActive(boolean active) {
285 277
		trimPanel.getTrim().setSelected(active);
286 278
	}
287
	
279

  
288 280
	/**
289 281
	 * Activa o desactiva el checkbox de eliminar extremos
290 282
	 * @param active true si deseamos activarlo y false para desactivarlo
291 283
	 */
292
	public void setRemoveEndsActive(boolean active){
284
	public void setRemoveEndsActive(boolean active) {
293 285
		trimPanel.getRemove().setSelected(active);
294 286
	}
295
	
287

  
296 288
	/**
297 289
	 * Asigna un valor al slider de porcentaje de recorte
298 290
	 * @param active true si deseamos activarlo y false para desactivarlo
299 291
	 */
300
	public void setTailTrimValue(double value){
292
	public void setTailTrimValue(double value) {
301 293
		trimPanel.getTrimSlider().setValue(value);
302 294
	}
303
	
295

  
304 296
	/**
305 297
	 * Selecciona un metodo de realce entre los disponibles (linear)
306 298
	 * @param method
307 299
	 */
308
	public void setEnhancedMethod(int method){
309
		switch(method){
310
		case LINEAR: break;
300
	public void setEnhancedMethod(int method) {
301
		switch (method) {
302
			case LINEAR:
303
				break;
311 304
		}
312 305
	}
313
}
314

  
306
}

Also available in: Unified diff