Revision 39466

View differences:

tags/v2_0_0_Build_2061/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" 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

  
tags/v2_0_0_Build_2061/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
    <parent>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>org.gvsig.maven.base.pom</artifactId>
14
        <version>1.0.8-SNAPSHOT</version>
15
    </parent>
16
    
17
	<scm>
18
		<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/libraries/org.gvsig.annotation</connection>
19
		<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/libraries/org.gvsig.annotation</developerConnection>
20
		<url>https://devel.gvsig.org/redmine/projects/gvsig-desktop/repository/show/branches/v2_0_0_prep/libraries/org.gvsig.annotation</url>
21
	</scm>
22

  
23
	<developers>
24
		<developer>
25
			<id>jpiera</id>
26
			<name>Jorge Piera</name>
27
			<email>jpiera@gvsig.org</email>
28
			<roles>
29
				<role>Architect</role>
30
				<role>Developer</role>
31
			</roles>
32
		</developer>
33
		<developer>
34
			<id>jjdelcerro</id>
35
			<name>Joaqu?n Jos? del Cerro</name>
36
			<email>jjdelcerro@gvsig.org</email>
37
			<roles>
38
				<role>Architect</role>			
39
			</roles>
40
		</developer>		
41
	</developers>
42
	<repositories>
43
		<repository>
44
			<id>gvsig-public-http-repository</id>
45
			<name>gvSIG maven public HTTP repository</name>
46
            <url>http://devel.gvsig.org/m2repo/j2se</url>
47
			<releases>
48
				<enabled>true</enabled>
49
				<updatePolicy>daily</updatePolicy>
50
				<checksumPolicy>warn</checksumPolicy>
51
			</releases>
52
			<snapshots>
53
				<enabled>true</enabled>
54
				<updatePolicy>daily</updatePolicy>
55
				<checksumPolicy>warn</checksumPolicy>
56
			</snapshots>
57
		</repository>
58
	</repositories>
59
	<build>
60
		<plugins>
61
            <!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION -->
62
            <plugin>
63
                <groupId>org.apache.maven.plugins</groupId>
64
                <artifactId>maven-surefire-plugin</artifactId>
65
                <configuration>
66
                    <skipTests>true</skipTests>
67
                </configuration>
68
            </plugin>
69
        </plugins>        
70
	</build>
71
    <dependencyManagement>
72
        <dependencies>          
73
            <dependency>
74
                <groupId>org.gvsig</groupId>
75
                <artifactId>org.gvsig.core.maven.dependencies</artifactId>
76
                <version>2.0.1-SNAPSHOT</version>
77
                <type>pom</type>
78
                <scope>import</scope>
79
            </dependency>
80
        </dependencies>
81
    </dependencyManagement>
82
	<dependencies>
83
		<dependency>
84
			<groupId>org.gvsig</groupId>
85
			<artifactId>org.gvsig.tools.lib</artifactId>
86
		</dependency>
87
		<dependency>
88
			<groupId>org.gvsig</groupId>
89
			<artifactId>org.gvsig.tools.lib</artifactId>
90
			<type>test-jar</type>
91
		</dependency>
92
        <dependency>
93
            <groupId>org.slf4j</groupId>
94
            <artifactId>slf4j-api</artifactId>
95
            <scope>compile</scope>
96
        </dependency>        	
97
	</dependencies>
98

  
99
	<modules>
100
		<module>org.gvsig.annotation.lib</module>
101
		<module>org.gvsig.annotation.swing</module>
102
		<module>org.gvsig.annotation.main</module>
103
	</modules>
104
</project>
0 105

  
tags/v2_0_0_Build_2061/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_2061/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_2061/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_2061/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_2061/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_2061/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_2061/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_2061/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/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
4
		 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5

  
6
	<modelVersion>4.0.0</modelVersion>
7
	<artifactId>org.gvsig.annotation.lib</artifactId>
8
	<packaging>pom</packaging>
9
	<name>org.gvsig.annotation.lib</name>
10
	<parent>
11
		<groupId>org.gvsig</groupId>
