Revision 14636
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.raster.principalcomponents</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
<version>2.2.143</version> |
|
7 |
<name>${project.artifactId}</name> |
|
8 |
<description /> |
|
9 |
<inceptionYear>2011</inceptionYear> |
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.desktop</artifactId> |
|
13 |
<version>2.0.330</version> |
|
14 |
</parent> |
|
15 |
|
|
16 |
<properties> |
|
17 |
<!-- El plugin versions:use-latest-versions falla con scope import --> |
|
18 |
<!-- asi que toca usar el versions:update-properties que si que funciona --> |
|
19 |
<org.gvsig.raster.version>2.2.160</org.gvsig.raster.version> |
|
20 |
<org.gvsig.geoprocess.version>2.2.170</org.gvsig.geoprocess.version> |
|
21 |
</properties> |
|
22 |
|
|
23 |
<repositories> |
|
24 |
<repository> |
|
25 |
<id>gvsig-public-http-repository</id> |
|
26 |
<name>gvSIG maven public HTTP repository</name> |
|
27 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
28 |
<releases> |
|
29 |
<enabled>true</enabled> |
|
30 |
<updatePolicy>daily</updatePolicy> |
|
31 |
<checksumPolicy>warn</checksumPolicy> |
|
32 |
</releases> |
|
33 |
<snapshots> |
|
34 |
<enabled>true</enabled> |
|
35 |
<updatePolicy>daily</updatePolicy> |
|
36 |
<checksumPolicy>warn</checksumPolicy> |
|
37 |
</snapshots> |
|
38 |
</repository> |
|
39 |
</repositories> |
|
40 |
|
|
41 |
<scm> |
|
42 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143</connection> |
|
43 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143</developerConnection> |
|
44 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143</url> |
|
45 |
</scm> |
|
46 |
<build> |
|
47 |
<plugins> |
|
48 |
<plugin> |
|
49 |
<groupId>org.apache.maven.plugins</groupId> |
|
50 |
<artifactId>maven-release-plugin</artifactId> |
|
51 |
<configuration> |
|
52 |
<tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.principalcomponents/tags/</tagBase> |
|
53 |
<goals>deploy</goals> |
|
54 |
</configuration> |
|
55 |
</plugin> |
|
56 |
</plugins> |
|
57 |
</build> |
|
58 |
|
|
59 |
<dependencyManagement> |
|
60 |
<dependencies> |
|
61 |
|
|
62 |
<dependency> |
|
63 |
<groupId>org.gvsig.legacy</groupId> |
|
64 |
<artifactId>jama</artifactId> |
|
65 |
<version>1.0.3</version> |
|
66 |
</dependency> |
|
67 |
|
|
68 |
<!-- |
|
69 |
Versions of other gvSIG projects |
|
70 |
--> |
|
71 |
<dependency> |
|
72 |
<groupId>org.gvsig</groupId> |
|
73 |
<artifactId>org.gvsig.raster</artifactId> |
|
74 |
<version>${org.gvsig.raster.version}</version> |
|
75 |
<type>pom</type> |
|
76 |
<scope>import</scope> |
|
77 |
</dependency> |
|
78 |
|
|
79 |
<dependency> |
|
80 |
<groupId>org.gvsig</groupId> |
|
81 |
<artifactId>org.gvsig.geoprocess</artifactId> |
|
82 |
<version>${org.gvsig.geoprocess.version}</version> |
|
83 |
<type>pom</type> |
|
84 |
<scope>import</scope> |
|
85 |
</dependency> |
|
86 |
<!-- |
|
87 |
Versions of child projects |
|
88 |
--> |
|
89 |
<dependency> |
|
90 |
<groupId>org.gvsig</groupId> |
|
91 |
<artifactId>org.gvsig.raster.principalcomponents.swing.api</artifactId> |
|
92 |
<version>2.2.143</version> |
|
93 |
</dependency> |
|
94 |
<dependency> |
|
95 |
<groupId>org.gvsig</groupId> |
|
96 |
<artifactId>org.gvsig.raster.principalcomponents.swing.impl</artifactId> |
|
97 |
<version>2.2.143</version> |
|
98 |
</dependency> |
|
99 |
<dependency> |
|
100 |
<groupId>org.gvsig</groupId> |
|
101 |
<artifactId>org.gvsig.raster.principalcomponents.algorithm</artifactId> |
|
102 |
<version>2.2.143</version> |
|
103 |
</dependency> |
|
104 |
<dependency> |
|
105 |
<groupId>org.gvsig</groupId> |
|
106 |
<artifactId>org.gvsig.raster.principalcomponents.toolbox.algorithm</artifactId> |
|
107 |
<version>2.2.143</version> |
|
108 |
</dependency> |
|
109 |
|
|
110 |
</dependencies> |
|
111 |
</dependencyManagement> |
|
112 |
<modules> |
|
113 |
<module>org.gvsig.raster.principalcomponents.algorithm</module> |
|
114 |
<module>org.gvsig.raster.principalcomponents.toolbox.algorithm</module> |
|
115 |
<module>org.gvsig.raster.principalcomponents.swing</module> |
|
116 |
<module>org.gvsig.raster.principalcomponents.app.principalcomponentsclient</module> |
|
117 |
</modules> |
|
118 |
</project> |
|
0 | 119 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/buildNumber.properties | ||
---|---|---|
1 |
#Tue Jul 27 01:28:40 CEST 2021 |
|
2 |
buildNumber=151 |
|
0 | 3 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>.</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>${project.artifactId}/lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
<outputDirectory>${project.artifactId}</outputDirectory> |
|
16 |
</file> |
|
17 |
|
|
18 |
<!-- <file> |
|
19 |
<source>${user.home}/.m2/repository/org/gvsig/org.gvsig.raster.principalcomponents.toolbox.algorithm/${project.version}/org.gvsig.raster.principalcomponents.toolbox.algorithm-${project.version}.jar</source> |
|
20 |
<outputDirectory>org.gvsig.raster.tools.toolbox.app.client/lib</outputDirectory> |
|
21 |
</file>--> |
|
22 |
</files> |
|
23 |
|
|
24 |
<fileSets> |
|
25 |
<fileSet> |
|
26 |
<directory>src/main/resources-plugin</directory> |
|
27 |
<outputDirectory>${project.artifactId}</outputDirectory> |
|
28 |
</fileSet> |
|
29 |
</fileSets> |
|
30 |
|
|
31 |
|
|
32 |
<dependencySets> |
|
33 |
<dependencySet> |
|
34 |
<useProjectArtifact>false</useProjectArtifact> |
|
35 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
36 |
<outputDirectory>${project.artifactId}/lib</outputDirectory> |
|
37 |
<includes> |
|
38 |
<include>org.gvsig:org.gvsig.raster.principalcomponents.app.principalcomponentsclient:jar</include> |
|
39 |
<include>org.gvsig:org.gvsig.raster.principalcomponents.lib.api:jar</include> |
|
40 |
<include>org.gvsig:org.gvsig.raster.principalcomponents.lib.impl:jar</include> |
|
41 |
<include>org.gvsig:org.gvsig.raster.principalcomponents.swing.api:jar</include> |
|
42 |
<include>org.gvsig:org.gvsig.raster.principalcomponents.swing.impl:jar</include> |
|
43 |
<include>org.gvsig:org.gvsig.raster.principalcomponents.algorithm:jar</include> |
|
44 |
<include>org.gvsig:org.gvsig.raster.principalcomponents.toolbox.algorithm:jar</include> |
|
45 |
</includes> |
|
46 |
</dependencySet> |
|
47 |
|
|
48 |
</dependencySets> |
|
49 |
</assembly> |
|
0 | 50 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/src/main/java/org/gvsig/raster/principalcomponents/app/MainWindow.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2011-2012 Prodevelop S.L |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
*/ |
|
21 |
package org.gvsig.raster.principalcomponents.app; |
|
22 |
|
|
23 |
import java.awt.BorderLayout; |
|
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
|
|
27 |
import javax.swing.JComponent; |
|
28 |
|
|
29 |
import org.gvsig.andami.PluginServices; |
|
30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
31 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
32 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
33 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
|
34 |
|
|
35 |
|
|
36 |
/** |
|
37 |
* Basic frame for a gvSIG <code>IWindow</code> object. This frame adds buttons |
|
38 |
* of Cancel, Accept and others. |
|
39 |
* |
|
40 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
41 |
*/ |
|
42 |
public class MainWindow extends DefaultButtonsPanel implements IWindow, ActionListener { |
|
43 |
|
|
44 |
private static final long serialVersionUID = -4401123724140025094L; |
|
45 |
private ActionListener listener = null; |
|
46 |
private WindowInfo info = null; |
|
47 |
|
|
48 |
private Object profile = WindowInfo.EDITOR_PROFILE; |
|
49 |
|
|
50 |
public MainWindow(JComponent panel, String title, int w, int h, ActionListener actionListener) { |
|
51 |
this.listener = actionListener; |
|
52 |
|
|
53 |
setLayout(new BorderLayout()); |
|
54 |
add(panel, BorderLayout.CENTER); |
|
55 |
|
|
56 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setVisible(false); |
|
57 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this); |
|
58 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this); |
|
59 |
|
|
60 |
info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE); |
|
61 |
info.setTitle(title); |
|
62 |
info.setWidth(w); |
|
63 |
info.setHeight(h); |
|
64 |
} |
|
65 |
|
|
66 |
public MainWindow(JComponent panel, String title, int w, int h, ActionListener actionListener, boolean closeButton) { |
|
67 |
this.listener = actionListener; |
|
68 |
|
|
69 |
setLayout(new BorderLayout()); |
|
70 |
add(panel, BorderLayout.CENTER); |
|
71 |
|
|
72 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setVisible(false); |
|
73 |
|
|
74 |
if(closeButton) { |
|
75 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setVisible(false); |
|
76 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).setVisible(false); |
|
77 |
getButtonsPanel().addClose(); |
|
78 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_CLOSE).addActionListener(this); |
|
79 |
} else { |
|
80 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this); |
|
81 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this); |
|
82 |
} |
|
83 |
|
|
84 |
info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE); |
|
85 |
info.setTitle(title); |
|
86 |
info.setWidth(w); |
|
87 |
info.setHeight(h); |
|
88 |
} |
|
89 |
|
|
90 |
public WindowInfo getWindowInfo() { |
|
91 |
return info; |
|
92 |
} |
|
93 |
|
|
94 |
public Object getWindowProfile() { |
|
95 |
return profile; |
|
96 |
} |
|
97 |
|
|
98 |
public void actionPerformed(ActionEvent e) { |
|
99 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) { |
|
100 |
listener.actionPerformed(e); |
|
101 |
PluginServices.getMDIManager().closeWindow(this); |
|
102 |
} |
|
103 |
|
|
104 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY)) { |
|
105 |
listener.actionPerformed(e); |
|
106 |
} |
|
107 |
|
|
108 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL)) { |
|
109 |
PluginServices.getMDIManager().closeWindow(this); |
|
110 |
} |
|
111 |
|
|
112 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CLOSE)) { |
|
113 |
PluginServices.getMDIManager().closeWindow(this); |
|
114 |
} |
|
115 |
} |
|
116 |
} |
|
0 | 117 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/src/main/java/org/gvsig/raster/principalcomponents/app/PrincipalComponentsExtension.java | ||
---|---|---|
1 |
package org.gvsig.raster.principalcomponents.app; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
import java.util.HashMap; |
|
6 |
|
|
7 |
import javax.swing.JPanel; |
|
8 |
|
|
9 |
import org.gvsig.andami.IconThemeHelper; |
|
10 |
import org.gvsig.andami.PluginServices; |
|
11 |
import org.gvsig.andami.plugins.Extension; |
|
12 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
13 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
14 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
15 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
16 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
17 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
|
18 |
import org.gvsig.i18n.Messages; |
|
19 |
import org.gvsig.raster.algorithm.BasicAPISwingPanel; |
|
20 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
21 |
import org.gvsig.raster.algorithm.process.IProcessActions; |
|
22 |
import org.gvsig.raster.algorithm.process.ProcessParamsManagement; |
|
23 |
import org.gvsig.raster.fmap.layers.*; |
|
24 |
import org.gvsig.raster.principalcomponents.algorithm.PCStatsDataStructure; |
|
25 |
import org.gvsig.raster.principalcomponents.algorithm.PrincipalComponentsAlgorithmLibrary; |
|
26 |
import org.gvsig.raster.principalcomponents.app.toolbox.ToolboxPCLoader; |
|
27 |
import org.gvsig.raster.principalcomponents.swing.PrincipalComponentsSwingLibrary; |
|
28 |
import org.gvsig.raster.principalcomponents.swing.PrincipalComponentsSwingLocator; |
|
29 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
30 |
import org.gvsig.tools.ToolsLocator; |
|
31 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
32 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
33 |
|
|
34 |
|
|
35 |
public class PrincipalComponentsExtension extends Extension implements ActionListener, IProcessActions { |
|
36 |
private BasicAPISwingPanel mainPanel = null; |
|
37 |
private BasicAPISwingPanel componentsPanel = null; |
|
38 |
private MainWindow windowMainPanel = null; |
|
39 |
private MainWindow windowComponentsPanel = null; |
|
40 |
private MainWindow statisticsPanel = null; |
|
41 |
private FLyrRaster lyr = null; |
|
42 |
private PCStatsDataStructure stats = null; |
|
43 |
|
|
44 |
public void initialize() { |
|
45 |
|
|
46 |
// Adds an entry to the TOC's floating menu to those layers defined in this extension |
|
47 |
|
|
48 |
//ExtensionPoint exPoint = ToolsLocator.getExtensionPointManager().add("My_TocActions"); |
|
49 |
//exPoint.append("MyMenuEntry", "", new PrincipalComponentsTocMenuEntry()); |
|
50 |
|
|
51 |
// Adds a new tab to the "add layer" dialog |
|
52 |
|
|
53 |
//AddLayer.addWizard(PrincipalComponentsWizard.class); |
|
54 |
|
|
55 |
// Adds a new button in the raster bar |
|
56 |
// TODO: Remove for providers |
|
57 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
58 |
ExtensionPoint point = extensionPoints.add("GenericToolBarMenu"); |
|
59 |
point.append("PrincipalComponents", "", PrincipalComponentsTocMenuEntry.getSingleton()); |
|
60 |
PrincipalComponentsTocMenuEntry.setExtension(this); |
|
61 |
|
|
62 |
Messages.addResourceFamily("org.gvsig.raster.principalcomponents.app.i18n.text", |
|
63 |
PrincipalComponentsExtension.class.getClassLoader(), |
|
64 |
PrincipalComponentsExtension.class.getClass().getName()); |
|
65 |
|
|
66 |
initilizeIcons(); |
|
67 |
} |
|
68 |
|
|
69 |
public void postInitialize() { |
|
70 |
new ToolboxPCLoader().registerTool(); |
|
71 |
} |
|
72 |
|
|
73 |
public void execute(String actionCommand) { |
|
74 |
if (actionCommand.compareTo("PrincipalComponents") == 0) { |
|
75 |
lyr = getSelectedLayer(); |
|
76 |
if(lyr == null) { |
|
77 |
RasterSwingLibrary.messageBoxError(Messages.getText("layer_not_found"), null); |
|
78 |
return; |
|
79 |
} |
|
80 |
|
|
81 |
String defaultROIEPSG = getFirstMapCtrl().getProjection().getAbrev(); |
|
82 |
|
|
83 |
mainPanel = PrincipalComponentsSwingLocator.getSwingManager().createPCAMainPanel( |
|
84 |
lyr.getDataStore(), |
|
85 |
lyr.getName(), |
|
86 |
lyr.getDataStore().getBandCount(), |
|
87 |
defaultROIEPSG); |
|
88 |
|
|
89 |
windowMainPanel = new MainWindow(mainPanel.getComponent(), |
|
90 |
Messages.getText("principal_components"), |
|
91 |
400, 350, |
|
92 |
this); |
|
93 |
|
|
94 |
PluginServices.getMDIManager().addCentredWindow(windowMainPanel); |
|
95 |
|
|
96 |
mainPanel.initialize(); |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Gets the Mapcontrol for the first view found. |
|
102 |
* @return |
|
103 |
*/ |
|
104 |
private MapControl getFirstMapCtrl() { |
|
105 |
IWindow[] windowList = PluginServices.getMDIManager().getOrderedWindows(); |
|
106 |
for (int i = 0; i < windowList.length; i++) { |
|
107 |
if(windowList[i] instanceof IView) { |
|
108 |
return ((IView)windowList[i]).getMapControl(); |
|
109 |
} |
|
110 |
} |
|
111 |
return null; |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* Gets the selected and valid layer |
|
116 |
* @return |
|
117 |
*/ |
|
118 |
private FLyrRaster getSelectedLayer() { |
|
119 |
|
|
120 |
MapControl firstMapCtrl = getFirstMapCtrl(); |
|
121 |
if (firstMapCtrl != null) { |
|
122 |
FLayer[] lyrList = |
|
123 |
firstMapCtrl.getMapContext().getLayers().getActives(); |
|
124 |
for (int i = 0; i < lyrList.length; i++) { |
|
125 |
if (lyrList[i] instanceof FLyrRaster) |
|
126 |
return (FLyrRaster) lyrList[i]; |
|
127 |
} |
|
128 |
} |
|
129 |
return null; |
|
130 |
} |
|
131 |
|
|
132 |
public boolean isEnabled() { |
|
133 |
FLyrRaster selectedLayer = getSelectedLayer(); |
|
134 |
if (selectedLayer == null) |
|
135 |
return false; |
|
136 |
|
|
137 |
if (!(selectedLayer instanceof ILayerState)) |
|
138 |
return false; |
|
139 |
|
|
140 |
if (!((ILayerState) selectedLayer).isOpen()) |
|
141 |
return false; |
|
142 |
|
|
143 |
if(((FLyrRaster) selectedLayer).getRender().getFilterList().get("colortable") != null) |
|
144 |
return false; |
|
145 |
|
|
146 |
return true; |
|
147 |
} |
|
148 |
|
|
149 |
public boolean isVisible() { |
|
150 |
FLyrRaster selectedLayer = getSelectedLayer(); |
|
151 |
if (selectedLayer == null) { |
|
152 |
return false; |
|
153 |
} |
|
154 |
|
|
155 |
if (!(selectedLayer instanceof IRasterLayerActions)) |
|
156 |
return false; |
|
157 |
|
|
158 |
return ((IRasterLayerActions) selectedLayer).isActionEnabled(IRasterLayerActions.ENHANCED); |
|
159 |
} |
|
160 |
|
|
161 |
void initilizeIcons(){ |
|
162 |
IconThemeHelper.registerIcon(null, "principal-components", this); |
|
163 |
IconThemeHelper.registerIcon(null, "gvsig-icon", this); |
|
164 |
IconThemeHelper.registerIcon(null, "gvsig-icon16x16", this); |
|
165 |
} |
|
166 |
|
|
167 |
public void actionPerformed(ActionEvent e) { |
|
168 |
//ACCEPT MAIN PANEL |
|
169 |
if( e.getSource() == ((DefaultButtonsPanel)windowMainPanel).getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY) || |
|
170 |
e.getSource() == ((DefaultButtonsPanel)windowMainPanel).getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) { |
|
171 |
DataProcess task = null; |
|
172 |
try { |
|
173 |
task = (DataProcess)mainPanel.getResult(); |
|
174 |
} catch (Exception e1) { |
|
175 |
RasterSwingLibrary.messageBoxError(Messages.getText("problems_creating_process"), null); |
|
176 |
return; |
|
177 |
} |
|
178 |
task.setActions(this); |
|
179 |
task.init(); |
|
180 |
task.start(); |
|
181 |
} |
|
182 |
|
|
183 |
//GENERATE STATISTICS BUTTON |
|
184 |
if( componentsPanel != null && |
|
185 |
PrincipalComponentsSwingLibrary.GENERATE_STATIST == componentsPanel.getComponentIDByObject(e.getSource())) { |
|
186 |
try { |
|
187 |
Object[] result = (Object[])componentsPanel.getResult(); |
|
188 |
JPanel statsPanel = PrincipalComponentsSwingLocator.getSwingManager().createStatisticsPanel( |
|
189 |
stats, |
|
190 |
(Boolean)result[1], |
|
191 |
(Boolean)result[2], |
|
192 |
(Boolean)result[3]); |
|
193 |
statisticsPanel = new MainWindow(statsPanel, |
|
194 |
Messages.getText("stats"), |
|
195 |
800, 500, |
|
196 |
this, |
|
197 |
true); |
|
198 |
|
|
199 |
PluginServices.getMDIManager().addWindow(statisticsPanel); |
|
200 |
} catch (Exception e1) { |
|
201 |
RasterSwingLibrary.messageBoxError(Messages.getText("problems_creating_process"), null); |
|
202 |
return; |
|
203 |
} |
|
204 |
} |
|
205 |
|
|
206 |
//ACCEPT COMPONENTS PANEL |
|
207 |
if( windowComponentsPanel != null && |
|
208 |
(e.getSource() == ((DefaultButtonsPanel)windowComponentsPanel).getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY) || |
|
209 |
e.getSource() == ((DefaultButtonsPanel)windowComponentsPanel).getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT))) { |
|
210 |
DataProcess task = null; |
|
211 |
try { |
|
212 |
Object[] result = (Object[])componentsPanel.getResult(); |
|
213 |
task = (DataProcess)result[0]; |
|
214 |
task.setActions(new ProcessEndActions(windowComponentsPanel, lyr)); |
|
215 |
task.init(); |
|
216 |
task.start(); |
|
217 |
} catch (Exception e1) { |
|
218 |
RasterSwingLibrary.messageBoxError(Messages.getText("problems_creating_process"), null); |
|
219 |
return; |
|
220 |
} |
|
221 |
} |
|
222 |
} |
|
223 |
|
|
224 |
@SuppressWarnings("unchecked") |
|
225 |
public void end(Object param) { |
|
226 |
HashMap<String, Object> params = (HashMap<String, Object>)param; |
|
227 |
String processName = (String)params.get(ProcessParamsManagement.PROCESS_NAME); |
|
228 |
|
|
229 |
//END STATISTICS PROCESS (after accept main dialog) |
|
230 |
if (processName.equals(PrincipalComponentsAlgorithmLibrary.PC_STATS_PROCESS_LABEL)) { |
|
231 |
PluginServices.getMDIManager().closeWindow(windowMainPanel); |
|
232 |
stats = (PCStatsDataStructure)params.get("STATS_RESULT"); |
|
233 |
String fileName = (String)params.get("PATH"); |
|
234 |
boolean[] bands = (boolean[])params.get("BANDS"); |
|
235 |
String rois = (String)params.get("ROI_EPSG"); |
|
236 |
|
|
237 |
componentsPanel = PrincipalComponentsSwingLocator.getSwingManager().createPCAComponentsListPanel( |
|
238 |
lyr.getDataStore(), |
|
239 |
stats, |
|
240 |
fileName, |
|
241 |
bands, |
|
242 |
rois); |
|
243 |
componentsPanel.addListener(this); |
|
244 |
windowComponentsPanel = new MainWindow(componentsPanel.getComponent(), |
|
245 |
Messages.getText("principal_components"), |
|
246 |
400, 350, |
|
247 |
this); |
|
248 |
PluginServices.getMDIManager().addCentredWindow(windowComponentsPanel); |
|
249 |
componentsPanel.initialize(); |
|
250 |
} |
|
251 |
} |
|
252 |
|
|
253 |
public void interrupted() { |
|
254 |
|
|
255 |
} |
|
256 |
|
|
257 |
public void updateProgress(int current, int total) { |
|
258 |
|
|
259 |
} |
|
260 |
} |
|
0 | 261 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/src/main/java/org/gvsig/raster/principalcomponents/app/PrincipalComponentsTocMenuEntry.java | ||
---|---|---|
1 |
package org.gvsig.raster.principalcomponents.app; |
|
2 |
|
|
3 |
import javax.swing.Icon; |
|
4 |
|
|
5 |
import org.gvsig.andami.IconThemeHelper; |
|
6 |
import org.gvsig.andami.plugins.Extension; |
|
7 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
|
8 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
|
9 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
10 |
import org.gvsig.i18n.Messages; |
|
11 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
12 |
import org.gvsig.raster.fmap.layers.ILayerState; |
|
13 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
|
14 |
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem; |
|
15 |
|
|
16 |
public class PrincipalComponentsTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
|
17 |
static private PrincipalComponentsTocMenuEntry singleton = null; |
|
18 |
private static Extension extension = null; |
|
19 |
|
|
20 |
|
|
21 |
public static void setExtension(Extension ext) { |
|
22 |
extension = ext; |
|
23 |
} |
|
24 |
|
|
25 |
private PrincipalComponentsTocMenuEntry() {} |
|
26 |
|
|
27 |
static public PrincipalComponentsTocMenuEntry getSingleton() { |
|
28 |
if (singleton == null) |
|
29 |
singleton = new PrincipalComponentsTocMenuEntry(); |
|
30 |
return singleton; |
|
31 |
} |
|
32 |
|
|
33 |
public String getGroup() { |
|
34 |
return "Multispectral"; |
|
35 |
} |
|
36 |
|
|
37 |
public int getGroupOrder() { |
|
38 |
return 55; |
|
39 |
} |
|
40 |
|
|
41 |
public int getOrder() { |
|
42 |
return 0; |
|
43 |
} |
|
44 |
|
|
45 |
public String getText() { |
|
46 |
return Messages.getText("principalcomponents"); |
|
47 |
} |
|
48 |
|
|
49 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
|
50 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
|
51 |
return false; |
|
52 |
|
|
53 |
if (!(selectedItems[0] instanceof ILayerState)) |
|
54 |
return false; |
|
55 |
|
|
56 |
if (!((ILayerState) selectedItems[0]).isOpen()) |
|
57 |
return false; |
|
58 |
|
|
59 |
if(((FLyrRaster) selectedItems[0]).getRender().getFilterList().get("colortable") != null) |
|
60 |
return false; |
|
61 |
|
|
62 |
return true; |
|
63 |
} |
|
64 |
|
|
65 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
|
66 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
|
67 |
return false; |
|
68 |
|
|
69 |
if (!(selectedItems[0] instanceof IRasterLayerActions)) |
|
70 |
return false; |
|
71 |
|
|
72 |
return ((IRasterLayerActions) selectedItems[0]).isActionEnabled(IRasterLayerActions.ENHANCED); |
|
73 |
} |
|
74 |
|
|
75 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
|
76 |
extension.execute("PrincipalComponents"); |
|
77 |
} |
|
78 |
|
|
79 |
public Icon getIcon() { |
|
80 |
return IconThemeHelper.getImageIcon("principal-components"); |
|
81 |
} |
|
82 |
|
|
83 |
} |
|
0 | 84 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/src/main/java/org/gvsig/raster/principalcomponents/app/ProcessEndActions.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2011-2012 Prodevelop S.L |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
*/ |
|
21 |
package org.gvsig.raster.principalcomponents.app; |
|
22 |
|
|
23 |
import java.io.File; |
|
24 |
import java.util.HashMap; |
|
25 |
|
|
26 |
import org.gvsig.andami.PluginServices; |
|
27 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
28 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
29 |
import org.gvsig.fmap.dal.DALLocator; |
|
30 |
import org.gvsig.fmap.dal.DataManager; |
|
31 |
import org.gvsig.fmap.dal.DataStore; |
|
32 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
33 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
34 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
|
35 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
36 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
37 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
38 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
39 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
40 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
41 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
42 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
43 |
import org.gvsig.raster.algorithm.process.IProcessActions; |
|
44 |
import org.gvsig.raster.algorithm.process.ProcessParamsManagement; |
|
45 |
import org.gvsig.raster.principalcomponents.algorithm.PrincipalComponentsAlgorithmLibrary; |
|
46 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
47 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
48 |
import org.gvsig.raster.util.RasterNotLoadException; |
|
49 |
|
|
50 |
/** |
|
51 |
* Actions when the process finalizes or is interrupted |
|
52 |
* |
|
53 |
* Nacho Brodin (nachobrodin@gmail.com) |
|
54 |
*/ |
|
55 |
public class ProcessEndActions implements IProcessActions { |
|
56 |
private IWindow window = null; |
|
57 |
private FLayer inputLyr = null; |
|
58 |
|
|
59 |
/** |
|
60 |
* Constructor |
|
61 |
* @param window |
|
62 |
* @param lyr |
|
63 |
* The input layer is only used to select the view where the new layer be loaded |
|
64 |
*/ |
|
65 |
public ProcessEndActions(IWindow window, FLayer lyr) { |
|
66 |
this.window = window; |
|
67 |
this.inputLyr = lyr; |
|
68 |
} |
|
69 |
|
|
70 |
@SuppressWarnings("unchecked") |
|
71 |
public void end(Object param) { |
|
72 |
if(window != null) { |
|
73 |
PluginServices.getMDIManager().closeWindow(window); |
|
74 |
window = null; |
|
75 |
} |
|
76 |
|
|
77 |
HashMap<String, Object> params = (HashMap<String, Object>)param; |
|
78 |
String processName = (String)params.get(ProcessParamsManagement.PROCESS_NAME); |
|
79 |
|
|
80 |
//End the process to get statistics (accept main dialog) |
|
81 |
if (processName.equals(PrincipalComponentsAlgorithmLibrary.PC_PROCESS_LABEL)) { |
|
82 |
String fileName = (String)params.get("FILENAME"); |
|
83 |
long milis = (Long)params.get("TIME"); |
|
84 |
processFinalize(fileName, milis); |
|
85 |
RasterSwingLocator.getSwingManager().showSummaryProcessDialog(fileName, milis); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Acciones que se realizan al finalizar de crear los recortes de imagen. |
|
91 |
* Este m?todo es llamado por el thread TailRasterProcess al finalizar. |
|
92 |
*/ |
|
93 |
private void processFinalize(String fileName, long milis) { |
|
94 |
if (!new File(fileName).exists()) |
|
95 |
return; |
|
96 |
|
|
97 |
if (RasterSwingLibrary.messageBoxYesOrNot("cargar_toc", null)) { |
|
98 |
try { |
|
99 |
loadLayer(fileName, fileName.substring(fileName.lastIndexOf(File.separator) + 1)); |
|
100 |
} catch (RasterNotLoadException e) { |
|
101 |
RasterSwingLibrary.messageBoxError("error_load_layer", e); |
|
102 |
} |
|
103 |
} |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* Gets the view |
|
108 |
* @return |
|
109 |
*/ |
|
110 |
private AbstractViewPanel getView() { |
|
111 |
IWindow[] w = PluginServices.getMDIManager().getAllWindows(); |
|
112 |
for (int i = 0; i < w.length; i++) { |
|
113 |
if(w[i] instanceof AbstractViewPanel) { |
|
114 |
FLayers lyrs = ((AbstractViewPanel)w[i]).getMapControl().getMapContext().getLayers(); |
|
115 |
for (int j = 0; j < lyrs.getLayersCount(); j++) { |
|
116 |
FLayer lyr = lyrs.getLayer(j); |
|
117 |
if(inputLyr == lyr) { |
|
118 |
return ((AbstractViewPanel) w[i]); |
|
119 |
} |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
123 |
return null; |
|
124 |
} |
|
125 |
|
|
126 |
@SuppressWarnings("deprecation") |
|
127 |
private void loadLayer(String fileName, String layerName) throws RasterNotLoadException { |
|
128 |
if(fileName == null) |
|
129 |
return; |
|
130 |
|
|
131 |
//Seleccionamos la vista de gvSIG |
|
132 |
AbstractViewPanel theView = getView(); |
|
133 |
|
|
134 |
theView.getMapControl().getMapContext().beginAtomicEvent(); |
|
135 |
|
|
136 |
try { |
|
137 |
DataManager dataManager = DALLocator.getDataManager(); |
|
138 |
|
|
139 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
|
140 |
RasterDataParameters storeParameters = provServ.createParameters(fileName); |
|
141 |
storeParameters.setURI(new File(fileName).toURI()); |
|
142 |
|
|
143 |
MapContextManager mcm = MapContextLocator.getMapContextManager(); |
|
144 |
|
|
145 |
DataStore dataStore = null; |
|
146 |
try { |
|
147 |
dataStore = dataManager.createStore(storeParameters); |
|
148 |
} catch (ValidateDataParametersException e) { |
|
149 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
150 |
} catch (InitializeException e) { |
|
151 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
152 |
} catch (ProviderNotRegisteredException e) { |
|
153 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
154 |
} |
|
155 |
|
|
156 |
if(layerName == null) { |
|
157 |
int endIndex = fileName.lastIndexOf("."); |
|
158 |
if (endIndex < 0) |
|
159 |
endIndex = fileName.length(); |
|
160 |
|
|
161 |
layerName = fileName.substring(fileName.lastIndexOf(File.separator) + 1, endIndex); |
|
162 |
} |
|
163 |
|
|
164 |
FLayer lyr = mcm.createLayer(layerName, dataStore); |
|
165 |
theView.getMapControl().getMapContext().getLayers().addLayer(lyr); |
|
166 |
|
|
167 |
} catch (LoadLayerException e) { |
|
168 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
169 |
} |
|
170 |
theView.getMapControl().getMapContext().invalidate(); |
|
171 |
theView.getMapControl().getMapContext().endAtomicEvent(); |
|
172 |
} |
|
173 |
|
|
174 |
public void interrupted() { |
|
175 |
|
|
176 |
} |
|
177 |
|
|
178 |
public void updateProgress(int current, int total) { |
|
179 |
|
|
180 |
} |
|
181 |
} |
|
0 | 182 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/src/main/java/org/gvsig/raster/principalcomponents/app/toolbox/PCToolboxAction.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 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 |
|
|
25 |
|
|
26 |
package org.gvsig.raster.principalcomponents.app.toolbox; |
|
27 |
|
|
28 |
import javax.swing.ImageIcon; |
|
29 |
|
|
30 |
import org.gvsig.andami.IconThemeHelper; |
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
32 |
import org.gvsig.geoprocess.sextante.gui.core.GUIFactory; |
|
33 |
import org.gvsig.i18n.Messages; |
|
34 |
import org.gvsig.raster.principalcomponents.app.PrincipalComponentsTocMenuEntry; |
|
35 |
|
|
36 |
/** |
|
37 |
* Input in Sextante framework for Principal Components tool |
|
38 |
* |
|
39 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
40 |
*/ |
|
41 |
public class PCToolboxAction extends AbstractToolboxAction { |
|
42 |
|
|
43 |
public PCToolboxAction() { |
|
44 |
ImageIcon ico = IconThemeHelper.getImageIcon("gvsig-icon16x16"); |
|
45 |
GUIFactory.registerExternalTool(Messages.getText("gv_tools"), ico, this); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public String getGroup() { |
|
50 |
return Messages.getText("multispectral"); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public void execute() { |
|
55 |
if(!super.loadLayer()) |
|
56 |
return; |
|
57 |
PrincipalComponentsTocMenuEntry.getSingleton().execute(null, new FLayer[]{lyr}); |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public String getName() { |
|
62 |
return Messages.getText("principalcomponents"); |
|
63 |
} |
|
64 |
|
|
65 |
public ImageIcon getIcon() { |
|
66 |
return (ImageIcon)PrincipalComponentsTocMenuEntry.getSingleton().getIcon(); |
|
67 |
} |
|
68 |
|
|
69 |
public boolean isPluginInstalled() { |
|
70 |
try { |
|
71 |
PrincipalComponentsTocMenuEntry.getSingleton(); |
|
72 |
} catch(Exception e) { |
|
73 |
return false; |
|
74 |
} catch(Error e) { |
|
75 |
return false; |
|
76 |
} |
|
77 |
return true; |
|
78 |
} |
|
79 |
} |
|
0 | 80 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/src/main/java/org/gvsig/raster/principalcomponents/app/toolbox/AbstractToolboxAction.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 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 |
|
|
25 |
package org.gvsig.raster.principalcomponents.app.toolbox; |
|
26 |
|
|
27 |
import org.gvsig.andami.PluginServices; |
|
28 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
29 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
30 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
32 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FLyrRasterIRasterLayer; |
|
33 |
import org.gvsig.i18n.Messages; |
|
34 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
35 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
36 |
|
|
37 |
import es.unex.sextante.dataObjects.IRasterLayer; |
|
38 |
import es.unex.sextante.gui.core.SextanteGUI; |
|
39 |
import es.unex.sextante.gui.core.ToolboxAction; |
|
40 |
|
|
41 |
/** |
|
42 |
* Base class for toolBox actions |
|
43 |
* |
|
44 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
45 |
*/ |
|
46 |
public abstract class AbstractToolboxAction extends ToolboxAction { |
|
47 |
protected FLyrRaster lyr = null; |
|
48 |
|
|
49 |
@Override |
|
50 |
public String getGroup() { |
|
51 |
return Messages.getText("group_tools"); |
|
52 |
} |
|
53 |
|
|
54 |
|
|
55 |
@Override |
|
56 |
public boolean isActive() { |
|
57 |
IWindow[] windows = PluginServices.getMDIManager().getAllWindows(); |
|
58 |
for (int i = 0; i < windows.length; i++) { |
|
59 |
if(windows[i] instanceof AbstractViewPanel) { |
|
60 |
FLayers lyrs = ((AbstractViewPanel)windows[i]).getMapControl().getMapContext().getLayers(); |
|
61 |
for (int j = 0; j < lyrs.getLayersCount(); j++) { |
|
62 |
if(lyrs.getLayer(j) instanceof FLyrRaster) |
|
63 |
return true; |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
return false; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Returns true if the plugin which gives the functionality is installed |
|
72 |
* in gvSIG |
|
73 |
* @return |
|
74 |
*/ |
|
75 |
public abstract boolean isPluginInstalled(); |
|
76 |
|
|
77 |
/** |
|
78 |
* Loads the raster layer for the tool |
|
79 |
* @return |
|
80 |
*/ |
|
81 |
public boolean loadLayer() { |
|
82 |
if(!isPluginInstalled()) { |
|
83 |
RasterSwingLibrary.messageBoxError(Messages.getText("plugin_not_installed"), null); |
|
84 |
return false; |
|
85 |
} |
|
86 |
|
|
87 |
if(!isActive()) { |
|
88 |
RasterSwingLibrary.messageBoxError(Messages.getText("layer_not_valid"), null); |
|
89 |
return false; |
|
90 |
} |
|
91 |
|
|
92 |
boolean existsRasterButNotActive = false; |
|
93 |
lyr = null; |
|
94 |
IWindow[] windows = PluginServices.getMDIManager().getOrderedWindows(); |
|
95 |
MapContext mapCtx = null; |
|
96 |
for (int i = 0; i < windows.length; i++) { |
|
97 |
if(windows[i] instanceof AbstractViewPanel) { |
|
98 |
mapCtx = ((AbstractViewPanel)windows[i]).getMapControl().getMapContext(); |
|
99 |
break; |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
IRasterLayer[] layers = SextanteGUI.getInputFactory().getRasterLayers(); |
|
104 |
for (int i = 0; i < layers.length; i++) { |
|
105 |
FLyrRaster l = (FLyrRaster)((FLyrRasterIRasterLayer)layers[i]).getBaseDataObject(); |
|
106 |
existsRasterButNotActive = true; |
|
107 |
if(l.isActive() && mapCtx == l.getMapContext()) { |
|
108 |
existsRasterButNotActive = false; |
|
109 |
lyr = l; |
|
110 |
break; |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
if(existsRasterButNotActive) { |
|
115 |
RasterSwingLibrary.messageBoxError(Messages.getText("raster_layer_not_active"), null); |
|
116 |
return false; |
|
117 |
} |
|
118 |
|
|
119 |
return true; |
|
120 |
} |
|
121 |
|
|
122 |
} |
|
0 | 123 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/src/main/java/org/gvsig/raster/principalcomponents/app/toolbox/ToolboxPCLoader.java | ||
---|---|---|
1 |
package org.gvsig.raster.principalcomponents.app.toolbox; |
|
2 |
|
|
3 |
import java.lang.reflect.Constructor; |
|
4 |
import java.lang.reflect.InvocationTargetException; |
|
5 |
|
|
6 |
import org.slf4j.Logger; |
|
7 |
import org.slf4j.LoggerFactory; |
|
8 |
|
|
9 |
/** |
|
10 |
* Loader for this tool in the toolbox dialog |
|
11 |
* |
|
12 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
13 |
*/ |
|
14 |
public class ToolboxPCLoader { |
|
15 |
private Logger log = LoggerFactory.getLogger(ToolboxPCLoader.class); |
|
16 |
private String errorMsg = "The tool Principal components are not been added in the toolbox"; |
|
17 |
|
|
18 |
public void registerTool() { |
|
19 |
try { |
|
20 |
Class<?> c = Class.forName("org.gvsig.raster.principalcomponents.app.toolbox.PCToolboxAction"); |
|
21 |
Constructor<?> constructor = c.getConstructor(); |
|
22 |
constructor.newInstance(); |
|
23 |
} catch (ClassNotFoundException e) { |
|
24 |
log.info(errorMsg, e); |
|
25 |
} catch (SecurityException e) { |
|
26 |
log.info(errorMsg, e); |
|
27 |
} catch (NoSuchMethodException e) { |
|
28 |
log.info(errorMsg, e); |
|
29 |
} catch (IllegalArgumentException e) { |
|
30 |
log.info(errorMsg, e); |
|
31 |
} catch (InstantiationException e) { |
|
32 |
log.info(errorMsg, e); |
|
33 |
} catch (IllegalAccessException e) { |
|
34 |
log.info(errorMsg, e); |
|
35 |
} catch (InvocationTargetException e) { |
|
36 |
log.info(errorMsg, e); |
|
37 |
} catch (NoClassDefFoundError e) { |
|
38 |
log.info("Geoprocess are not installed." + errorMsg, e); |
|
39 |
} |
|
40 |
} |
|
41 |
|
|
42 |
} |
|
0 | 43 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<depends plugin-name="org.gvsig.raster.mainplugin" /> |
|
4 |
|
|
5 |
<depends plugin-name="org.gvsig.geoprocess.app.mainplugin" optional="true" /> |
|
6 |
<depends plugin-name="org.gvsig.geoprocess.app.algorithm" optional="true" /> |
|
7 |
|
|
8 |
<resourceBundle name="text"/> |
|
9 |
<libraries library-dir="lib"/> |
|
10 |
<extensions> |
|
11 |
<extension class-name="org.gvsig.raster.principalcomponents.app.PrincipalComponentsExtension" |
|
12 |
description="" |
|
13 |
active="true" |
|
14 |
priority="1"> |
|
15 |
|
|
16 |
<menu text="Layer/multispectral/principal_components" |
|
17 |
name="PrincipalComponents"/> |
|
18 |
|
|
19 |
<action |
|
20 |
name="PrincipalComponents" |
|
21 |
label="principal_components" |
|
22 |
action-command="PrincipalComponents" |
|
23 |
icon="principal-components" |
|
24 |
position="000601600" |
|
25 |
accelerator="" |
|
26 |
/> |
|
27 |
</extension> |
|
28 |
</extensions> |
|
29 |
</plugin-config> |
|
0 | 30 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/src/main/resources-plugin/org/gvsig/raster/principalcomponents/app/i18n/text.properties | ||
---|---|---|
1 |
principalcomponents=Componentes principales |
|
2 |
layer_not_found=No hay seleccionada una capa v?lida |
|
3 |
problems_creating_process=No se ha podido crear el proceso |
|
4 |
gv_tools=gvSIG Herramientas |
|
5 |
group_tools=Capas raster |
|
6 |
raster_layer_not_active=Esta herramienta necesita una capa raster seleccionada en la vista |
|
7 |
multispectral=Raster multiespectral |
|
0 | 8 |
org.gvsig.raster.principalcomponents/tags/org.gvsig.raster.principalcomponents-2.2.143/org.gvsig.raster.principalcomponents.app.principalcomponentsclient/src/main/resources-plugin/org/gvsig/raster/principalcomponents/app/i18n/text_en.properties | ||
---|---|---|
1 |
principalcomponents=Principal components |
|
2 |
layer_not_found=There is not selected a valid layer |
|
3 |
problems_creating_process=The process has not be created |
|
4 |
gv_tools=gvSIG Tools |
|
5 |
group_tools=Tools for raster layers |
|
6 |
raster_layer_not_active=This tool needs a raster layer selected in the view |
|
7 |
multispectral=Multispectral raster |
|
0 | 8 |
Also available in: Unified diff