Revision 11784
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/resources-plugin/org/gvsig/raster/principalcomponents/swing/impl/i18n/text.properties | ||
---|---|---|
1 |
components_selection=Selecci?n de componentes |
|
2 |
autovalor=Autovalor |
|
3 |
by_band=Por banda |
|
4 |
var_covar=Matriz varianza-covarianza |
|
5 |
autovector=Autovector |
|
6 |
generate=Generar |
|
7 |
stats=Estadisticas |
|
0 | 8 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/resources-plugin/org/gvsig/raster/principalcomponents/swing/impl/i18n/text_en.properties | ||
---|---|---|
1 |
components_selection=Component selection |
|
2 |
autovalor=Eigenvalue |
|
3 |
by_band=By band |
|
4 |
var_covar=Matrix variance-covariance |
|
5 |
autovector=Eigenvector |
|
6 |
generate=Generate |
|
7 |
stats=Statistics |
|
0 | 8 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/resources/org/gvsig/raster/principalcomponents/swing/impl/i18n/text.properties | ||
---|---|---|
1 |
components_selection=Selecci?n de componentes |
|
2 |
autovalor=Autovalor |
|
3 |
by_band=Por banda |
|
4 |
var_covar=Matriz varianza-covarianza |
|
5 |
autovector=Autovector |
|
6 |
generate=Generar |
|
7 |
stats=Estadisticas |
|
8 |
use_rois=Usar regiones de inter?s de la capa |
|
9 |
band=Banda |
|
10 |
max=M?ximo |
|
11 |
min=M?nimo |
|
12 |
mean=Media |
|
13 |
variance=Varianza |
|
14 |
standard_deviation=Desviaci?n est?ndar |
|
0 | 15 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/resources/org/gvsig/raster/principalcomponents/swing/impl/i18n/text_en.properties | ||
---|---|---|
1 |
components_selection=Component selection |
|
2 |
autovalor=Eigenvalue |
|
3 |
by_band=By band |
|
4 |
var_covar=Matrix variance-covariance |
|
5 |
autovector=Eigenvector |
|
6 |
generate=Generate |
|
7 |
stats=Statistics |
|
8 |
use_rois=Use regions of interest of the layer |
|
9 |
band=Band |
|
10 |
max=Maximum |
|
11 |
min=Minimum |
|
12 |
mean=Mean |
|
13 |
variance=Variance |
|
14 |
standard_deviation=Standard deviation |
|
0 | 15 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.principalcomponents.swing.impl.PrincipalComponentsDefaultSwingImplLibrary |
|
0 | 2 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/java/org/gvsig/raster/principalcomponents/swing/impl/main/PCAComponentsListPanelImpl.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.principalcomponents.swing.impl.main; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.GridBagConstraints; |
|
26 |
import java.awt.GridBagLayout; |
|
27 |
import java.awt.event.ActionListener; |
|
28 |
import java.util.EventListener; |
|
29 |
import java.util.List; |
|
30 |
|
|
31 |
import javax.swing.BorderFactory; |
|
32 |
import javax.swing.JButton; |
|
33 |
import javax.swing.JComponent; |
|
34 |
import javax.swing.JPanel; |
|
35 |
import javax.swing.JRadioButton; |
|
36 |
|
|
37 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
38 |
import org.gvsig.i18n.Messages; |
|
39 |
import org.gvsig.raster.algorithm.BasicAPISwingPanel; |
|
40 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
41 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
42 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
43 |
import org.gvsig.raster.principalcomponents.algorithm.PCStatsDataStructure; |
|
44 |
import org.gvsig.raster.principalcomponents.algorithm.PrincipalComponentsAlgorithmLibrary; |
|
45 |
import org.gvsig.raster.principalcomponents.swing.PrincipalComponentsSwingLibrary; |
|
46 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
47 |
import org.gvsig.raster.swing.RasterSwingManager; |
|
48 |
import org.gvsig.raster.swing.pagedtable.ModelLoader; |
|
49 |
import org.gvsig.raster.swing.pagedtable.PagedTable; |
|
50 |
|
|
51 |
/** |
|
52 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
53 |
*/ |
|
54 |
public class PCAComponentsListPanelImpl extends JPanel implements BasicAPISwingPanel { |
|
55 |
private static final long serialVersionUID = 1L; |
|
56 |
private Object inputStore = null; |
|
57 |
private PagedTable table = null; |
|
58 |
private JRadioButton byBandRadioButton = null; |
|
59 |
private JRadioButton varCovarRadioButton = null; |
|
60 |
private JRadioButton autovectorRadioButton = null; |
|
61 |
private JButton generateButton = null; |
|
62 |
private PCStatsDataStructure stats = null; |
|
63 |
private String fileName = null; |
|
64 |
private boolean[] bands = null; |
|
65 |
private String roisEPSG = null; |
|
66 |
|
|
67 |
public PCAComponentsListPanelImpl( |
|
68 |
Object inputStore, |
|
69 |
PCStatsDataStructure stats, |
|
70 |
String fileName, |
|
71 |
boolean[] bands, |
|
72 |
String roisEPSG) { |
|
73 |
this.inputStore = inputStore; |
|
74 |
this.stats = stats; |
|
75 |
this.fileName = fileName; |
|
76 |
this.bands = bands; |
|
77 |
this.roisEPSG = roisEPSG; |
|
78 |
init(); |
|
79 |
} |
|
80 |
|
|
81 |
private void init() { |
|
82 |
setLayout(new GridBagLayout()); |
|
83 |
|
|
84 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
85 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; |
|
86 |
gridBagConstraints1.weightx = 1; |
|
87 |
gridBagConstraints1.weighty = 1; |
|
88 |
gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 0); |
|
89 |
gridBagConstraints1.gridx = 0; |
|
90 |
gridBagConstraints1.gridy = 0; |
|
91 |
add(getInputsPanel(), gridBagConstraints1); |
|
92 |
|
|
93 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
94 |
gridBagConstraints1.weighty = 0; |
|
95 |
gridBagConstraints1.gridy = 1; |
|
96 |
add(getPanelStatistics(), gridBagConstraints1); |
|
97 |
} |
|
98 |
|
|
99 |
public JPanel getPanelStatistics() { |
|
100 |
JPanel p = new JPanel(); |
|
101 |
p.setBorder(BorderFactory.createTitledBorder(Messages.getText("statistics"))); |
|
102 |
p.setLayout(new GridBagLayout()); |
|
103 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
104 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
105 |
gridBagConstraints1.weightx = 1; |
|
106 |
gridBagConstraints1.insets = new java.awt.Insets(0, 0, 2, 0); |
|
107 |
gridBagConstraints1.gridwidth = 2; |
|
108 |
|
|
109 |
gridBagConstraints1.gridx = 0; |
|
110 |
gridBagConstraints1.gridy = 0; |
|
111 |
p.add(getByBandRadioButton(), gridBagConstraints1); |
|
112 |
|
|
113 |
gridBagConstraints1.gridwidth = 1; |
|
114 |
gridBagConstraints1.gridy = 1; |
|
115 |
p.add(getVarCovarRadioButton(), gridBagConstraints1); |
|
116 |
|
|
117 |
gridBagConstraints1.gridwidth = 2; |
|
118 |
gridBagConstraints1.gridy = 2; |
|
119 |
p.add(getAutovectorRadioButton(), gridBagConstraints1); |
|
120 |
|
|
121 |
gridBagConstraints1.gridwidth = 1; |
|
122 |
gridBagConstraints1.gridx = 1; |
|
123 |
gridBagConstraints1.gridy = 1; |
|
124 |
p.add(getGenerateButton(), gridBagConstraints1); |
|
125 |
|
|
126 |
return p; |
|
127 |
} |
|
128 |
|
|
129 |
public JRadioButton getByBandRadioButton() { |
|
130 |
if(byBandRadioButton == null) { |
|
131 |
byBandRadioButton = new JRadioButton(Messages.getText("by_band")); |
|
132 |
byBandRadioButton.setSelected(true); |
|
133 |
} |
|
134 |
return byBandRadioButton; |
|
135 |
} |
|
136 |
|
|
137 |
public JRadioButton getVarCovarRadioButton() { |
|
138 |
if(varCovarRadioButton == null) |
|
139 |
varCovarRadioButton = new JRadioButton(Messages.getText("var_covar")); |
|
140 |
return varCovarRadioButton; |
|
141 |
} |
|
142 |
|
|
143 |
public JRadioButton getAutovectorRadioButton() { |
|
144 |
if(autovectorRadioButton == null) |
|
145 |
autovectorRadioButton = new JRadioButton(Messages.getText("autovector")); |
|
146 |
return autovectorRadioButton; |
|
147 |
} |
|
148 |
|
|
149 |
public JButton getGenerateButton() { |
|
150 |
if(generateButton == null) |
|
151 |
generateButton = new JButton(Messages.getText("generate")); |
|
152 |
return generateButton; |
|
153 |
} |
|
154 |
|
|
155 |
private JPanel getInputsPanel() { |
|
156 |
JPanel p = new JPanel(); |
|
157 |
p.setBorder(BorderFactory.createTitledBorder(Messages.getText("components_selection"))); |
|
158 |
p.setLayout(new BorderLayout()); |
|
159 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
160 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; |
|
161 |
gridBagConstraints1.weightx = 1; |
|
162 |
gridBagConstraints1.weighty = 1; |
|
163 |
gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2); |
|
164 |
|
|
165 |
gridBagConstraints1.gridx = 0; |
|
166 |
gridBagConstraints1.gridy = 0; |
|
167 |
p.add(getPagedTable().getComponent(), BorderLayout.CENTER); |
|
168 |
|
|
169 |
return p; |
|
170 |
} |
|
171 |
|
|
172 |
public JComponent getComponent() { |
|
173 |
return this; |
|
174 |
} |
|
175 |
|
|
176 |
public PagedTable getPagedTable() { |
|
177 |
if(table == null) { |
|
178 |
RasterSwingManager manager = RasterSwingLocator.getSwingManager(); |
|
179 |
String[] columnNames = { |
|
180 |
"", |
|
181 |
"C", |
|
182 |
Messages.getText("autovalor"), |
|
183 |
"%"}; |
|
184 |
int[] columnSizes = {30, 35, -1, -1}; |
|
185 |
|
|
186 |
BandTableModel model = new BandTableModel(columnNames); |
|
187 |
ModelLoader loader = manager.createModelLoader(model); |
|
188 |
CheckBoxColumnRenderer render = new CheckBoxColumnRenderer(null); |
|
189 |
CheckBoxColumnEditor editor = new CheckBoxColumnEditor(); |
|
190 |
loader.setRenderForColumn(0, render); |
|
191 |
loader.setCellEditorForColumn(0, editor); |
|
192 |
loader.setColumnNames(columnNames); |
|
193 |
loader.setColumnWidths(columnSizes); |
|
194 |
|
|
195 |
table = manager.createPagedTable(loader); |
|
196 |
table.showControllerTable(false); |
|
197 |
table.showMoveRowsControls(false); |
|
198 |
} |
|
199 |
return table; |
|
200 |
} |
|
201 |
|
|
202 |
public Object getResult() throws ProcessException { |
|
203 |
DataProcess task = RasterBaseAlgorithmLibrary.getManager().createRasterTask(PrincipalComponentsAlgorithmLibrary.PC_PROCESS_LABEL); |
|
204 |
List<String> params = task.getRasterTaskInputParameters(PrincipalComponentsAlgorithmLibrary.PC_PROCESS_LABEL); |
|
205 |
for (int i = 0; i < params.size(); i++) { |
|
206 |
String paramName = params.get(i); |
|
207 |
Class<?> paramType = task.getParameterTypeByProcess(PrincipalComponentsAlgorithmLibrary.PC_PROCESS_LABEL, paramName); |
|
208 |
if(paramType == RasterDataStore.class) { |
|
209 |
task.addParam(paramName, (RasterDataStore)inputStore); |
|
210 |
} |
|
211 |
if(paramName.equals("SELECTEDPCS") && paramType == Boolean[].class) { |
|
212 |
boolean[] components = new boolean[getPagedTable().getRowCount()]; |
|
213 |
for (int j = 0; j < getPagedTable().getRowCount(); j++) { |
|
214 |
Object obj = getPagedTable().getValueAt(j, 0); |
|
215 |
if(obj instanceof Boolean) |
|
216 |
components[j] = ((Boolean)obj).booleanValue(); |
|
217 |
} |
|
218 |
task.addParam(paramName, components); |
|
219 |
} |
|
220 |
|
|
221 |
if(paramName.equals("BANDS") && paramType == Boolean[].class) { |
|
222 |
task.addParam(paramName, bands); |
|
223 |
} |
|
224 |
|
|
225 |
if(paramType == PCStatsDataStructure.class) { |
|
226 |
task.addParam(paramName, stats); |
|
227 |
} |
|
228 |
|
|
229 |
if(paramType == String.class) { |
|
230 |
task.addParam(paramName, fileName); |
|
231 |
} |
|
232 |
|
|
233 |
if(paramName.equals("ROI_EPSG")) { |
|
234 |
task.addParam(paramName, roisEPSG); |
|
235 |
} |
|
236 |
} |
|
237 |
return new Object[]{task, getByBandRadioButton().isSelected(), getVarCovarRadioButton().isSelected(), getAutovectorRadioButton().isSelected()}; |
|
238 |
} |
|
239 |
|
|
240 |
|
|
241 |
public void initialize() { |
|
242 |
double acumulado = 0; |
|
243 |
for (int i = 0; i < stats.getAutovalues().length; i++) |
|
244 |
acumulado += stats.getAutovalues()[i]; |
|
245 |
int autova[] = new int[stats.getAutovalues().length]; |
|
246 |
int cont = stats.getAutovalues().length - 1; |
|
247 |
for (int i = 0; i < stats.getAutovalues().length; i++) { |
|
248 |
autova[i] = cont; |
|
249 |
cont--; |
|
250 |
} |
|
251 |
|
|
252 |
for (int i = stats.getAutovalues().length-1; i >= 0; i--) { |
|
253 |
getPagedTable().addRow(new Object[] {true, |
|
254 |
autova[i], |
|
255 |
stats.getAutovalues()[i], |
|
256 |
stats.getAutovalues()[i] / acumulado}); |
|
257 |
} |
|
258 |
} |
|
259 |
|
|
260 |
public int getComponentIDByObject(Object obj) { |
|
261 |
return obj == getGenerateButton() ? PrincipalComponentsSwingLibrary.GENERATE_STATIST : -1; |
|
262 |
} |
|
263 |
|
|
264 |
public void addListener(EventListener listener) { |
|
265 |
if(listener instanceof ActionListener) |
|
266 |
getGenerateButton().addActionListener((ActionListener)listener); |
|
267 |
} |
|
268 |
|
|
269 |
} |
|
0 | 270 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/java/org/gvsig/raster/principalcomponents/swing/impl/main/PrincipalComponentsPanelImpl.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.principalcomponents.swing.impl.main; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.GridBagConstraints; |
|
26 |
import java.awt.GridBagLayout; |
|
27 |
import java.io.File; |
|
28 |
import java.util.EventListener; |
|
29 |
import java.util.List; |
|
30 |
|
|
31 |
import javax.swing.BorderFactory; |
|
32 |
import javax.swing.JComponent; |
|
33 |
import javax.swing.JLabel; |
|
34 |
import javax.swing.JPanel; |
|
35 |
|
|
36 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
37 |
import org.gvsig.i18n.Messages; |
|
38 |
import org.gvsig.raster.algorithm.BasicAPISwingPanel; |
|
39 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
40 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
41 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
42 |
import org.gvsig.raster.principalcomponents.algorithm.PrincipalComponentsAlgorithmLibrary; |
|
43 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
44 |
import org.gvsig.raster.swing.RasterSwingManager; |
|
45 |
import org.gvsig.raster.swing.newlayer.CreateNewLayerPanel; |
|
46 |
import org.gvsig.raster.swing.pagedtable.ModelLoader; |
|
47 |
import org.gvsig.raster.swing.pagedtable.PagedTable; |
|
48 |
|
|
49 |
/** |
|
50 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
51 |
*/ |
|
52 |
public class PrincipalComponentsPanelImpl extends JPanel implements BasicAPISwingPanel { |
|
53 |
private static final long serialVersionUID = 1L; |
|
54 |
private String layerName = null; |
|
55 |
private CreateNewLayerPanel newLayerPanel = null; |
|
56 |
private Object inputStore = null; |
|
57 |
private PagedTable table = null; |
|
58 |
private int bandList = 0; |
|
59 |
|
|
60 |
public PrincipalComponentsPanelImpl(Object inputStore, String layerName, int bandList) { |
|
61 |
this.inputStore = inputStore; |
|
62 |
this.layerName = layerName; |
|
63 |
this.bandList = bandList; |
|
64 |
init(); |
|
65 |
} |
|
66 |
|
|
67 |
private void init() { |
|
68 |
setLayout(new GridBagLayout()); |
|
69 |
|
|
70 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
71 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
72 |
gridBagConstraints1.weightx = 1; |
|
73 |
gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 0); |
|
74 |
gridBagConstraints1.gridx = 0; |
|
75 |
gridBagConstraints1.gridy = 0; |
|
76 |
add(getLayerPanel(), gridBagConstraints1); |
|
77 |
|
|
78 |
gridBagConstraints1.gridy = 2; |
|
79 |
add((JComponent)getCreateNewLayerPanel(), gridBagConstraints1); |
|
80 |
|
|
81 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; |
|
82 |
gridBagConstraints1.gridy = 1; |
|
83 |
gridBagConstraints1.weighty = 1; |
|
84 |
add(getInputsPanel(), gridBagConstraints1); |
|
85 |
} |
|
86 |
|
|
87 |
private JPanel getLayerPanel() { |
|
88 |
JPanel p = new JPanel(); |
|
89 |
p.setBorder(BorderFactory.createTitledBorder(Messages.getText("layer"))); |
|
90 |
p.setLayout(new GridBagLayout()); |
|
91 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
92 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
93 |
gridBagConstraints1.weightx = 1; |
|
94 |
gridBagConstraints1.insets = new java.awt.Insets(0, 0, 2, 0); |
|
95 |
|
|
96 |
gridBagConstraints1.gridx = 0; |
|
97 |
gridBagConstraints1.gridy = 0; |
|
98 |
p.add(new JLabel(layerName), gridBagConstraints1); |
|
99 |
|
|
100 |
return p; |
|
101 |
} |
|
102 |
|
|
103 |
private JPanel getInputsPanel() { |
|
104 |
JPanel p = new JPanel(); |
|
105 |
p.setBorder(BorderFactory.createTitledBorder(Messages.getText("bands"))); |
|
106 |
p.setLayout(new BorderLayout()); |
|
107 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
108 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; |
|
109 |
gridBagConstraints1.weightx = 1; |
|
110 |
gridBagConstraints1.weighty = 1; |
|
111 |
gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2); |
|
112 |
|
|
113 |
gridBagConstraints1.gridx = 0; |
|
114 |
gridBagConstraints1.gridy = 0; |
|
115 |
p.add(getPagedTable().getComponent(), BorderLayout.CENTER); |
|
116 |
|
|
117 |
return p; |
|
118 |
} |
|
119 |
|
|
120 |
public JComponent getComponent() { |
|
121 |
return this; |
|
122 |
} |
|
123 |
|
|
124 |
public PagedTable getPagedTable() { |
|
125 |
if(table == null) { |
|
126 |
RasterSwingManager manager = RasterSwingLocator.getSwingManager(); |
|
127 |
String[] columnNames = { |
|
128 |
"", |
|
129 |
Messages.getText("bands")}; |
|
130 |
int[] columnSizes = {30, -1}; |
|
131 |
|
|
132 |
BandTableModel model = new BandTableModel(columnNames); |
|
133 |
ModelLoader loader = manager.createModelLoader(model); |
|
134 |
CheckBoxColumnRenderer render = new CheckBoxColumnRenderer(null); |
|
135 |
CheckBoxColumnEditor editor = new CheckBoxColumnEditor(); |
|
136 |
loader.setRenderForColumn(0, render); |
|
137 |
loader.setCellEditorForColumn(0, editor); |
|
138 |
loader.setColumnNames(columnNames); |
|
139 |
loader.setColumnWidths(columnSizes); |
|
140 |
|
|
141 |
table = manager.createPagedTable(loader); |
|
142 |
table.showControllerTable(false); |
|
143 |
table.showMoveRowsControls(false); |
|
144 |
} |
|
145 |
return table; |
|
146 |
} |
|
147 |
|
|
148 |
public DataProcess getResult() throws ProcessException { |
|
149 |
DataProcess task = RasterBaseAlgorithmLibrary.getManager().createRasterTask(PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL); |
|
150 |
List<String> params = task.getRasterTaskInputParameters(PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL); |
|
151 |
for (int i = 0; i < params.size(); i++) { |
|
152 |
String paramName = params.get(i); |
|
153 |
Class<?> paramType = task.getParameterTypeByProcess(PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL, paramName); |
|
154 |
if(paramType == RasterDataStore[].class) { |
|
155 |
task.addParam(paramName, new RasterDataStore[]{(RasterDataStore)inputStore}); |
|
156 |
} |
|
157 |
if(paramType == String.class) { |
|
158 |
String filename = newLayerPanel.getDirectorySelected() + File.separator + newLayerPanel.getFileSelected(); |
|
159 |
if(!filename.endsWith(".tif")) |
|
160 |
filename += ".tif"; |
|
161 |
task.addParam(paramName, filename); |
|
162 |
} |
|
163 |
if(paramType == Boolean[].class) { |
|
164 |
boolean[] bands = new boolean[getPagedTable().getRowCount()]; |
|
165 |
for (int j = 0; j < getPagedTable().getRowCount(); j++) { |
|
166 |
Object obj = getPagedTable().getValueAt(j, 0); |
|
167 |
if(obj instanceof Boolean) |
|
168 |
bands[j] = ((Boolean)obj).booleanValue(); |
|
169 |
} |
|
170 |
task.addParam(paramName, bands); |
|
171 |
} |
|
172 |
} |
|
173 |
return task; |
|
174 |
} |
|
175 |
|
|
176 |
public CreateNewLayerPanel getCreateNewLayerPanel() { |
|
177 |
if(newLayerPanel == null) { |
|
178 |
newLayerPanel = RasterSwingLocator.getSwingManager().createNewLayerPanel(); |
|
179 |
} |
|
180 |
return newLayerPanel; |
|
181 |
} |
|
182 |
|
|
183 |
public void initialize() { |
|
184 |
for (int i = 0; i < bandList; i++) { |
|
185 |
getPagedTable().addRow(new Object[]{true, "B" + i}); |
|
186 |
} |
|
187 |
} |
|
188 |
|
|
189 |
public int getComponentIDByObject(Object obj) { |
|
190 |
return -1; |
|
191 |
} |
|
192 |
|
|
193 |
public void addListener(EventListener listener) { |
|
194 |
// TODO Auto-generated method stub |
|
195 |
|
|
196 |
} |
|
197 |
|
|
198 |
} |
|
0 | 199 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/java/org/gvsig/raster/principalcomponents/swing/impl/main/PCAMainPanelImpl.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.principalcomponents.swing.impl.main; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.GridBagConstraints; |
|
26 |
import java.awt.GridBagLayout; |
|
27 |
import java.io.File; |
|
28 |
import java.util.EventListener; |
|
29 |
import java.util.List; |
|
30 |
|
|
31 |
import javax.swing.BorderFactory; |
|
32 |
import javax.swing.JCheckBox; |
|
33 |
import javax.swing.JComponent; |
|
34 |
import javax.swing.JLabel; |
|
35 |
import javax.swing.JPanel; |
|
36 |
|
|
37 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
38 |
import org.gvsig.i18n.Messages; |
|
39 |
import org.gvsig.raster.algorithm.BasicAPISwingPanel; |
|
40 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
41 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
42 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
43 |
import org.gvsig.raster.principalcomponents.algorithm.PrincipalComponentsAlgorithmLibrary; |
|
44 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
45 |
import org.gvsig.raster.swing.RasterSwingManager; |
|
46 |
import org.gvsig.raster.swing.newlayer.CreateNewLayerPanel; |
|
47 |
import org.gvsig.raster.swing.pagedtable.ModelLoader; |
|
48 |
import org.gvsig.raster.swing.pagedtable.PagedTable; |
|
49 |
|
|
50 |
/** |
|
51 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
52 |
*/ |
|
53 |
public class PCAMainPanelImpl extends JPanel implements BasicAPISwingPanel { |
|
54 |
private static final long serialVersionUID = 1L; |
|
55 |
private String layerName = null; |
|
56 |
private CreateNewLayerPanel newLayerPanel = null; |
|
57 |
private Object inputStore = null; |
|
58 |
private PagedTable table = null; |
|
59 |
private JCheckBox roisCheck = null; |
|
60 |
private int bandList = 0; |
|
61 |
private String roisEPSG = null; |
|
62 |
|
|
63 |
public PCAMainPanelImpl(Object inputStore, String layerName, int bandList, String roisEPSG) { |
|
64 |
this.inputStore = inputStore; |
|
65 |
this.layerName = layerName; |
|
66 |
this.bandList = bandList; |
|
67 |
this.roisEPSG = roisEPSG; |
|
68 |
init(); |
|
69 |
} |
|
70 |
|
|
71 |
private void init() { |
|
72 |
setLayout(new GridBagLayout()); |
|
73 |
|
|
74 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
75 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
76 |
gridBagConstraints1.weightx = 1; |
|
77 |
gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 0); |
|
78 |
gridBagConstraints1.gridx = 0; |
|
79 |
gridBagConstraints1.gridy = 0; |
|
80 |
add(getLayerPanel(), gridBagConstraints1); |
|
81 |
|
|
82 |
gridBagConstraints1.gridy = 2; |
|
83 |
add((JComponent)getCreateNewLayerPanel(), gridBagConstraints1); |
|
84 |
|
|
85 |
if(roisEPSG != null) { |
|
86 |
gridBagConstraints1.gridy = 3; |
|
87 |
add(getROIsCheck(), gridBagConstraints1); |
|
88 |
} |
|
89 |
|
|
90 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; |
|
91 |
gridBagConstraints1.gridy = 1; |
|
92 |
gridBagConstraints1.weighty = 1; |
|
93 |
add(getInputsPanel(), gridBagConstraints1); |
|
94 |
} |
|
95 |
|
|
96 |
private JPanel getLayerPanel() { |
|
97 |
JPanel p = new JPanel(); |
|
98 |
p.setBorder(BorderFactory.createTitledBorder(Messages.getText("layer"))); |
|
99 |
p.setLayout(new GridBagLayout()); |
|
100 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
101 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
102 |
gridBagConstraints1.weightx = 1; |
|
103 |
gridBagConstraints1.insets = new java.awt.Insets(0, 0, 2, 0); |
|
104 |
|
|
105 |
gridBagConstraints1.gridx = 0; |
|
106 |
gridBagConstraints1.gridy = 0; |
|
107 |
p.add(new JLabel(layerName), gridBagConstraints1); |
|
108 |
|
|
109 |
return p; |
|
110 |
} |
|
111 |
|
|
112 |
private JPanel getInputsPanel() { |
|
113 |
JPanel p = new JPanel(); |
|
114 |
p.setBorder(BorderFactory.createTitledBorder(Messages.getText("bands"))); |
|
115 |
p.setLayout(new BorderLayout()); |
|
116 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
117 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; |
|
118 |
gridBagConstraints1.weightx = 1; |
|
119 |
gridBagConstraints1.weighty = 1; |
|
120 |
gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2); |
|
121 |
|
|
122 |
gridBagConstraints1.gridx = 0; |
|
123 |
gridBagConstraints1.gridy = 0; |
|
124 |
p.add(getPagedTable().getComponent(), BorderLayout.CENTER); |
|
125 |
|
|
126 |
return p; |
|
127 |
} |
|
128 |
|
|
129 |
public JComponent getComponent() { |
|
130 |
return this; |
|
131 |
} |
|
132 |
|
|
133 |
public PagedTable getPagedTable() { |
|
134 |
if(table == null) { |
|
135 |
RasterSwingManager manager = RasterSwingLocator.getSwingManager(); |
|
136 |
String[] columnNames = { |
|
137 |
"", |
|
138 |
Messages.getText("bands")}; |
|
139 |
int[] columnSizes = {30, -1}; |
|
140 |
|
|
141 |
BandTableModel model = new BandTableModel(columnNames); |
|
142 |
ModelLoader loader = manager.createModelLoader(model); |
|
143 |
CheckBoxColumnRenderer render = new CheckBoxColumnRenderer(null); |
|
144 |
CheckBoxColumnEditor editor = new CheckBoxColumnEditor(); |
|
145 |
loader.setRenderForColumn(0, render); |
|
146 |
loader.setCellEditorForColumn(0, editor); |
|
147 |
loader.setColumnNames(columnNames); |
|
148 |
loader.setColumnWidths(columnSizes); |
|
149 |
|
|
150 |
table = manager.createPagedTable(loader); |
|
151 |
table.showControllerTable(false); |
|
152 |
table.showMoveRowsControls(false); |
|
153 |
} |
|
154 |
return table; |
|
155 |
} |
|
156 |
|
|
157 |
public DataProcess getResult() throws ProcessException { |
|
158 |
DataProcess task = RasterBaseAlgorithmLibrary.getManager().createRasterTask(PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL); |
|
159 |
List<String> params = task.getRasterTaskInputParameters(PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL); |
|
160 |
for (int i = 0; i < params.size(); i++) { |
|
161 |
String paramName = params.get(i); |
|
162 |
Class<?> paramType = task.getParameterTypeByProcess(PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL, paramName); |
|
163 |
if(paramType == RasterDataStore.class) { |
|
164 |
task.addParam(paramName, (RasterDataStore)inputStore); |
|
165 |
} |
|
166 |
if(paramName.equals("PATH")) { |
|
167 |
String filename = newLayerPanel.getDirectorySelected() + File.separator + newLayerPanel.getFileSelected(); |
|
168 |
if(!filename.endsWith(".tif")) |
|
169 |
filename += ".tif"; |
|
170 |
task.addParam(paramName, filename); |
|
171 |
} |
|
172 |
if(paramType == Boolean[].class) { |
|
173 |
boolean[] bands = new boolean[getPagedTable().getRowCount()]; |
|
174 |
for (int j = 0; j < getPagedTable().getRowCount(); j++) { |
|
175 |
Object obj = getPagedTable().getValueAt(j, 0); |
|
176 |
if(obj instanceof Boolean) |
|
177 |
bands[j] = ((Boolean)obj).booleanValue(); |
|
178 |
} |
|
179 |
task.addParam(paramName, bands); |
|
180 |
} |
|
181 |
|
|
182 |
if(getROIsCheck().isSelected()) { |
|
183 |
if(paramName.equals("ROI_EPSG")) { |
|
184 |
task.addParam(paramName, roisEPSG); |
|
185 |
} |
|
186 |
} |
|
187 |
} |
|
188 |
return task; |
|
189 |
} |
|
190 |
|
|
191 |
public JCheckBox getROIsCheck() { |
|
192 |
if(roisCheck == null) { |
|
193 |
roisCheck = new JCheckBox(Messages.getText("use_rois")); |
|
194 |
} |
|
195 |
return roisCheck; |
|
196 |
} |
|
197 |
|
|
198 |
public CreateNewLayerPanel getCreateNewLayerPanel() { |
|
199 |
if(newLayerPanel == null) { |
|
200 |
newLayerPanel = RasterSwingLocator.getSwingManager().createNewLayerPanel(); |
|
201 |
} |
|
202 |
return newLayerPanel; |
|
203 |
} |
|
204 |
|
|
205 |
public void initialize() { |
|
206 |
for (int i = 0; i < bandList; i++) { |
|
207 |
getPagedTable().addRow(new Object[]{true, "B" + i}); |
|
208 |
} |
|
209 |
} |
|
210 |
|
|
211 |
public int getComponentIDByObject(Object obj) { |
|
212 |
return -1; |
|
213 |
} |
|
214 |
|
|
215 |
public void addListener(EventListener listener) { |
|
216 |
} |
|
217 |
} |
|
0 | 218 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/java/org/gvsig/raster/principalcomponents/swing/impl/main/CheckBoxColumnEditor.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.raster.principalcomponents.swing.impl.main; |
|
25 |
|
|
26 |
import java.awt.Component; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
|
|
30 |
import javax.swing.AbstractCellEditor; |
|
31 |
import javax.swing.JCheckBox; |
|
32 |
import javax.swing.JTable; |
|
33 |
import javax.swing.SwingUtilities; |
|
34 |
import javax.swing.table.TableCellEditor; |
|
35 |
|
|
36 |
/** |
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
38 |
*/ |
|
39 |
public class CheckBoxColumnEditor extends AbstractCellEditor |
|
40 |
implements TableCellEditor { |
|
41 |
final private static long serialVersionUID = -3370601314380922368L; |
|
42 |
public JCheckBox theCheckBox; |
|
43 |
|
|
44 |
public CheckBoxColumnEditor() { |
|
45 |
super(); |
|
46 |
theCheckBox = new JCheckBox(); |
|
47 |
theCheckBox.addActionListener(new ActionListener() { |
|
48 |
public void actionPerformed(ActionEvent event) { |
|
49 |
fireEditingStopped() ; |
|
50 |
|
|
51 |
} |
|
52 |
}); |
|
53 |
} |
|
54 |
|
|
55 |
public Component getTableCellEditorComponent(JTable table, Object obj, |
|
56 |
boolean isSelected, |
|
57 |
int row, int col) { |
|
58 |
theCheckBox.setHorizontalAlignment(SwingUtilities.CENTER); |
|
59 |
|
|
60 |
Boolean lValueAsBoolean = (Boolean) obj; |
|
61 |
theCheckBox.setSelected(lValueAsBoolean.booleanValue()); |
|
62 |
|
|
63 |
return theCheckBox; |
|
64 |
} |
|
65 |
|
|
66 |
public Object getCellEditorValue() { |
|
67 |
return new Boolean(theCheckBox.isSelected()); |
|
68 |
} |
|
69 |
} |
|
0 | 70 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/java/org/gvsig/raster/principalcomponents/swing/impl/main/CheckBoxColumnRenderer.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.raster.principalcomponents.swing.impl.main; |
|
25 |
|
|
26 |
import java.awt.Component; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
|
|
30 |
import javax.swing.JCheckBox; |
|
31 |
import javax.swing.JTable; |
|
32 |
import javax.swing.SwingConstants; |
|
33 |
import javax.swing.table.TableCellRenderer; |
|
34 |
|
|
35 |
/** |
|
36 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
37 |
*/ |
|
38 |
public class CheckBoxColumnRenderer extends JCheckBox implements TableCellRenderer { |
|
39 |
final private static long serialVersionUID = -3370601314380922368L; |
|
40 |
private ActionListener listener = null; |
|
41 |
|
|
42 |
public CheckBoxColumnRenderer() {} |
|
43 |
|
|
44 |
public CheckBoxColumnRenderer(ActionListener listener) { |
|
45 |
this.listener = listener; |
|
46 |
} |
|
47 |
|
|
48 |
public Component getTableCellRendererComponent(JTable table, |
|
49 |
Object value, |
|
50 |
boolean isSelected, |
|
51 |
boolean hasFocus, |
|
52 |
int row, int column) { |
|
53 |
if (value == null) { |
|
54 |
this.setSelected(false); |
|
55 |
} |
|
56 |
if(isSelected) |
|
57 |
if(listener != null) |
|
58 |
listener.actionPerformed(new ActionEvent(this, row, "SELECT_ROW")); |
|
59 |
|
|
60 |
if(value instanceof Boolean){ |
|
61 |
Boolean ValueAsBoolean = (Boolean) value; |
|
62 |
this.setSelected(ValueAsBoolean.booleanValue()); |
|
63 |
this.setHorizontalAlignment(SwingConstants.CENTER); |
|
64 |
} |
|
65 |
|
|
66 |
return this; |
|
67 |
} |
|
68 |
} |
|
0 | 69 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/java/org/gvsig/raster/principalcomponents/swing/impl/main/BandTableModel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.raster.principalcomponents.swing.impl.main; |
|
25 |
|
|
26 |
import javax.swing.table.DefaultTableModel; |
|
27 |
|
|
28 |
import org.gvsig.raster.swing.pagedtable.TableModel; |
|
29 |
/** |
|
30 |
* Model for the band table |
|
31 |
* |
|
32 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
33 |
*/ |
|
34 |
public class BandTableModel extends DefaultTableModel implements TableModel { |
|
35 |
final private static long serialVersionUID = -3370601314380922368L; |
|
36 |
private int nColumns = 0; |
|
37 |
|
|
38 |
public BandTableModel(String[] columnNames) { |
|
39 |
super(new Object[0][columnNames.length], columnNames); |
|
40 |
this.nColumns = columnNames.length; |
|
41 |
} |
|
42 |
|
|
43 |
public Class<?> getColumnClass(int c) { |
|
44 |
return String.class; |
|
45 |
} |
|
46 |
|
|
47 |
public void setValueAt(Object value, int row, int col) { |
|
48 |
super.setValueAt(value, row, col); |
|
49 |
} |
|
50 |
|
|
51 |
public void addNew() { |
|
52 |
Object[] line = new Object[nColumns]; |
|
53 |
line[0] = new Boolean(true); |
|
54 |
for (int i = 0; i < nColumns; i++) |
|
55 |
line[i] = new String(""); |
|
56 |
super.addRow(line); |
|
57 |
} |
|
58 |
|
|
59 |
public Object[] getNewLine() { |
|
60 |
Object[] o = new Object[nColumns]; |
|
61 |
o[0] = new Boolean(true); |
|
62 |
for (int i = 1; i < nColumns; i++) |
|
63 |
o[i] = ""; |
|
64 |
return o; |
|
65 |
} |
|
66 |
|
|
67 |
public void addNewLine() { |
|
68 |
// TODO Auto-generated method stub |
|
69 |
|
|
70 |
} |
|
71 |
} |
|
0 | 72 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.106/org.gvsig.raster.principalcomponents.swing/org.gvsig.raster.principalcomponents.swing.impl/src/main/java/org/gvsig/raster/principalcomponents/swing/impl/main/ComponentsTableModel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.raster.principalcomponents.swing.impl.main; |
|
25 |
|
|
26 |
import javax.swing.table.DefaultTableModel; |
|
27 |
|
|
28 |
import org.gvsig.raster.swing.pagedtable.TableModel; |
|
29 |
/** |
|
30 |
* Model for the list of components |
|
31 |
* |
|
32 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
33 |
*/ |
|
34 |
public class ComponentsTableModel extends DefaultTableModel implements TableModel { |
|
35 |
final private static long serialVersionUID = -3370601314380922368L; |
|
36 |
private int nColumns = 0; |
|
37 |
|
|
38 |
public ComponentsTableModel(String[] columnNames) { |
|
39 |
super(new Object[0][columnNames.length], columnNames); |
|
40 |
this.nColumns = columnNames.length; |
|
41 |
} |
|
42 |
|
|
43 |
public Class<?> getColumnClass(int c) { |
|
44 |
return String.class; |
|
45 |
} |
|
46 |
|
|
47 |
public void setValueAt(Object value, int row, int col) { |
|
48 |
super.setValueAt(value, row, col); |
|
49 |
} |
|
50 |
|
|
51 |
public void addNew() { |
|
52 |
Object[] line = new Object[nColumns]; |
|
53 |
line[0] = new Boolean(true); |
|
54 |
for (int i = 0; i < nColumns; i++) |
|
55 |
line[i] = new String(""); |
|
56 |
super.addRow(line); |
|
57 |
} |
|
58 |
|
|
59 |
public Object[] getNewLine() { |
|
60 |
Object[] o = new Object[nColumns]; |
Also available in: Unified diff