12
		<artifactId>org.gvsig.annotation</artifactId>
13
		<version>1.0.0-SNAPSHOT</version>
14
	</parent>
15

  
16
	<modules>
17
		<module>org.gvsig.annotation.lib.api</module>
18
		<module>org.gvsig.annotation.lib.impl</module>
19
	</modules>
20
</project>
0 21

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/test/java/org/gvsig/annotation/AnnotationCreationServiceTest.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;
23

  
24
import java.io.File;
25
import java.util.ArrayList;
26
import java.util.List;
27

  
28
import org.gvsig.fmap.crs.CRSFactory;
29
import org.gvsig.fmap.dal.DALLocator;
30
import org.gvsig.fmap.dal.DataManager;
31
import org.gvsig.fmap.dal.DataStoreParameters;
32
import org.gvsig.fmap.dal.feature.Feature;
33
import org.gvsig.fmap.dal.feature.FeatureSet;
34
import org.gvsig.fmap.dal.feature.FeatureStore;
35
import org.gvsig.fmap.dal.feature.FeatureType;
36
import org.gvsig.fmap.geom.Geometry;
37
import org.gvsig.fmap.geom.exception.CreateGeometryException;
38
import org.gvsig.fmap.geom.primitive.Point;
39
import org.gvsig.i18n.Messages;
40
import org.gvsig.tools.dispose.DisposableIterator;
41
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
42

  
43

  
44
/**
45
 * API compatibility tests for {@link AnnotationCreationService} implementations.
46
 * 
47
 * @author gvSIG Team
48
 * @version $Id$
49
 */
