Revision 37387

View differences:

tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/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" 
6
			  value="${org.gvsig.initial.build.basedir}/.."/>
7
	<property name="build.basedir" 
8
		      value="${workspace.basedir}/org.gvsig.maven.base.build"
9
		      description="Eclipse workspace location"/>
10
	<property name="build.jar.version" 
11
			 	  value="1.0.6-SNAPSHOT" />
12
	<property name="build.jar.file" 
13
		 	  value="org.gvsig.maven.base.build-${build.jar.version}.jar" />
14
	
15
	<target name="check-maven-base-build-available">
16
		<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" 
17
				   property="maven-base-build-available"/>
18
	</target>
19
	
20
	<target name="get-maven-base-build-local" 
21
			depends="check-maven-base-build-available"
22
			if="maven-base-build-available">
23
		<!-- Unzip de build jar file from the maven repository into the workspace root folder -->
24
		<unzip src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}"
25
		       dest="${workspace.basedir}">
26
		    <patternset>
27
		        <exclude name="META-INF/**"/>
28
		    </patternset>
29
		</unzip>	
30
	</target>
31
	
32
	<target name="get-maven-base-build-remote" 
33
			depends="check-maven-base-build-available"
34
			unless="maven-base-build-available">
35
		<!-- Download the build jar file -->
36
		<get src="http://gvsig-desktop.forge.osor.eu/downloads/pub/projects/gvSIG-desktop/maven-repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" 
37
			 dest="target/${build.jar.file}"
38
			 verbose="true"/>
39
		
40
		<!-- Unzip de build jar file into the workspace root folder -->
41
		<unzip src="target/${build.jar.file}"
42
		       dest="${workspace.basedir}">
43
		    <patternset>
44
		        <exclude name="META-INF/**"/>
45
		    </patternset>
46
		</unzip>	
47
	</target>
48
	
49
	<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote">
50
		
51
		<mkdir dir="target"/>
52
	
53
		<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug"/>
54
		
55
		<!-- Copy the maven launchers to the workspace metadata folder -->
56
		<copy todir="${workspace.basedir}/.metadata">
57
		    <fileset dir="${build.basedir}/eclipse-launchers"/>
58
		</copy>
59
		
60
		<!-- Configure the eclipse workspace -->
61
		<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace"/>
62

  
63
		<!-- Configure the gvSIG profile -->
64
		<ant antfile="${build.basedir}/check-gvsig-profile.xml" target="initialize"/>
65

  
66
		<!-- Compile, install and generate eclipse projects -->
67
		<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse"/>
68
		
69
		<echo>INFORMATION!!!</echo>
70
		<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo>
71
		
72
		<!-- TODO: copiar al proyecto de configuraciĆ³n general -->
73
	</target>
74
 	
75
	<target name="clean">
76
		<delete dir="target"/>
77
	</target>
78

  
79
</project>
0 80

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
	<modelVersion>4.0.0</modelVersion>
6
	<artifactId>org.gvsig.annotation</artifactId>
7
	<packaging>pom</packaging>
8
	<version>1.0.0-SNAPSHOT</version>
9
	<name>org.gvsig.annotation</name>
10
	<description>Annotation example project</description>
11
	<url>http://gvsig-desktop.forge.osor.eu/downloads/pub/projects/gvSIG-desktop/docs/reference/org.gvsig.annotation/${project.version}/basic/org.gvsig.annotation</url>
12
    <parent>
13
        <groupId>org.gvsig</groupId>
14
        <artifactId>org.gvsig.maven.base.pom</artifactId>
15
        <version>1.0.8-SNAPSHOT</version>
16
    </parent>
17
    
18
	<scm>
19
		<connection>scm:svn:https://svn.forge.osor.eu/svn/gvsig-annotation/org.gvsig.annotation/library/trunk</connection>
20
		<developerConnection>scm:svn:https://svn.forge.osor.eu/svn/gvsig-annotation/org.gvsig.annotation/library/trunk</developerConnection>
21
		<url>https://forge.osor.eu/plugins/scmsvn/viewcvs.php/org.gvsig.annotation/library/trunk/?root=gvsig-annotation</url>
22
	</scm>
23

  
24
	<developers>
25
		<developer>
26
			<id>jpiera</id>
27
			<name>Jorge Piera</name>
28
			<email>jpiera@gvsig.org</email>
29
			<roles>
30
				<role>Architect</role>
31
				<role>Developer</role>
32
			</roles>
33
		</developer>
34
		<developer>
35
			<id>jjdelcerro</id>
36
			<name>Joaqu?n Jos? del Cerro</name>
37
			<email>jjdelcerro@gvsig.org</email>
38
			<roles>
39
				<role>Architect</role>			
40
			</roles>
41
		</developer>		
42
	</developers>
43

  
44
	<distributionManagement>
45
		<site>
46
			<id>gvsig-repository</id>
47
			<url>scp://shell.forge.osor.eu/home/groups/gvsig-desktop/www/downloads/pub/projects/gvSIG-desktop/docs/reference/org.gvsig.annotation/${project.version}/basic/org.gvsig.annotation</url>
48
		</site>
49
	</distributionManagement>
50
	<repositories>
51
		<repository>
52
			<id>gvsig-public-http-repository</id>
53
			<name>gvSIG maven public HTTP repository</name>
54
			<url>http://gvsig-desktop.forge.osor.eu/downloads/pub/projects/gvSIG-desktop/maven-repository</url>
