38 |
38 |
private MainWindow windowMainPanel = null;
|
39 |
39 |
private MainWindow windowComponentsPanel = null;
|
40 |
40 |
private MainWindow statisticsPanel = null;
|
41 |
|
private FLyrRaster lyr = null;
|
42 |
|
private PCStatsDataStructure stats = null;
|
43 |
|
|
|
41 |
private FLyrRaster lyr = null;
|
|
42 |
private PCStatsDataStructure stats = null;
|
|
43 |
|
44 |
44 |
public void initialize() {
|
45 |
|
|
|
45 |
|
46 |
46 |
// Adds an entry to the TOC's floating menu to those layers defined in this extension
|
47 |
|
|
|
47 |
|
48 |
48 |
//ExtensionPoint exPoint = ToolsLocator.getExtensionPointManager().add("My_TocActions");
|
49 |
49 |
//exPoint.append("MyMenuEntry", "", new PrincipalComponentsTocMenuEntry());
|
50 |
50 |
|
51 |
51 |
// Adds a new tab to the "add layer" dialog
|
52 |
|
|
|
52 |
|
53 |
53 |
//AddLayer.addWizard(PrincipalComponentsWizard.class);
|
54 |
|
|
|
54 |
|
55 |
55 |
// Adds a new button in the raster bar
|
56 |
56 |
// TODO: Remove for providers
|
57 |
57 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
|
58 |
58 |
ExtensionPoint point = extensionPoints.add("GenericToolBarMenu");
|
59 |
59 |
point.append("PrincipalComponents", "", PrincipalComponentsTocMenuEntry.getSingleton());
|
60 |
60 |
PrincipalComponentsTocMenuEntry.setExtension(this);
|
61 |
|
|
|
61 |
|
62 |
62 |
Messages.addResourceFamily("org.gvsig.raster.principalcomponents.app.i18n.text",
|
63 |
63 |
PrincipalComponentsExtension.class.getClassLoader(),
|
64 |
|
PrincipalComponentsExtension.class.getClass().getName());
|
|
64 |
PrincipalComponentsExtension.class.getClass().getName());
|
65 |
65 |
|
66 |
66 |
initilizeIcons();
|
67 |
67 |
}
|
68 |
|
|
|
68 |
|
69 |
69 |
public void postInitialize() {
|
70 |
70 |
new ToolboxPCLoader().registerTool();
|
71 |
71 |
}
|
... | ... | |
77 |
77 |
RasterSwingLibrary.messageBoxError(Messages.getText("layer_not_found"), null);
|
78 |
78 |
return;
|
79 |
79 |
}
|
80 |
|
|
|
80 |
|
81 |
81 |
String defaultROIEPSG = getFirstMapCtrl().getProjection().getAbrev();
|
82 |
|
|
|
82 |
|
83 |
83 |
mainPanel = PrincipalComponentsSwingLocator.getSwingManager().createPCAMainPanel(
|
84 |
84 |
lyr.getDataStore(),
|
85 |
85 |
lyr.getName(),
|
86 |
86 |
lyr.getDataStore().getBandCount(),
|
87 |
87 |
defaultROIEPSG);
|
88 |
|
|
89 |
|
windowMainPanel = new MainWindow(mainPanel.getComponent(),
|
90 |
|
Messages.getText("principal_components"),
|
91 |
|
400, 350,
|
|
88 |
|
|
89 |
windowMainPanel = new MainWindow(mainPanel.getComponent(),
|
|
90 |
Messages.getText("principal_components"),
|
|
91 |
400, 350,
|
92 |
92 |
this);
|
93 |
|
|
|
93 |
|
94 |
94 |
PluginServices.getMDIManager().addCentredWindow(windowMainPanel);
|
95 |
|
|
|
95 |
|
96 |
96 |
mainPanel.initialize();
|
97 |
97 |
}
|
98 |
98 |
}
|
99 |
|
|
|
99 |
|
100 |
100 |
/**
|
101 |
101 |
* Gets the Mapcontrol for the first view found.
|
102 |
102 |
* @return
|
103 |
103 |
*/
|
104 |
104 |
private MapControl getFirstMapCtrl() {
|
105 |
|
IWindow[] windowList = PluginServices.getMDIManager().getAllWindows();
|
|
105 |
IWindow[] windowList = PluginServices.getMDIManager().getOrderedWindows();
|
106 |
106 |
for (int i = 0; i < windowList.length; i++) {
|
107 |
107 |
if(windowList[i] instanceof IView) {
|
108 |
108 |
return ((IView)windowList[i]).getMapControl();
|
109 |
109 |
}
|
110 |
|
}
|
|
110 |
}
|
111 |
111 |
return null;
|
112 |
112 |
}
|
113 |
113 |
|
... | ... | |
121 |
121 |
if(lyrList[i] instanceof FLyrRaster)
|
122 |
122 |
return (FLyrRaster)lyrList[i];
|
123 |
123 |
}
|
124 |
|
return null;
|
|
124 |
return null;
|
125 |
125 |
}
|
126 |
126 |
|
127 |
127 |
public boolean isEnabled() {
|
... | ... | |
139 |
139 |
}
|
140 |
140 |
|
141 |
141 |
public void actionPerformed(ActionEvent e) {
|
142 |
|
//ACCEPT MAIN PANEL
|
|
142 |
//ACCEPT MAIN PANEL
|
143 |
143 |
if( e.getSource() == ((DefaultButtonsPanel)windowMainPanel).getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY) ||
|
144 |
144 |
e.getSource() == ((DefaultButtonsPanel)windowMainPanel).getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) {
|
145 |
145 |
DataProcess task = null;
|
... | ... | |
153 |
153 |
task.init();
|
154 |
154 |
task.start();
|
155 |
155 |
}
|
156 |
|
|
|
156 |
|
157 |
157 |
//GENERATE STATISTICS BUTTON
|
158 |
|
if( componentsPanel != null &&
|
|
158 |
if( componentsPanel != null &&
|
159 |
159 |
PrincipalComponentsSwingLibrary.GENERATE_STATIST == componentsPanel.getComponentIDByObject(e.getSource())) {
|
160 |
160 |
try {
|
161 |
161 |
Object[] result = (Object[])componentsPanel.getResult();
|
162 |
162 |
JPanel statsPanel = PrincipalComponentsSwingLocator.getSwingManager().createStatisticsPanel(
|
163 |
|
stats,
|
164 |
|
(Boolean)result[1],
|
165 |
|
(Boolean)result[2],
|
|
163 |
stats,
|
|
164 |
(Boolean)result[1],
|
|
165 |
(Boolean)result[2],
|
166 |
166 |
(Boolean)result[3]);
|
167 |
|
statisticsPanel = new MainWindow(statsPanel,
|
168 |
|
Messages.getText("stats"),
|
169 |
|
800, 500,
|
|
167 |
statisticsPanel = new MainWindow(statsPanel,
|
|
168 |
Messages.getText("stats"),
|
|
169 |
800, 500,
|
170 |
170 |
this,
|
171 |
171 |
true);
|
172 |
|
|
|
172 |
|
173 |
173 |
PluginServices.getMDIManager().addWindow(statisticsPanel);
|
174 |
174 |
} catch (Exception e1) {
|
175 |
175 |
RasterSwingLibrary.messageBoxError(Messages.getText("problems_creating_process"), null);
|
176 |
176 |
return;
|
177 |
177 |
}
|
178 |
178 |
}
|
179 |
|
|
|
179 |
|
180 |
180 |
//ACCEPT COMPONENTS PANEL
|
181 |
181 |
if( windowComponentsPanel != null &&
|
182 |
182 |
(e.getSource() == ((DefaultButtonsPanel)windowComponentsPanel).getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY) ||
|
... | ... | |
199 |
199 |
public void end(Object param) {
|
200 |
200 |
HashMap<String, Object> params = (HashMap<String, Object>)param;
|
201 |
201 |
String processName = (String)params.get(ProcessParamsManagement.PROCESS_NAME);
|
202 |
|
|
|
202 |
|
203 |
203 |
//END STATISTICS PROCESS (after accept main dialog)
|
204 |
204 |
if (processName.equals(PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL)) {
|
205 |
205 |
PluginServices.getMDIManager().closeWindow(windowMainPanel);
|
... | ... | |
207 |
207 |
String fileName = (String)params.get("PATH");
|
208 |
208 |
boolean[] bands = (boolean[])params.get("BANDS");
|
209 |
209 |
String rois = (String)params.get("ROI_EPSG");
|
210 |
|
|
|
210 |
|
211 |
211 |
componentsPanel = PrincipalComponentsSwingLocator.getSwingManager().createPCAComponentsListPanel(
|
212 |
|
lyr.getDataStore(),
|
213 |
|
stats,
|
214 |
|
fileName,
|
|
212 |
lyr.getDataStore(),
|
|
213 |
stats,
|
|
214 |
fileName,
|
215 |
215 |
bands,
|
216 |
216 |
rois);
|
217 |
217 |
componentsPanel.addListener(this);
|
218 |
|
windowComponentsPanel = new MainWindow(componentsPanel.getComponent(),
|
219 |
|
Messages.getText("principal_components"),
|
220 |
|
400, 350,
|
|
218 |
windowComponentsPanel = new MainWindow(componentsPanel.getComponent(),
|
|
219 |
Messages.getText("principal_components"),
|
|
220 |
400, 350,
|
221 |
221 |
this);
|
222 |
222 |
PluginServices.getMDIManager().addCentredWindow(windowComponentsPanel);
|
223 |
223 |
componentsPanel.initialize();
|
224 |
224 |
}
|
225 |
225 |
}
|
226 |
|
|
|
226 |
|
227 |
227 |
public void interrupted() {
|
228 |
|
|
|
228 |
|
229 |
229 |
}
|
230 |
|
|
|
230 |
|
231 |
231 |
public void updateProgress(int current, int total) {
|
232 |
|
|
|
232 |
|
233 |
233 |
}
|
234 |
234 |
}
|