50
public abstract class AnnotationCreationServiceTest extends
51
    AbstractLibraryAutoInitTestCase {
52

  
53
    protected AnnotationManager manager;
54
    protected DataManager dataManager;
55

  
56
    @Override
57
    protected void doSetUp() throws Exception {
58
        manager = AnnotationLocator.getManager();
59
        dataManager = DALLocator.getDataManager();
60
    }
61

  
62
    /**
63
     * Returns an instance of the {@link AnnotationCreationService}.
64
     * 
65
     * @return a {@link AnnotationCreationService} instance
66
     * @throws Exception
67
     *             if there is any error creating the instance
68
     */
69
    protected AnnotationCreationService createService() throws Exception {
70
    	String sourceFileName = getClass().getClassLoader().getResource("org/gvsig/annotation/data/andalucia.shp").getFile();
71
    	DataStoreParameters sourceParameters = dataManager.createStoreParameters("Shape");
72
     	sourceParameters.setDynValue("shpfile", sourceFileName);
73
     	sourceParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030"));
74
     	FeatureStore sourceStore = (FeatureStore) dataManager.openStore("Shape", sourceParameters);
75
    	return manager.getAnnotationCreationService(sourceStore);
76
    }
77

  
78
    /**
79
     * Test for the {@link AnnotationCreationService#getMessage()} method.
80
     * 
81
     * @throws Exception
82
     *             if there is any error in the tests
83
     */
84
    public void testAnnotationServiceMessage() throws Exception {
85
        AnnotationCreationService annotationCreationService = createService();
86
            
87
        File temporalFolder = new File(System.getProperty("java.io.tmpdir") +  File.separator + "tmp_gvsig_annotation");
88
        if (!temporalFolder.exists()){
89
        	if (!temporalFolder.mkdir()){
90
        		throw new Exception("Impossible to create the destination folder");
91
        	}
92
        }
93
        
94
        String destinationFileName =  temporalFolder.getAbsolutePath() + File.separator + Math.random() + ".shp";		
95
                    
96
        annotationCreationService.createAnnotationStore(destinationFileName, 1);
97
        
98
        DataStoreParameters destinationParameters = dataManager.createStoreParameters("Shape");
99
        destinationParameters.setDynValue("shpfile", destinationFileName);
100
        destinationParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030"));
101
    	FeatureStore destinationStore = (FeatureStore) dataManager.openStore("Shape", destinationParameters);
102
        
103
    	assertNotNull(destinationStore);
104
    	
105
    	FeatureType featureType = destinationStore.getDefaultFeatureType();
106
    	assertEquals(7, featureType.getAttributeDescriptors().length);
107
    	
108
     	assertEquals(destinationStore.getFeatureCount(), annotationCreationService.getFeatureStore().getFeatureCount());
109
    	
110
    	assertNotNull(featureType.getDefaultGeometryAttribute());
111
    	assertEquals(featureType.getDefaultGeometryAttribute().getGeometryType(), Geometry.TYPES.POINT);
112
    	    
113
    	//Check the geometries
114
    	FeatureSet featureSet = destinationStore.getFeatureSet();
115
    	DisposableIterator iterator = featureSet.iterator();
116
    	
117
    	Feature feature;
118
    	TextPointPairList textPointPairList = getResult();
119
    	while (iterator.hasNext()){
120
    		feature = (Feature)iterator.next();
121
    		assertNotNull(feature.get(Messages.getText(AnnotationManager.TEXTVALUE_ATTRIBUTE_NAME)));
122
    		String text = feature.getString(AnnotationManager.TEXTVALUE_ATTRIBUTE_NAME);
123
    		TextPointPair textPointPair = textPointPairList.search(text);
124
    		if (textPointPair != null){
125
	    		//Check the geometry
126
	    		Point point = (Point)feature.getDefaultGeometry();
127
	    		assertEquals(point.getX(), textPointPair.getPoint().getX(), 0.01);
128
	    		assertEquals(point.getY(), textPointPair.getPoint().getY(), 0.01);
129
	    	}
130
    		int color = feature.getInt(AnnotationManager.FONTCOLOR_ATTRIBUTE_NAME);
131
    		assertEquals(color, manager.getDefaultFontColor()); 
132
    		
133
    		double heigth = feature.getDouble(AnnotationManager.FONTHEGTH_ATTRIBUTE_NAME);
134
    		assertEquals(heigth, manager.getDefaultFontHeight()); 
135
    		
136
    		double rotation = feature.getDouble(AnnotationManager.FONTROTATION_ATTRIBUTE_NAME);
137
    		assertEquals(rotation, manager.getDefaultFontRotation()); 
138
    		
139
    		String type = feature.getString(AnnotationManager.FONTTYPE_ATTRIBUTE_NAME);
140
    		assertEquals(type, manager.getDefaultFontType()); 
141
    		
142
    		String style = feature.getString(AnnotationManager.FONTSTYLE_ATTRIBUTE_NAME);
143
    		assertEquals(style, manager.getDefaultFontStyle());     		
144
    	}
145
    	
146
    	destinationStore.dispose();
147
    	annotationCreationService.getFeatureStore().dispose();
148
    }
149
    
150
    public abstract TextPointPairList getResult() throws CreateGeometryException;
151
    
152
    public class TextPointPairList{
153
    	List<TextPointPair> textPointPairs = new ArrayList<TextPointPair>();
154

  
155
		public TextPointPairList() {
156
			super();
157
		}
158
    	
159
		public void addPoint(String text, Point point){
160
			textPointPairs.add(new TextPointPair(text, point));
161
		}
162
		
163
		public TextPointPair search(String text){
164
			for (TextPointPair textPointPair : textPointPairs) {
165
				if (textPointPair.getText().equals(text)){
166
					return textPointPair;
167
				}
168
			}
169
			return null;
170
		}    	
171
    }
172
    
173
    
174
    
175
    private class TextPointPair{
176
    	private String text;
177
		private Point point;
178
		
179
    	public TextPointPair(String text, Point point) {
180
			super();
181
			this.text = text;
182
			this.point = point;
183
		}
184
    	
185
    	public String getText() {
186
			return text;
187
		}
188

  
189
		public Point getPoint() {
190
			return point;
191
		}    	
192
    }
193

  
194
    /**
195
     * Test for the {@link AnnotationCreationService#getManager()} method.
196
     * 
197
     * @throws Exception
198
     *             if there is any error in the tests
199
     */
200
    public void testAnnotationServiceManager() throws Exception {
201
        AnnotationCreationService annotationCreationService = createService();
202
        assertEquals(manager, annotationCreationService.getManager());
203
    }
204
}
0 205

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/test/java/org/gvsig/annotation/AnnotationManagerTest.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;
23

  
24
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
25

  
26
/**
27
 * API compatibility tests for {@link AnnotationManager} implementations.
28
 * 
29
 * @author gvSIG Team
30
 * @version $Id$
31
 */
