Revision 21422

View differences:

trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/vectorizacion/ui/HighPassPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.rastertools.vectorizacion.ui;
20

  
21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
23
import java.awt.Insets;
24
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionListener;
26

  
27
import javax.swing.BorderFactory;
28
import javax.swing.JCheckBox;
29
import javax.swing.JPanel;
30

  
31
import org.gvsig.gui.beans.checkslidertext.CheckSliderTextContainer;
32
import org.gvsig.raster.util.RasterToolsUtil;
33

  
34
/**
35
 * Panel con los controles del filtro de paso alto.
36
 * 
37
 * 09/06/2008
38
 * @author Nacho Brodin nachobrodin@gmail.com
39
 */
40
public class HighPassPanel extends JPanel implements ActionListener {
41
	private static final long         serialVersionUID  = 1L;
42
	private JCheckBox                 active            = null;
43
	private CheckSliderTextContainer  radio             = null;
44
	private boolean                   enabled           = true;
45
	
46
	public HighPassPanel() {
47
		init();
48
	}
49
	
50
	/**
51
	 * Inicializaci?n de los componentes gr?ficos
52
	 */
53
	private void init() {
54
		setLayout(new GridBagLayout());
55
		setBorder(BorderFactory.createTitledBorder(null, RasterToolsUtil.getText(this, "highpassfilter"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
56
		GridBagConstraints gbc = new GridBagConstraints();
57
		gbc.fill = GridBagConstraints.HORIZONTAL;
58
		gbc.weightx = 1;
59
		gbc.insets = new Insets(0, 0, 5, 0);
60
		
61
		this.add(getActive(), gbc);
62
		
63
		gbc.gridy = 1;
64
		this.add(getRadio(), gbc);
65
		
66
		getActive().addActionListener(this);
67
		setComponentEnabled(false);
68
	}
69
	
70
	/**
71
	 * Obtiene el check de activo 
72
	 * @return JCheckBox
73
	 */
74
	public JCheckBox getActive() {
75
		if(active == null) {
76
			active = new JCheckBox();
77
			active.setSelected(false);
78
		}
79
		return active;
80
	}
81
		
82
	/**
83
	 * Obtiene la barra deslizadora con el radio del filtro de paso alto
84
	 * @return CheckSliderTextContainer
85
	 */
86
	public CheckSliderTextContainer getRadio() {
87
		if(radio == null)
88
			radio = new CheckSliderTextContainer(0, 255, 127, false, RasterToolsUtil.getText(this, "radio"), true, false, false);
89
		return radio;
90
	}
91

  
92
	/**
93
	 * Gesti?n del evento del check de activaci?n y desactivaci?n
94
	 */
95
	public void actionPerformed(ActionEvent e) {
96
		setComponentEnabled(enabled);
97
	}
98

  
99
	/**
100
	 * Activa o desactiva el componente. El estado de activaci?n y desactivaci?n de un
101
	 * componente depende de los controles que contiene. En este caso activa o desactiva
102
	 * la barra de incremento.
103
	 * @param enabled
104
	 */
105
	public void setComponentEnabled(boolean enabled) {
106
		getRadio().setControlEnabled(enabled);
107
		this.enabled = !enabled;
108
	}
109
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/vectorizacion/ui/GrayConversionPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.rastertools.vectorizacion.ui;
20

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

  
28
import javax.swing.BorderFactory;
29
import javax.swing.JLabel;
30
import javax.swing.JPanel;
31

  
32
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
33
import org.gvsig.raster.beans.previewbase.IPreviewRenderProcess;
34
import org.gvsig.raster.beans.previewbase.IUserPanelInterface;
35
import org.gvsig.raster.beans.previewbase.PreviewBasePanel;
36
import org.gvsig.raster.util.RasterToolsUtil;
37

  
38
import com.iver.utiles.swing.JComboBox;
39

  
40
/**
41
 * Panel para la conversi?n a escala de grises. Lleva incluida una previsualizaci?n
42
 * de capa.
43
 * 
44
 * 09/06/2008
45
 * @author Nacho Brodin nachobrodin@gmail.com
46
 */
47
public class GrayConversionPanel extends JPanel {
48
	private static final long      serialVersionUID   = -1;
49
	private PreviewBasePanel       previewBasePanel   = null;
50
	private JPanel                 centralPanel       = null;
51
	private IPreviewRenderProcess  renderProcess      = null;
52
	private FLyrRasterSE           lyr                = null;
53
	
54
	private NoisePanel             noisePanel         = null;
55
	private HighPassPanel          highPassPanel      = null;
56
	private PosterizationPanel     posterizationPanel = null;
57
	
58
	private JComboBox              comboLevels        = null;
59
	private JPanel                 levelsPanel        = null;
60
	private JComboBox              outputScale        = null;
61
	private JPanel                 outputScalePanel   = null;
62
	
63
	/**
64
	 * Panel que forma parte del componente interior de la preview
65
	 * 10/06/2008
66
	 * @author Nacho Brodin nachobrodin@gmail.com
67
	 */
68
	public class MainPanel extends JPanel implements IUserPanelInterface {
69
		private static final long serialVersionUID = 1L;
70

  
71
		/*
72
		 * (non-Javadoc)
73
		 * @see org.gvsig.raster.beans.previewbase.IUserPanelInterface#getPanel()
74
		 */
75
		public JPanel getPanel() {
76
			return this;
77
		}
78

  
79
		/*
80
		 * (non-Javadoc)
81
		 * @see org.gvsig.raster.beans.previewbase.IUserPanelInterface#getTitle()
82
		 */
83
		public String getTitle() {
84
			return "grayscaleconversion";
85
		}
86
		
87
	}
88
	
89
	/**
90
	 * Constructor.
91
	 * @param lyr
92
	 */
93
	public GrayConversionPanel(FLyrRasterSE lyr, IPreviewRenderProcess previewRender) {
94
		this.lyr = lyr;
95
		this.renderProcess = previewRender;
96
		init();
97
	}
98
	
99
	/**
100
	 * Constructor sin par?metro para poder instanciar como Bean
101
	 */
102
	public GrayConversionPanel() {
103
		renderProcess = new GrayConversionPreviewRender();
104
		init();
105
	}
106
	
107
	/**
108
	 * Inicializa los componentes gr?ficos
109
	 */
110
	private void init() {
111
		setLayout(new BorderLayout());
112
		add(getPreviewBasePanel(), BorderLayout.CENTER);
113
	}
114
	
115
	/**
116
	 * Obtiene el panel con el histograma
117
	 * @return HistogramPanel
118
	 */
119
	public PreviewBasePanel getPreviewBasePanel() {
120
		if (previewBasePanel == null) {
121
			ArrayList panels = new ArrayList();
122
			panels.add(getCentralPanel());
123
			previewBasePanel = new PreviewBasePanel(panels, null, null, renderProcess, lyr);
124
			previewBasePanel.setPreviewSize(new Dimension(230, 215));
125
		}
126
		return previewBasePanel;
127
	}
128
	
129
	/**
130
	 * Obtiene el panel central con los paneles que contienen las opciones de
131
	 * configuraci?n del cuadro.
132
	 * @return
133
	 */
134
	public JPanel getCentralPanel() {
135
		if(centralPanel == null) {
136
			centralPanel = new MainPanel();
137
			centralPanel.setBorder(BorderFactory.createTitledBorder(null, RasterToolsUtil.getText(this, "grayescaleconversion"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
138
			centralPanel.setLayout(new GridBagLayout());
139
			GridBagConstraints gbc = new GridBagConstraints();
140
			gbc.weightx = 1;
141
			gbc.fill = GridBagConstraints.HORIZONTAL;
142
			gbc.insets = new Insets(0, 2, 2, 2);
143
			
144
			gbc.gridy = 0;
145
			centralPanel.add(getLevelPanel(), gbc);
146
			
147
			gbc.gridy = 1;
148
			centralPanel.add(getOutputScalePanel(), gbc);
149
			
150
			gbc.insets = new Insets(0, 0, 0, 0);
151
			gbc.gridy = 2;
152
			posterizationPanel = new PosterizationPanel();
153
			centralPanel.add(posterizationPanel, gbc);
154
			
155
			gbc.gridy = 3;
156
			highPassPanel = new HighPassPanel();
157
			centralPanel.add(highPassPanel, gbc);
158
			
159
			gbc.gridy = 4;
160
			noisePanel = new NoisePanel();
161
			centralPanel.add(noisePanel, gbc);
162
		}
163
		return centralPanel;
164
	}
165
	
166
	/**
167
	 * Obtiene el panel con los niveles
168
	 * @return
169
	 */
170
	public JPanel getLevelPanel() {
171
		if(levelsPanel == null) {
172
			levelsPanel = new JPanel();
173
			levelsPanel.setLayout(new BorderLayout());
174
			levelsPanel.add(new JLabel(RasterToolsUtil.getText(this, "levels")), BorderLayout.WEST);
175
			levelsPanel.add(getComboLevels(), BorderLayout.CENTER);
176
		}
177
		return levelsPanel;
178
	} 
179
	
180
	/**
181
	 * Obtiene el combo con los niveles
182
	 * @return
183
	 */
184
	public JComboBox getComboLevels() {
185
		if(comboLevels == null) {
186
			comboLevels = new JComboBox();
187
		}
188
		return comboLevels;
189
	} 
190
	
191
	/**
192
	 * Obtiene el panel con la escala de salida
193
	 * @return
194
	 */
195
	public JPanel getOutputScalePanel() {
196
		if(outputScalePanel == null) {
197
			outputScalePanel = new JPanel();
198
			outputScalePanel.setLayout(new BorderLayout());
199
			outputScalePanel.add(new JLabel(RasterToolsUtil.getText(this, "outputscale")), BorderLayout.WEST);
200
			outputScalePanel.add(getComboOutputScale(), BorderLayout.CENTER);
201
		}
202
		return outputScalePanel;
203
	} 
204
	
205
	/**
206
	 * Obtiene el combo con la escala de salida
207
	 * @return
208
	 */
209
	public JComboBox getComboOutputScale() {
210
		if(outputScale == null) {
211
			outputScale = new JComboBox();
212
		}
213
		return outputScale;
214
	} 
215
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/vectorizacion/ui/GrayConversionPreviewRender.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.rastertools.vectorizacion.ui;
20

  
21
import org.gvsig.raster.beans.previewbase.IPreviewRenderProcess;
22
import org.gvsig.raster.grid.filter.FilterTypeException;
23
import org.gvsig.raster.hierarchy.IRasterRendering;
24

  
25
/**
26
 * Clase para el renderizado de la vista previa en la conversi?n 
27
 * a escala de grises.
28
 * 10/06/2008
29
 * @author Nacho Brodin nachobrodin@gmail.com
30
 */
31
public class GrayConversionPreviewRender implements IPreviewRenderProcess  {
32

  
33
	/*
34
	 * (non-Javadoc)
35
	 * @see org.gvsig.raster.beans.previewbase.IPreviewRenderProcess#process(org.gvsig.raster.hierarchy.IRasterRendering)
36
	 */
37
	public void process(IRasterRendering rendering) throws FilterTypeException {
38
	}
39

  
40
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/vectorizacion/ui/PosterizationPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.rastertools.vectorizacion.ui;
20

  
21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
23
import java.awt.Insets;
24
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionListener;
26

  
27
import javax.swing.BorderFactory;
28
import javax.swing.JCheckBox;
29
import javax.swing.JPanel;
30

  
31
import org.gvsig.gui.beans.checkslidertext.CheckSliderTextContainer;
32
import org.gvsig.gui.beans.datainput.DataInputContainer;
33
import org.gvsig.raster.util.RasterToolsUtil;
34

  
35
/**
36
 * Panel con los controles para la posterizaci?n.
37
 * 
38
 * 09/06/2008
39
 * @author Nacho Brodin nachobrodin@gmail.com
40
 */
41
public class PosterizationPanel extends JPanel implements ActionListener {
42
	private static final long         serialVersionUID  = 1L;
43
	private JCheckBox                 active            = null;
44
	private DataInputContainer        levels            = null;
45
	private CheckSliderTextContainer  threshold         = null;
46
	private boolean                   enabled           = true;
47
	
48
	public PosterizationPanel() {
49
		init();
50
	}
51
	
52
	/**
53
	 * Inicializaci?n de los componentes gr?ficos
54
	 */
55
	private void init() {
56
		setLayout(new GridBagLayout());
57
		setBorder(BorderFactory.createTitledBorder(null, RasterToolsUtil.getText(this, "posterization"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
58
		GridBagConstraints gbc = new GridBagConstraints();
59
		gbc.fill = GridBagConstraints.HORIZONTAL;
60
		gbc.weightx = 1;
61
		gbc.insets = new Insets(0, 0, 5, 0);
62
		
63
		this.add(getActive(), gbc);
64
		
65
		gbc.gridy = 1;
66
		this.add(getLevels(), gbc);
67
		
68
		gbc.gridy = 2;
69
		this.add(getThreshold(), gbc);
70
		
71
		getActive().addActionListener(this);
72
		setComponentEnabled(false);
73
	}
74
	
75
	/**
76
	 * Obtiene el check de activo 
77
	 * @return JCheckBox
78
	 */
79
	public JCheckBox getActive() {
80
		if(active == null)
81
			active = new JCheckBox();
82
		return active;
83
	}
84
	
85
	/**
86
	 * Obtiene el control con el n?mero de niveles
87
	 * @return DataInputContainer
88
	 */
89
	public DataInputContainer getLevels() {
90
		if(levels == null) {
91
			levels = new DataInputContainer();
92
			levels.setLabelText(RasterToolsUtil.getText(this, "levels"));
93
		}
94
		return levels;
95
	}
96
	
97
	/**
98
	 * Obtiene la barra deslizadora con el umbral de posterizaci?n
99
	 * @return CheckSliderTextContainer
100
	 */
101
	public CheckSliderTextContainer getThreshold() {
102
		if(threshold == null)
103
			threshold = new CheckSliderTextContainer(0, 255, 127, false, RasterToolsUtil.getText(this, "threshold"), true, false, false);
104
		return threshold;
105
	}
106

  
107
	/**
108
	 * Gesti?n del evento del check de activaci?n y desactivaci?n
109
	 */
110
	public void actionPerformed(ActionEvent e) {
111
		setComponentEnabled(enabled);
112
	}
113

  
114
	/**
115
	 * Activa o desactiva el componente. El estado de activaci?n y desactivaci?n de un
116
	 * componente depende de los controles que contiene. En este caso activa o desactiva
117
	 * la barra de incremento y el campo de texto con el n?mero de niveles.
118
	 * @param enabled
119
	 */
120
	public void setComponentEnabled(boolean enabled) {
121
		getThreshold().setControlEnabled(enabled);
122
		getLevels().setControlEnabled(enabled);
123
		this.enabled = !enabled;
124
	}
125
}
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/vectorizacion/ui/NoisePanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.rastertools.vectorizacion.ui;
20

  
21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
23
import java.awt.Insets;
24
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionListener;
26

  
27
import javax.swing.BorderFactory;
28
import javax.swing.JCheckBox;
29
import javax.swing.JPanel;
30

  
31
import org.gvsig.gui.beans.checkslidertext.CheckSliderTextContainer;
32
import org.gvsig.raster.util.RasterToolsUtil;
33

  
34
/**
35
 * Panel con los controles del filtro de ruido.
36
 * 
37
 * 09/06/2008
38
 * @author Nacho Brodin nachobrodin@gmail.com
39
 */
40
public class NoisePanel extends JPanel implements ActionListener {
41
	private static final long         serialVersionUID  = 1L;
42
	private JCheckBox                 active            = null;
43
	private CheckSliderTextContainer  threshold         = null;
44
	private boolean                   enabled           = true;
45
	
46
	public NoisePanel() {
47
		init();
48
	}
49
	
50
	/**
51
	 * Inicializaci?n de los componentes gr?ficos
52
	 */
53
	private void init() {
54
		setLayout(new GridBagLayout());
55
		setBorder(BorderFactory.createTitledBorder(null, RasterToolsUtil.getText(this, "noisefilter"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
56
		GridBagConstraints gbc = new GridBagConstraints();
57
		gbc.fill = GridBagConstraints.HORIZONTAL;
58
		gbc.weightx = 1;
59
		gbc.insets = new Insets(0, 0, 5, 0);
60
		
61
		this.add(getActive(), gbc);
62
		
63
		gbc.gridy = 1;
64
		this.add(getThreshold(), gbc);
65
		
66
		getActive().addActionListener(this);
67
		setComponentEnabled(false);
68
	}
69
	
70
	/**
71
	 * Obtiene el check de activo 
72
	 * @return JCheckBox
73
	 */
74
	public JCheckBox getActive() {
75
		if(active == null)
76
			active = new JCheckBox();
77
		return active;
78
	}
79
		
80
	/**
81
	 * Obtiene la barra deslizadora con el radio del filtro de paso alto
82
	 * @return CheckSliderTextContainer
83
	 */
84
	public CheckSliderTextContainer getThreshold() {
85
		if(threshold == null)
86
			threshold = new CheckSliderTextContainer(0, 255, 127, false, RasterToolsUtil.getText(this, "threshold"), true, false, false);
87
		return threshold;
88
	}
89

  
90
	/**
91
	 * Gesti?n del evento del check de activaci?n y desactivaci?n
92
	 */
93
	public void actionPerformed(ActionEvent e) {
94
		setComponentEnabled(enabled);
95
	}
96

  
97
	/**
98
	 * Activa o desactiva el componente. El estado de activaci?n y desactivaci?n de un
99
	 * componente depende de los controles que contiene. En este caso activa o desactiva
100
	 * la barra de incremento.
101
	 * @param enabled
102
	 */
103
	public void setComponentEnabled(boolean enabled) {
104
		getThreshold().setControlEnabled(enabled);
105
		this.enabled = !enabled;
106
	}
107
}

Also available in: Unified diff