55
			<releases>
56
				<enabled>true</enabled>
57
				<updatePolicy>daily</updatePolicy>
58
				<checksumPolicy>warn</checksumPolicy>
59
			</releases>
60
			<snapshots>
61
				<enabled>true</enabled>
62
				<updatePolicy>daily</updatePolicy>
63
				<checksumPolicy>warn</checksumPolicy>
64
			</snapshots>
65
		</repository>
66
	</repositories>
67
	<build>
68
		<plugins>
69
			<plugin>
70
				<groupId>org.apache.maven.plugins</groupId>
71
				<artifactId>maven-release-plugin</artifactId>
72
				<configuration>
73
					<tagBase>https://svn.forge.osor.eu/svn/gvsig-annotation/org.gvsig.annotation/library/tags</tagBase>
74
				</configuration>
75
			</plugin>
76
            <!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION -->
77
            <plugin>
78
                <groupId>org.apache.maven.plugins</groupId>
79
                <artifactId>maven-surefire-plugin</artifactId>
80
                <configuration>
81
                    <skipTests>true</skipTests>
82
                </configuration>
83
            </plugin>
84
        </plugins>        
85
	</build>
86
    <dependencyManagement>
87
        <dependencies>          
88
            <dependency>
89
                <groupId>org.gvsig</groupId>
90
                <artifactId>org.gvsig.core.maven.dependencies</artifactId>
91
                <version>2.0.1-SNAPSHOT</version>
92
                <type>pom</type>
93
                <scope>import</scope>
94
            </dependency>
95
        </dependencies>
96
    </dependencyManagement>
97
	<dependencies>
98
		<dependency>
99
			<groupId>org.gvsig</groupId>
100
			<artifactId>org.gvsig.tools.lib</artifactId>
101
		</dependency>
102
		<dependency>
103
			<groupId>org.gvsig</groupId>
104
			<artifactId>org.gvsig.tools.lib</artifactId>
105
			<type>test-jar</type>
106
		</dependency>
107
        <dependency>
108
            <groupId>org.slf4j</groupId>
109
            <artifactId>slf4j-api</artifactId>
110
            <scope>compile</scope>
111
        </dependency>        	
112
	</dependencies>
113

  
114
	<modules>
115
		<module>org.gvsig.annotation.lib</module>
116
		<module>org.gvsig.annotation.swing</module>
117
		<module>org.gvsig.annotation.main</module>
118
	</modules>
119
</project>
0 120

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/README.txt
1
The first time you checkout the current project to a new workspace, 
2
you have to prepare it to be able to work easily with maven from
3
eclipse itself.
4

  
5
Perform the following steps:
6

  
7
1.- Launch the *prepare-workspace.xml* ant build file. 
8
    You can do it by loading the file into the ant view, 
9
    and running the default task, or right-clicking the 
10
    file from the package explorer or the navigator and
11
    select the option: *Run as > Ant build*. 
12
    
13
2.- Restart eclipse.
14

  
15
3.- Import the subprojects of the project you have just checked out.
16

  
17
Those steps are only needed once per workspace.     
18

  
0 19

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.main/src/main/java/org/gvsig/annotation/main/Main.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.annotation.main;
23

  
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26

  
27
import org.gvsig.annotation.AnnotationCreationService;
28
import org.gvsig.annotation.AnnotationLocator;
29
import org.gvsig.annotation.AnnotationManager;
30
import org.gvsig.annotation.swing.AnnotationSwingLocator;
31
import org.gvsig.annotation.swing.AnnotationSwingManager;
32
import org.gvsig.annotation.swing.AnnotationWindowManager;
33
import org.gvsig.annotation.swing.JAnnotationCreationServicePanel;
34
import org.gvsig.fmap.crs.CRSFactory;
35
import org.gvsig.fmap.dal.DALLocator;
36
import org.gvsig.fmap.dal.DataManager;
37
import org.gvsig.fmap.dal.DataStoreParameters;
38
import org.gvsig.fmap.dal.feature.FeatureStore;
39
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
40

  
41
/**
42
 * Main executable class for testing the Annotation library.
43
 * 
44
 * @author gvSIG Team
45
 * @version $Id$
46
 */