32
public abstract class AnnotationManagerTest extends
33
    AbstractLibraryAutoInitTestCase {
34

  
35
    protected AnnotationManager manager;
36

  
37
    @Override
38
    protected void doSetUp() throws Exception {
39
        manager = AnnotationLocator.getManager();
40
    }
41

  
42
    /**
43
     * Test for the {@link AnnotationManager#getAnnotationCreationService()}
44
     * method.
45
     * 
46
     * @throws Exception
47
     *             if there is any error in the tests
48
     */
49
    public void testGetAnnotationCreationService() throws Exception {
50
       
51
    }
52

  
53
}
0 54

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.annotation.AnnotationLibrary
tags/v2_0_0_Build_2061/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/AnnotationCreationServiceException.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;
29

  
30
import org.gvsig.tools.service.ServiceException;
31

  
32
/**
33
 * Exception thrown by the {@link AnnotationCreationService}.
34
 * 
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
36
 */
37
public class AnnotationCreationServiceException extends ServiceException {
38
	private static final long serialVersionUID = -4200816057552322619L;
39
	private final static String MESSAGE_KEY = "_AnnotationCreationServiceException";	
40

  
41

  
42
	public AnnotationCreationServiceException(String message, Throwable e) {
43
		super(message, e, MESSAGE_KEY, serialVersionUID);
44
		this.initCause(e);		
45
	}
46
}
0 47

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/AnnotationLibrary.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;
23

  
24
import org.gvsig.fmap.dal.DALLibrary;
25
import org.gvsig.tools.library.AbstractLibrary;
26
import org.gvsig.tools.library.LibraryException;
27
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
28

  
29
/**
30
 * Library for API initialization and configuration.
31
 * 
32
 * @author gvSIG team
33
 * @version $Id$
34
 */
35
public class AnnotationLibrary extends AbstractLibrary {
36
	
37
    @Override
38
    public void doRegistration() {
39
        registerAsAPI(AnnotationLibrary.class);
40
        require(DALLibrary.class);
41
    }
42

  
43
	@Override
44
    protected void doInitialize() throws LibraryException {
45
        // Do nothing
46
		
47
    }
48

  
49
    @Override
50
    protected void doPostInitialize() throws LibraryException {
51
    	
52
    	// Validate there is any implementation registered.
53
        AnnotationManager manager = AnnotationLocator.getManager();
54
        if (manager == null) {
55
            throw new ReferenceNotRegisteredException(
56
                AnnotationLocator.MANAGER_NAME, AnnotationLocator
57
                    .getInstance());
58
        }
59
    }
60

  
61
}
0 62

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/AnnotationCreationService.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
package org.gvsig.annotation;
24

  
25
import org.gvsig.annotation.calculator.AnnotationPositionCalculator;
26
import org.gvsig.fmap.dal.exception.DataException;
27
import org.gvsig.fmap.dal.feature.FeatureStore;
28
import org.gvsig.tools.task.MonitorableTask;
29

  
30
/**
31
 * <p>
32
 * This service is used to create an annotation layer.
33
 * </p>
34
 * <p>
35
 * It inherits if {@link MonitorableTask}, and it means that the annotation 
36
 * process can be monitorized by one or more observers that can listen
37
 * all the export events.
38
 * <p>
39
 * @author gvSIG team
40
 * @version $Id$
41
 */
