Revision 46123
tags/org.gvsig.desktop-2.0.345/license.txt | ||
---|---|---|
1 |
gvSIG. Desktop Geographic Information System. |
|
2 |
|
|
3 |
Copyright (C) 2007-2020 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.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<artifactId>org.gvsig.temporarystorage</artifactId> |
|
4 |
<packaging>pom</packaging> |
|
5 |
<description /> |
|
6 |
<parent> |
|
7 |
<groupId>org.gvsig</groupId> |
|
8 |
<artifactId>org.gvsig.desktop.library</artifactId> |
|
9 |
<version>2.0.345</version> |
|
10 |
</parent> |
|
11 |
<modules> |
|
12 |
<module>org.gvsig.temporarystorage.lib</module> |
|
13 |
</modules> |
|
14 |
</project> |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/org.gvsig.temporarystorage.lib.api/src/main/java/org/gvsig/temporarystorage/TemporaryStorageManager.java | ||
---|---|---|
1 |
package org.gvsig.temporarystorage; |
|
2 |
|
|
3 |
import java.util.Iterator; |
|
4 |
|
|
5 |
public interface TemporaryStorageManager extends Iterable<TemporaryStorageGroup> { |
|
6 |
|
|
7 |
/** |
|
8 |
* Si existe lo devuelbe, si no falla. |
|
9 |
* @param groupName |
|
10 |
* @return |
|
11 |
*/ |
|
12 |
public TemporaryStorageGroup get(String groupName); |
|
13 |
|
|
14 |
public boolean contains(String groupName); |
|
15 |
|
|
16 |
/** |
|
17 |
* Si no existe crea el grupo y lo devuelbe, y si ya existe lo devuelbe sin |
|
18 |
* crear nada. |
|
19 |
* @param groupName |
|
20 |
* @return |
|
21 |
*/ |
|
22 |
public TemporaryStorageGroup create(String groupName); |
|
23 |
|
|
24 |
public TemporaryStorageGroup create(String groupName, Class classOfElements); |
|
25 |
|
|
26 |
@Override |
|
27 |
public Iterator<TemporaryStorageGroup> iterator(); |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @param groupName |
|
32 |
* @return |
|
33 |
*/ |
|
34 |
public boolean remove(String groupName); |
|
35 |
|
|
36 |
} |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/org.gvsig.temporarystorage.lib.api/src/main/java/org/gvsig/temporarystorage/TemporaryStorageGroup.java | ||
---|---|---|
1 |
package org.gvsig.temporarystorage; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import org.apache.commons.lang3.tuple.Pair; |
|
5 |
|
|
6 |
public interface TemporaryStorageGroup { |
|
7 |
|
|
8 |
public String getName(); |
|
9 |
|
|
10 |
public Class getClassOfElements(); |
|
11 |
|
|
12 |
public boolean contains(String name); |
|
13 |
|
|
14 |
public void put(String name, Object obj); |
|
15 |
|
|
16 |
/** |
|
17 |
* return the object or null if not exists |
|
18 |
* @param name |
|
19 |
* @return |
|
20 |
*/ |
|
21 |
public Object get(String name); |
|
22 |
|
|
23 |
public boolean remove(String name); |
|
24 |
|
|
25 |
public List<Pair<String, Object>> asList(); |
|
26 |
} |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/org.gvsig.temporarystorage.lib.api/src/main/java/org/gvsig/temporarystorage/TemporaryStorageLocator.java | ||
---|---|---|
1 |
package org.gvsig.temporarystorage; |
|
2 |
|
|
3 |
import org.gvsig.tools.locator.AbstractLocator; |
|
4 |
import org.gvsig.tools.locator.LocatorException; |
|
5 |
|
|
6 |
|
|
7 |
public class TemporaryStorageLocator extends AbstractLocator { |
|
8 |
|
|
9 |
private static final String LOCATOR_NAME = "TemporaryStorageLocator"; |
|
10 |
|
|
11 |
public static final String MANAGER_NAME = "TemporaryStorageManager"; |
|
12 |
|
|
13 |
private static final String MANAGER_DESCRIPTION = "TemporaryStorage of gvSIG"; |
|
14 |
|
|
15 |
/** |
|
16 |
* Unique instance. |
|
17 |
*/ |
|
18 |
private static final TemporaryStorageLocator instance = new TemporaryStorageLocator(); |
|
19 |
|
|
20 |
/** |
|
21 |
* Return the singleton instance. |
|
22 |
* |
|
23 |
* @return the singleton instance |
|
24 |
*/ |
|
25 |
public static TemporaryStorageLocator getInstance() { |
|
26 |
return instance; |
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* Returns the Locator name. |
|
31 |
* |
|
32 |
* @return String containing the locator name. |
|
33 |
*/ |
|
34 |
@Override |
|
35 |
public String getLocatorName() { |
|
36 |
return LOCATOR_NAME; |
|
37 |
} |
|
38 |
|
|
39 |
public static TemporaryStorageManager getTemporaryStorageManager() throws LocatorException { |
|
40 |
return (TemporaryStorageManager) getInstance().get(MANAGER_NAME); |
|
41 |
} |
|
42 |
|
|
43 |
public static void registerManager(Class clazz) { |
|
44 |
getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
|
45 |
} |
|
46 |
|
|
47 |
public static void registerDefaultManager(Class clazz) { |
|
48 |
getInstance().registerDefault(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
|
49 |
} |
|
50 |
|
|
51 |
} |
|
0 | 52 |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/org.gvsig.temporarystorage.lib.api/src/main/java/org/gvsig/temporarystorage/TemporaryStorageLibrary.java | ||
---|---|---|
1 |
package org.gvsig.temporarystorage; |
|
2 |
|
|
3 |
import org.gvsig.tools.ToolsLibrary; |
|
4 |
import org.gvsig.tools.library.AbstractLibrary; |
|
5 |
import org.gvsig.tools.library.LibraryException; |
|
6 |
|
|
7 |
public class TemporaryStorageLibrary extends AbstractLibrary { |
|
8 |
|
|
9 |
@Override |
|
10 |
public void doRegistration() { |
|
11 |
registerAsAPI(TemporaryStorageLibrary.class); |
|
12 |
require(ToolsLibrary.class); |
|
13 |
} |
|
14 |
|
|
15 |
@Override |
|
16 |
protected void doInitialize() throws LibraryException { |
|
17 |
} |
|
18 |
|
|
19 |
@Override |
|
20 |
protected void doPostInitialize() throws LibraryException { |
|
21 |
|
|
22 |
} |
|
23 |
} |
|
24 |
|
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/org.gvsig.temporarystorage.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.temporarystorage.TemporaryStorageLibrary |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/org.gvsig.temporarystorage.lib.api/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<groupId>org.gvsig</groupId> |
|
4 |
<artifactId>org.gvsig.temporarystorage.lib.api</artifactId> |
|
5 |
<name>org.gvsig.temporarystorage.lib.api</name> |
|
6 |
<parent> |
|
7 |
<groupId>org.gvsig</groupId> |
|
8 |
<artifactId>org.gvsig.temporarystorage.lib</artifactId> |
|
9 |
<version>2.0.345</version> |
|
10 |
</parent> |
|
11 |
|
|
12 |
<build> |
|
13 |
<plugins> |
|
14 |
<plugin> |
|
15 |
<groupId>org.apache.maven.plugins</groupId> |
|
16 |
<artifactId>maven-jar-plugin</artifactId> |
|
17 |
<configuration> |
|
18 |
</configuration> |
|
19 |
<executions> |
|
20 |
<!-- Generates a jar file only with the test classes --> |
|
21 |
<execution> |
|
22 |
<goals> |
|
23 |
<goal>test-jar</goal> |
|
24 |
</goals> |
|
25 |
</execution> |
|
26 |
</executions> |
|
27 |
</plugin> |
|
28 |
</plugins> |
|
29 |
</build> |
|
30 |
|
|
31 |
<dependencies> |
|
32 |
<dependency> |
|
33 |
<groupId>org.gvsig</groupId> |
|
34 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
35 |
<scope>compile</scope> |
|
36 |
</dependency> |
|
37 |
|
|
38 |
</dependencies> |
|
39 |
</project> |
|
0 | 40 |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.temporarystorage</artifactId> |
|
6 |
<version>2.0.345</version> |
|
7 |
</parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.temporarystorage.lib</artifactId> |
|
10 |
<packaging>pom</packaging> |
|
11 |
<modules> |
|
12 |
<module>org.gvsig.temporarystorage.lib.api</module> |
|
13 |
<module>org.gvsig.temporarystorage.lib.impl</module> |
|
14 |
</modules> |
|
15 |
</project> |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/org.gvsig.temporarystorage.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.temporarystorage.impl.TemporaryStorageImplLibrary |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/org.gvsig.temporarystorage.lib.impl/src/main/java/org/gvsig/temporarystorage/impl/DefaultTemporaryStorageManager.java | ||
---|---|---|
1 |
package org.gvsig.temporarystorage.impl; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.Map; |
|
6 |
import org.gvsig.temporarystorage.TemporaryStorageGroup; |
|
7 |
import org.gvsig.temporarystorage.TemporaryStorageManager; |
|
8 |
|
|
9 |
public class DefaultTemporaryStorageManager implements TemporaryStorageManager { |
|
10 |
|
|
11 |
private final Map<String,TemporaryStorageGroup> groups; |
|
12 |
|
|
13 |
public DefaultTemporaryStorageManager() { |
|
14 |
this.groups = new HashMap<>(); |
|
15 |
} |
|
16 |
|
|
17 |
@Override |
|
18 |
public TemporaryStorageGroup get(String groupName) { |
|
19 |
return this.groups.get(groupName); |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
public boolean contains(String groupName) { |
|
24 |
return this.groups.containsKey(groupName); |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
public TemporaryStorageGroup create(String groupName) { |
|
29 |
return this.create(groupName, Object.class); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public TemporaryStorageGroup create(String groupName, Class classOfElements) { |
|
34 |
TemporaryStorageGroup group = this.groups.get(groupName); |
|
35 |
if( group!=null ) { |
|
36 |
return group; |
|
37 |
} |
|
38 |
group = new DefaultTemporaryStorageGroup(groupName, classOfElements); |
|
39 |
this.groups.put(groupName, group); |
|
40 |
return group; |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public Iterator<TemporaryStorageGroup> iterator() { |
|
45 |
return this.groups.values().iterator(); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public boolean remove(String groupName) { |
|
50 |
return this.groups.remove(groupName)!=null; |
|
51 |
} |
|
52 |
|
|
53 |
} |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/org.gvsig.temporarystorage.lib.impl/src/main/java/org/gvsig/temporarystorage/impl/DefaultTemporaryStorageGroup.java | ||
---|---|---|
1 |
package org.gvsig.temporarystorage.impl; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Collections; |
|
5 |
import java.util.Comparator; |
|
6 |
import java.util.List; |
|
7 |
import org.apache.commons.lang3.StringUtils; |
|
8 |
import org.apache.commons.lang3.tuple.MutablePair; |
|
9 |
import org.apache.commons.lang3.tuple.Pair; |
|
10 |
import org.gvsig.temporarystorage.TemporaryStorageGroup; |
|
11 |
|
|
12 |
public class DefaultTemporaryStorageGroup implements TemporaryStorageGroup { |
|
13 |
|
|
14 |
private final String name; |
|
15 |
private final Class classOfElements; |
|
16 |
private final List<Pair<String, Object>> elements; |
|
17 |
|
|
18 |
public DefaultTemporaryStorageGroup(String name, Class classOfElements) { |
|
19 |
this.name = name; |
|
20 |
this.classOfElements = classOfElements; |
|
21 |
this.elements = new ArrayList<>(); |
|
22 |
} |
|
23 |
|
|
24 |
@Override |
|
25 |
public String getName() { |
|
26 |
return this.name; |
|
27 |
} |
|
28 |
|
|
29 |
@Override |
|
30 |
public Class getClassOfElements() { |
|
31 |
return this.classOfElements; |
|
32 |
} |
|
33 |
|
|
34 |
private MutablePair<String, Object> getElement(String name) { |
|
35 |
if( StringUtils.isEmpty(name) ) { |
|
36 |
return null; |
|
37 |
} |
|
38 |
for (Pair<String, Object> element : this.elements) { |
|
39 |
if( name.equalsIgnoreCase(element.getKey()) ) { |
|
40 |
return (MutablePair<String, Object>) element; |
|
41 |
} |
|
42 |
} |
|
43 |
return null; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public boolean contains(String name) { |
|
48 |
Pair<String, Object> element = this.getElement(name); |
|
49 |
return element!=null; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public void put(String name, Object obj) { |
|
54 |
if( !this.classOfElements.isInstance(obj) ) { |
|
55 |
throw new IllegalArgumentException("The object can't be of class "+this.classOfElements.getName()+"."); |
|
56 |
} |
|
57 |
MutablePair<String, Object> element = this.getElement(name); |
|
58 |
if( element == null ) { |
|
59 |
element = new MutablePair<>(name,obj); |
|
60 |
this.elements.add(element); |
|
61 |
this.elements.sort(new Comparator<Pair<String, Object>>() { |
|
62 |
@Override |
|
63 |
public int compare(Pair<String, Object> o1, Pair<String, Object> o2) { |
|
64 |
return o1.compareTo(o2); |
|
65 |
} |
|
66 |
}); |
|
67 |
} else { |
|
68 |
element.setValue(obj); |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public Object get(String name) { |
|
74 |
Pair<String, Object> element = this.getElement(name); |
|
75 |
if( element == null ) { |
|
76 |
return null; |
|
77 |
} |
|
78 |
return element.getValue(); |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public boolean remove(String name) { |
|
83 |
Pair<String, Object> element = this.getElement(name); |
|
84 |
if( element == null ) { |
|
85 |
return false; |
|
86 |
} |
|
87 |
return this.elements.remove(element); |
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public List<Pair<String, Object>> asList() { |
|
92 |
return Collections.unmodifiableList(elements); |
|
93 |
} |
|
94 |
|
|
95 |
} |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/org.gvsig.temporarystorage.lib.impl/src/main/java/org/gvsig/temporarystorage/impl/TemporaryStorageImplLibrary.java | ||
---|---|---|
1 |
package org.gvsig.temporarystorage.impl; |
|
2 |
|
|
3 |
|
|
4 |
import org.gvsig.temporarystorage.TemporaryStorageLibrary; |
|
5 |
import org.gvsig.temporarystorage.TemporaryStorageLocator; |
|
6 |
import org.gvsig.tools.library.AbstractLibrary; |
|
7 |
import org.gvsig.tools.library.LibraryException; |
|
8 |
|
|
9 |
public class TemporaryStorageImplLibrary extends AbstractLibrary { |
|
10 |
|
|
11 |
@Override |
|
12 |
public void doRegistration() { |
|
13 |
registerAsImplementationOf(TemporaryStorageLibrary.class); |
|
14 |
} |
|
15 |
|
|
16 |
@Override |
|
17 |
protected void doInitialize() throws LibraryException { |
|
18 |
TemporaryStorageLocator.registerManager(DefaultTemporaryStorageManager.class); |
|
19 |
} |
|
20 |
|
|
21 |
@Override |
|
22 |
protected void doPostInitialize() throws LibraryException { |
|
23 |
|
|
24 |
} |
|
25 |
} |
|
26 |
|
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.temporarystorage/org.gvsig.temporarystorage.lib/org.gvsig.temporarystorage.lib.impl/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<artifactId>org.gvsig.temporarystorage.lib.impl</artifactId> |
|
4 |
<name>org.gvsig.temporarystorage.lib.impl</name> |
|
5 |
<parent> |
|
6 |
<groupId>org.gvsig</groupId> |
|
7 |
<artifactId>org.gvsig.temporarystorage.lib</artifactId> |
|
8 |
<version>2.0.345</version> |
|
9 |
</parent> |
|
10 |
<groupId>org.gvsig</groupId> |
|
11 |
<dependencies> |
|
12 |
<dependency> |
|
13 |
<groupId>org.gvsig</groupId> |
|
14 |
<artifactId>org.gvsig.temporarystorage.lib.api</artifactId> |
|
15 |
<scope>compile</scope> |
|
16 |
</dependency> |
|
17 |
</dependencies> |
|
18 |
</project> |
|
0 | 19 |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.annotation</artifactId> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<name>${project.artifactId}</name> |
|
8 |
<description>Annotation</description> |
|
9 |
|
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.desktop.library</artifactId> |
|
13 |
<version>2.0.345</version> |
|
14 |
</parent> |
|
15 |
|
|
16 |
<dependencies> |
|
17 |
<dependency> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
20 |
</dependency> |
|
21 |
<dependency> |
|
22 |
<groupId>org.gvsig</groupId> |
|
23 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
24 |
<type>test-jar</type> |
|
25 |
<scope>test</scope> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>org.slf4j</groupId> |
|
29 |
<artifactId>slf4j-api</artifactId> |
|
30 |
<scope>compile</scope> |
|
31 |
</dependency> |
|
32 |
</dependencies> |
|
33 |
|
|
34 |
<modules> |
|
35 |
<module>org.gvsig.annotation.lib</module> |
|
36 |
<module>org.gvsig.annotation.swing</module> |
|
37 |
<module>org.gvsig.annotation.main</module> |
|
38 |
</modules> |
|
39 |
</project> |
|
0 | 40 |
tags/org.gvsig.desktop-2.0.345/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.345</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.345/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.345/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.345/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.345/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.345/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.345/org.gvsig.desktop.library/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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
|
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.annotation.lib</artifactId> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<name>org.gvsig.annotation.lib</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.annotation</artifactId> |
|
11 |
<version>2.0.345</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<modules> |
|
15 |
<module>org.gvsig.annotation.lib.api</module> |
|
16 |
<module>org.gvsig.annotation.lib.impl</module> |
|
17 |
</modules> |
|
18 |
</project> |
|
0 | 19 |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/test/java/org/gvsig/annotation/AnnotationCreationServiceTest.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; |
|
25 |
|
|
26 |
import java.io.File; |
|
27 |
import java.util.ArrayList; |
|
28 |
import java.util.List; |
|
29 |
|
|
30 |
import org.gvsig.fmap.crs.CRSFactory; |
|
31 |
import org.gvsig.fmap.dal.DALLocator; |
|
32 |
import org.gvsig.fmap.dal.DataManager; |
|
33 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
34 |
import org.gvsig.fmap.dal.feature.Feature; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
36 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
37 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
38 |
import org.gvsig.fmap.geom.Geometry; |
|
39 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
40 |
import org.gvsig.fmap.geom.primitive.Point; |
|
41 |
import org.gvsig.i18n.Messages; |
|
42 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
43 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
44 |
|
|
45 |
|
|
46 |
/** |
|
47 |
* API compatibility tests for {@link AnnotationCreationService} implementations. |
|
48 |
* |
|
49 |
* @author gvSIG Team |
|
50 |
* @version $Id$ |
|
51 |
*/ |
|
52 |
public abstract class AnnotationCreationServiceTest extends |
|
53 |
AbstractLibraryAutoInitTestCase { |
|
54 |
|
|
55 |
protected AnnotationManager manager; |
|
56 |
protected DataManager dataManager; |
|
57 |
|
|
58 |
@Override |
|
59 |
protected void doSetUp() throws Exception { |
|
60 |
manager = AnnotationLocator.getManager(); |
|
61 |
dataManager = DALLocator.getDataManager(); |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Returns an instance of the {@link AnnotationCreationService}. |
|
66 |
* |
|
67 |
* @return a {@link AnnotationCreationService} instance |
|
68 |
* @throws Exception |
|
69 |
* if there is any error creating the instance |
|
70 |
*/ |
|
71 |
protected AnnotationCreationService createService() throws Exception { |
|
72 |
String sourceFileName = getClass().getClassLoader().getResource("org/gvsig/annotation/data/andalucia.shp").getFile(); |
|
73 |
DataStoreParameters sourceParameters = dataManager.createStoreParameters("Shape"); |
|
74 |
sourceParameters.setDynValue("shpfile", sourceFileName); |
|
75 |
sourceParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030")); |
|
76 |
FeatureStore sourceStore = (FeatureStore) dataManager.openStore("Shape", sourceParameters); |
|
77 |
return manager.getAnnotationCreationService(sourceStore); |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* Test for the {@link AnnotationCreationService#getMessage()} method. |
|
82 |
* |
|
83 |
* @throws Exception |
|
84 |
* if there is any error in the tests |
|
85 |
*/ |
|
86 |
public void testAnnotationServiceMessage() throws Exception { |
|
87 |
AnnotationCreationService annotationCreationService = createService(); |
|
88 |
|
|
89 |
File temporalFolder = new File(System.getProperty("java.io.tmpdir") + File.separator + "tmp_gvsig_annotation"); |
|
90 |
if (!temporalFolder.exists()){ |
|
91 |
if (!temporalFolder.mkdir()){ |
|
92 |
throw new Exception("Impossible to create the destination folder"); |
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
String destinationFileName = temporalFolder.getAbsolutePath() + File.separator + Math.random() + ".shp"; |
|
97 |
|
|
98 |
annotationCreationService.createAnnotationStore(destinationFileName, 1); |
|
99 |
|
|
100 |
DataStoreParameters destinationParameters = dataManager.createStoreParameters("Shape"); |
|
101 |
destinationParameters.setDynValue("shpfile", destinationFileName); |
|
102 |
destinationParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030")); |
|
103 |
FeatureStore destinationStore = (FeatureStore) dataManager.openStore("Shape", destinationParameters); |
|
104 |
|
|
105 |
assertNotNull(destinationStore); |
|
106 |
|
|
107 |
FeatureType featureType = destinationStore.getDefaultFeatureType(); |
|
108 |
assertEquals(7, featureType.getAttributeDescriptors().length); |
|
109 |
|
|
110 |
assertEquals(destinationStore.getFeatureCount(), annotationCreationService.getFeatureStore().getFeatureCount()); |
|
111 |
|
|
112 |
assertNotNull(featureType.getDefaultGeometryAttribute()); |
|
113 |
assertEquals(featureType.getDefaultGeometryAttribute().getGeometryType(), Geometry.TYPES.POINT); |
|
114 |
|
|
115 |
//Check the geometries |
|
116 |
FeatureSet featureSet = destinationStore.getFeatureSet(); |
|
117 |
DisposableIterator iterator = featureSet.fastIterator(); |
|
118 |
|
|
119 |
Feature feature; |
|
120 |
TextPointPairList textPointPairList = getResult(); |
|
121 |
while (iterator.hasNext()){ |
|
122 |
feature = (Feature)iterator.next(); |
|
123 |
assertNotNull(feature.get(Messages.getText(AnnotationManager.TEXTVALUE_ATTRIBUTE_NAME))); |
|
124 |
String text = feature.getString(AnnotationManager.TEXTVALUE_ATTRIBUTE_NAME); |
|
125 |
TextPointPair textPointPair = textPointPairList.search(text); |
|
126 |
if (textPointPair != null){ |
|
127 |
//Check the geometry |
|
128 |
Point point = (Point)feature.getDefaultGeometry(); |
|
129 |
assertEquals(point.getX(), textPointPair.getPoint().getX(), 0.01); |
|
130 |
assertEquals(point.getY(), textPointPair.getPoint().getY(), 0.01); |
|
131 |
} |
|
132 |
int color = feature.getInt(AnnotationManager.FONTCOLOR_ATTRIBUTE_NAME); |
|
133 |
assertEquals(color, manager.getDefaultFontColor()); |
|
134 |
|
|
135 |
double heigth = feature.getDouble(AnnotationManager.FONTHEGTH_ATTRIBUTE_NAME); |
|
136 |
assertEquals(heigth, manager.getDefaultFontHeight()); |
|
137 |
|
|
138 |
double rotation = feature.getDouble(AnnotationManager.FONTROTATION_ATTRIBUTE_NAME); |
|
139 |
assertEquals(rotation, manager.getDefaultFontRotation()); |
|
140 |
|
|
141 |
String type = feature.getString(AnnotationManager.FONTTYPE_ATTRIBUTE_NAME); |
|
142 |
assertEquals(type, manager.getDefaultFontType()); |
|
143 |
|
|
144 |
String style = feature.getString(AnnotationManager.FONTSTYLE_ATTRIBUTE_NAME); |
|
145 |
assertEquals(style, manager.getDefaultFontStyle()); |
|
146 |
} |
|
147 |
|
|
148 |
destinationStore.dispose(); |
|
149 |
annotationCreationService.getFeatureStore().dispose(); |
|
150 |
} |
|
151 |
|
|
152 |
public abstract TextPointPairList getResult() throws CreateGeometryException; |
|
153 |
|
|
154 |
public class TextPointPairList{ |
|
155 |
List<TextPointPair> textPointPairs = new ArrayList<TextPointPair>(); |
|
156 |
|
|
157 |
public TextPointPairList() { |
|
158 |
super(); |
|
159 |
} |
|
160 |
|
|
161 |
public void addPoint(String text, Point point){ |
|
162 |
textPointPairs.add(new TextPointPair(text, point)); |
|
163 |
} |
|
164 |
|
|
165 |
public TextPointPair search(String text){ |
|
166 |
for (TextPointPair textPointPair : textPointPairs) { |
|
167 |
if (textPointPair.getText().equals(text)){ |
|
168 |
return textPointPair; |
|
169 |
} |
|
170 |
} |
|
171 |
return null; |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
private class TextPointPair{ |
|
178 |
private String text; |
|
179 |
private Point point; |
|
180 |
|
|
181 |
public TextPointPair(String text, Point point) { |
|
182 |
super(); |
|
183 |
this.text = text; |
|
184 |
this.point = point; |
|
185 |
} |
|
186 |
|
|
187 |
public String getText() { |
|
188 |
return text; |
|
189 |
} |
|
190 |
|
|
191 |
public Point getPoint() { |
|
192 |
return point; |
|
193 |
} |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* Test for the {@link AnnotationCreationService#getManager()} method. |
|
198 |
* |
|
199 |
* @throws Exception |
|
200 |
* if there is any error in the tests |
|
201 |
*/ |
|
202 |
public void testAnnotationServiceManager() throws Exception { |
|
203 |
AnnotationCreationService annotationCreationService = createService(); |
|
204 |
assertEquals(manager, annotationCreationService.getManager()); |
|
205 |
} |
|
206 |
} |
|
0 | 207 |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/test/java/org/gvsig/annotation/AnnotationManagerTest.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; |
|
25 |
|
|
26 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
27 |
|
|
28 |
/** |
|
29 |
* API compatibility tests for {@link AnnotationManager} implementations. |
|
30 |
* |
|
31 |
* @author gvSIG Team |
|
32 |
* @version $Id$ |
|
33 |
*/ |
|
34 |
public abstract class AnnotationManagerTest extends |
|
35 |
AbstractLibraryAutoInitTestCase { |
|
36 |
|
|
37 |
protected AnnotationManager manager; |
|
38 |
|
|
39 |
@Override |
|
40 |
protected void doSetUp() throws Exception { |
|
41 |
manager = AnnotationLocator.getManager(); |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* Test for the {@link AnnotationManager#getAnnotationCreationService()} |
|
46 |
* method. |
|
47 |
* |
|
48 |
* @throws Exception |
|
49 |
* if there is any error in the tests |
|
50 |
*/ |
|
51 |
public void testGetAnnotationCreationService() throws Exception { |
|
52 |
|
|
53 |
} |
|
54 |
|
|
55 |
} |
|
0 | 56 |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/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/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/AnnotationDataTypes.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 |
/* |
|
25 |
* AUTHORS (In addition to CIT): |
|
26 |
* 2010 {Prodevelop} {Task} |
|
27 |
*/ |
|
28 |
|
|
29 |
package org.gvsig.annotation; |
|
30 |
|
|
31 |
import org.gvsig.fmap.dal.DataStore; |
|
32 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
33 |
|
|
34 |
/** |
|
35 |
* DataTypes for the fields that are created in an annotation {@link DataStore}. |
|
36 |
* |
|
37 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
|
38 |
*/ |
|
39 |
public class AnnotationDataTypes { |
|
40 |
public static int TEXT = DataTypes.STRING; |
|
41 |
public static int FONTROTATION = DataTypes.DOUBLE; |
|
42 |
public static int FONTCOLOR = DataTypes.INT; |
|
43 |
public static int FONTHEIGHT = DataTypes.DOUBLE; |
|
44 |
public static int FONTTYPE = DataTypes.STRING; |
|
45 |
public static int FONTSTYLE = DataTypes.STRING; |
|
46 |
} |
|
47 |
|
|
0 | 48 |
tags/org.gvsig.desktop-2.0.345/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/AnnotationException.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; |
|
25 |
|
|
26 |
import org.gvsig.tools.exception.BaseException; |
|
27 |
|
|
28 |
/** |
|
29 |
* Generic exception thrown in the Annotation API when the exception or error |
|
30 |
* may be dealt by the program or the user of the program which is a client of |
|
31 |
* the Annotation API. |
|
32 |
* |
|
33 |
* @see {@link AnnotationCreationService} |
|
34 |
* @see {@link AnnotationManager} |
|
35 |
* @author gvSIG team. |
|
36 |
* @version $Id$ |
|
37 |
*/ |
|
38 |
public class AnnotationException extends BaseException { |
|
39 |
|
|
40 |
private static final long serialVersionUID = 6756475060924237176L; |
|
41 |
|
|
42 |
private static final String MESSAGE = |
|
43 |
"An error has been produced in the Annotation library"; |
|
44 |
|
|
45 |
private static final String KEY = "_AnnotationException"; |
|
46 |
|
|
47 |
/** |
|
48 |
* Constructor to be used in rare cases, usually you must create a new child |
|
49 |
* exception class for each case. |
|
50 |
* <strong>Don't use this constructor in child classes.</strong> |
|
51 |
*/ |
|
52 |
public AnnotationException() { |
|
53 |
super(MESSAGE, KEY, serialVersionUID); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* Constructor to be used in rare cases, usually you must create a new child |
|
58 |
* exception class for each case. |
|
59 |
* <p> |
|
60 |
* <strong>Don't use this constructor in child classes.</strong> |
|
61 |
* </p> |
|
62 |
* |
Also available in: Unified diff