47
public class Main {
48

  
49
    private static final Logger LOG = LoggerFactory.getLogger(Main.class);
50

  
51
    private AnnotationManager annotationManager;
52
    private AnnotationSwingManager annotationSwingManager;
53
    private DataManager dataManager;
54

  
55
    public static void main(String args[]) throws Exception {
56
        new DefaultLibrariesInitializer().fullInitialize();
57
        Main main = new Main();
58
        main.show();
59
    }    
60
    
61
    @SuppressWarnings("serial")
62
    public void show() throws Exception {
63
        annotationManager = AnnotationLocator.getManager();
64
        annotationSwingManager = AnnotationSwingLocator.getSwingManager();
65
        dataManager = DALLocator.getDataManager();
66
        
67
        
68
        JAnnotationCreationServicePanel annotationCreationService = annotationSwingManager.createAnnotation(createService());
69
        annotationSwingManager.getWindowManager().showWindow(annotationCreationService, "Annotation App. example", AnnotationWindowManager.MODE_DIALOG);
70
    }   
71
    
72
    /**
73
     * Returns an instance of the {@link AnnotationCreationService}.
74
     * 
75
     * @return a {@link AnnotationCreationService} instance
76
     * @throws Exception
77
     *             if there is any error creating the instance
78
     */
79
    protected AnnotationCreationService createService() throws Exception {
80
    	String sourceFileName = getClass().getClassLoader().getResource("org/gvsig/annotation/data/andalucia.shp").getFile();
81
    	DataStoreParameters sourceParameters = dataManager.createStoreParameters("Shape");
82
     	sourceParameters.setDynValue("shpfile", sourceFileName);
83
     	sourceParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030"));
84
     	FeatureStore sourceStore = (FeatureStore) dataManager.openStore("Shape", sourceParameters);
85
    	return annotationManager.getAnnotationCreationService(sourceStore);
86
    }
87

  
88
}
0 89

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.main/src/main/java/org/gvsig/annotation/main/PreferencesMain.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.annotation.main;
23

  
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26

  
27
import org.gvsig.annotation.AnnotationCreationService;
28
import org.gvsig.annotation.AnnotationLocator;
29
import org.gvsig.annotation.AnnotationManager;
30
import org.gvsig.annotation.swing.AnnotationSwingLocator;
31
import org.gvsig.annotation.swing.AnnotationSwingManager;
32
import org.gvsig.annotation.swing.AnnotationWindowManager;
33
import org.gvsig.annotation.swing.JAnnotationPreferencesPanel;
34
import org.gvsig.fmap.crs.CRSFactory;
35
import org.gvsig.fmap.dal.DALLocator;
36
import org.gvsig.fmap.dal.DataManager;
37
import org.gvsig.fmap.dal.DataStoreParameters;
38
import org.gvsig.fmap.dal.feature.FeatureStore;
39
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
40

  
41
/**
42
 * Main executable class for testing the Annotation library.
43
 * 
44
 * @author gvSIG Team
45
 * @version $Id$
46
 */
47
public class PreferencesMain {
48

  
49
    private static final Logger LOG = LoggerFactory.getLogger(PreferencesMain.class);
50

  
51
    private AnnotationManager annotationManager;
52
    private AnnotationSwingManager annotationSwingManager;
53
    private DataManager dataManager;
54

  
55
    public static void main(String args[]) throws Exception {
56
        new DefaultLibrariesInitializer().fullInitialize();
57
        PreferencesMain main = new PreferencesMain();
58
        main.show();
59
    }    
60
    
61
    @SuppressWarnings("serial")
62
    public void show() throws Exception {
63
        annotationManager = AnnotationLocator.getManager();
64
        annotationSwingManager = AnnotationSwingLocator.getSwingManager();
65
        dataManager = DALLocator.getDataManager();
66
        
67
        
68
        JAnnotationPreferencesPanel annotationPreferencesPanel = annotationSwingManager.createAnnotationPreferences();
69
        annotationSwingManager.getWindowManager().showPreferencesWindow(annotationPreferencesPanel, "Annotation Preferences. example", AnnotationWindowManager.MODE_DIALOG);
70
    }   
71
    
72
    /**
73
     * Returns an instance of the {@link AnnotationCreationService}.
74
     * 
75
     * @return a {@link AnnotationCreationService} instance
76
     * @throws Exception
77
     *             if there is any error creating the instance
78
     */
79
    protected AnnotationCreationService createService() throws Exception {
80
    	String sourceFileName = getClass().getClassLoader().getResource("org/gvsig/annotation/data/andalucia.shp").getFile();
81
    	DataStoreParameters sourceParameters = dataManager.createStoreParameters("Shape");
82
     	sourceParameters.setDynValue("shpfile", sourceFileName);
83
     	sourceParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030"));
84
     	FeatureStore sourceStore = (FeatureStore) dataManager.openStore("Shape", sourceParameters);
85
    	return annotationManager.getAnnotationCreationService(sourceStore);
86
    }
87

  
88
}
0 89

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.main/src/main/java/org/gvsig/annotation/main/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.annotation package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>Annotation library testing and demo application.</p>
11

  
12
</body>
13
</html>
0 14

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.main/src/main/resources/README.txt
1
Put into this folder the resources needed by your classes.
2

  
3
This folder is added to the classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your classes.
0 9

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.main/src/main/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.annotation">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
0 38

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.main/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.annotation.main</artifactId>
6
	<packaging>jar</packaging>
7
	<name>org.gvsig.annotation.main</name>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.annotation</artifactId>
11
		<version>1.0.0-SNAPSHOT</version>
12
	</parent>
13
	<dependencies>
14
		<dependency>
15
			<groupId>org.gvsig</groupId>
16
			<artifactId>org.gvsig.annotation.lib.api</artifactId>
17
			<version>1.0.0-SNAPSHOT</version>
18
            <scope>compile</scope>
19
		</dependency>
20
		<dependency>
21
			<groupId>org.gvsig</groupId>
22
			<artifactId>org.gvsig.annotation.lib.impl</artifactId>
23
			<version>1.0.0-SNAPSHOT</version>
24
			<scope>runtime</scope>
25
		</dependency>
26
		<dependency>
27
			<groupId>org.gvsig</groupId>
28
			<artifactId>org.gvsig.annotation.swing.api</artifactId>
29
			<version>1.0.0-SNAPSHOT</version>
30
            <scope>compile</scope>
31
		</dependency>
32
		<dependency>
33
			<groupId>org.gvsig</groupId>