42
public interface AnnotationCreationService extends MonitorableTask {
43

  
44
	/**
45
	 * @return
46
	 * the store that is used like input.
47
	 */
48
	public FeatureStore getFeatureStore();
49
	
50
	/**
51
	 * This method creates a {@link FeatureStore} with the annotations. 
52
	 * @param destinationShapeFile 
53
	 * path there the shape this the annotation information is created.
54
	 * @param textValueAttributeIndex
55
	 * attribute index of the original {@link FeatureStore} that contains the text.
56
	 * @return
57
	 * a new store with the annotation information.
58
	 * @throws AnnotationCreationException
59
	 * if there is an error creating the annotation store. 
60
	 */
61
    public FeatureStore createAnnotationStore(String destinationShapeFile, int textValueAttributeIndex) throws AnnotationCreationException;
62
	
63
    /**
64
	 * This method creates a {@link FeatureStore} with the annotations. 
65
	 * @param destinationShapeFile 
66
	 * path there the shape this the annotation information is created.
67
	 * @param textValueAttributeName
68
	 * attribute name of the original {@link FeatureStore} that contains the text.
69
	 * @return
70
	 * a new store with the annotation information.
71
	 * @throws AnnotationCreationException
72
	 * if there is an error creating the annotation store. 
73
	 */
74
    public FeatureStore createAnnotationStore(String destinationShapeFile, String textValueAttributeName) throws AnnotationCreationException;   
75
    
76
    /**
77
     * Sets the {@link AnnotationCreationFinishAction} that is used at the end
78
     * of the annotation creation service. 
79
     * @param annotationCreationFinishAction
80
     * it contains an action that can be executed at the end of the annotation
81
     * creation process.
82
     */
83
    public void setAnnotationCreationFinishAction(AnnotationCreationFinishAction annotationCreationFinishAction);
84
    
85
    /**
86
     * @return
87
     * the {@link AnnotationCreationFinishAction} used at the end of the annotation
88
     * creation process.
89
     */
90
    public AnnotationCreationFinishAction getAnnotationCreationFinishAction();
91
    
92
    /**
93
     * Sets an {@link AnnotationPositionCalculator} used to calculate the
94
     * position of the 
95
     * @param annotationPositionCalculator
96
     */
97
    public void setAnnotationPositionCalculator(AnnotationPositionCalculator annotationPositionCalculator);
98
       
99
    public void setFontTypetAttribute(int index) throws DataException;
100
    
101
    public void setFontStyleAttribute(int index) throws DataException;
102
    			
103
    public void setFontColorAttribute(int index) throws DataException;
104
    
105
    public void setFontHeigthAttribute(int index) throws DataException;
106
    
107
    public void setFontRotationAttribute(int index) throws DataException;
108
    
109
    public void setFontTypetAttribute(String attributeName) throws DataException;
110
    
111
    public void setFontStyleAttribute(String attributeName) throws DataException;
112
    		
113
    public void setFontColorAttribute(String attributeName) throws DataException;
114
    
115
    public void setFontHeigthAttribute(String attributeName) throws DataException;
116
    
117
    public void setFontRotationAttribute(String attributeName) throws DataException;
118
    
119
    /**
120
     * Returns the {@link AnnotationManager}
121
     * 
122
     * @return {@link AnnotationManager}
123
     * @see {@link AnnotationManager}
124
     */
125
    public AnnotationManager getManager();
126
}
0 127

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/AnnotationManager.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;
23

  
24
import java.awt.Color;
25
import java.util.List;
26

  
27
import org.gvsig.annotation.calculator.AnnotationPositionCalculator;
28
import org.gvsig.annotation.calculator.AnnotationPositionCalculatorCreationException;
29
import org.gvsig.fmap.dal.feature.FeatureStore;
30
import org.gvsig.tools.service.ServiceException;
31

  
32
/**
33
 * This class is responsible of the management of the library's business logic.
34
 * It is the library's main entry point, and provides all the services to manage
35
 * {@link AnnotationCreationService}s.
36
 * 
37
 * @see AnnotationCreationService
38
 * @author gvSIG team
39
 * @version $Id$
40
 */
