Revision 47626
tags/org.gvsig.desktop-2.0.439/license.txt | ||
---|---|---|
1 |
gvSIG. Desktop Geographic Information System. |
|
2 |
|
|
3 |
Copyright (C) 2007-2023 gvSIG Association. |
|
4 |
|
|
5 |
This program is free software; you can redistribute it and/or |
|
6 |
modify it under the terms of the GNU General Public License |
|
7 |
as published by the Free Software Foundation; either version 3 |
|
8 |
of the License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
|
|
18 |
For any additional information, do not hesitate to contact us |
|
19 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
tags/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/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/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.main/src/main/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2013 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 3 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
28 |
|
|
29 |
<!-- |
|
30 |
Log4J configuration file for unit tests execution. |
|
31 |
--> |
|
32 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
33 |
|
|
34 |
<!-- Appender configuration to show logging messages through the console --> |
|
35 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
36 |
<layout class="org.apache.log4j.PatternLayout"> |
|
37 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
38 |
</layout> |
|
39 |
</appender> |
|
40 |
|
|
41 |
<!-- |
|
42 |
Activate logging messages of DEBUG level of higher only for the |
|
43 |
org.gvsig.tools packages. |
|
44 |
You can put full classes names or packages instead, to configure |
|
45 |
logging for all the classes and subpackages of the package. |
|
46 |
--> |
|
47 |
<category name="org.gvsig.tools"> |
|
48 |
<priority value="DEBUG" /> |
|
49 |
</category> |
|
50 |
<category name="org.gvsig.annotation"> |
|
51 |
<priority value="DEBUG" /> |
|
52 |
</category> |
|
53 |
|
|
54 |
<!-- |
|
55 |
By default, show only logging messages of INFO level or higher, |
|
56 |
through the previously configured CONSOLE appender. |
|
57 |
--> |
|
58 |
<root> |
|
59 |
<priority value="INFO" /> |
|
60 |
<appender-ref ref="CONSOLE" /> |
|
61 |
</root> |
|
62 |
</log4j:configuration> |
|
0 | 63 |
tags/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/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 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2013 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 3 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
28 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
29 |
<head> |
|
30 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
31 |
<title>org.gvsig.annotation package documentation</title> |
|
32 |
</head> |
|
33 |
<body> |
|
34 |
|
|
35 |
<p>Annotation library testing and demo application.</p> |
|
36 |
|
|
37 |
</body> |
|
38 |
</html> |
|
0 | 39 |
tags/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.main/src/main/java/org/gvsig/annotation/main/Main.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.annotation.main; |
|
25 |
|
|
26 |
import org.slf4j.Logger; |
|
27 |
import org.slf4j.LoggerFactory; |
|
28 |
|
|
29 |
import org.gvsig.annotation.AnnotationCreationService; |
|
30 |
import org.gvsig.annotation.AnnotationLocator; |
|
31 |
import org.gvsig.annotation.AnnotationManager; |
|
32 |
import org.gvsig.annotation.swing.AnnotationSwingLocator; |
|
33 |
import org.gvsig.annotation.swing.AnnotationSwingManager; |
|
34 |
import org.gvsig.annotation.swing.AnnotationWindowManager; |
|
35 |
import org.gvsig.annotation.swing.JAnnotationCreationServicePanel; |
|
36 |
import org.gvsig.fmap.crs.CRSFactory; |
|
37 |
import org.gvsig.fmap.dal.DALLocator; |
|
38 |
import org.gvsig.fmap.dal.DataManager; |
|
39 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
40 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
41 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
42 |
|
|
43 |
/** |
|
44 |
* Main executable class for testing the Annotation library. |
|
45 |
* |
|
46 |
* @author gvSIG Team |
|
47 |
* @version $Id$ |
|
48 |
*/ |
|
49 |
public class Main { |
|
50 |
|
|
51 |
private static final Logger LOG = LoggerFactory.getLogger(Main.class); |
|
52 |
|
|
53 |
private AnnotationManager annotationManager; |
|
54 |
private AnnotationSwingManager annotationSwingManager; |
|
55 |
private DataManager dataManager; |
|
56 |
|
|
57 |
public static void main(String args[]) throws Exception { |
|
58 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
59 |
Main main = new Main(); |
|
60 |
main.show(); |
|
61 |
} |
|
62 |
|
|
63 |
@SuppressWarnings("serial") |
|
64 |
public void show() throws Exception { |
|
65 |
annotationManager = AnnotationLocator.getManager(); |
|
66 |
annotationSwingManager = AnnotationSwingLocator.getSwingManager(); |
|
67 |
dataManager = DALLocator.getDataManager(); |
|
68 |
|
|
69 |
|
|
70 |
JAnnotationCreationServicePanel annotationCreationService = annotationSwingManager.createAnnotation(createService()); |
|
71 |
annotationSwingManager.getWindowManager().showWindow(annotationCreationService, "Annotation App. example", AnnotationWindowManager.MODE_DIALOG); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Returns an instance of the {@link AnnotationCreationService}. |
|
76 |
* |
|
77 |
* @return a {@link AnnotationCreationService} instance |
|
78 |
* @throws Exception |
|
79 |
* if there is any error creating the instance |
|
80 |
*/ |
|
81 |
protected AnnotationCreationService createService() throws Exception { |
|
82 |
String sourceFileName = getClass().getClassLoader().getResource("org/gvsig/annotation/data/andalucia.shp").getFile(); |
|
83 |
DataStoreParameters sourceParameters = dataManager.createStoreParameters("Shape"); |
|
84 |
sourceParameters.setDynValue("shpfile", sourceFileName); |
|
85 |
sourceParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030")); |
|
86 |
FeatureStore sourceStore = (FeatureStore) dataManager.openStore("Shape", sourceParameters); |
|
87 |
return annotationManager.getAnnotationCreationService(sourceStore); |
|
88 |
} |
|
89 |
|
|
90 |
} |
|
0 | 91 |
tags/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.main/src/main/java/org/gvsig/annotation/main/PreferencesMain.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.annotation.main; |
|
25 |
|
|
26 |
import org.slf4j.Logger; |
|
27 |
import org.slf4j.LoggerFactory; |
|
28 |
|
|
29 |
import org.gvsig.annotation.AnnotationCreationService; |
|
30 |
import org.gvsig.annotation.AnnotationLocator; |
|
31 |
import org.gvsig.annotation.AnnotationManager; |
|
32 |
import org.gvsig.annotation.swing.AnnotationSwingLocator; |
|
33 |
import org.gvsig.annotation.swing.AnnotationSwingManager; |
|
34 |
import org.gvsig.annotation.swing.AnnotationWindowManager; |
|
35 |
import org.gvsig.annotation.swing.JAnnotationPreferencesPanel; |
|
36 |
import org.gvsig.fmap.crs.CRSFactory; |
|
37 |
import org.gvsig.fmap.dal.DALLocator; |
|
38 |
import org.gvsig.fmap.dal.DataManager; |
|
39 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
40 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
41 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
42 |
|
|
43 |
/** |
|
44 |
* Main executable class for testing the Annotation library. |
|
45 |
* |
|
46 |
* @author gvSIG Team |
|
47 |
* @version $Id$ |
|
48 |
*/ |
|
49 |
public class PreferencesMain { |
|
50 |
|
|
51 |
private static final Logger LOG = LoggerFactory.getLogger(PreferencesMain.class); |
|
52 |
|
|
53 |
private AnnotationManager annotationManager; |
|
54 |
private AnnotationSwingManager annotationSwingManager; |
|
55 |
private DataManager dataManager; |
|
56 |
|
|
57 |
public static void main(String args[]) throws Exception { |
|
58 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
59 |
PreferencesMain main = new PreferencesMain(); |
|
60 |
main.show(); |
|
61 |
} |
|
62 |
|
|
63 |
@SuppressWarnings("serial") |
|
64 |
public void show() throws Exception { |
|
65 |
annotationManager = AnnotationLocator.getManager(); |
|
66 |
annotationSwingManager = AnnotationSwingLocator.getSwingManager(); |
|
67 |
dataManager = DALLocator.getDataManager(); |
|
68 |
|
|
69 |
|
|
70 |
JAnnotationPreferencesPanel annotationPreferencesPanel = annotationSwingManager.createAnnotationPreferences(); |
|
71 |
annotationSwingManager.getWindowManager().showPreferencesWindow(annotationPreferencesPanel, "Annotation Preferences. example", AnnotationWindowManager.MODE_DIALOG); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Returns an instance of the {@link AnnotationCreationService}. |
|
76 |
* |
|
77 |
* @return a {@link AnnotationCreationService} instance |
|
78 |
* @throws Exception |
|
79 |
* if there is any error creating the instance |
|
80 |
*/ |
|
81 |
protected AnnotationCreationService createService() throws Exception { |
|
82 |
String sourceFileName = getClass().getClassLoader().getResource("org/gvsig/annotation/data/andalucia.shp").getFile(); |
|
83 |
DataStoreParameters sourceParameters = dataManager.createStoreParameters("Shape"); |
|
84 |
sourceParameters.setDynValue("shpfile", sourceFileName); |
|
85 |
sourceParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030")); |
|
86 |
FeatureStore sourceStore = (FeatureStore) dataManager.openStore("Shape", sourceParameters); |
|
87 |
return annotationManager.getAnnotationCreationService(sourceStore); |
|
88 |
} |
|
89 |
|
|
90 |
} |
|
0 | 91 |
tags/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.annotation.main</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>${project.artifactId}</name> |
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.annotation</artifactId> |
|
10 |
<version>2.0.439</version> |
|
11 |
</parent> |
|
12 |
<dependencies> |
|
13 |
<dependency> |
|
14 |
<groupId>org.gvsig</groupId> |
|
15 |
<artifactId>org.gvsig.annotation.lib.api</artifactId> |
|
16 |
<scope>compile</scope> |
|
17 |
</dependency> |
|
18 |
<dependency> |
|
19 |
<groupId>org.gvsig</groupId> |
|
20 |
<artifactId>org.gvsig.annotation.swing.api</artifactId> |
|
21 |
<scope>compile</scope> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
36 |
<scope>compile</scope> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
41 |
<scope>compile</scope> |
|
42 |
</dependency> |
|
43 |
</dependencies> |
|
44 |
</project> |
|
0 | 45 |
tags/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.annotation.lib.impl</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>org.gvsig.annotation.lib.impl</name> |
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.annotation.lib</artifactId> |
|
10 |
<version>2.0.439</version> |
|
11 |
</parent> |
|
12 |
<dependencies> |
|
13 |
<dependency> |
|
14 |
<groupId>org.gvsig</groupId> |
|
15 |
<artifactId>org.gvsig.annotation.lib.api</artifactId> |
|
16 |
<scope>compile</scope> |
|
17 |
</dependency> |
|
18 |
<dependency> |
|
19 |
<groupId>org.gvsig</groupId> |
|
20 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
21 |
<scope>compile</scope> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.i18n</artifactId> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
36 |
<scope>compile</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.metadata.lib.basic.api</artifactId> |
|
46 |
<scope>compile</scope> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>org.gvsig</groupId> |
|
50 |
<artifactId>org.gvsig.timesupport.lib.api</artifactId> |
|
51 |
<scope>compile</scope> |
|
52 |
</dependency> |
|
53 |
<dependency> |
|
54 |
<groupId>org.gvsig</groupId> |
|
55 |
<artifactId>org.gvsig.fmap.dal.file.lib</artifactId> |
|
56 |
<scope>compile</scope> |
|
57 |
</dependency> |
|
58 |
|
|
59 |
|
|
60 |
<!-- |
|
61 |
|
|
62 |
<dependency> |
|
63 |
<groupId>org.gvsig</groupId> |
|
64 |
<artifactId>org.gvsig.annotation.lib.api</artifactId> |
|
65 |
<type>test-jar</type> |
|
66 |
<scope>test</scope> |
|
67 |
</dependency> |
|
68 |
<dependency> |
|
69 |
<groupId>org.gvsig</groupId> |
|
70 |
<artifactId>org.gvsig.fmap.dal.file.shp</artifactId> |
|
71 |
<scope>test</scope> |
|
72 |
</dependency> |
|
73 |
<dependency> |
|
74 |
<groupId>org.gvsig</groupId> |
|
75 |
<artifactId>org.gvsig.fmap.dal.file.dbf</artifactId> |
|
76 |
<scope>test</scope> |
|
77 |
</dependency> |
|
78 |
<dependency> |
|
79 |
<groupId>org.gvsig</groupId> |
|
80 |
<artifactId>org.gvsig.proj.lib.proj4j</artifactId> |
|
81 |
<scope>compile</scope> |
|
82 |
</dependency> |
|
83 |
--> |
|
84 |
|
|
85 |
</dependencies> |
|
86 |
|
|
87 |
<build> |
|
88 |
<plugins> |
|
89 |
<plugin> |
|
90 |
<!-- Skip compilation tests --> |
|
91 |
<groupId>org.apache.maven.plugins</groupId> |
|
92 |
<artifactId>maven-compiler-plugin</artifactId> |
|
93 |
<executions> |
|
94 |
<execution> |
|
95 |
<id>default-testCompile</id> |
|
96 |
<phase>process-test-sources</phase> |
|
97 |
<goals> |
|
98 |
<goal>testCompile</goal> |
|
99 |
</goals> |
|
100 |
<configuration> |
|
101 |
<skip>true</skip> |
|
102 |
</configuration> |
|
103 |
</execution> |
|
104 |
</executions> |
|
105 |
</plugin> |
|
106 |
</plugins> |
|
107 |
</build> |
|
108 |
|
|
109 |
</project> |
|
0 | 110 |
tags/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/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 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2013 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 3 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
28 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
29 |
<head> |
|
30 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
31 |
<title>org.gvsig.annotation package documentation</title> |
|
32 |
</head> |
|
33 |
<body> |
|
34 |
|
|
35 |
<p>Annotation library API default implementation.</p> |
|
36 |
|
|
37 |
</body> |
|
38 |
</html> |
|
0 | 39 |
tags/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/DefaultAnnotationCreationService.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.annotation.impl; |
|
25 |
|
|
26 |
import java.io.File; |
|
27 |
import java.io.FileOutputStream; |
|
28 |
import java.io.IOException; |
|
29 |
import java.io.InputStream; |
|
30 |
import java.io.OutputStream; |
|
31 |
|
|
32 |
import org.gvsig.annotation.AnnotationCreationException; |
|
33 |
import org.gvsig.annotation.AnnotationCreationFinishAction; |
|
34 |
import org.gvsig.annotation.AnnotationCreationService; |
|
35 |
import org.gvsig.annotation.AnnotationDataTypes; |
|
36 |
import org.gvsig.annotation.AnnotationManager; |
|
37 |
import org.gvsig.annotation.calculator.AnnotationPositionCalculationException; |
|
38 |
import org.gvsig.annotation.calculator.AnnotationPositionCalculator; |
|
39 |
import org.gvsig.annotation.calculator.AnnotationPositionCalculatorCreationException; |
|
40 |
import org.gvsig.fmap.dal.DALLocator; |
|
41 |
import org.gvsig.fmap.dal.DataManager; |
|
42 |
import org.gvsig.fmap.dal.DataTypes; |
|
43 |
import org.gvsig.fmap.dal.exception.DataException; |
|
44 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
45 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
46 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
47 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
48 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
49 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
50 |
import org.gvsig.fmap.dal.feature.Feature; |
|
51 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
52 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
53 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
54 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
55 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
56 |
import org.gvsig.fmap.geom.Geometry; |
|
57 |
import org.gvsig.tools.ToolsLocator; |
|
58 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
59 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
|
60 |
import org.gvsig.tools.task.AbstractMonitorableTask; |
|
61 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
62 |
import org.gvsig.tools.task.TaskStatusManager; |
|
63 |
|
|
64 |
import org.apache.commons.lang3.StringUtils; |
|
65 |
import org.slf4j.Logger; |
|
66 |
import org.slf4j.LoggerFactory; |
|
67 |
|
|
68 |
|
|
69 |
/** |
|
70 |
* Default {@link AnnotationCreationService} implementation. |
|
71 |
* |
|
72 |
* @author gvSIG Team |
|
73 |
* @version $Id$ |
|
74 |
*/ |
|
75 |
public class DefaultAnnotationCreationService extends AbstractMonitorableTask implements AnnotationCreationService { |
|
76 |
private static final Logger LOG = LoggerFactory.getLogger(DefaultAnnotationCreationService.class); |
|
77 |
private static final String TEMPLATE_NAME = "template.gvslab"; |
|
78 |
private static DataManager dataManager = DALLocator.getDataManager(); |
|
79 |
|
|
80 |
private AnnotationManager manager; |
|
81 |
private FeatureStore sourceStore; |
|
82 |
|
|
83 |
private int sourceFontTypeAttribute = -1; |
|
84 |
private int sourceFontStyleAttribute = -1; |
|
85 |
private int sourceFontColorAttribute = -1; |
|
86 |
private int sourceRotationAttribute = -1; |
|
87 |
private int sourceHeigthAttribute = -1; |
|
88 |
private AnnotationPositionCalculator annotationPositionCalculator = null; |
|
89 |
|
|
90 |
private String destinationGeometryAttributeName = null; |
|
91 |
|
|
92 |
private AnnotationCreationFinishAction annotationCreationFinishAction = null; |
|
93 |
|
|
94 |
/** |
|
95 |
* {@link DefaultAnnotationCreationService} constructor with a |
|
96 |
* {@link AnnotationManager}. |
|
97 |
* |
|
98 |
* @param manager |
|
99 |
* to use in the service |
|
100 |
* @throws DataException |
|
101 |
*/ |
|
102 |
public DefaultAnnotationCreationService(FeatureStore featureStore, AnnotationManager manager) throws DataException { |
|
103 |
super("annotation"); |
|
104 |
this.sourceStore = featureStore; |
|
105 |
this.manager = manager; |
|
106 |
destinationGeometryAttributeName = featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName(); |
|
107 |
} |
|
108 |
|
|
109 |
public AnnotationManager getManager() { |
|
110 |
return this.manager; |
|
111 |
} |
|
112 |
|
|
113 |
public FeatureStore createAnnotationStore(String destinationShapeFile, int textValueAttribute) |
|
114 |
throws AnnotationCreationException { |
|
115 |
try { |
|
116 |
if (destinationShapeFile == null){ |
|
117 |
throw new AnnotationCreationException("File can not be null"); |
|
118 |
} |
|
119 |
|
|
120 |
String destinationShapeFileWithoutExtension = destinationShapeFile.toLowerCase().replaceAll("\\.shp", ""); |
|
121 |
if (destinationShapeFileWithoutExtension.length() == destinationShapeFile.length()-4){ |
|
122 |
destinationShapeFileWithoutExtension = destinationShapeFile.substring(0, destinationShapeFile.length()-4); |
|
123 |
}else{ |
|
124 |
destinationShapeFileWithoutExtension = destinationShapeFile; |
|
125 |
} |
|
126 |
|
|
127 |
NewFeatureStoreParameters newFeatureStoreParameters = (NewFeatureStoreParameters)dataManager.createNewStoreParameters("FilesystemExplorer", "Shape"); |
|
128 |
newFeatureStoreParameters.setDynValue("shpfile", destinationShapeFileWithoutExtension + ".shp"); |
|
129 |
newFeatureStoreParameters.setDynValue("dbffile", destinationShapeFileWithoutExtension + ".dbf"); |
|
130 |
newFeatureStoreParameters.setDynValue("shxfile", destinationShapeFileWithoutExtension + ".shx"); |
|
131 |
newFeatureStoreParameters.setDynValue("crs", sourceStore.getDefaultFeatureType().getDefaultSRS()); |
|
132 |
|
|
133 |
EditableFeatureType editableFeatureType = sourceStore.getDefaultFeatureType().getEditable();//newFeatureStoreParameters.getDefaultFeatureType().getEditable(); |
|
134 |
FeatureAttributeDescriptor[] featureAttributeDescriptors = editableFeatureType.getAttributeDescriptors(); |
|
135 |
for (int i=featureAttributeDescriptors.length-1 ; i>=0 ; i--){ |
|
136 |
editableFeatureType.remove(i); |
|
137 |
} |
|
138 |
initializeFeatureType(editableFeatureType); |
|
139 |
newFeatureStoreParameters.setDefaultFeatureType(editableFeatureType); |
|
140 |
|
|
141 |
dataManager.newStore("FilesystemExplorer", "Shape", newFeatureStoreParameters, true); |
|
142 |
|
|
143 |
//If there is not an annotationPositionCalculator it gets the default |
|
144 |
if (annotationPositionCalculator == null){ |
|
145 |
annotationPositionCalculator = manager.getDefaultAnnotationPositionCalculator(); |
|
146 |
} |
|
147 |
|
|
148 |
FeatureStore destinationStore = (FeatureStore) dataManager.openStore("Shape", newFeatureStoreParameters); |
|
149 |
|
|
150 |
copyFeatureStore(sourceStore, |
|
151 |
destinationStore, |
|
152 |
textValueAttribute); |
|
153 |
|
|
154 |
try { |
|
155 |
copyLegend(destinationStore); |
|
156 |
} catch (IOException e) { |
|
157 |
LOG.error("Error copying the legend"); |
|
158 |
} |
|
159 |
|
|
160 |
if (annotationCreationFinishAction != null){ |
|
161 |
annotationCreationFinishAction.finished(destinationStore); |
|
162 |
} |
|
163 |
|
|
164 |
return destinationStore; |
|
165 |
} catch (InitializeException e) { |
|
166 |
throw new AnnotationCreationException(e); |
|
167 |
} catch (ProviderNotRegisteredException e) { |
|
168 |
throw new AnnotationCreationException(e); |
|
169 |
} catch (ValidateDataParametersException e) { |
|
170 |
throw new AnnotationCreationException(e); |
|
171 |
} catch (DynFieldNotFoundException e) { |
|
172 |
throw new AnnotationCreationException(e); |
|
173 |
} catch (DataException e) { |
|
174 |
throw new AnnotationCreationException(e); |
|
175 |
} catch (AnnotationPositionCalculatorCreationException e) { |
|
176 |
throw new AnnotationCreationException(e); |
|
177 |
} |
|
178 |
} |
|
179 |
|
|
180 |
public FeatureStore createAnnotationStore(String destinationShapeFile, |
|
181 |
String textValueAttributeName) throws AnnotationCreationException { |
|
182 |
try { |
|
183 |
return createAnnotationStore(destinationShapeFile, getIndex(textValueAttributeName)); |
|
184 |
} catch (DataException e) { |
|
185 |
throw new AnnotationCreationException(e); |
|
186 |
} |
|
187 |
} |
|
188 |
|
|
189 |
private void initializeFeatureType(EditableFeatureType editableFeatureType) throws DataException |
|
190 |
{ |
|
191 |
EditableFeatureAttributeDescriptor geometryType = editableFeatureType.add(destinationGeometryAttributeName, DataTypes.GEOMETRY); |
|
192 |
geometryType.setAllowNull(false); |
|
193 |
geometryType.setGeometryType(Geometry.TYPES.POINT).setGeometrySubType(Geometry.SUBTYPES.GEOM2D); |
|
194 |
geometryType.setSRS(sourceStore.getDefaultFeatureType().getDefaultSRS()); |
|
195 |
geometryType.setObjectClass(Geometry.class); |
|
196 |
editableFeatureType.setDefaultGeometryAttributeName(destinationGeometryAttributeName); |
|
197 |
|
|
198 |
editableFeatureType.add(AnnotationManager.TEXTVALUE_ATTRIBUTE_NAME, AnnotationDataTypes.TEXT, 256).setAllowNull(true); |
|
199 |
editableFeatureType.add(AnnotationManager.FONTTYPE_ATTRIBUTE_NAME, AnnotationDataTypes.FONTTYPE, 30).setAllowNull(true); |
|
200 |
editableFeatureType.add(AnnotationManager.FONTSTYLE_ATTRIBUTE_NAME, AnnotationDataTypes.FONTSTYLE, 30).setAllowNull(true); |
|
201 |
editableFeatureType.add(AnnotationManager.FONTCOLOR_ATTRIBUTE_NAME, AnnotationDataTypes.FONTCOLOR, 20).setAllowNull(true); |
|
202 |
editableFeatureType.add(AnnotationManager.FONTROTATION_ATTRIBUTE_NAME, AnnotationDataTypes.FONTROTATION, 5).setAllowNull(true); |
|
203 |
editableFeatureType.add(AnnotationManager.FONTHEGTH_ATTRIBUTE_NAME, AnnotationDataTypes.FONTHEIGHT, 5).setAllowNull(true); |
|
204 |
} |
|
205 |
|
|
206 |
private AttributeInserter createInserter(int attributePosition, Object defaultValue) |
|
207 |
{ |
|
208 |
if (attributePosition > -1){ |
|
209 |
return new StoreAttributeInserter(attributePosition); |
|
210 |
}else{ |
|
211 |
return new DefaultAttributeInserter(defaultValue); |
|
212 |
} |
|
213 |
} |
|
214 |
|
|
215 |
private void copyFeatureStore(FeatureStore sourceStore, |
|
216 |
FeatureStore destinationStore, int textAttribute) |
|
217 |
throws AnnotationCreationException, DataException { |
|
218 |
FeatureSet featureSet = null; |
|
219 |
DisposableIterator iterator = null; |
|
220 |
|
|
221 |
try{ |
|
222 |
//Start the edition |
|
223 |
destinationStore.edit(); |
|
224 |
|
|
225 |
//Copy data |
|
226 |
featureSet = sourceStore.getFeatureSet(); |
|
227 |
iterator = featureSet.fastIterator(); |
|
228 |
|
|
229 |
|
|
230 |
taskStatus.setRangeOfValues(0, featureSet.getSize()); |
|
231 |
|
|
232 |
//Create the attribute inserter's |
|
233 |
AttributeInserter fontTypeAttributeInserter = createInserter(sourceFontTypeAttribute, manager.getDefaultFontType()); |
|
234 |
AttributeInserter fontStyleAttributeInserter = createInserter(sourceFontStyleAttribute, manager.getDefaultFontStyle()); |
|
235 |
AttributeInserter fontColorAttributeInserter = createInserter(sourceFontColorAttribute, manager.getDefaultFontColor()); |
|
236 |
AttributeInserter fontRotationAttributeInserter = createInserter(sourceRotationAttribute, manager.getDefaultFontRotation()); |
|
237 |
AttributeInserter fontHeigthAttributeInserter = createInserter(sourceHeigthAttribute, manager.getDefaultFontHeight()); |
|
238 |
|
|
239 |
Feature sourceFeature; |
|
240 |
long featureCount = 0; |
|
241 |
while (iterator.hasNext()) { |
|
242 |
sourceFeature = (Feature) iterator.next(); |
|
243 |
|
|
244 |
EditableFeature destinationFeature = destinationStore.createNewFeature().getEditable(); |
|
245 |
try { |
|
246 |
destinationFeature.set(destinationGeometryAttributeName, annotationPositionCalculator.getAnnotationPosition(sourceFeature)); |
|
247 |
} catch (AnnotationPositionCalculationException e) { |
|
248 |
LOG.error("Not possible to get the point for the geometry", e); |
|
249 |
} |
|
250 |
String s = (String) sourceFeature.get(textAttribute); |
|
251 |
if (StringUtils.isEmpty(s)) { |
|
252 |
s = this.getManager().getDefaultTextValue(); |
|
253 |
} |
|
254 |
destinationFeature.set(AnnotationManager.TEXTVALUE_ATTRIBUTE_NAME, s); |
|
255 |
destinationFeature.set(AnnotationManager.FONTTYPE_ATTRIBUTE_NAME, fontTypeAttributeInserter.getValue(sourceFeature)); |
|
256 |
destinationFeature.set(AnnotationManager.FONTSTYLE_ATTRIBUTE_NAME, fontStyleAttributeInserter.getValue(sourceFeature)); |
|
257 |
destinationFeature.set(AnnotationManager.FONTCOLOR_ATTRIBUTE_NAME, fontColorAttributeInserter.getValue(sourceFeature)); |
|
258 |
destinationFeature.set(AnnotationManager.FONTROTATION_ATTRIBUTE_NAME, fontRotationAttributeInserter.getValue(sourceFeature)); |
|
259 |
destinationFeature.set(AnnotationManager.FONTHEGTH_ATTRIBUTE_NAME, fontHeigthAttributeInserter.getValue(sourceFeature)); |
|
260 |
|
|
261 |
destinationStore.insert(destinationFeature); |
|
262 |
featureCount++; |
|
263 |
this.taskStatus.setCurValue(featureCount); |
|
264 |
|
|
265 |
if (this.taskStatus.isCancellationRequested()) { |
|
266 |
destinationStore.cancelEditing(); |
|
267 |
this.taskStatus.cancel(); |
|
268 |
return; |
|
269 |
} |
|
270 |
} |
|
271 |
}finally{ |
|
272 |
|
|
273 |
//Finish the edition |
|
274 |
if(destinationStore.isEditing()){ |
|
275 |
destinationStore.finishEditing(); |
|
276 |
} |
|
277 |
|
|
278 |
//Dispose resources |
|
279 |
if(iterator != null){ |
|
280 |
iterator.dispose(); |
|
281 |
} |
|
282 |
if(featureSet != null){ |
|
283 |
featureSet.dispose(); |
|
284 |
} |
|
285 |
|
|
286 |
if(this.taskStatus.isRunning()){ |
|
287 |
this.taskStatus.terminate(); |
|
288 |
} |
|
289 |
//this.taskStatus.remove(); |
|
290 |
} |
|
291 |
} |
|
292 |
|
|
293 |
private void copyLegend(FeatureStore destinationStore) throws ValidateDataParametersException, DataException, IOException { |
|
294 |
FilesystemServerExplorer filesystemServerExplorer = (FilesystemServerExplorer)destinationStore.getExplorer(); |
|
295 |
File target = filesystemServerExplorer.getResourcePath(destinationStore, "gvslab"); |
|
296 |
|
|
297 |
//Copy the template |
|
298 |
InputStream in = getClass().getClassLoader().getResourceAsStream(TEMPLATE_NAME); |
|
299 |
OutputStream out = null; |
|
300 |
|
|
301 |
out = new FileOutputStream(target); |
|
302 |
|
|
303 |
byte[] buf = new byte[1024]; |
|
304 |
int len; |
|
305 |
while ((len = in.read(buf)) > 0) { |
|
306 |
out.write(buf, 0, len); |
|
307 |
} |
|
308 |
in.close(); |
|
309 |
out.close(); |
|
310 |
} |
|
311 |
|
|
312 |
private void checkAttribute(int index, int[] type) throws DataException{ |
|
313 |
if (index >= sourceStore.getDefaultFeatureType().size()){ |
|
314 |
throw new IllegalArgumentException("Attribute not found"); |
|
315 |
} |
|
316 |
int datatype = sourceStore.getDefaultFeatureType().getAttributeDescriptor(index).getDataType().getType(); |
|
317 |
|
|
318 |
boolean validType = false; |
|
319 |
if(type != null) { |
|
320 |
for (int i = 0; i < type.length; i++) { |
|
321 |
if(datatype == type[i]) { |
|
322 |
validType = true; |
|
323 |
} |
|
324 |
} |
|
325 |
} |
|
326 |
|
|
327 |
if (!validType) { |
|
328 |
throw new IllegalArgumentException("The Attribute has not have the fine type"); |
|
329 |
} |
|
330 |
} |
|
331 |
|
|
332 |
|
|
333 |
public void setFontTypeAttribute(int index) throws DataException { |
|
334 |
checkAttribute(index, new int[]{AnnotationDataTypes.FONTTYPE}); |
|
335 |
this.sourceFontTypeAttribute = index; |
|
336 |
} |
|
337 |
|
|
338 |
public void setFontStyleAttribute(int index) throws DataException { |
|
339 |
checkAttribute(index, new int[]{AnnotationDataTypes.FONTSTYLE}); |
|
340 |
this.sourceFontStyleAttribute = index; |
|
341 |
} |
|
342 |
|
|
343 |
public void setFontColorAttribute(int index) throws DataException { |
|
344 |
checkAttribute(index, new int[]{AnnotationDataTypes.FONTCOLOR}); |
|
345 |
this.sourceFontColorAttribute = index; |
|
346 |
} |
|
347 |
|
|
348 |
public void setFontHeigthAttribute(int index) throws DataException { |
|
349 |
checkAttribute(index, new int[]{AnnotationDataTypes.FONTHEIGHT, DataTypes.INT, DataTypes.LONG, DataTypes.FLOAT}); |
|
350 |
this.sourceHeigthAttribute = index; |
|
351 |
} |
|
352 |
|
|
353 |
public void setFontRotationAttribute(int index) throws DataException { |
|
354 |
checkAttribute(index, new int[]{AnnotationDataTypes.FONTROTATION}); |
|
355 |
this.sourceRotationAttribute = index; |
|
356 |
} |
|
357 |
|
|
358 |
public void setAnnotationPositionCalculator( |
|
359 |
AnnotationPositionCalculator annotationPositionCalculator) { |
|
360 |
this.annotationPositionCalculator = annotationPositionCalculator; |
|
361 |
} |
|
362 |
|
|
363 |
public int getIndex(String attributeName) throws DataException{ |
|
364 |
FeatureAttributeDescriptor featureAttributeDescriptor = sourceStore.getDefaultFeatureType().getAttributeDescriptor(attributeName); |
|
365 |
if (featureAttributeDescriptor != null){ |
|
366 |
return featureAttributeDescriptor.getIndex(); |
|
367 |
} |
|
368 |
return -1; |
|
369 |
} |
|
370 |
|
|
371 |
public void setFontColorAttribute(String attributeName) throws DataException { |
|
372 |
setFontColorAttribute(getIndex(attributeName)); |
|
373 |
} |
|
374 |
|
|
375 |
public void setFontHeigthAttribute(String attributeName) throws DataException { |
|
376 |
setFontHeigthAttribute(getIndex(attributeName)); |
|
377 |
} |
|
378 |
|
|
379 |
public void setFontRotationAttribute(String attributeName) throws DataException { |
|
380 |
setFontRotationAttribute(getIndex(attributeName)); |
|
381 |
} |
|
382 |
|
|
383 |
public void setFontStyleAttribute(String attributeName) throws DataException { |
|
384 |
setFontStyleAttribute(getIndex(attributeName)); |
|
385 |
} |
|
386 |
|
|
387 |
public void setFontTypeAttribute(String attributeName) throws DataException { |
|
388 |
setFontTypeAttribute(getIndex(attributeName)); |
|
389 |
} |
|
390 |
|
|
391 |
|
|
392 |
public FeatureStore getFeatureStore() { |
|
393 |
return sourceStore; |
|
394 |
} |
|
395 |
|
|
396 |
private interface AttributeInserter{ |
|
397 |
public Object getValue(Feature feature); |
|
398 |
} |
|
399 |
|
|
400 |
|
|
401 |
private class StoreAttributeInserter implements AttributeInserter{ |
|
402 |
private int attributePosition = -1; |
|
403 |
|
|
404 |
public StoreAttributeInserter(int attributePosition) { |
|
405 |
super(); |
|
406 |
this.attributePosition = attributePosition; |
|
407 |
} |
|
408 |
|
|
409 |
public Object getValue(Feature feature){ |
|
410 |
return feature.get(attributePosition); |
|
411 |
} |
|
412 |
} |
|
413 |
|
|
414 |
private class DefaultAttributeInserter implements AttributeInserter{ |
|
415 |
private Object defaultValue = null; |
|
416 |
|
|
417 |
public DefaultAttributeInserter(Object defaultValue) { |
|
418 |
super(); |
|
419 |
this.defaultValue = defaultValue; |
|
420 |
} |
|
421 |
|
|
422 |
public Object getValue(Feature feature){ |
|
423 |
return defaultValue; |
|
424 |
} |
|
425 |
} |
|
426 |
|
|
427 |
public AnnotationCreationFinishAction getAnnotationCreationFinishAction() { |
|
428 |
return annotationCreationFinishAction; |
|
429 |
} |
|
430 |
|
|
431 |
|
|
432 |
public void setAnnotationCreationFinishAction( |
|
433 |
AnnotationCreationFinishAction annotationCreationFinishAction) { |
|
434 |
this.annotationCreationFinishAction = annotationCreationFinishAction; |
|
435 |
} |
|
436 |
} |
|
0 | 437 |
tags/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/AnnotationDefaultImplLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.annotation.impl; |
|
25 |
|
|
26 |
import java.awt.Color; |
|
27 |
|
|
28 |
import org.gvsig.annotation.AnnotationLibrary; |
|
29 |
import org.gvsig.annotation.AnnotationLocator; |
|
30 |
import org.gvsig.annotation.AnnotationManager; |
|
31 |
import org.gvsig.annotation.impl.calculator.CentroidPositionCalculatior; |
|
32 |
import org.gvsig.tools.library.AbstractLibrary; |
|
33 |
import org.gvsig.tools.library.LibraryException; |
|
34 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
35 |
|
|
36 |
/** |
|
37 |
* Library for default implementation initialization and configuration. |
|
38 |
* |
|
39 |
* @author gvSIG team |
|
40 |
* @version $Id$ |
|
41 |
*/ |
|
42 |
public class AnnotationDefaultImplLibrary extends AbstractLibrary { |
|
43 |
|
|
44 |
@Override |
|
45 |
public void doRegistration() { |
|
46 |
registerAsImplementationOf(AnnotationLibrary.class); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
protected void doInitialize() throws LibraryException { |
|
51 |
AnnotationLocator.registerManager(DefaultAnnotationManager.class); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
protected void doPostInitialize() throws LibraryException { |
|
56 |
AnnotationManager annotationManager = AnnotationLocator.getManager(); |
|
57 |
|
|
58 |
if (annotationManager == null) { |
|
59 |
throw new ReferenceNotRegisteredException( |
|
60 |
AnnotationLocator.MANAGER_NAME, AnnotationLocator |
|
61 |
.getInstance()); |
|
62 |
} |
|
63 |
|
|
64 |
annotationManager.registerDefaultAnnotationPositionCalculator(CentroidPositionCalculatior.class); |
|
65 |
|
|
66 |
//Adding font types |
|
67 |
annotationManager.addFontType("Arial"); |
|
68 |
annotationManager.addFontType("Dialog"); |
|
69 |
annotationManager.addFontType("DialogInput"); |
|
70 |
annotationManager.addFontType("Serif"); |
|
71 |
annotationManager.addFontType("SansSerif"); |
|
72 |
annotationManager.addFontType("Monospaced"); |
|
73 |
annotationManager.addFontType("Courier"); |
|
74 |
annotationManager.addFontType("TimesRoman"); |
|
75 |
annotationManager.addFontType("Helvetica"); |
|
76 |
|
|
77 |
//Adding font styles |
|
78 |
annotationManager.addFontStyle("Plain"); |
|
79 |
annotationManager.addFontStyle("Italic"); |
|
80 |
annotationManager.addFontStyle("Bold"); |
|
81 |
|
|
82 |
//Setting the default values if there are not registered |
|
83 |
if (annotationManager.getDefaultTextValue() == null){ |
|
84 |
annotationManager.setDefaultTextValue("Text"); |
|
85 |
} |
|
86 |
|
|
87 |
if (annotationManager.getDefaultFontColor() == -1){ |
|
88 |
annotationManager.setDefaultFontColor(Color.BLACK); |
|
89 |
} |
|
90 |
|
|
91 |
if (annotationManager.getDefaultFontHeight() == -1){ |
|
92 |
annotationManager.setDefaultFontHeight(10); |
|
93 |
} |
|
94 |
|
|
95 |
if (annotationManager.getDefaultFontRotation() == -1){ |
|
96 |
annotationManager.setDefaultFontRotation(0); |
|
97 |
} |
|
98 |
|
|
99 |
if (annotationManager.getDefaultFontStyle() == null){ |
|
100 |
annotationManager.setDefaultFontStyle("Plain"); |
|
101 |
} |
|
102 |
|
|
103 |
if (annotationManager.getDefaultFontType() == null){ |
|
104 |
annotationManager.setDefaultFontType("Arial"); |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
} |
|
0 | 109 |
tags/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/calculator/CentroidPositionCalculatior.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
25 |
* |
|
26 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
27 |
* of the Valencian Government (CIT) |
|
28 |
* |
|
29 |
* This program is free software; you can redistribute it and/or |
|
30 |
* modify it under the terms of the GNU General Public License |
|
31 |
* as published by the Free Software Foundation; either version 2 |
|
32 |
* of the License, or (at your option) any later version. |
|
33 |
* |
|
34 |
* This program is distributed in the hope that it will be useful, |
|
35 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
36 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
37 |
* GNU General Public License for more details. |
|
38 |
* |
|
39 |
* You should have received a copy of the GNU General Public License |
|
40 |
* along with this program; if not, write to the Free Software |
|
41 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
42 |
* MA 02110-1301, USA. |
|
43 |
* |
|
44 |
*/ |
|
45 |
|
|
46 |
/* |
|
47 |
* AUTHORS (In addition to CIT): |
|
48 |
* 2010 {Prodevelop} {Task} |
|
49 |
*/ |
|
50 |
|
|
51 |
package org.gvsig.annotation.impl.calculator; |
|
52 |
|
|
53 |
import org.gvsig.annotation.calculator.AnnotationPositionCalculationException; |
|
54 |
import org.gvsig.annotation.calculator.AnnotationPositionCalculator; |
|
55 |
import org.gvsig.fmap.dal.feature.Feature; |
|
56 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
57 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
58 |
import org.gvsig.fmap.geom.primitive.Point; |
|
59 |
import org.gvsig.i18n.Messages; |
|
60 |
|
|
61 |
/** |
|
62 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
|
63 |
*/ |
|
64 |
public class CentroidPositionCalculatior implements AnnotationPositionCalculator{ |
|
65 |
|
|
66 |
public Point getAnnotationPosition(Feature feature) throws AnnotationPositionCalculationException { |
|
67 |
try { |
|
68 |
return feature.getDefaultGeometry().centroid(); |
|
69 |
} catch (GeometryOperationNotSupportedException e) { |
|
70 |
throw new AnnotationPositionCalculationException(e); |
|
71 |
} catch (GeometryOperationException e) { |
|
72 |
throw new AnnotationPositionCalculationException(e); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
public String getName() { |
|
77 |
return Messages.getText("centroid"); |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
0 | 81 |
tags/org.gvsig.desktop-2.0.439/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/DefaultAnnotationManager.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.annotation.impl; |
|
25 |
|
|
26 |
import java.awt.Color; |
|
27 |
import java.util.ArrayList; |
|
28 |
import java.util.Collections; |
|
29 |
import java.util.List; |
|
30 |
|
|
31 |
import org.gvsig.annotation.AnnotationCreationService; |
|
32 |
import org.gvsig.annotation.AnnotationCreationServiceException; |
|
33 |
import org.gvsig.annotation.AnnotationManager; |
|
34 |
import org.gvsig.annotation.calculator.AnnotationPositionCalculator; |
|
35 |
import org.gvsig.annotation.calculator.AnnotationPositionCalculatorCreationException; |
|
36 |
import org.gvsig.fmap.dal.exception.DataException; |
|
37 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
38 |
import org.gvsig.tools.ToolsLocator; |
|
39 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
40 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
41 |
import org.gvsig.tools.service.ServiceException; |
|
42 |
|
|
43 |
/** |
|
44 |
* Default {@link AnnotationManager} implementation. |
|
45 |
* |
|
46 |
* @author gvSIG Team |
|
47 |
* @version $Id$ |
|
48 |
*/ |
|
49 |
public class DefaultAnnotationManager implements AnnotationManager { |
|
50 |
private static final String ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT = "AnnotationPositionCalculatorExtensionPoint"; |
|
51 |
private ExtensionPointManager extensionPointManager = ToolsLocator.getExtensionPointManager(); |
|
52 |
private static final String DEFAULT_ANNOTATION_POSITION_CALCULATOR = "DefaultAnnotationPositionCalculator"; |
|
53 |
|
|
54 |
private String defaultTextValue = null; |
|
55 |
private int defaultFontColor = -1; |
|
56 |
private double defaultFontHeight = -1; |
|
57 |
private double defaultFontRotation = -1; |
|
58 |
private String defaultFontStyle = null; |
|
59 |
private String defaultFontType = null; |
|
60 |
|
|
61 |
private List<String> fontTypes = Collections.synchronizedList(new ArrayList<String>()); |
|
62 |
private List<String> fontStyles = Collections.synchronizedList(new ArrayList<String>()); |
|
63 |
|
|
64 |
|
|
65 |
public AnnotationCreationService getAnnotationCreationService(FeatureStore featureStore) |
|
66 |
throws ServiceException { |
|
67 |
AnnotationCreationService fc; |
|
68 |
try { |
|
69 |
fc = new DefaultAnnotationCreationService(featureStore, this); |
|
70 |
} catch (DataException e) { |
|
71 |
throw new AnnotationCreationServiceException("Impossible to create the annotation service", e); |
|
72 |
} |
|
73 |
return fc; |
|
74 |
} |
|
75 |
|
|
76 |
public AnnotationPositionCalculator getAnnotationPositionCalculator( |
|
77 |
String name) throws AnnotationPositionCalculatorCreationException { |
|
78 |
if (extensionPointManager.get(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT).has(name)){ |
|
79 |
try { |
|
80 |
return (AnnotationPositionCalculator)extensionPointManager.get(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT).create(name); |
|
81 |
} catch (InstantiationException e) { |
|
82 |
throw new AnnotationPositionCalculatorCreationException(name, e); |
|
83 |
} catch (IllegalAccessException e) { |
|
84 |
throw new AnnotationPositionCalculatorCreationException(name, e); |
|
85 |
} |
|
86 |
}else{ |
|
87 |
throw new IllegalArgumentException("There is not an annotation position calculator registered with this name"); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
public List<String> getAnnotationPositionCalculatorList() { |
|
92 |
return extensionPointManager.get(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT).getNames(); |
|
93 |
} |
|
94 |
|
|
95 |
public AnnotationPositionCalculator getDefaultAnnotationPositionCalculator() throws AnnotationPositionCalculatorCreationException { |
|
96 |
return getAnnotationPositionCalculator(DEFAULT_ANNOTATION_POSITION_CALCULATOR); |
|
97 |
} |
|
98 |
|
|
99 |
public void registerAnnotationPositionCalculator(String name, |
|
100 |
Class annotationPositionCalculatorClass) { |
|
101 |
if (!AnnotationPositionCalculator.class.isAssignableFrom(annotationPositionCalculatorClass)) { |
|
102 |
throw new IllegalArgumentException(annotationPositionCalculatorClass.getName() |
|
103 |
+ " must implement the AnnotationPositionCalculator interface"); |
|
104 |
} |
|
105 |
|
|
106 |
ExtensionPoint extensionPoint = extensionPointManager.add(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT, ""); |
|
107 |
extensionPoint.append(name, name, annotationPositionCalculatorClass); |
|
108 |
} |
|
109 |
|
|
110 |
public void registerDefaultAnnotationPositionCalculator(Class annotationPositionCalculatorClass) { |
|
111 |
registerAnnotationPositionCalculator(DEFAULT_ANNOTATION_POSITION_CALCULATOR, |
|
112 |
annotationPositionCalculatorClass); |
|
113 |
} |
|
114 |
|
|
115 |
public void addFontStyle(String fontStyle) { |
|
116 |
fontStyles.add(fontStyle); |
|
117 |
} |
|
118 |
|
|
119 |
public void addFontType(String fontType) { |
|
120 |
fontTypes.add(fontType); |
|
121 |
} |
|
122 |
|
|
123 |
public int getDefaultFontColor() { |
|
124 |
return defaultFontColor; |
|
125 |
} |
|
126 |
|
|
127 |
public double getDefaultFontHeight() { |
|
128 |
return defaultFontHeight; |
|
129 |
} |
|
130 |
|
|
131 |
public double getDefaultFontRotation() { |
|
132 |
return defaultFontRotation; |
|
133 |
} |
|
134 |
|
|
135 |
public String getDefaultFontStyle() { |
|
136 |
return defaultFontStyle; |
|
137 |
} |
|
138 |
|
|
139 |
public String getDefaultFontType() { |
|
140 |
return defaultFontType; |
|
141 |
} |
|
142 |
|
|
143 |
public String getDefaultTextValue() { |
|
144 |
return defaultTextValue; |
|
145 |
} |
|
146 |
|
|
147 |
public List<String> getFontStyles() { |
|
148 |
return fontStyles; |
|
149 |
} |
|
150 |
|
|
151 |
public List<String> getFontTypes() { |
|
152 |
return fontTypes; |
|
153 |
} |
|
154 |
|
|
155 |
public void setDefaultFontColor(int fontColor) { |
|
156 |
this.defaultFontColor = fontColor; |
|
157 |
} |
|
158 |
|
|
159 |
public void setDefaultFontColor(Color fontColor) { |
|
160 |
this.defaultFontColor = fontColor.getRGB(); |
|
161 |
} |
|
162 |
|
|
163 |
public void setDefaultFontHeight(double fontHeight) { |
|
164 |
this.defaultFontHeight = fontHeight; |
|
165 |
} |
|
166 |
|
|
167 |
public void setDefaultFontRotation(double fontRotation) { |
|
168 |
this.defaultFontRotation = fontRotation; |
|
169 |
} |
|
170 |
|
|
171 |
public void setDefaultFontStyle(String fontStyle) { |
|
172 |
this.defaultFontStyle = fontStyle; |
|
173 |
} |
|
174 |
|
|
175 |
public void setDefaultFontType(String fontType) { |
|
176 |
this.defaultFontType = fontType; |
|
177 |
} |
|
178 |
|
|
179 |
public void setDefaultTextValue(String textValue) { |
|
180 |
this.defaultTextValue = textValue; |
|
181 |
} |
|
182 |
|
|
183 |
|
|
184 |
} |
|
0 | 185 |
Also available in: Unified diff