34
			<artifactId>org.gvsig.annotation.swing.impl</artifactId>
35
			<version>1.0.0-SNAPSHOT</version>
36
			<scope>runtime</scope>
37
		</dependency>
38
        <dependency>
39
            <groupId>org.gvsig</groupId>
40
            <artifactId>org.gvsig.tools.lib</artifactId>
41
            <scope>compile</scope>
42
        </dependency>
43
        <dependency>
44
            <groupId>org.gvsig</groupId>
45
            <artifactId>org.gvsig.tools.swing.impl</artifactId>
46
            <scope>runtime</scope>
47
        </dependency>
48
        <dependency>
49
            <groupId>org.gvsig</groupId>
50
            <artifactId>org.gvsig.fmap.dal</artifactId>
51
            <scope>compile</scope>
52
        </dependency>
53
        <dependency>
54
            <groupId>org.gvsig</groupId>
55
            <artifactId>org.gvsig.projection</artifactId>
56
            <scope>compile</scope>
57
        </dependency>
58
        <dependency>
59
            <groupId>org.gvsig</groupId>
60
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
61
            <scope>compile</scope>
62
        </dependency>
63
	</dependencies>
64
</project>
0 65

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.annotation">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
0 38

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
0 9

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/test/java/org/gvsig/annotation/impl/DefaultAnnotationCreationServiceTest.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.annotation.impl;
23

  
24
import org.gvsig.annotation.AnnotationCreationService;
25
import org.gvsig.annotation.AnnotationCreationServiceTest;
26
import org.gvsig.fmap.geom.Geometry;
27
import org.gvsig.fmap.geom.GeometryLocator;
28
import org.gvsig.fmap.geom.GeometryManager;
29
import org.gvsig.fmap.geom.exception.CreateGeometryException;
30

  
31
/**
32
 * {@link AnnotationCreationService} API compatibility tests for the
33
 * {@link DefaultAnnotationCreationService} implementation.
34
 * 
35
 * @author gvSIG Team
36
 * @version $Id$
37
 */
38
public class DefaultAnnotationCreationServiceTest extends AnnotationCreationServiceTest {
39
		
40
	public DefaultAnnotationCreationServiceTest() {
41
		super();		
42
	}
43

  
44
	@Override
45
	public TextPointPairList getResult() throws CreateGeometryException {
46
		GeometryManager geometryManager = GeometryLocator.getGeometryManager();
47
		TextPointPairList textPointPairList = new TextPointPairList();
48
		textPointPairList.addPoint("Sevilla", geometryManager.createPoint(262760.53, 4146732.91, Geometry.SUBTYPES.GEOM2D));
49
		return textPointPairList;
50
	}
51
}
0 52

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/test/java/org/gvsig/annotation/impl/DefaultAnnotationManagerTest.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.annotation.impl;
23

  
24
import org.gvsig.annotation.AnnotationManager;
25
import org.gvsig.annotation.AnnotationManagerTest;
26

  
27
/**
28
 * {@link AnnotationManager} API compatibility tests for the
29
 * {@link DefaultAnnotationManager} implementation.
30
 * 
31
 * @author gvSIG Team
32
 * @version $Id$
33
 */
34
public class DefaultAnnotationManagerTest extends AnnotationManagerTest {
35

  
36
    // Nothing to add
37
}
0 38

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/resources/locale/text.properties
1
# Resource bundle texts for the Spanish language locale (es)
2
centroid=Centroide
3

  
0 4

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/resources/locale/text_en.properties
1
# Resource bundle texts for the English language locale (en)
2
infofile_exception=Exception in installation file install.info
3
infofile_not_found=File install.info not found
4
infofile_property_not_found=The property %(propertyName) is mandatory but it is not in the install.info file
5
infofile_found=File install.info exists
6
infofile_reading_error=Error reading the install.info file
7
infofile_writing_error=Error writing the install.info file
8
plugin_to_install=Plugin to install
9
plugin_description=Plugin description
10
advanced_mode_selection=Advanced options
11
ant_script=Ant script
12
files_to_copy=Files to copy
13
output_options=Output options
14
progress=Install progress
15
advanced_mode=The advanced mode option allows to copy resources that are located out of the plugin directory. We don't recommend to use this option.
16
initializing=Inicializando 
17
create_output_file_exception=Error creating the output file
18
select_installer=Select the installer
19
select_plugins=Select the plugins to install
20
execute_adding_error=Error adding a resource
21
name=Name
22
description=Description
23
version=Version
24
build=Build
25
is_official=Is official
26
status=Status
27
code=Code
28
enable_advanced_mode=Enable the advanced mode
29
compressing=Compressing
30
finished=Finished
31
standard_installation=Standard installation
32
installation_from_file=Installation from file
33
official=Official
34
not_official=Not official
35
application_directory_not_found=Application directory not found
36
package_not_found=The package has not been found
37
make_plugin_package_exception=Exception creating the package for a plugin
38
not_valid_xml=The XML is not a valid XML
39

  
0 40

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.annotation.impl.AnnotationDefaultImplLibrary
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/calculator/CentroidPositionCalculatior.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

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Prodevelop}   {Task}
26
*/
27
 