41
public interface AnnotationManager {
42
	/**
43
	 * Name of the datastore attribute that contains the text
44
	 * of the annotation.
45
	 */
46
	public static final String TEXTVALUE_ATTRIBUTE_NAME = "Text";
47
	
48
	/**
49
	 * Name of the datastore attribute that contains the font type
50
	 * of the annotation.
51
	 */
52
	public static final String FONTTYPE_ATTRIBUTE_NAME = "FontType";
53
	
54
	/**
55
	 * Name of the datastore attribute that contains the font style
56
	 * of the annotation.
57
	 */
58
	public static final String FONTSTYLE_ATTRIBUTE_NAME = "FontStyle";
59
	
60
	/**
61
	 * Name of the datastore attribute that contains the font color
62
	 * of the annotation.
63
	 */
64
	public static final String FONTCOLOR_ATTRIBUTE_NAME = "FontColor";
65
	
66
	/**
67
	 * Name of the datastore attribute that contains the font rotation
68
	 * of the annotation.
69
	 */
70
	public static final String FONTROTATION_ATTRIBUTE_NAME = "Rotation";
71
	
72
	/**
73
	 * Name of the datastore attribute that contains the font heigth
74
	 * of the annotation.
75
	 */
76
	public static final String FONTHEGTH_ATTRIBUTE_NAME = "Heigth";
77

  
78
	/**
79
	 * Create an instance of a {@link AnnotationCreationService}.
80
	 * 
81
	 * @param the feature store that is used like input.
82
	 * @return {@link AnnotationCreationService}
83
	 * @throws ServiceException
84
	 *             if there is an error getting the service
85
	 */
86
	public AnnotationCreationService getAnnotationCreationService(FeatureStore featureStore)
87
	throws ServiceException;
88

  
89
	/**
90
	 * It registers a class that can be used to caclulate the position of an
91
	 * annotation.
92
	 * @param name
93
	 * The name used to register the class.
94
	 * @param annotationPositionCalculatorClass
95
	 * The class that is able to calculate an annotation point.
96
	 */
97
	public void registerAnnotationPositionCalculator(String name, Class annotationPositionCalculatorClass);
98

  
99
	/**
100
	 * It registers the default implementation of an {@link AnnotationPositionCalculator}
101
	 * class. It will be used by default if the user don't specify any of them.
102
	 * @param annotationPositionCalculatorClass
103
	 * A class that is able to calculate an annotation point.
104
	 */
105
	public void registerDefaultAnnotationPositionCalculator(Class annotationPositionCalculatorClass);
106

  
107
	/**
108
	 * It returns an object that can be used to create the point
109
	 * where the annotation is displayed.
110
	 * @param name
111
	 * the name used to register the class.
112
	 * @return
113
	 * a class that is able to calculate an annotation point.
114
	 * @throws AnnotationPositionCalculatorCreationException
115
	 * if is not possible to create the object.
116
	 */
117
	public AnnotationPositionCalculator getAnnotationPositionCalculator(String name) throws AnnotationPositionCalculatorCreationException;
118

  
119
	/**
120
	 * It returns the default {@link AnnotationPositionCalculator}.
121
	 * @return
122
	 * the default {@link AnnotationPositionCalculator}.
123
	 * @throws AnnotationPositionCalculatorCreationException
124
	 * if is not possible to create the object.
125
	 */
126
	public AnnotationPositionCalculator getDefaultAnnotationPositionCalculator() throws AnnotationPositionCalculatorCreationException;
127

  
128
	/**
129
	 * @return
130
	 * the list of the names used to register the {@link AnnotationPositionCalculator} classes.
131
	 */
132
	public List<String> getAnnotationPositionCalculatorList();
133

  
134
	/**
135
	 * Value used like the default value for the text field.
136
	 * @return
137
	 * the default text value.
138
	 */
139
	public String getDefaultTextValue();
140

  
141
	/**
142
	 * Set the default value for the text field.
143
	 * @param textValue
144
	 * the default text value.
145
	 */
146
	public void setDefaultTextValue(String textValue);
147

  
148
	/**
149
	 * Value used like the default value for the font type field.
150
	 * @return
151
	 * the default font type value.
152
	 */
153
	public String getDefaultFontType();
154

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

Also available in: Unified diff