Revision 2182
org.gvsig.raster.mosaic/tags/espanya_virtual_version_gvSIG2.1/prepare-workspace.xml | ||
---|---|---|
1 |
<project name="org.gvsig.initial.build" default="prepare-workspace"> |
|
2 |
|
|
3 |
<dirname property="org.gvsig.initial.build.basedir" file="${ant.file.org.gvsig.initial.build}" /> |
|
4 |
|
|
5 |
<property name="workspace.basedir" value="${org.gvsig.initial.build.basedir}/.." /> |
|
6 |
<property name="build.basedir" value="${workspace.basedir}/org.gvsig.maven.base.build" description="Eclipse workspace location" /> |
|
7 |
<property name="build.jar.version" value="1.0.8-SNAPSHOT" /> |
|
8 |
<property name="build.jar.file" value="org.gvsig.maven.base.build-${build.jar.version}.jar" /> |
|
9 |
|
|
10 |
<property name="ant.libs.dir" location="${build.basedir}" description="Additional ant tasks libs folder" /> |
|
11 |
|
|
12 |
<target name="check-maven-base-build-available"> |
|
13 |
<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" property="maven-base-build-available" /> |
|
14 |
</target> |
|
15 |
|
|
16 |
<target name="get-maven-base-build-local" depends="check-maven-base-build-available" if="maven-base-build-available"> |
|
17 |
<!-- Unzip de build jar file from the maven repository into the workspace root folder --> |
|
18 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
19 |
<zipfileset src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}"> |
|
20 |
<patternset> |
|
21 |
<exclude name="META-INF/**" /> |
|
22 |
</patternset> |
|
23 |
</zipfileset> |
|
24 |
</copy> |
|
25 |
</target> |
|
26 |
|
|
27 |
<target name="get-maven-base-build-remote" depends="check-maven-base-build-available" unless="maven-base-build-available"> |
|
28 |
<mkdir dir="target" /> |
|
29 |
|
|
30 |
<!-- Download the build jar file --> |
|
31 |
<get src="http://devel.gvsig.org/m2repo/j2se/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" dest="target/${build.jar.file}" verbose="true" /> |
|
32 |
|
|
33 |
<!-- Unzip de build jar file into the workspace root folder --> |
|
34 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
35 |
<zipfileset src="target/${build.jar.file}"> |
|
36 |
<patternset> |
|
37 |
<exclude name="META-INF/**" /> |
|
38 |
</patternset> |
|
39 |
</zipfileset> |
|
40 |
</copy> |
|
41 |
|
|
42 |
</target> |
|
43 |
|
|
44 |
<target name="find.depends.natives.file"> |
|
45 |
<condition property="depends.natives.file.exists"> |
|
46 |
<available file="${org.gvsig.initial.build.basedir}/DEPENDS_ON_NATIVE_LIBRARIES"/> |
|
47 |
</condition> |
|
48 |
</target> |
|
49 |
|
|
50 |
<target name="find.gvsig.platform.properties.file" |
|
51 |
depends="find.depends.natives.file" |
|
52 |
if="depends.natives.file.exists"> |
|
53 |
<condition property="gvsig.platform.exists"> |
|
54 |
<available file="${user.home}/.gvsig.platform.properties"/> |
|
55 |
</condition> |
|
56 |
</target> |
|
57 |
|
|
58 |
<target name="check.gvsig.platform.properties" |
|
59 |
depends="find.gvsig.platform.properties.file"> |
|
60 |
<fail if="depends.natives.file.exists" unless="gvsig.platform.exists"> |
|
61 |
ERROR!! |
|
62 |
|
|
63 |
You have to define your gvSIG platform properties, |
|
64 |
by creating the file: ${user.home}/.gvsig.platform.properties |
|
65 |
with the following content: |
|
66 |
|
|
67 |
native_platform=linux |
|
68 |
native_distribution=all |
|
69 |
native_compiler=gcc4 |
|
70 |
native_arch=i386 |
|
71 |
native_libraryType=dynamic |
|
72 |
export native_classifier=${native_platform}-${native_distribution}-${native_compiler}-${native_arch}-${native_libraryType} |
|
73 |
|
|
74 |
Replace the fifth initial variables values with the ones appropiate |
|
75 |
to your platform. |
|
76 |
|
|
77 |
If you use maven in the command line, you can use the previous file also |
|
78 |
to define the MAVEN_OPTS environment variable, by adding to your |
|
79 |
.bash_rc file something like this: |
|
80 |
|
|
81 |
if [ -f "${HOME}/.gvsig.platform.properties" ] |
|
82 |
then |
|
83 |
. ${HOME}/.gvsig.platform.properties |
|
84 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m -Dnative-classifier=${native_classifier}" |
|
85 |
else |
|
86 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m" |
|
87 |
fi |
|
88 |
|
|
89 |
It will work if you use the bash shell. In any other case or platform, you'll |
|
90 |
have to define your MAVEN_OPTS environment variable and set the |
|
91 |
"native-classifier" parameter directly. |
|
92 |
</fail> |
|
93 |
|
|
94 |
</target> |
|
95 |
|
|
96 |
<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote,check.gvsig.platform.properties"> |
|
97 |
|
|
98 |
<mkdir dir="target" /> |
|
99 |
|
|
100 |
<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug" /> |
|
101 |
|
|
102 |
<!-- Copy the maven launchers to the workspace metadata folder --> |
|
103 |
<copy todir="${workspace.basedir}/.metadata"> |
|
104 |
<fileset dir="${build.basedir}/eclipse-launchers"> |
|
105 |
<exclude name="**/org.eclipse.jdt.core.prefs" /> |
|
106 |
<exclude name="**/org.eclipse.core.variables.prefs" /> |
|
107 |
</fileset> |
|
108 |
</copy> |
|
109 |
|
|
110 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" append="true"> |
|
111 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.jdt.core.prefs" /> |
|
112 |
</concat> |
|
113 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" append="true"> |
|
114 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.core.variables.prefs" /> |
|
115 |
</concat> |
|
116 |
|
|
117 |
<!-- Configure the eclipse workspace --> |
|
118 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace" /> |
|
119 |
|
|
120 |
<!-- Configure the gvSIG profile --> |
|
121 |
<ant antfile="${build.basedir}/check-gvsig-profile.xml" /> |
|
122 |
|
|
123 |
<property name="user-settings-file-location" value="${user.home}/.m2/settings.xml" /> |
|
124 |
|
|
125 |
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"> |
|
126 |
<classpath> |
|
127 |
<pathelement location="${ant.libs.dir}/com.oopsconsultancy.xmltask-1.16.1.jar" /> |
|
128 |
</classpath> |
|
129 |
</taskdef> |
|
130 |
|
|
131 |
<xmltask source="${user-settings-file-location}" dest="${user-settings-file-location}"> |
|
132 |
<copy path="//:settings/:profiles/:profile[:id/text() = 'gvsig-install']/:properties/:gvsig.install.dir/text()" property="current-gvsig-location" /> |
|
133 |
</xmltask> |
|
134 |
|
|
135 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
136 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
137 |
|
|
138 |
<!-- Compile, install and generate eclipse projects --> |
|
139 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse" /> |
|
140 |
|
|
141 |
<echo>INFORMATION!!!</echo> |
|
142 |
<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo> |
|
143 |
|
|
144 |
<!-- TODO: copiar al proyecto de configuración general --> |
|
145 |
</target> |
|
146 |
|
|
147 |
<target name="clean"> |
|
148 |
<delete dir="target" /> |
|
149 |
</target> |
|
150 |
|
|
151 |
</project> |
|
0 | 152 |
org.gvsig.raster.mosaic/tags/espanya_virtual_version_gvSIG2.1/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.mosaic</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
<version>2.1.0-SNAPSHOT</version> |
|
7 |
<name>org.gvsig.raster.mosaic</name> |
|
8 |
<description>Mosaic support for raster in gvSIG</description> |
|
9 |
<inceptionYear>2011</inceptionYear> |
|
10 |
|
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.desktop</artifactId> |
|
14 |
<version>2.0.16-SNAPSHOT</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<scm> |
|
18 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.app/trunk/org.gvsig.raster.app</connection> |
|
19 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.app/trunk/org.gvsig.raster.app</developerConnection> |
|
20 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.mosaic/trunk/org.gvsig.raster.mosaic</url> |
|
21 |
</scm> |
|
22 |
|
|
23 |
<dependencyManagement> |
|
24 |
<dependencies> |
|
25 |
<dependency> |
|
26 |
<groupId>org.gvsig</groupId> |
|
27 |
<artifactId>org.gvsig.raster.mosaic.io</artifactId> |
|
28 |
<version>2.1.0-SNAPSHOT</version> |
|
29 |
</dependency> |
|
30 |
<dependency> |
|
31 |
<groupId>org.gvsig</groupId> |
|
32 |
<artifactId>org.gvsig.raster.tools.app.basic</artifactId> |
|
33 |
<version>2.1.0-SNAPSHOT</version> |
|
34 |
</dependency> |
|
35 |
<dependency> |
|
36 |
<groupId>org.gvsig</groupId> |
|
37 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
38 |
<version>2.1.0-SNAPSHOT</version> |
|
39 |
</dependency> |
|
40 |
<dependency> |
|
41 |
<groupId>org.gvsig</groupId> |
|
42 |
<artifactId>org.gvsig.raster.fmap</artifactId> |
|
43 |
<version>2.1.0-SNAPSHOT</version> |
|
44 |
</dependency> |
|
45 |
<dependency> |
|
46 |
<groupId>org.gvsig</groupId> |
|
47 |
<artifactId>org.gvsig.raster.cache.lib.api</artifactId> |
|
48 |
<version>2.1.0-SNAPSHOT</version> |
|
49 |
</dependency> |
|
50 |
<dependency> |
|
51 |
<groupId>org.gvsig</groupId> |
|
52 |
<artifactId>org.gvsig.raster.cache.lib.impl</artifactId> |
|
53 |
<version>2.1.0-SNAPSHOT</version> |
|
54 |
</dependency> |
|
55 |
<dependency> |
|
56 |
<groupId>org.gvsig</groupId> |
|
57 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
58 |
<version>2.1.0-SNAPSHOT</version> |
|
59 |
</dependency> |
|
60 |
<dependency> |
|
61 |
<groupId>org.gvsig</groupId> |
|
62 |
<artifactId>org.gvsig.raster.lib.impl</artifactId> |
|
63 |
<version>2.1.0-SNAPSHOT</version> |
|
64 |
</dependency> |
|
65 |
</dependencies> |
|
66 |
</dependencyManagement> |
|
67 |
|
|
68 |
<modules> |
|
69 |
<module>org.gvsig.raster.mosaic.io</module> |
|
70 |
<module>org.gvsig.raster.mosaic.app</module> |
|
71 |
</modules> |
|
72 |
</project> |
|
0 | 73 |
org.gvsig.raster.mosaic/tags/espanya_virtual_version_gvSIG2.1/org.gvsig.raster.mosaic.app/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>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
|
|
26 |
<dependencySets> |
|
27 |
<dependencySet> |
|
28 |
<useProjectArtifact>false</useProjectArtifact> |
|
29 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
30 |
<outputDirectory>lib</outputDirectory> |
|
31 |
<includes> |
|
32 |
<include>org.gvsig:org.gvsig.raster.mosaic.app:jar</include> |
|
33 |
<include>org.gvsig:org.gvsig.raster.mosaic.io:jar</include> |
|
34 |
</includes> |
|
35 |
</dependencySet> |
|
36 |
</dependencySets> |
|
37 |
</assembly> |
|
0 | 38 |
org.gvsig.raster.mosaic/tags/espanya_virtual_version_gvSIG2.1/org.gvsig.raster.mosaic.app/src/main/java/org/gvsig/raster/mosaic/app/MosaicSupportExtension.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.mosaic.app; |
|
23 |
|
|
24 |
import org.gvsig.andami.PluginServices; |
|
25 |
import org.gvsig.andami.plugins.Extension; |
|
26 |
import org.gvsig.raster.mosaic.app.gui.MosaicPropertiesPanel; |
|
27 |
import org.gvsig.tools.ToolsLocator; |
|
28 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
29 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
30 |
|
|
31 |
/** |
|
32 |
* Extension to add mosaic support. This extension adds a panel to the properties raster dialog |
|
33 |
* |
|
34 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
35 |
*/ |
|
36 |
public class MosaicSupportExtension extends Extension { |
|
37 |
|
|
38 |
public void execute(String actionCommand) { |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
public void initialize() { |
|
43 |
initializeIcons(); |
|
44 |
|
|
45 |
// Adds a panel to the properties dialog. |
|
46 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
47 |
ExtensionPoint point = extensionPoints.add("RasterSEPropertiesDialog"); |
|
48 |
point.append("Mosaico", "", MosaicPropertiesPanel.class); |
|
49 |
} |
|
50 |
|
|
51 |
/* |
|
52 |
* (non-Javadoc) |
|
53 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
54 |
*/ |
|
55 |
public boolean isEnabled() { |
|
56 |
return true; |
|
57 |
} |
|
58 |
|
|
59 |
/* |
|
60 |
* (non-Javadoc) |
|
61 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
62 |
*/ |
|
63 |
public boolean isVisible() { |
|
64 |
return true; |
|
65 |
} |
|
66 |
|
|
67 |
void initializeIcons() { |
|
68 |
PluginServices.getIconTheme().registerDefault( |
|
69 |
"open-timeserie", |
|
70 |
this.getClass().getClassLoader().getResource("images/clock.jpg") |
|
71 |
); |
|
72 |
PluginServices.getIconTheme().registerDefault( |
|
73 |
"down-arrow", |
|
74 |
this.getClass().getClassLoader().getResource("images/down-16x16.png") |
|
75 |
); |
|
76 |
PluginServices.getIconTheme().registerDefault( |
|
77 |
"up-arrow", |
|
78 |
this.getClass().getClassLoader().getResource("images/up-16x16.png") |
|
79 |
); |
|
80 |
} |
|
81 |
|
|
82 |
} |
|
0 | 83 |
org.gvsig.raster.mosaic/tags/espanya_virtual_version_gvSIG2.1/org.gvsig.raster.mosaic.app/src/main/java/org/gvsig/raster/mosaic/app/gui/FileListTableModel.java | ||
---|---|---|
1 |
package org.gvsig.raster.mosaic.app.gui; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
import javax.swing.table.AbstractTableModel; |
|
25 |
|
|
26 |
/** |
|
27 |
* Table model for the file list |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
29 |
*/ |
|
30 |
public class FileListTableModel extends AbstractTableModel { |
|
31 |
private static final long serialVersionUID = 1L; |
|
32 |
private String[] columnNames = null; |
|
33 |
private Object[][] data = null; |
|
34 |
private Object[][] dataWithPath = null; |
|
35 |
private Object[][] dataWithoutPath = null; |
|
36 |
private boolean seePath = false; |
|
37 |
|
|
38 |
public FileListTableModel(String[] columnNames, Object[][] data) { |
|
39 |
this.columnNames = columnNames; |
|
40 |
this.data = data; |
|
41 |
} |
|
42 |
|
|
43 |
public int getColumnCount() { |
|
44 |
return columnNames.length; |
|
45 |
} |
|
46 |
|
|
47 |
public int getRowCount() { |
|
48 |
if(data != null) |
|
49 |
return data.length; |
|
50 |
return 0; |
|
51 |
} |
|
52 |
|
|
53 |
public String getColumnName(int col) { |
|
54 |
return columnNames[col]; |
|
55 |
} |
|
56 |
|
|
57 |
public Object getValueAt(int row, int col) { |
|
58 |
if(data != null) |
|
59 |
return data[row][col]; |
|
60 |
return null; |
|
61 |
} |
|
62 |
|
|
63 |
@SuppressWarnings("unchecked") |
|
64 |
public Class getColumnClass(int c) { |
|
65 |
return getValueAt(0, c).getClass(); |
|
66 |
} |
|
67 |
|
|
68 |
public boolean isCellEditable(int row, int col) { |
|
69 |
return col == 0 ? true : false; |
|
70 |
} |
|
71 |
|
|
72 |
public void setData(Object[][] dataWith, Object[][] dataWithout) { |
|
73 |
dataWithPath = dataWith; |
|
74 |
dataWithoutPath = dataWithout; |
|
75 |
setSeeFlag(seePath); |
|
76 |
fireTableDataChanged(); |
|
77 |
} |
|
78 |
|
|
79 |
public void setSeeFlag(boolean seePath) { |
|
80 |
this.seePath = seePath; |
|
81 |
if(seePath) |
|
82 |
data = dataWithPath; |
|
83 |
else |
|
84 |
data = dataWithoutPath; |
|
85 |
} |
|
86 |
|
|
87 |
public Object[][] getDataWithPath() { |
|
88 |
return dataWithPath; |
|
89 |
} |
|
90 |
|
|
91 |
public Object[][] getDataWithoutPath() { |
|
92 |
return dataWithoutPath; |
|
93 |
} |
|
94 |
|
|
95 |
public void clearModel() { |
|
96 |
data = null; |
|
97 |
dataWithPath = null; |
|
98 |
dataWithoutPath = null; |
|
99 |
fireTableDataChanged(); |
|
100 |
} |
|
101 |
|
|
102 |
public void setValueAt(Object value, int row, int col) { |
|
103 |
if(col == 0) { |
|
104 |
dataWithPath[row][col] = value; |
|
105 |
dataWithoutPath[row][col] = value; |
|
106 |
} else |
|
107 |
data[row][col] = value; |
|
108 |
fireTableCellUpdated(row, col); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Goes a list of rows up in the table |
|
113 |
* @param row |
|
114 |
*/ |
|
115 |
public void upRows(int[] indexes) { |
|
116 |
for (int i = 0; i < indexes.length; i++) { |
|
117 |
int row = indexes[i]; |
|
118 |
|
|
119 |
if(row == 0) |
|
120 |
continue; |
|
121 |
Object[] aux = dataWithPath[row]; |
|
122 |
dataWithPath[row] = dataWithPath[row - 1]; |
|
123 |
dataWithPath[row - 1] = aux; |
|
124 |
|
|
125 |
aux = dataWithoutPath[row]; |
|
126 |
dataWithoutPath[row] = dataWithoutPath[row - 1]; |
|
127 |
dataWithoutPath[row - 1] = aux; |
|
128 |
} |
|
129 |
|
|
130 |
fireTableDataChanged(); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Goes a list of rows down in the table |
|
135 |
* @param row |
|
136 |
*/ |
|
137 |
public void downRows(int[] indexes) { |
|
138 |
for (int i = indexes.length - 1; i >= 0; i--) { |
|
139 |
int row = indexes[i]; |
|
140 |
|
|
141 |
if(row == data.length - 1) |
|
142 |
continue; |
|
143 |
Object[] aux = dataWithPath[row + 1]; |
|
144 |
dataWithPath[row + 1] = dataWithPath[row]; |
|
145 |
dataWithPath[row] = aux; |
|
146 |
|
|
147 |
aux = dataWithoutPath[row + 1]; |
|
148 |
dataWithoutPath[row + 1] = dataWithoutPath[row]; |
|
149 |
dataWithoutPath[row] = aux; |
|
150 |
} |
|
151 |
|
|
152 |
fireTableDataChanged(); |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* Deletes the list of rows |
|
157 |
* @param index |
|
158 |
*/ |
|
159 |
public void delete(int[] index) { |
|
160 |
if(index == null) |
|
161 |
return; |
|
162 |
Object[][] dataWithPath = new Object[this.dataWithoutPath.length - index.length][2]; |
|
163 |
Object[][] dataWithoutPath = new Object[this.dataWithoutPath.length - index.length][2]; |
|
164 |
int cont = 0; |
|
165 |
for (int i = 0; i < this.dataWithPath.length; i++) { |
|
166 |
if(!isInList(i, index)) { |
|
167 |
dataWithPath[cont][0] = dataWithoutPath[cont][0] = this.dataWithPath[i][0]; |
|
168 |
dataWithPath[cont][1] = this.dataWithPath[i][1]; |
|
169 |
dataWithoutPath[cont][1] = this.dataWithoutPath[i][1]; |
|
170 |
cont ++; |
|
171 |
} |
|
172 |
} |
|
173 |
this.dataWithPath = dataWithPath; |
|
174 |
this.dataWithoutPath = dataWithoutPath; |
|
175 |
setSeeFlag(seePath); |
|
176 |
fireTableDataChanged(); |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* Returns true if i is in the list of indexes |
|
181 |
* @param i |
|
182 |
* @param index |
|
183 |
* @return |
|
184 |
*/ |
|
185 |
private boolean isInList(int i, int[] index) { |
|
186 |
for (int j = 0; j < index.length; j++) { |
|
187 |
if(i == index[j]) |
|
188 |
return true; |
|
189 |
} |
|
190 |
return false; |
|
191 |
} |
|
192 |
} |
|
0 | 193 |
org.gvsig.raster.mosaic/tags/espanya_virtual_version_gvSIG2.1/org.gvsig.raster.mosaic.app/src/main/java/org/gvsig/raster/mosaic/app/gui/MosaicPropertiesPanel.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.mosaic.app.gui; |
|
23 |
|
|
24 |
import java.awt.Dimension; |
|
25 |
import java.awt.FlowLayout; |
|
26 |
import java.awt.GridBagConstraints; |
|
27 |
import java.awt.GridBagLayout; |
|
28 |
import java.awt.Insets; |
|
29 |
import java.io.File; |
|
30 |
import java.util.ArrayList; |
|
31 |
|
|
32 |
import javax.swing.BorderFactory; |
|
33 |
import javax.swing.ButtonGroup; |
|
34 |
import javax.swing.JButton; |
|
35 |
import javax.swing.JCheckBox; |
|
36 |
import javax.swing.JPanel; |
|
37 |
import javax.swing.JRadioButton; |
|
38 |
import javax.swing.JScrollPane; |
|
39 |
import javax.swing.JTable; |
|
40 |
import javax.swing.table.TableColumnModel; |
|
41 |
|
|
42 |
import org.gvsig.andami.PluginServices; |
|
43 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
44 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
|
45 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
46 |
import org.gvsig.raster.mosaic.io.MosaicDataParameters; |
|
47 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
|
48 |
|
|
49 |
/** |
|
50 |
* |
|
51 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
52 |
*/ |
|
53 |
public class MosaicPropertiesPanel extends AbstractPanel { |
|
54 |
private static final long serialVersionUID = 1L; |
|
55 |
private final String[] columnNames = { "", "Fichero" }; |
|
56 |
private FileListTableModel model = null; |
|
57 |
private MosaicPropertiesListener listener = null; |
|
58 |
|
|
59 |
private JButton addButton = null; |
|
60 |
private JButton createButton = null; |
|
61 |
private JButton deleteButton = null; |
|
62 |
private JButton optionsModifyButton = null; |
|
63 |
private JButton deleteCacheButton = null; |
|
64 |
private JButton downArrowButton = null; |
|
65 |
private JButton upArrowButton = null; |
|
66 |
|
|
67 |
private JCheckBox seeListCheck = null; |
|
68 |
|
|
69 |
private JRadioButton addDirectoryRadio = null; |
|
70 |
private JRadioButton addFilesRadio = null; |
|
71 |
private ButtonGroup radioGroup = null; |
|
72 |
|
|
73 |
private JPanel createPanel = null; |
|
74 |
private JPanel optionsPanel = null; |
|
75 |
private JPanel southPanel = null; |
|
76 |
private JPanel iconsPanel = null; |
|
77 |
private JPanel buttonsPanel = null; |
|
78 |
private JTable table = null; |
|
79 |
private JScrollPane scrollPanel = null; |
|
80 |
|
|
81 |
private FLyrRaster fLayer = null; |
|
82 |
|
|
83 |
/** |
|
84 |
* This method initializes |
|
85 |
*/ |
|
86 |
public MosaicPropertiesPanel() { |
|
87 |
super(); |
|
88 |
initialize(); |
|
89 |
listener = new MosaicPropertiesListener(this); |
|
90 |
this.setPreferredSize(new Dimension(100, 80)); |
|
91 |
super.setLabel(PluginServices.getText(this, "mosaic_panel")); |
|
92 |
} |
|
93 |
|
|
94 |
@Override |
|
95 |
protected void initialize() { |
|
96 |
setLayout(new GridBagLayout()); |
|
97 |
|
|
98 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
99 |
gbc.insets = new Insets(0, 0, 0, 0); |
|
100 |
gbc.fill = GridBagConstraints.BOTH; |
|
101 |
gbc.weightx = 1.0; |
|
102 |
gbc.weighty = 1.0; |
|
103 |
|
|
104 |
add(getScrollTable(), gbc); |
|
105 |
|
|
106 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
107 |
gbc.weighty = 0.0; |
|
108 |
|
|
109 |
gbc.gridy = 1; |
|
110 |
add(getIconsPanel(), gbc); |
|
111 |
|
|
112 |
gbc.gridy = 2; |
|
113 |
add(getSouthPanel(), gbc); |
|
114 |
|
|
115 |
getRadioGroup(); |
|
116 |
setCreateStatus(); |
|
117 |
} |
|
118 |
|
|
119 |
/* |
|
120 |
* (non-Javadoc) |
|
121 |
* @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#setReference(java.lang.Object) |
|
122 |
*/ |
|
123 |
public void setReference(Object ref) { |
|
124 |
super.setReference(ref); |
|
125 |
|
|
126 |
if (!(ref instanceof FLyrRaster)) |
|
127 |
return; |
|
128 |
|
|
129 |
fLayer = (FLyrRaster) ref; |
|
130 |
DataStoreParameters dsp = fLayer.getDataStore().getParameters(); |
|
131 |
if(dsp instanceof MosaicDataParameters) { |
|
132 |
MosaicDataParameters mosaicParams = (MosaicDataParameters)dsp; |
|
133 |
getModel().clearModel(); |
|
134 |
ArrayList<File> fileArray = new ArrayList<File>(); |
|
135 |
for (int i = 0; i < mosaicParams.getProviderCount(); i++) { |
|
136 |
fileArray.add(new File(mosaicParams.getURIByProvider(i))); |
|
137 |
} |
|
138 |
listener.addDataToTableDataModel(fileArray); |
|
139 |
setCreateStatus(); |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
public JButton getAddButton() { |
|
144 |
if(addButton == null) { |
|
145 |
addButton = new JButton(RasterToolsUtil.getText(this, "add")); |
|
146 |
addButton.setPreferredSize(new Dimension(80, 24)); |
|
147 |
} |
|
148 |
return addButton; |
|
149 |
} |
|
150 |
|
|
151 |
public JButton getCreateButton() { |
|
152 |
if(createButton == null) { |
|
153 |
createButton = new JButton(RasterToolsUtil.getText(this, "create")); |
|
154 |
createButton.setPreferredSize(new Dimension(80, 24)); |
|
155 |
} |
|
156 |
return createButton; |
|
157 |
} |
|
158 |
|
|
159 |
public JButton getDeleteButton() { |
|
160 |
if(deleteButton == null) { |
|
161 |
deleteButton = new JButton(RasterToolsUtil.getText(this, "delete")); |
|
162 |
deleteButton.setPreferredSize(new Dimension(80, 24)); |
|
163 |
} |
|
164 |
return deleteButton; |
|
165 |
} |
|
166 |
|
|
167 |
public JButton getOptionsModifyButton() { |
|
168 |
if(optionsModifyButton == null) { |
|
169 |
optionsModifyButton = new JButton(RasterToolsUtil.getText(this, "modify_options")); |
|
170 |
} |
|
171 |
return optionsModifyButton; |
|
172 |
} |
|
173 |
|
|
174 |
public JButton getUpArrowButton() { |
|
175 |
if(upArrowButton == null) { |
|
176 |
upArrowButton = new JButton(PluginServices.getIconTheme().get("up-arrow")); |
|
177 |
} |
|
178 |
return upArrowButton; |
|
179 |
} |
|
180 |
|
|
181 |
public JButton getDownArrowButton() { |
|
182 |
if(downArrowButton == null) { |
|
183 |
downArrowButton = new JButton(PluginServices.getIconTheme().get("down-arrow")); |
|
184 |
} |
|
185 |
return downArrowButton; |
|
186 |
} |
|
187 |
|
|
188 |
public JButton getDeleteCacheButton() { |
|
189 |
if(deleteCacheButton == null) { |
|
190 |
deleteCacheButton = new JButton(RasterToolsUtil.getText(this, "delete_cache_button")); |
|
191 |
deleteCacheButton.setToolTipText(RasterToolsUtil.getText(this, "delete_cache_button_tip")); |
|
192 |
} |
|
193 |
return deleteCacheButton; |
|
194 |
} |
|
195 |
|
|
196 |
public JCheckBox getSeeListCheck() { |
|
197 |
if(seeListCheck == null) { |
|
198 |
seeListCheck = new JCheckBox(RasterToolsUtil.getText(this, "see_path")); |
|
199 |
} |
|
200 |
return seeListCheck; |
|
201 |
} |
|
202 |
|
|
203 |
public JRadioButton getAddDirectoryRadio() { |
|
204 |
if(addDirectoryRadio == null) { |
|
205 |
addDirectoryRadio = new JRadioButton(RasterToolsUtil.getText(this, "add_directory")); |
|
206 |
addDirectoryRadio.setSelected(false); |
|
207 |
} |
|
208 |
return addDirectoryRadio; |
|
209 |
} |
|
210 |
|
|
211 |
public JRadioButton getAddFilesRadio() { |
|
212 |
if(addFilesRadio == null) { |
|
213 |
addFilesRadio = new JRadioButton(RasterToolsUtil.getText(this, "add_files")); |
|
214 |
addFilesRadio.setSelected(true); |
|
215 |
} |
|
216 |
return addFilesRadio; |
|
217 |
} |
|
218 |
|
|
219 |
public ButtonGroup getRadioGroup() { |
|
220 |
if(radioGroup == null) { |
|
221 |
radioGroup = new ButtonGroup(); |
|
222 |
radioGroup.add(getAddDirectoryRadio()); |
|
223 |
radioGroup.add(getAddFilesRadio()); |
|
224 |
} |
|
225 |
return radioGroup; |
|
226 |
} |
|
227 |
|
|
228 |
public JPanel getCreatePanel() { |
|
229 |
if(createPanel == null) { |
|
230 |
createPanel = new JPanel(); |
|
231 |
createPanel.setBorder(BorderFactory.createTitledBorder(RasterToolsUtil.getText(this, "create_mosaic"))); |
|
232 |
createPanel.setLayout(new GridBagLayout()); |
|
233 |
|
|
234 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
235 |
gbc.insets = new Insets(0, 0, 0, 0); |
|
236 |
gbc.fill = GridBagConstraints.BOTH; |
|
237 |
gbc.weightx = 1.0; |
|
238 |
gbc.weighty = 1.0; |
|
239 |
|
|
240 |
gbc.gridy = 0; |
|
241 |
createPanel.add(getAddFilesRadio(), gbc); |
|
242 |
gbc.gridy = 1; |
|
243 |
createPanel.add(getAddDirectoryRadio(), gbc); |
|
244 |
|
|
245 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
246 |
gbc.weightx = 1.0; |
|
247 |
gbc.weighty = 0.0; |
|
248 |
|
|
249 |
gbc.gridy = 2; |
|
250 |
createPanel.add(getButtonsPanel(), gbc); |
|
251 |
|
|
252 |
} |
|
253 |
return createPanel; |
|
254 |
} |
|
255 |
|
|
256 |
public JPanel getButtonsPanel() { |
|
257 |
if(buttonsPanel == null) { |
|
258 |
buttonsPanel = new JPanel(); |
|
259 |
buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
|
260 |
buttonsPanel.add(getAddButton()); |
|
261 |
buttonsPanel.add(getCreateButton()); |
|
262 |
buttonsPanel.add(getDeleteButton()); |
|
263 |
} |
|
264 |
return buttonsPanel; |
|
265 |
} |
|
266 |
|
|
267 |
|
|
268 |
public JPanel getOptionsPanel() { |
|
269 |
if(optionsPanel == null) { |
|
270 |
optionsPanel = new JPanel(); |
|
271 |
optionsPanel.setBorder(BorderFactory.createTitledBorder(RasterToolsUtil.getText(this, "options"))); |
|
272 |
optionsPanel.setLayout(new GridBagLayout()); |
|
273 |
|
|
274 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
275 |
gbc.insets = new Insets(0, 0, 0, 0); |
|
276 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
277 |
gbc.weightx = 1.0; |
|
278 |
|
|
279 |
gbc.gridy = 0; |
|
280 |
optionsPanel.add(getSeeListCheck(), gbc); |
|
281 |
|
|
282 |
gbc.gridy = 1; |
|
283 |
optionsPanel.add(getOptionsModifyButton(), gbc); |
|
284 |
|
|
285 |
gbc.gridy = 2; |
|
286 |
optionsPanel.add(getDeleteCacheButton(), gbc); |
|
287 |
|
|
288 |
gbc.fill = GridBagConstraints.BOTH; |
|
289 |
gbc.weighty = 1.0; |
|
290 |
|
|
291 |
gbc.gridy = 2; |
|
292 |
optionsPanel.add(new JPanel(), gbc); |
|
293 |
} |
|
294 |
return optionsPanel; |
|
295 |
} |
|
296 |
|
|
297 |
public JPanel getSouthPanel() { |
|
298 |
if(southPanel == null) { |
|
299 |
southPanel = new JPanel(); |
|
300 |
southPanel.setLayout(new GridBagLayout()); |
|
301 |
|
|
302 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
303 |
gbc.insets = new Insets(0, 0, 0, 0); |
|
304 |
gbc.fill = GridBagConstraints.BOTH; |
|
305 |
gbc.weightx = 1.0; |
|
306 |
gbc.weighty = 1.0; |
|
307 |
|
|
308 |
gbc.gridx = 0; |
|
309 |
southPanel.add(getCreatePanel(), gbc); |
|
310 |
|
|
311 |
gbc.gridx = 1; |
|
312 |
southPanel.add(getOptionsPanel(), gbc); |
|
313 |
} |
|
314 |
return southPanel; |
|
315 |
} |
|
316 |
|
|
317 |
public JPanel getIconsPanel() { |
|
318 |
if(iconsPanel == null) { |
|
319 |
FlowLayout fl = new FlowLayout(); |
|
320 |
fl.setAlignment(FlowLayout.CENTER); |
|
321 |
iconsPanel = new JPanel(fl); |
|
322 |
//iconsPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); |
|
323 |
iconsPanel.add(getUpArrowButton()); |
|
324 |
iconsPanel.add(getDownArrowButton()); |
|
325 |
} |
|
326 |
return iconsPanel; |
|
327 |
} |
|
328 |
|
|
329 |
public JScrollPane getScrollTable() { |
|
330 |
if(scrollPanel == null) { |
|
331 |
scrollPanel = new JScrollPane(); |
|
332 |
scrollPanel.setViewportView(getFileList()); |
|
333 |
} |
|
334 |
return scrollPanel; |
|
335 |
} |
|
336 |
|
|
337 |
public FileListTableModel getModel() { |
|
338 |
if(model == null) |
|
339 |
model = new FileListTableModel(columnNames, null); |
|
340 |
return model; |
|
341 |
} |
|
342 |
|
|
343 |
public JTable getFileList() { |
|
344 |
if(table == null) { |
|
345 |
table = new JTable(getModel()); |
|
346 |
TableColumnModel columnModel = table.getColumnModel(); |
|
347 |
columnModel.getColumn(0).setMaxWidth(26); |
|
348 |
} |
|
349 |
return table; |
|
350 |
} |
|
351 |
|
|
352 |
public FLyrRaster getfLayer() { |
|
353 |
return fLayer; |
|
354 |
} |
|
355 |
|
|
356 |
|
|
357 |
/** |
|
358 |
* Enables o disables buttons |
|
359 |
*/ |
|
360 |
public void setCreateStatus() { |
|
361 |
if(getFileList().getModel().getRowCount() == 0) { |
|
362 |
getAddButton().setEnabled(false); |
|
363 |
getCreateButton().setEnabled(true); |
|
364 |
getDeleteButton().setEnabled(false); |
|
365 |
getOptionsModifyButton().setEnabled(false); |
|
366 |
} else { |
|
367 |
getAddButton().setEnabled(true); |
|
368 |
getCreateButton().setEnabled(false); |
|
369 |
getDeleteButton().setEnabled(true); |
|
370 |
getOptionsModifyButton().setEnabled(true); |
|
371 |
} |
|
372 |
} |
|
373 |
|
|
374 |
public void accept() { |
|
375 |
listener.accept(); |
|
376 |
} |
|
377 |
|
|
378 |
public void apply() { |
|
379 |
listener.apply(); |
|
380 |
} |
|
381 |
|
|
382 |
public void cancel() { |
|
383 |
listener.cancel(); |
|
384 |
} |
|
385 |
|
|
386 |
public void selected() { |
|
387 |
listener.selected(); |
|
388 |
} |
|
389 |
|
|
390 |
|
|
391 |
} |
|
0 | 392 |
org.gvsig.raster.mosaic/tags/espanya_virtual_version_gvSIG2.1/org.gvsig.raster.mosaic.app/src/main/java/org/gvsig/raster/mosaic/app/gui/LayerNameDialog.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.mosaic.app.gui; |
|
20 |
|
|
21 |
import java.awt.BorderLayout; |
|
22 |
import java.awt.GridBagConstraints; |
|
23 |
import java.awt.GridBagLayout; |
|
24 |
import java.awt.Insets; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
|
|
27 |
import javax.swing.JOptionPane; |
|
28 |
import javax.swing.JPanel; |
|
29 |
import javax.swing.JTextField; |
|
30 |
|
|
31 |
import org.gvsig.andami.PluginServices; |
|
32 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
33 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
34 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
35 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
|
36 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
|
37 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
|
38 |
|
|
39 |
/** |
|
40 |
* <code>LayerNameDialog</code>. |
|
41 |
* Window to introduce the name of the new layer |
|
42 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
43 |
*/ |
|
44 |
public class LayerNameDialog extends DefaultButtonsPanel implements IWindow, ButtonsPanelListener { |
|
45 |
private static final long serialVersionUID = 7362459094802955247L; |
|
46 |
private JPanel panel = null; |
|
47 |
private String layerName = null; |
|
48 |
private JTextField name = null; |
|
49 |
private ButtonsPanelListener listener = null; |
|
50 |
private Point2D position = null; |
|
51 |
|
|
52 |
/** |
|
53 |
* Builds a new window. |
|
54 |
* @param width |
|
55 |
* @param height |
|
56 |
*/ |
|
57 |
public LayerNameDialog(Point2D position, int width, int height, ButtonsPanelListener listener) { |
|
58 |
super(ButtonsPanel.BUTTONS_ACCEPTCANCEL); |
|
59 |
this.position = position; |
|
60 |
layerName = null; |
|
61 |
this.listener = listener; |
|
62 |
this.setSize(width, height); |
|
63 |
this.setLayout(new BorderLayout(5, 5)); |
|
64 |
this.add(getMainPanel(), java.awt.BorderLayout.CENTER); |
|
65 |
this.addButtonPressedListener(this); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Gets the main panel |
|
70 |
* @return JPanel |
|
71 |
*/ |
|
72 |
public JPanel getMainPanel() { |
|
73 |
if (panel == null) { |
|
74 |
panel = new JPanel(); |
|
75 |
panel.setLayout(new GridBagLayout()); |
|
76 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
77 |
gbc.insets = new Insets(0, 0, 0, 0); |
|
78 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
79 |
gbc.anchor = GridBagConstraints.CENTER; |
|
80 |
gbc.weightx = 1.0; |
|
81 |
panel.add(getNameField(), gbc); |
|
82 |
} |
|
83 |
return panel; |
|
84 |
} |
|
85 |
|
|
86 |
private JTextField getNameField() { |
|
87 |
if(name == null) { |
|
88 |
name = new JTextField(); |
|
89 |
} |
|
90 |
return name; |
|
91 |
} |
|
92 |
|
|
93 |
/* |
|
94 |
* (non-Javadoc) |
|
95 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo() |
|
96 |
*/ |
|
97 |
public WindowInfo getWindowInfo() { |
|
98 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE); |
|
99 |
m_viewinfo.setTitle(PluginServices.getText(this, "layer_name")); |
|
100 |
m_viewinfo.setHeight(this.getHeight()); |
|
101 |
m_viewinfo.setWidth(this.getWidth()); |
|
102 |
m_viewinfo.setX((int)position.getX()); |
|
103 |
m_viewinfo.setY((int)position.getY()); |
|
104 |
return m_viewinfo; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* Cancel actions |
|
109 |
*/ |
|
110 |
private void close() { |
|
111 |
try { |
|
112 |
PluginServices.getMDIManager().closeWindow(this); |
|
113 |
} catch (ArrayIndexOutOfBoundsException e) { |
|
114 |
//Si la ventana no se puede eliminar no hacemos nada |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* Accept actions |
|
120 |
*/ |
|
121 |
private void accept() { |
|
122 |
String txt = getNameField().getText(); |
|
123 |
if(txt == null || txt.compareTo("") == 0) { |
|
124 |
JOptionPane.showMessageDialog(null, PluginServices.getText(this, "character_not_valid"), "", JOptionPane.ERROR_MESSAGE); |
|
125 |
return; |
|
126 |
} |
|
127 |
|
|
128 |
byte[] byteList = txt.getBytes(); |
|
129 |
for (int i = 0; i < byteList.length; i++) { |
|
130 |
if(byteList[i] < 45 || |
|
131 |
(byteList[i] > 45 && byteList[i] < 48) || |
|
132 |
(byteList[i] > 57 && byteList[i] < 65) || |
|
133 |
(byteList[i] > 90 && byteList[i] < 95) || |
|
134 |
(byteList[i] > 95 && byteList[i] < 97) || |
|
135 |
(byteList[i] > 122 && byteList[i] < 126) || |
|
136 |
(byteList[i] > 126)) { |
|
137 |
JOptionPane.showMessageDialog(null, PluginServices.getText(this, "character_not_valid"), "", JOptionPane.ERROR_MESSAGE); |
|
138 |
return; |
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
layerName = txt; |
|
143 |
close(); |
|
144 |
listener.actionButtonPressed(new ButtonsPanelEvent(layerName, ButtonsPanel.BUTTON_ACCEPT)); |
|
145 |
} |
|
146 |
|
|
147 |
/* |
|
148 |
* (non-Javadoc) |
|
149 |
* @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent) |
|
150 |
*/ |
|
151 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
|
152 |
if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) { |
|
153 |
close(); |
|
154 |
} |
|
155 |
|
|
156 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) { |
|
157 |
accept(); |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
public Object getWindowProfile() { |
|
162 |
return WindowInfo.PROPERTIES_PROFILE; |
|
163 |
} |
|
164 |
} |
|
0 | 165 |
org.gvsig.raster.mosaic/tags/espanya_virtual_version_gvSIG2.1/org.gvsig.raster.mosaic.app/src/main/java/org/gvsig/raster/mosaic/app/gui/MosaicPropertiesListener.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.mosaic.app.gui; |
|
23 |
|
|
24 |
import java.awt.Component; |
|
25 |
import java.awt.event.ActionEvent; |
|
26 |
import java.awt.event.ActionListener; |
|
27 |
import java.awt.geom.Point2D; |
|
28 |
import java.io.File; |
|
29 |
import java.io.IOException; |
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import javax.swing.event.TableModelEvent; |
|
34 |
import javax.swing.event.TableModelListener; |
|
35 |
|
|
36 |
import org.gvsig.andami.PluginServices; |
|
37 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
38 |
import org.gvsig.fmap.dal.DALLocator; |
|
39 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
40 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
41 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
42 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
43 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
44 |
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider; |
|
45 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
46 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
47 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
48 |
import org.gvsig.fmap.dal.spi.DataStoreProvider; |
|
49 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
50 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
|
51 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
|
52 |
import org.gvsig.gui.beans.swing.JFileChooser; |
|
53 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
54 |
import org.gvsig.raster.mosaic.io.MosaicDataParameters; |
|
55 |
import org.gvsig.raster.mosaic.io.MosaicProvider; |
|
56 |
import org.gvsig.raster.mosaic.io.MosaicRasterFormat; |
|
57 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
|
58 |
|
|
59 |
|
|
60 |
/** |
|
61 |
* Class for listen to events from the mosaic GUI |
|
62 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
63 |
*/ |
|
64 |
public class MosaicPropertiesListener implements TableModelListener, ActionListener, ButtonsPanelListener { |
|
65 |
private MosaicPropertiesPanel panel = null; |
|
66 |
private String layerName = null; |
|
67 |
private String suffix = ".mrf"; |
|
68 |
|
|
69 |
|
|
70 |
public MosaicPropertiesListener(MosaicPropertiesPanel panel) { |
|
71 |
this.panel = panel; |
|
72 |
panel.getAddButton().addActionListener(this); |
|
73 |
panel.getCreateButton().addActionListener(this); |
|
74 |
panel.getSeeListCheck().addActionListener(this); |
|
75 |
panel.getDeleteButton().addActionListener(this); |
|
76 |
panel.getDeleteCacheButton().addActionListener(this); |
|
77 |
panel.getUpArrowButton().addActionListener(this); |
|
78 |
panel.getDownArrowButton().addActionListener(this); |
|
79 |
panel.getModel().addTableModelListener(this); |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* Events in the table |
|
84 |
*/ |
|
85 |
public void tableChanged(TableModelEvent e) { |
|
86 |
if(e.getColumn() == 0) { |
|
87 |
MosaicDataParameters params = (MosaicDataParameters)panel.getfLayer().getDataStore().getParameters(); |
|
88 |
Object[][] data = panel.getModel().getDataWithoutPath(); |
|
89 |
for (int i = 0; i < data.length; i++) { |
|
90 |
boolean b = ((Boolean)data[i][0]).booleanValue(); |
|
91 |
params.setVisibleProvider(i, b); |
|
92 |
} |
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
public void accept() { |
|
97 |
apply(); |
|
98 |
} |
|
99 |
|
|
100 |
public void apply() { |
|
101 |
addFilesToProviderFromTable(); |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* Gets the name of the layer |
|
106 |
* @return |
|
107 |
*/ |
|
108 |
public String getLayerName() { |
|
109 |
if(layerName == null) { |
|
110 |
layerName = panel.getfLayer().getName(); |
|
111 |
if(layerName.endsWith(suffix)) { |
|
112 |
int index = layerName.lastIndexOf(suffix); |
|
113 |
layerName = layerName.substring(0, index); |
|
114 |
} |
|
115 |
} |
|
116 |
return layerName; |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* Adds all files in the table to the MosaicProvider or creates one if this doesn't exist. |
|
121 |
*/ |
|
122 |
@SuppressWarnings("deprecation") |
|
123 |
private void addFilesToProviderFromTable() { |
|
124 |
if(panel.getModel().getRowCount() == 0) |
|
125 |
return; |
|
126 |
try { |
|
127 |
RasterDataStore dataStore = panel.getfLayer().getDataStore(); |
|
128 |
RasterDataParameters paramFirstFile = (RasterDataParameters)dataStore.getParameters(); |
|
129 |
boolean create = !(paramFirstFile instanceof MosaicDataParameters); |
|
130 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
|
131 |
|
|
132 |
String basePath = paramFirstFile.getURI().substring(0, paramFirstFile.getURI().lastIndexOf(File.separator) + 1); |
|
133 |
String path = basePath + layerName + suffix; |
|
134 |
|
|
135 |
MosaicDataParameters newParamsMosaic = null; |
|
136 |
|
|
137 |
//Gets the mosaic provider parameters if we are creating a new mosaic |
|
138 |
if(create) { |
|
139 |
DataServerExplorerParameters explParams = dataManager.createServerExplorerParameters(MosaicProvider.NAME); |
|
140 |
DataServerExplorer explorer = dataManager.openServerExplorer(MosaicProvider.NAME, explParams); |
|
141 |
newParamsMosaic = (MosaicDataParameters)dataManager.createStoreParameters(explorer.getProviderName()); |
|
142 |
|
|
143 |
newParamsMosaic.setURI(path); |
|
144 |
//Temporal hasta que est? el cuadro de configuraci?n. Se pone el tama?o de pixel de la imagen maestra |
|
145 |
newParamsMosaic.setPixelSize(dataStore.getCellSize()); |
|
146 |
} else |
|
147 |
newParamsMosaic = (MosaicDataParameters)paramFirstFile; |
|
148 |
|
|
149 |
Object[][] data = panel.getModel().getDataWithPath(); |
|
150 |
ArrayList<File> uriList = new ArrayList<File>(); |
|
151 |
|
|
152 |
DataServerExplorerParameters param = (DataServerExplorerParameters) dataManager.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
|
153 |
FilesystemServerExplorer fsexplorer = (FilesystemServerExplorer) dataManager.createServerExplorer(param); |
|
154 |
|
|
155 |
//Iterates all files and builds a new provider for each one |
|
156 |
for (int i = 0; i < data.length; i++) { |
|
157 |
String file = (String)data[i][1]; |
|
158 |
uriList.add(new File(file)); |
|
159 |
if(!newParamsMosaic.existsProvider(file)) { |
|
160 |
File f = new File(file); |
|
161 |
fsexplorer.setCurrentPath(new File(basePath)); |
|
162 |
|
|
163 |
List<String> provName = fsexplorer.getProviderNameList(f); |
|
164 |
if(provName.size() > 0) { |
|
165 |
for (int j = 0; j < provName.size(); j++) { |
|
166 |
DataStoreParameters newparams = fsexplorer.createStoreParameters(f, provName.get(j)); |
|
167 |
((FilesystemStoreParameters)newparams).setFile(f); |
|
168 |
DataStoreProvider prov = dataManager.createProvider((DataStoreProviderServices)dataStore, newparams); |
|
169 |
if(newParamsMosaic.addNotTiledProvider(prov)) |
|
170 |
break; |
|
171 |
} |
|
172 |
} |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
if(create) { |
|
177 |
DataStoreProvider provMosaic = dataManager.createProvider((DataStoreProviderServices)dataStore, newParamsMosaic); |
|
178 |
((DefaultFLyrRaster)panel.getfLayer()).setName(layerName); |
|
179 |
//Assigns the MultifileProvider to the store |
|
180 |
dataStore.setProvider((CoverageStoreProvider)provMosaic); |
|
181 |
panel.getfLayer().getRender().setLastTransparency(panel.getfLayer().getDataStore().getTransparency()); |
|
182 |
} |
|
183 |
|
|
184 |
saveMosaicFileLayer(layerName, paramFirstFile.getURI(), uriList); |
|
185 |
panel.setCreateStatus(); |
|
186 |
} catch (Exception exc) { |
|
187 |
RasterToolsUtil.messageBoxError("addfile_mosaic_error", panel, exc); |
|
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Removes a provider from the MosaicProvider |
|
193 |
* @param fileName |
|
194 |
*/ |
|
195 |
private void removeFileFromProvider(String fileName) { |
|
196 |
try { |
|
197 |
RasterDataStore dataStore = panel.getfLayer().getDataStore(); |
|
198 |
RasterDataParameters params = (RasterDataParameters)dataStore.getParameters(); |
|
199 |
if(params instanceof MosaicDataParameters) { |
|
200 |
MosaicDataParameters paramsMosaic = (MosaicDataParameters)params; |
|
201 |
ArrayList<File> uriList = new ArrayList<File>(); |
|
202 |
|
|
203 |
for (int i = paramsMosaic.getProviderCount() - 1; i >= 0; i--) { |
|
204 |
String uri = paramsMosaic.getURIByProvider(i); |
|
205 |
if(fileName.compareTo(uri) == 0) |
|
206 |
paramsMosaic.removeProvider(i); |
|
207 |
else |
|
208 |
uriList.add(new File(uri)); |
|
209 |
} |
|
210 |
saveMosaicFileLayer(layerName, params.getURI(), uriList); |
|
211 |
panel.setCreateStatus(); |
|
212 |
} |
|
213 |
} catch (Exception exc) { |
|
214 |
RasterToolsUtil.messageBoxError("removefile_mosaic_error", panel, exc); |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
/** |
|
219 |
* Goes a provider up in the list |
|
220 |
* @param fileName |
|
221 |
*/ |
|
222 |
private void upProviders(int[] indexes) { |
|
223 |
try { |
|
224 |
RasterDataStore dataStore = panel.getfLayer().getDataStore(); |
|
225 |
RasterDataParameters params = (RasterDataParameters)dataStore.getParameters(); |
|
226 |
if(params instanceof MosaicDataParameters) { |
|
227 |
MosaicDataParameters paramsMosaic = (MosaicDataParameters)params; |
|
228 |
ArrayList<File> uriList = new ArrayList<File>(); |
|
229 |
|
|
230 |
for (int i = 0; i < indexes.length; i++) { |
|
231 |
int row = indexes[i]; |
|
232 |
|
|
233 |
if(row == 0) |
|
234 |
continue; |
|
235 |
|
|
236 |
paramsMosaic.swapProvider(row, row - 1); |
|
237 |
} |
|
238 |
for (int i = 0; i < paramsMosaic.getProviderCount(); i++) { |
|
239 |
uriList.add(new File(paramsMosaic.getURIByProvider(i))); |
|
240 |
} |
|
241 |
saveMosaicFileLayer(getLayerName(), params.getURI(), uriList); |
|
242 |
panel.setCreateStatus(); |
|
243 |
} |
|
244 |
} catch (Exception exc) { |
|
245 |
RasterToolsUtil.messageBoxError("removefile_mosaic_error", panel, exc); |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
249 |
/** |
|
250 |
* Goes a provider up in the list |
|
251 |
* @param fileName |
|
252 |
*/ |
|
253 |
private void downProviders(int[] indexes) { |
|
254 |
try { |
|
255 |
RasterDataStore dataStore = panel.getfLayer().getDataStore(); |
|
256 |
RasterDataParameters params = (RasterDataParameters)dataStore.getParameters(); |
|
257 |
if(params instanceof MosaicDataParameters) { |
|
258 |
MosaicDataParameters paramsMosaic = (MosaicDataParameters)params; |
|
259 |
ArrayList<File> uriList = new ArrayList<File>(); |
|
260 |
|
|
261 |
for (int i = indexes.length - 1; i >= 0; i--) { |
|
262 |
int row = indexes[i]; |
|
263 |
|
|
264 |
if(row == paramsMosaic.getProviderCount() - 1) |
|
265 |
continue; |
|
266 |
|
|
267 |
paramsMosaic.swapProvider(row, row + 1); |
|
268 |
} |
|
269 |
for (int i = 0; i < paramsMosaic.getProviderCount(); i++) { |
|
270 |
uriList.add(new File(paramsMosaic.getURIByProvider(i))); |
|
271 |
} |
|
272 |
saveMosaicFileLayer(getLayerName(), params.getURI(), uriList); |
|
273 |
panel.setCreateStatus(); |
|
274 |
} |
|
275 |
} catch (Exception exc) { |
|
276 |
RasterToolsUtil.messageBoxError("removefile_mosaic_error", panel, exc); |
|
277 |
} |
|
278 |
} |
|
279 |
|
|
280 |
/** |
|
281 |
* Saves the new layer in disk |
|
282 |
* @param layerName |
|
283 |
* @param file |
|
284 |
* @param uriList |
|
285 |
* @throws IOException |
|
286 |
*/ |
|
287 |
private String saveMosaicFileLayer(String layerName, String file, ArrayList<File> uriList) throws IOException { |
|
288 |
String path = file.substring(0, file.lastIndexOf(File.separator) + 1); |
|
289 |
path = path + layerName + suffix; |
|
290 |
|
|
291 |
MosaicRasterFormat format = new MosaicRasterFormat(); |
|
292 |
for (int i = 0; i < uriList.size(); i++) { |
|
293 |
format.addFile(uriList.get(i)); |
|
294 |
} |
|
295 |
format.setName(layerName); |
|
296 |
|
|
297 |
format.write(path); |
|
298 |
return path; |
|
299 |
} |
|
300 |
|
|
301 |
public void cancel() { |
|
302 |
|
|
303 |
} |
|
304 |
|
|
305 |
public void selected() { |
|
306 |
|
|
307 |
} |
|
308 |
|
|
309 |
/* |
|
310 |
* (non-Javadoc) |
|
311 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
312 |
*/ |
|
313 |
public void actionPerformed(ActionEvent e) { |
|
314 |
if(e.getSource() == panel.getCreateButton()) { |
|
315 |
WindowInfo wi = PluginServices.getMDIManager().getActiveWindow().getWindowInfo(); |
Also available in: Unified diff