28
package org.gvsig.annotation.impl.calculator;
29

  
30
import org.gvsig.annotation.calculator.AnnotationPositionCalculationException;
31
import org.gvsig.annotation.calculator.AnnotationPositionCalculator;
32
import org.gvsig.fmap.dal.feature.Feature;
33
import org.gvsig.fmap.geom.operation.GeometryOperationException;
34
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
35
import org.gvsig.fmap.geom.primitive.Point;
36
import org.gvsig.i18n.Messages;
37

  
38
/**
39
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
40
 */
41
public class CentroidPositionCalculatior implements AnnotationPositionCalculator{
42

  
43
	public Point getAnnotationPosition(Feature feature) throws AnnotationPositionCalculationException {
44
		try {
45
			return feature.getDefaultGeometry().centroid();
46
		} catch (GeometryOperationNotSupportedException e) {
47
			throw new AnnotationPositionCalculationException(e);
48
		} catch (GeometryOperationException e) {
49
			throw new AnnotationPositionCalculationException(e);
50
		}
51
	}
52

  
53
	public String getName() {
54
		return Messages.getText("centroid");
55
	}
56
}
57

  
0 58

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/DefaultAnnotationManager.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.annotation.impl;
23

  
24
import java.awt.Color;
25
import java.util.ArrayList;
26
import java.util.Collections;
27
import java.util.List;
28

  
29
import org.gvsig.annotation.AnnotationCreationService;
30
import org.gvsig.annotation.AnnotationCreationServiceException;
31
import org.gvsig.annotation.AnnotationManager;
32
import org.gvsig.annotation.calculator.AnnotationPositionCalculator;
33
import org.gvsig.annotation.calculator.AnnotationPositionCalculatorCreationException;
34
import org.gvsig.fmap.dal.exception.DataException;
35
import org.gvsig.fmap.dal.feature.FeatureStore;
36
import org.gvsig.tools.ToolsLocator;
37
import org.gvsig.tools.extensionpoint.ExtensionPoint;
38
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
39
import org.gvsig.tools.service.ServiceException;
40

  
41
/**
42
 * Default {@link AnnotationManager} implementation.
43
 * 
44
 * @author gvSIG Team
45
 * @version $Id$
46
 */
47
public class DefaultAnnotationManager implements AnnotationManager {
48
	private static final String ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT = "AnnotationPositionCalculatorExtensionPoint";
49
	private ExtensionPointManager extensionPointManager = ToolsLocator.getExtensionPointManager();
50
	private static final String DEFAULT_ANNOTATION_POSITION_CALCULATOR = "DefaultAnnotationPositionCalculator";
51
	
52
	private String defaultTextValue = null;
53
	private int defaultFontColor = -1;
54
	private double defaultFontHeight = -1;
55
	private double defaultFontRotation = -1;
56
	private String defaultFontStyle = null;
57
	private String defaultFontType = null;
58
	
59
	private List<String> fontTypes = Collections.synchronizedList(new ArrayList<String>());
60
	private List<String> fontStyles = Collections.synchronizedList(new ArrayList<String>());
61
	
62
	
63
    public AnnotationCreationService getAnnotationCreationService(FeatureStore featureStore)
64
        throws ServiceException {
65
        AnnotationCreationService fc;
66
		try {
67
			fc = new DefaultAnnotationCreationService(featureStore, this);
68
		} catch (DataException e) {
69
			throw new AnnotationCreationServiceException("Impossible to create the annotation service", e);
70
		}
71
        return fc;
72
    }
73

  
74
	public AnnotationPositionCalculator getAnnotationPositionCalculator(
75
			String name) throws AnnotationPositionCalculatorCreationException {
76
		if (extensionPointManager.get(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT).has(name)){
77
			try {
78
				return (AnnotationPositionCalculator)extensionPointManager.get(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT).create(name);
79
			} catch (InstantiationException e) {
80
				throw new AnnotationPositionCalculatorCreationException(name, e);
81
			} catch (IllegalAccessException e) {
82
				throw new AnnotationPositionCalculatorCreationException(name, e);
83
			}
84
		}else{
85
			throw new IllegalArgumentException("There is not an annotation position calculator registered with this name"); 
86
		}		
87
	}
88

  
89
	public List<String> getAnnotationPositionCalculatorList() {
90
		return extensionPointManager.get(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT).getNames();
91
	}
92

  
93
	public AnnotationPositionCalculator getDefaultAnnotationPositionCalculator() throws AnnotationPositionCalculatorCreationException {
94
		return getAnnotationPositionCalculator(DEFAULT_ANNOTATION_POSITION_CALCULATOR);
95
	}
96

  
97
	public void registerAnnotationPositionCalculator(String name,
98
			Class annotationPositionCalculatorClass) {
99
		if (!AnnotationPositionCalculator.class.isAssignableFrom(annotationPositionCalculatorClass)) {
100
			throw new IllegalArgumentException(annotationPositionCalculatorClass.getName()
101
					+ " must implement the AnnotationPositionCalculator interface");
102
		}
103
		
104
		ExtensionPoint extensionPoint = extensionPointManager.add(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT, "");
105
		extensionPoint.append(name, name, annotationPositionCalculatorClass);		
106
	}
107

  
108
	public void registerDefaultAnnotationPositionCalculator(Class annotationPositionCalculatorClass) {
109
		registerAnnotationPositionCalculator(DEFAULT_ANNOTATION_POSITION_CALCULATOR,
110
				annotationPositionCalculatorClass);
111
	}
112

  
113
	public void addFontStyle(String fontStyle) {
114
		fontStyles.add(fontStyle);		
115
	}
116

  
117
	public void addFontType(String fontType) {
118
		fontTypes.add(fontType);		
119
	}
120

  
121
	public int getDefaultFontColor() {
122
		return defaultFontColor;
123
	}
124

  
125
	public double getDefaultFontHeight() {
126
		return defaultFontHeight;
127
	}
128

  
129
	public double getDefaultFontRotation() {
130
		return defaultFontRotation;
131
	}
132

  
133
	public String getDefaultFontStyle() {
134
		return defaultFontStyle;
135
	}
136

  
137
	public String getDefaultFontType() {
138
		return defaultFontType;
139
	}
140

  
141
	public String getDefaultTextValue() {
142
		return defaultTextValue;
143
	}
144

  
145
	public List<String> getFontStyles() {
146
		return fontStyles;
147
	}
148

  
149
	public List<String> getFontTypes() {
150
		return fontTypes;
151
	}
152

  
153
	public void setDefaultFontColor(int fontColor) {
154
		this.defaultFontColor = fontColor;		
155
	}
156
	
157
	public void setDefaultFontColor(Color fontColor) {
158
		this.defaultFontColor = fontColor.getRGB();		
159
	}
160

  
161
	public void setDefaultFontHeight(double fontHeight) {
162
		this.defaultFontHeight = fontHeight;		
163
	}
164

  
165
	public void setDefaultFontRotation(double fontRotation) {
166
		this.defaultFontRotation = fontRotation;		
167
	}
168

  
169
	public void setDefaultFontStyle(String fontStyle) {
170
		this.defaultFontStyle = fontStyle;		
171
	}
172

  
173
	public void setDefaultFontType(String fontType) {
174
		this.defaultFontType = fontType;		
175
	}
176

  
177
	public void setDefaultTextValue(String textValue) {
178
		this.defaultTextValue = textValue;		
179
	}
180

  
181

  
182
}
0 183

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.annotation package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>Annotation library API default implementation.</p>
11

  
12
</body>
13
</html>
0 14

  
tags/v2_0_0_Build_2041/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/DefaultAnnotationCreationService.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.annotation.impl;
23

  
24
import java.io.File;
25
import java.io.FileOutputStream;
26
import java.io.IOException;
27
import java.io.InputStream;
28
import java.io.OutputStream;
29

  
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32

  
33
import org.gvsig.annotation.AnnotationCreationException;
34
import org.gvsig.annotation.AnnotationCreationFinishAction;
35
import org.gvsig.annotation.AnnotationCreationService;
36
import org.gvsig.annotation.AnnotationDataTypes;
37
import org.gvsig.annotation.AnnotationManager;
38
import org.gvsig.annotation.calculator.AnnotationPositionCalculationException;
39
import org.gvsig.annotation.calculator.AnnotationPositionCalculator;
40
import org.gvsig.annotation.calculator.AnnotationPositionCalculatorCreationException;
41
import org.gvsig.fmap.dal.DALLocator;
42
import org.gvsig.fmap.dal.DataManager;
43
import org.gvsig.fmap.dal.DataTypes;
44
import org.gvsig.fmap.dal.exception.DataException;
45
import org.gvsig.fmap.dal.exception.InitializeException;
46
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
47
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
48
import org.gvsig.fmap.dal.feature.EditableFeature;
49
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
50
import org.gvsig.fmap.dal.feature.EditableFeatureType;
51
import org.gvsig.fmap.dal.feature.Feature;
52
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
53
import org.gvsig.fmap.dal.feature.FeatureSet;
54
import org.gvsig.fmap.dal.feature.FeatureStore;
55
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
56
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
57
import org.gvsig.fmap.geom.Geometry;
58
import org.gvsig.tools.dispose.DisposableIterator;
59
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
60
import org.gvsig.tools.task.AbstractMonitorableTask;
61

  
62

  
63
/**
64
 * Default {@link AnnotationCreationService} implementation.
65
 * 
66
 * @author gvSIG Team
67
 * @version $Id$
68
 */
69
public class DefaultAnnotationCreationService extends AbstractMonitorableTask implements AnnotationCreationService {
70
	private static final Logger LOG = LoggerFactory.getLogger(DefaultAnnotationCreationService.class);
71
	private static DataManager dataManager = DALLocator.getDataManager();
72

  
73
	private AnnotationManager manager;
74
	private FeatureStore sourceStore;
75

  
76
	private int sourceFontTypeAttribute = -1;
77
	private int sourceFontStyleAttribute = -1;
78
	private int sourceFontColorAttribute = -1;
79
	private int sourceRotationAttribute = -1;
80
	private int sourceHeigthAttribute = -1;
81
	private AnnotationPositionCalculator annotationPositionCalculator = null;
82

  
83
	private String destinationGeometryAttributeName = null;
84

  
85
	private AnnotationCreationFinishAction annotationCreationFinishAction = null; 
86

  
87
	/**
88
	 * {@link DefaultAnnotationCreationService} constructor with a
89
	 * {@link AnnotationManager}.
90
	 * 
91
	 * @param manager
92
	 *            to use in the service
93
	 * @throws DataException 
94
	 */
95
	public DefaultAnnotationCreationService(FeatureStore featureStore, AnnotationManager manager) throws DataException {
96
		super("annotation");
97
	    this.sourceStore = featureStore; 
98
		this.manager = manager;
99
		destinationGeometryAttributeName = featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName();
100
	}
101

  
102
	public AnnotationManager getManager() {
103
		return this.manager;
104
	}
105

  
106
	public FeatureStore createAnnotationStore(String destinationShapeFile, int textValueAttribute)
107
	throws AnnotationCreationException {		
108
		try {
109
			if (destinationShapeFile == null){
110
				throw new AnnotationCreationException("File can not be null");
111
			}	
112

  
113
			String destinationShapeFileWithoutExtension = destinationShapeFile.toLowerCase().replaceAll("\\.shp", "");
114
			if (destinationShapeFileWithoutExtension.length() == destinationShapeFile.length()-4){
115
				destinationShapeFileWithoutExtension =  destinationShapeFile.substring(0, destinationShapeFile.length()-4);
116
			}else{
117
				destinationShapeFileWithoutExtension = destinationShapeFile;
118
			}			
119

  
120
			NewFeatureStoreParameters newFeatureStoreParameters = (NewFeatureStoreParameters)dataManager.createNewStoreParameters("FilesystemExplorer", "Shape");
121
			newFeatureStoreParameters.setDynValue("shpfile", destinationShapeFileWithoutExtension + ".shp");
122
			newFeatureStoreParameters.setDynValue("dbffile", destinationShapeFileWithoutExtension + ".dbf");
123
			newFeatureStoreParameters.setDynValue("shxfile", destinationShapeFileWithoutExtension + ".shx");
124
			newFeatureStoreParameters.setDynValue("crs", sourceStore.getDefaultFeatureType().getDefaultSRS());
125

  
126
			EditableFeatureType editableFeatureType = sourceStore.getDefaultFeatureType().getEditable();//newFeatureStoreParameters.getDefaultFeatureType().getEditable();
127
			FeatureAttributeDescriptor[] featureAttributeDescriptors = editableFeatureType.getAttributeDescriptors();
128
			for (int i=featureAttributeDescriptors.length-1  ; i>=0 ; i--){
129
				editableFeatureType.remove(i);
130
			}
131
			initializeFeatureType(editableFeatureType);
132
			newFeatureStoreParameters.setDefaultFeatureType(editableFeatureType);
133

  
134
			dataManager.newStore("FilesystemExplorer", "Shape", newFeatureStoreParameters, true);
135

  
136
			//If there is not an annotationPositionCalculator it gets the default 
137
			if (annotationPositionCalculator == null){
138
				annotationPositionCalculator = manager.getDefaultAnnotationPositionCalculator();
139
			}	
140

  
141
			FeatureStore destinationStore = (FeatureStore) dataManager.openStore("Shape", newFeatureStoreParameters);
142

  
143
			copyFeatureStore(sourceStore, 
144
					destinationStore,
145
					textValueAttribute);	
146

  
147
			try {
148
				copyLegend(destinationStore);
149
			} catch (IOException e) {
150
				LOG.error("Error copying the legend");
151
			}
152

  
153
			if (annotationCreationFinishAction != null){
154
				annotationCreationFinishAction.finished(destinationStore);
155
			}
156

  
157
			return destinationStore;
158
		} catch (InitializeException e) {
159
			throw new AnnotationCreationException(e);
160
		} catch (ProviderNotRegisteredException e) {
161
			throw new AnnotationCreationException(e);
162
		} catch (ValidateDataParametersException e) {
163
			throw new AnnotationCreationException(e);
164
		} catch (DynFieldNotFoundException e) {
165
			throw new AnnotationCreationException(e);
166
		} catch (DataException e) {
167
			throw new AnnotationCreationException(e);
168
		} catch (AnnotationPositionCalculatorCreationException e) {
169
			throw new AnnotationCreationException(e);
170
		} 			
171
	}	
172

  
173
	public FeatureStore createAnnotationStore(String destinationShapeFile,
174
			String textValueAttributeName) throws AnnotationCreationException {
175
		try {
176
			return createAnnotationStore(destinationShapeFile, getIndex(textValueAttributeName));
177
		} catch (DataException e) {
178
			throw new AnnotationCreationException(e);
179
		}			
180
	}
181

  
182
	private void initializeFeatureType(EditableFeatureType editableFeatureType) throws DataException
183
	{		
184
		EditableFeatureAttributeDescriptor geometryType = editableFeatureType.add(destinationGeometryAttributeName, DataTypes.GEOMETRY);
185
		geometryType.setAllowNull(false);		
186
		geometryType.setGeometryType(Geometry.TYPES.POINT).setGeometrySubType(Geometry.SUBTYPES.GEOM2D);
187
		geometryType.setSRS(sourceStore.getDefaultFeatureType().getDefaultSRS());
188
		geometryType.setObjectClass(Geometry.class);
189

  
190
		editableFeatureType.add(AnnotationManager.TEXTVALUE_ATTRIBUTE_NAME, AnnotationDataTypes.TEXT, 256).setAllowNull(true);
191
		editableFeatureType.add(AnnotationManager.FONTTYPE_ATTRIBUTE_NAME, AnnotationDataTypes.FONTTYPE, 30).setAllowNull(true);
192
		editableFeatureType.add(AnnotationManager.FONTSTYLE_ATTRIBUTE_NAME, AnnotationDataTypes.FONTSTYLE, 30).setAllowNull(true);
193
		editableFeatureType.add(AnnotationManager.FONTCOLOR_ATTRIBUTE_NAME, AnnotationDataTypes.FONTCOLOR, 20).setAllowNull(true);
194
		editableFeatureType.add(AnnotationManager.FONTROTATION_ATTRIBUTE_NAME, AnnotationDataTypes.FONTROTATION, 5).setAllowNull(true);
195
		editableFeatureType.add(AnnotationManager.FONTHEGTH_ATTRIBUTE_NAME, AnnotationDataTypes.FONTHEIGHT, 5).setAllowNull(true);
196
	}
197

  
198
	private AttributeInserter createInserter(int attributePosition, Object defaultValue)
199
	{
200
		if (attributePosition > -1){
201
			return new StoreAttributeInserter(attributePosition);
202
		}else{
203
			return new DefaultAttributeInserter(defaultValue);
204
		}
205
	}
206

  
207
	private void copyFeatureStore(FeatureStore sourceStore,
208
			FeatureStore destinationStore, int textAttribute)
209
	throws AnnotationCreationException, DataException {		
210

  
211
		//Start the edition
212
		destinationStore.edit();
213

  
214
		//Copy data
215
		FeatureSet featureSet = sourceStore.getFeatureSet();
216
		DisposableIterator iterator = featureSet.iterator();
217
		
218
		taskStatus.setRangeOfValues(0, featureSet.getSize());
219

  
220
		//Create the attribute inserter's
221
		AttributeInserter fontTypeAttributeInserter = createInserter(sourceFontTypeAttribute, manager.getDefaultFontType());		
222
		AttributeInserter fontStyleAttributeInserter = createInserter(sourceFontStyleAttribute, manager.getDefaultFontStyle());		
223
		AttributeInserter fontColorAttributeInserter = createInserter(sourceFontColorAttribute, manager.getDefaultFontColor());		
224
		AttributeInserter fontRotationAttributeInserter = createInserter(sourceRotationAttribute, manager.getDefaultFontRotation());		
225
		AttributeInserter fontHeigthAttributeInserter = createInserter(sourceHeigthAttribute, manager.getDefaultFontHeight());		
226

  
227
		Feature sourceFeature;
228
		long featureCount = 0;
229
		while (iterator.hasNext()) {			
230
			sourceFeature = (Feature) iterator.next();
231

  
232
			EditableFeature destinationFeature = destinationStore.createNewFeature().getEditable();
233
			try {
234
				destinationFeature.set(destinationGeometryAttributeName, annotationPositionCalculator.getAnnotationPosition(sourceFeature));
235
			} catch (AnnotationPositionCalculationException e) {
236
				LOG.error("Not possible to get the point for the geometry", e);				
237
			}
238
			destinationFeature.set(AnnotationManager.TEXTVALUE_ATTRIBUTE_NAME, sourceFeature.get(textAttribute));
239
			destinationFeature.set(AnnotationManager.FONTTYPE_ATTRIBUTE_NAME, fontTypeAttributeInserter.getValue(sourceFeature));
240
			destinationFeature.set(AnnotationManager.FONTSTYLE_ATTRIBUTE_NAME, fontStyleAttributeInserter.getValue(sourceFeature));
241
			destinationFeature.set(AnnotationManager.FONTCOLOR_ATTRIBUTE_NAME, fontColorAttributeInserter.getValue(sourceFeature));
242
			destinationFeature.set(AnnotationManager.FONTROTATION_ATTRIBUTE_NAME, fontRotationAttributeInserter.getValue(sourceFeature));
243
			destinationFeature.set(AnnotationManager.FONTHEGTH_ATTRIBUTE_NAME, fontHeigthAttributeInserter.getValue(sourceFeature));
244

  
245
			destinationStore.insert(destinationFeature);
246
    		featureCount++;  
247
    		this.taskStatus.setCurValue(featureCount);
248
    
249
            if (this.taskStatus.isCancellationRequested()) {
250
                return;
251
            }
252
		}
253

  
254
		//Finish the edition
255
		destinationStore.finishEditing();
256

  
257
		//Dispose resources
258
		iterator.dispose();		
259
		featureSet.dispose();
260
		
261
		this.taskStatus.terminate();
262
        this.taskStatus.remove();		
263
	}
264

  
265
	private void copyLegend(FeatureStore destinationStore) throws ValidateDataParametersException, DataException, IOException {
266
		FilesystemServerExplorer filesystemServerExplorer = (FilesystemServerExplorer)destinationStore.getExplorer();
267
		File target = filesystemServerExplorer.getResourcePath(destinationStore, "gvl");
268

  
269
		//Copy the template
270
		InputStream in = getClass().getClassLoader().getResourceAsStream("legend.template.gvl");
271
		OutputStream out = null;
272

  
273
		out = new FileOutputStream(target);
274

  
275
		byte[] buf = new byte[1024];
276
		int len;
277
		while ((len = in.read(buf)) > 0) { 
278
			out.write(buf, 0, len); 
279
		} 
280
		in.close();
281
		out.close(); 		
282
	}
283

  
284
	private void checkAttribute(int index, int type) throws DataException{
285
		if (index >= sourceStore.getDefaultFeatureType().size()){
286
			throw new IllegalArgumentException("Attribute not found");
287
		}
288
		if (sourceStore.getDefaultFeatureType().getAttributeDescriptor(index).getDataType().getType() != type){
289
			throw new IllegalArgumentException("The Attribute has not have the fine type");
290
		}
291
	}
292

  
293

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff