Revision 34226
tags/v2_0_0_Build_2022/extensions/org.gvsig.symbology/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
4 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 |
|
5 |
http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
6 |
|
|
7 |
<modelVersion>4.0.0</modelVersion> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.symbology</artifactId> |
|
10 |
<packaging>jar</packaging> |
|
11 |
<version>2.0-SNAPSHOT</version> |
|
12 |
<name>org.gvsig.symbology</name> |
|
13 |
<description>Advanced legends and symbols</description> |
|
14 |
<url>http://www.gvsig.org</url> |
|
15 |
<scm> |
|
16 |
<connection>scm:svn:http://subversion.gvsig.org/gvSIG/branches/v2_0_0_prep/extensions/org.gvsig.symbology</connection> |
|
17 |
<developerConnection>scm:svn:https://gvsig.org/svn/gvSIG/branches/v2_0_0_prep/extensions/org.gvsig.symbology</developerConnection> |
|
18 |
<url>http://subversion.gvsig.org/viewvc/?root=gvSIG</url> |
|
19 |
<tag>HEAD</tag> |
|
20 |
</scm> |
|
21 |
<parent> |
|
22 |
<groupId>org.gvsig</groupId> |
|
23 |
<!--artifactId>gvsig-base-extension-pom</artifactId--> |
|
24 |
<artifactId>gvsig-base-library-pom</artifactId> |
|
25 |
<version>2.0-SNAPSHOT</version> |
|
26 |
</parent> |
|
27 |
<distributionManagement> |
|
28 |
<site> |
|
29 |
<id>gvsig-repository</id> |
|
30 |
<url>${site-repository}/</url> |
|
31 |
</site> |
|
32 |
</distributionManagement> |
|
33 |
|
|
34 |
<properties> |
|
35 |
<build-dir>${basedir}/../build</build-dir> |
|
36 |
</properties> |
|
37 |
<developers> |
|
38 |
<developer> |
|
39 |
<id>developer1</id> |
|
40 |
<name>Name Surname</name> |
|
41 |
<email>name@domain</email> |
|
42 |
<roles> |
|
43 |
<role>Architect</role> |
|
44 |
<role>Developer</role> |
|
45 |
</roles> |
|
46 |
</developer> |
|
47 |
<developer> |
|
48 |
<id>developer2</id> |
|
49 |
<name>Name2 Surname</name> |
|
50 |
<email>name2@domain</email> |
|
51 |
<roles> |
|
52 |
<role>Developer</role> |
|
53 |
</roles> |
|
54 |
</developer> |
|
55 |
</developers> |
|
56 |
<dependencies> |
|
57 |
<dependency> |
|
58 |
<groupId>org.gvsig</groupId> |
|
59 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
60 |
</dependency> |
|
61 |
<dependency> |
|
62 |
<groupId>org.gvsig</groupId> |
|
63 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
64 |
<type>test-jar</type> |
|
65 |
<scope>test</scope> |
|
66 |
</dependency> |
|
67 |
<dependency> |
|
68 |
<groupId>org.gvsig</groupId> |
|
69 |
<artifactId>org.gvsig.utils</artifactId> |
|
70 |
<version>2.0-SNAPSHOT</version> |
|
71 |
</dependency> |
|
72 |
<dependency> |
|
73 |
<groupId>org.gvsig</groupId> |
|
74 |
<artifactId>org.gvsig.i18n</artifactId> |
|
75 |
<version>2.0-SNAPSHOT</version> |
|
76 |
</dependency> |
|
77 |
<dependency> |
|
78 |
<groupId>org.gvsig</groupId> |
|
79 |
<artifactId>org.gvsig.compat</artifactId> |
|
80 |
<version>2.0-SNAPSHOT</version> |
|
81 |
</dependency> |
|
82 |
<dependency> |
|
83 |
<groupId>org.gvsig</groupId> |
|
84 |
<artifactId>org.gvsig.compat</artifactId> |
|
85 |
<version>2.0-SNAPSHOT</version> |
|
86 |
<classifier>se</classifier> |
|
87 |
<scope>test</scope> |
|
88 |
</dependency> |
|
89 |
<dependency> |
|
90 |
<groupId>org.gvsig</groupId> |
|
91 |
<artifactId>org.gvsig.fmap.geometry</artifactId> |
|
92 |
<version>2.0-SNAPSHOT</version> |
|
93 |
</dependency> |
|
94 |
<dependency> |
|
95 |
<groupId>org.gvsig</groupId> |
|
96 |
<artifactId>org.gvsig.fmap.geometry</artifactId> |
|
97 |
<version>2.0-SNAPSHOT</version> |
|
98 |
<classifier>impl</classifier> |
|
99 |
<scope>test</scope> |
|
100 |
</dependency> |
|
101 |
<dependency> |
|
102 |
<groupId>org.gvsig</groupId> |
|
103 |
<artifactId>org.gvsig.fmap.mapcontext</artifactId> |
|
104 |
<version>2.0-SNAPSHOT</version> |
|
105 |
</dependency> |
|
106 |
<dependency> |
|
107 |
<groupId>org.gvsig</groupId> |
|
108 |
<artifactId>org.gvsig.fmap.mapcontext</artifactId> |
|
109 |
<version>2.0-SNAPSHOT</version> |
|
110 |
<classifier>operation</classifier> |
|
111 |
</dependency> |
|
112 |
<dependency> |
|
113 |
<groupId>org.gvsig</groupId> |
|
114 |
<artifactId>org.gvsig.projection</artifactId> |
|
115 |
<version>2.0-SNAPSHOT</version> |
|
116 |
<classifier>cresques-impl</classifier> |
|
117 |
<scope>test</scope> |
|
118 |
</dependency> |
|
119 |
<dependency> |
|
120 |
<groupId>org.gvsig</groupId> |
|
121 |
<artifactId>org.gvsig.fmap.dal</artifactId> |
|
122 |
<version>2.0-SNAPSHOT</version> |
|
123 |
<classifier>impl</classifier> |
|
124 |
<scope>test</scope> |
|
125 |
</dependency> |
|
126 |
<dependency> |
|
127 |
<groupId>org.gvsig</groupId> |
|
128 |
<artifactId>org.gvsig.fmap.dal</artifactId> |
|
129 |
<version>2.0-SNAPSHOT</version> |
|
130 |
<classifier>spi</classifier> |
|
131 |
<scope>test</scope> |
|
132 |
</dependency> |
|
133 |
<dependency> |
|
134 |
<groupId>org.apache.xmlgraphics</groupId> |
|
135 |
<artifactId>batik-awt-util</artifactId> |
|
136 |
</dependency> |
|
137 |
</dependencies> |
|
138 |
<build> |
|
139 |
<resources> |
|
140 |
<resource> |
|
141 |
<directory>src/main/resources</directory> |
|
142 |
<excludes> |
|
143 |
<exclude>config/**</exclude> |
|
144 |
<exclude>about/**</exclude> |
|
145 |
<exclude>images/**</exclude> |
|
146 |
<exclude>locale/**</exclude> |
|
147 |
</excludes> |
|
148 |
</resource> |
|
149 |
</resources> |
|
150 |
<plugins> |
|
151 |
<plugin> |
|
152 |
<groupId>org.apache.maven.plugins</groupId> |
|
153 |
<artifactId>maven-jar-plugin</artifactId> |
|
154 |
<configuration> |
|
155 |
<excludes> |
|
156 |
<exclude>**/impl/**</exclude> |
|
157 |
</excludes> |
|
158 |
</configuration> |
|
159 |
<executions> |
|
160 |
<!-- |
|
161 |
Generates a jar file only with the mapcontext implementation |
|
162 |
--> |
|
163 |
<execution> |
|
164 |
<id>impl</id> |
|
165 |
<phase>package</phase> |
|
166 |
<goals> |
|
167 |
<goal>jar</goal> |
|
168 |
</goals> |
|
169 |
<configuration> |
|
170 |
<classifier>impl</classifier> |
|
171 |
<excludes> |
|
172 |
<exclude>NONE</exclude> |
|
173 |
</excludes> |
|
174 |
<includes> |
|
175 |
<include>**/impl/**</include> |
|
176 |
</includes> |
|
177 |
</configuration> |
|
178 |
</execution> |
|
179 |
</executions> |
|
180 |
</plugin> |
|
181 |
<plugin> |
|
182 |
<artifactId>maven-antrun-plugin</artifactId> |
|
183 |
<executions> |
|
184 |
<execution> |
|
185 |
<id>services</id> |
|
186 |
<phase>package</phase> |
|
187 |
<goals> |
|
188 |
<goal>run</goal> |
|
189 |
</goals> |
|
190 |
<configuration> |
|
191 |
<tasks> |
|
192 |
<jar destfile="${project.build.directory}/${project.build.finalName}.jar" |
|
193 |
update="true"> |
|
194 |
<fileset dir="${basedir}/resources/api" /> |
|
195 |
</jar> |
|
196 |
<jar destfile="${project.build.directory}/${project.build.finalName}-impl.jar" |
|
197 |
update="true"> |
|
198 |
<fileset dir="${basedir}/resources/impl" /> |
|
199 |
</jar> |
|
200 |
</tasks> |
|
201 |
</configuration> |
|
202 |
</execution> |
|
203 |
</executions> |
|
204 |
</plugin> |
|
205 |
<plugin> |
|
206 |
<groupId>org.apache.maven.plugins</groupId> |
|
207 |
<artifactId>maven-surefire-plugin</artifactId> |
|
208 |
<configuration> |
|
209 |
<additionalClasspathElements> |
|
210 |
<additionalClasspathElement>${basedir}/resources/api</additionalClasspathElement> |
|
211 |
<additionalClasspathElement>${basedir}/resources/impl</additionalClasspathElement> |
|
212 |
</additionalClasspathElements> |
|
213 |
<!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION --> |
|
214 |
<skipTests>true</skipTests> |
|
215 |
</configuration> |
|
216 |
</plugin> |
|
217 |
<plugin> |
|
218 |
<groupId>org.apache.maven.plugins</groupId> |
|
219 |
<artifactId>maven-compiler-plugin</artifactId> |
|
220 |
<configuration> |
|
221 |
<testExcludes> |
|
222 |
<exclude>**</exclude> |
|
223 |
</testExcludes> |
|
224 |
</configuration> |
|
225 |
</plugin> |
|
226 |
|
|
227 |
</plugins> |
|
228 |
</build> |
|
229 |
<profiles> |
|
230 |
<profile> |
|
231 |
<id>eclipse-project</id> |
|
232 |
<build> |
|
233 |
<defaultGoal>antrun:run</defaultGoal> |
|
234 |
<plugins> |
|
235 |
<plugin> |
|
236 |
<artifactId>maven-antrun-plugin</artifactId> |
|
237 |
<configuration> |
|
238 |
<tasks> |
|
239 |
<ant antfile="${build-dir}/ant-tasks/eclipse-tasks.xml" |
|
240 |
target="eclipse.all"/> |
|
241 |
</tasks> |
|
242 |
</configuration> |
|
243 |
</plugin> |
|
244 |
</plugins> |
|
245 |
</build> |
|
246 |
</profile> |
|
247 |
</profiles> |
|
248 |
</project> |
tags/v2_0_0_Build_2022/extensions/org.gvsig.symbology/resources/impl/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.symbology.impl.SymbologyDefaultImplLibrary |
tags/v2_0_0_Build_2022/extensions/org.gvsig.symbology/resources/api/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.symbology.SymbologyLibrary |
tags/v2_0_0_Build_2022/extensions/org.gvsig.symbology/README.txt | ||
---|---|---|
1 |
The project structure of this project is the following: |
|
2 |
|
|
3 |
Project |
|
4 |
|-pom.xml: Maven 2 configuration file. |
|
5 |
`-src |
|
6 |
|-main: Project source code, resources and configuration |
|
7 |
| |-java: Java source code |
|
8 |
| |-resources: Resources needed by the code (resource bundles, images, etc.) |
|
9 |
|`-javadoc: Javadoc common resources |
|
10 |
`-test: Unit tests source code, resources and configuration |
|
11 |
|-java: Unit tests java source code |
|
12 |
`-resources: Resources needed by the test code (resource bundles, images, etc.) |
|
13 |
|
|
14 |
Look at the main folders for a README.txt file with more information on the |
|
15 |
contents of each folder. |
tags/v2_0_0_Build_2022/extensions/org.gvsig.symbology/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>distribution</id> |
|
3 |
<formats> |
|
4 |
<format>dir</format> |
|
5 |
</formats> |
|
6 |
<fileSets> |
|
7 |
<!-- Extructure for the extension --> |
|
8 |
<fileSet> |
|
9 |
<directory>src/main/resources/config</directory> |
|
10 |
<outputDirectory>${extension.install.dir.name} |
|
11 |
</outputDirectory> |
|
12 |
</fileSet> |
|
13 |
<fileSet> |
|
14 |
<directory>src/main/resources/images</directory> |
|
15 |
<outputDirectory>${extension.install.dir.name}/images |
|
16 |
</outputDirectory> |
|
17 |
</fileSet> |
|
18 |
<fileSet> |
|
19 |
<directory>src/main/resources/about</directory> |
|
20 |
<outputDirectory>${extension.install.dir.name} |
|
21 |
</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
<fileSet> |
|
24 |
<directory>src/main/resources/locale</directory> |
|
25 |
<outputDirectory>${extension.install.dir.name} |
|
26 |
</outputDirectory> |
|
27 |
</fileSet> |
|
28 |
</fileSets> |
|
29 |
<files> |
|
30 |
<file> |
|
31 |
<source>package.info</source> |
|
32 |
<outputDirectory>${extension.install.dir.name} |
|
33 |
</outputDirectory> |
|
34 |
</file> |
|
35 |
</files> |
|
36 |
|
|
37 |
<dependencySets> |
|
38 |
<dependencySet> |
|
39 |
<outputDirectory>${extension.install.dir.name}/${library-dir} |
|
40 |
</outputDirectory> |
|
41 |
<includes> |
|
42 |
<include>org.gvsig:org.gvsig.symbology</include> |
|
43 |
</includes> |
|
44 |
</dependencySet> |
|
45 |
</dependencySets> |
|
46 |
</assembly> |
tags/v2_0_0_Build_2022/extensions/org.gvsig.symbology/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
InputCoordinatesPanel class. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.symbology.gui.InputCoordinatesPanel"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
|
|
26 |
<!-- |
|
27 |
By default, show only logging messages of INFO level or higher, |
|
28 |
through the previously configured CONSOLE appender. |
|
29 |
--> |
|
30 |
<root> |
|
31 |
<priority value="INFO" /> |
|
32 |
<appender-ref ref="CONSOLE" /> |
|
33 |
</root> |
|
34 |
</log4j:configuration> |
tags/v2_0_0_Build_2022/extensions/org.gvsig.symbology/src/test/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your test classes. |
|
2 |
|
|
3 |
This folder is added to the Tests classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your tests classes. |
tags/v2_0_0_Build_2022/extensions/org.gvsig.symbology/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/AllTests.java | ||
---|---|---|
1 |
package org.gvsig.symbology.fmap.mapcontext.rendering; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import junit.framework.Test; |
|
6 |
import junit.framework.TestCase; |
|
7 |
import junit.framework.TestSuite; |
|
8 |
|
|
9 |
import org.cresques.cts.IProjection; |
|
10 |
import org.gvsig.fmap.crs.CRSFactory; |
|
11 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
12 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
13 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
14 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
15 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.TestDrawFills; |
|
16 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.TestDrawLines; |
|
17 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.TestDrawMarkers; |
|
18 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.TestISymbol; |
|
19 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.TestMultiLayerSymbol; |
|
20 |
|
|
21 |
public class AllTests extends TestCase{ |
|
22 |
/** |
|
23 |
* The EPSG:4326 projection |
|
24 |
*/ |
|
25 |
public static IProjection TEST_DEFAULT_PROJECTION = |
|
26 |
CRSFactory.getCRS("EPSG:4326"); |
|
27 |
|
|
28 |
/** |
|
29 |
* The EPSG:23030 projection |
|
30 |
*/ |
|
31 |
public static IProjection TEST_DEFAULT_MERCATOR_PROJECTION = |
|
32 |
CRSFactory.getCRS("EPSG:23030"); |
|
33 |
|
|
34 |
/** |
|
35 |
* The EPSG:23029 projection |
|
36 |
*/ |
|
37 |
public static IProjection test_newProjection = |
|
38 |
CRSFactory.getCRS("EPSG:23029"); |
|
39 |
|
|
40 |
public static Test suite() { |
|
41 |
TestSuite suite = new TestSuite("Test for com.iver.cit.gvsig.fmap"); |
|
42 |
//$JUnit-BEGIN$ |
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
/* Symbols (jaume) */ |
|
47 |
// integration tests |
|
48 |
// ISymbol |
|
49 |
suite.addTestSuite(TestISymbol.class); |
|
50 |
suite.addTestSuite(TestMultiLayerSymbol.class); |
|
51 |
|
|
52 |
// CartographicSupport |
|
53 |
suite.addTestSuite(TestCartographicSupportForSymbol.class); |
|
54 |
|
|
55 |
// |
|
56 |
/* |
|
57 |
* Feature iterators |
|
58 |
* */ |
|
59 |
// suite.addTestSuite(FeatureIteratorTest.class); |
|
60 |
|
|
61 |
/* |
|
62 |
* Other Tests present in FMap (cesar) |
|
63 |
* Remove them from here and the src-test dir if they are not |
|
64 |
* useful anymore. |
|
65 |
*/ |
|
66 |
|
|
67 |
// suite.addTestSuite(TestAbstractIntervalLegend.class); |
|
68 |
suite.addTestSuite(TestCartographicSupportForSymbol.class); |
|
69 |
suite.addTestSuite(TestDrawFills.class); |
|
70 |
suite.addTestSuite(TestDrawLines.class); |
|
71 |
suite.addTestSuite(TestDrawMarkers.class); |
|
72 |
// suite.addTestSuite(TestIClassifiedLegend.class); |
|
73 |
// suite.addTestSuite(TestILegend.class); |
|
74 |
suite.addTestSuite(TestMultiLayerSymbol.class); |
|
75 |
|
|
76 |
//$JUnit-END$ |
|
77 |
return suite; |
|
78 |
} |
|
79 |
|
|
80 |
//// jaume |
|
81 |
//// PASTED FROM FeatureIteratorTest.java to be globally accessible |
|
82 |
static final String fwAndamiDriverPath = "../_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers"; |
|
83 |
private static File baseDataPath; |
|
84 |
private static File baseDriversPath; |
|
85 |
|
|
86 |
|
|
87 |
public static void setUpDrivers() { |
|
88 |
// try { |
|
89 |
// URL url = AllTests.class.getResource("testdata"); |
|
90 |
// if (url == null) |
|
91 |
// throw new Exception("No se encuentra el directorio con datos de prueba"); |
|
92 |
// |
|
93 |
// baseDataPath = new File(url.getFile()); |
|
94 |
// if (!baseDataPath.exists()) |
|
95 |
// throw new Exception("No se encuentra el directorio con datos de prueba"); |
|
96 |
// |
|
97 |
// baseDriversPath = new File(fwAndamiDriverPath); |
|
98 |
// if (!baseDriversPath.exists()) |
|
99 |
// throw new Exception("Can't find drivers path: " + fwAndamiDriverPath); |
|
100 |
// |
|
101 |
// LayerFactory.setDriversPath(baseDriversPath.getAbsolutePath()); |
|
102 |
// if (LayerFactory.getDM().getDriverNames().length < 1) |
|
103 |
// throw new Exception("Can't find drivers in path: " + fwAndamiDriverPath); |
|
104 |
// } catch (Exception e) { |
|
105 |
// throw new RuntimeException(e); |
|
106 |
// } |
|
107 |
} |
|
108 |
|
|
109 |
public static FLayer newLayer(String fileName, |
|
110 |
String driverName) |
|
111 |
throws LoadLayerException { |
|
112 |
// File file = new File(baseDataPath, fileName); |
|
113 |
// return LayerFactory.createLayer(fileName, |
|
114 |
// driverName, |
|
115 |
// file, TEST_DEFAULT_MERCATOR_PROJECTION); |
|
116 |
return null; |
|
117 |
} |
|
118 |
|
|
119 |
public static MapContext newMapContext(IProjection projection) { |
|
120 |
ViewPort vp = new ViewPort(projection); |
|
121 |
return new MapContext(vp); |
|
122 |
} |
|
123 |
|
|
124 |
//// end past |
|
125 |
} |
tags/v2_0_0_Build_2022/extensions/org.gvsig.symbology/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/TestAbstractIntervalLegend.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.symbology.fmap.mapcontext.rendering.legend; |
|
42 |
|
|
43 |
import java.awt.Dimension; |
|
44 |
import java.awt.Rectangle; |
|
45 |
import java.util.ArrayList; |
|
46 |
import java.util.Hashtable; |
|
47 |
import java.util.Iterator; |
|
48 |
import java.util.List; |
|
49 |
import java.util.Set; |
|
50 |
|
|
51 |
import org.cresques.cts.IProjection; |
|
52 |
import org.gvsig.fmap.dal.DataQuery; |
|
53 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
54 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
55 |
import org.gvsig.fmap.dal.DataSet; |
|
56 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
57 |
import org.gvsig.fmap.dal.exception.DataException; |
|
58 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
59 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
60 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
61 |
import org.gvsig.fmap.dal.feature.Feature; |
|
62 |
import org.gvsig.fmap.dal.feature.FeatureCache; |
|
63 |
import org.gvsig.fmap.dal.feature.FeatureIndex; |
|
64 |
import org.gvsig.fmap.dal.feature.FeatureIndexes; |
|
65 |
import org.gvsig.fmap.dal.feature.FeatureLocks; |
|
66 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
67 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
68 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
69 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
70 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
71 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransforms; |
|
72 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
73 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
74 |
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException; |
|
75 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
76 |
import org.gvsig.fmap.geom.GeometryManager; |
|
77 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
78 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
79 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
80 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
81 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
82 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend; |
|
83 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
84 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
85 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractIntervalLegend; |
|
86 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.FInterval; |
|
87 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.TestISymbol; |
|
88 |
import org.gvsig.tools.dynobject.DynClass; |
|
89 |
import org.gvsig.tools.dynobject.DynObject; |
|
90 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
|
91 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
92 |
import org.gvsig.tools.exception.BaseException; |
|
93 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
94 |
import org.gvsig.tools.observer.Observer; |
|
95 |
import org.gvsig.tools.persistence.PersistentState; |
|
96 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
97 |
import org.gvsig.tools.undo.RedoException; |
|
98 |
import org.gvsig.tools.undo.UndoException; |
|
99 |
import org.gvsig.tools.visitor.Visitor; |
|
100 |
|
|
101 |
/** |
|
102 |
* Integration test to ensure that the legends which implements the |
|
103 |
* IVectorialIntervalLegend interface follow the rules that follow the managing |
|
104 |
* of them by the application. |
|
105 |
* |
|
106 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es |
|
107 |
*/ |
|
108 |
public class TestAbstractIntervalLegend extends AbstractLibraryAutoInitTestCase { |
|
109 |
|
|
110 |
private static final Integer v0 = new Integer(0); |
|
111 |
private static final Integer v1 = new Integer(1); |
|
112 |
private static final Integer v2 = new Integer(2); |
|
113 |
private static final Integer v3 = new Integer(3); |
|
114 |
|
|
115 |
private static final String FIELD3 = "field3"; |
|
116 |
private static final String FIELD2 = "field2"; |
|
117 |
private static final String FIELD1 = "field1"; |
|
118 |
private static final String FIELD0 = "field0"; |
|
119 |
private static final int FIELDID = 0; |
|
120 |
|
|
121 |
private static final Integer[] feature0Values = new Integer[] { v0, v1, v2, v3, }; |
|
122 |
private static final Integer[] feature1Values = new Integer[] { v3, v0, v1, v2, }; |
|
123 |
private static final Integer[] feature2Values = new Integer[] { v2, v3, v0, v1, }; |
|
124 |
private static final Integer[] feature3Values = new Integer[] { v1, v2, v3, v0, }; |
|
125 |
|
|
126 |
private static final Integer[][] featureValues = new Integer[][] { |
|
127 |
feature0Values, |
|
128 |
feature1Values, |
|
129 |
feature2Values, |
|
130 |
feature3Values,}; |
|
131 |
|
|
132 |
private static String[] fieldNames = new String[] {FIELD0,FIELD1,FIELD2,FIELD3,}; |
|
133 |
|
|
134 |
|
|
135 |
// private static final Value v4 = (Value)ValueFactory.createValue(4); |
|
136 |
// private static final Value v5 = (Value)ValueFactory.createValue(5); |
|
137 |
// private static final Value v6 = (Value)ValueFactory.createValue(6); |
|
138 |
// private static final Value v7 = (Value)ValueFactory.createValue(7); |
|
139 |
// private static final Value v8 = (Value)ValueFactory.createValue(8); |
|
140 |
// private static final Value v9 = (Value)ValueFactory.createValue(9); |
|
141 |
|
|
142 |
private AbstractIntervalLegend[] intervalLegends; |
|
143 |
private MockDataSource mockDataSource = new MockDataSource(); |
|
144 |
|
|
145 |
/** |
|
146 |
* To avoid duplicated validation logic in the test a mock object is created |
|
147 |
* to use a DataSource for this test. |
|
148 |
* |
|
149 |
*/ |
|
150 |
private class MockDataSource implements FeatureStore { |
|
151 |
|
|
152 |
public boolean allowWrite() { |
|
153 |
|
|
154 |
return false; |
|
155 |
} |
|
156 |
|
|
157 |
public void beginEditingGroup(String description) |
|
158 |
throws NeedEditingModeException { |
|
159 |
|
|
160 |
|
|
161 |
} |
|
162 |
|
|
163 |
public boolean canWriteGeometry(int gvSIGgeometryType) |
|
164 |
throws DataException { |
|
165 |
|
|
166 |
return false; |
|
167 |
} |
|
168 |
|
|
169 |
public void cancelEditing() throws DataException { |
|
170 |
|
|
171 |
|
|
172 |
} |
|
173 |
|
|
174 |
public FeatureSelection createFeatureSelection() throws DataException { |
|
175 |
|
|
176 |
return null; |
|
177 |
} |
|
178 |
|
|
179 |
public FeatureIndex createIndex(FeatureType featureType, |
|
180 |
String attributeName, String indexName) throws DataException { |
|
181 |
|
|
182 |
return null; |
|
183 |
} |
|
184 |
|
|
185 |
public EditableFeature createNewFeature() throws DataException { |
|
186 |
|
|
187 |
return null; |
|
188 |
} |
|
189 |
|
|
190 |
public EditableFeature createNewFeature(FeatureType type, |
|
191 |
Feature defaultValues) throws DataException { |
|
192 |
|
|
193 |
return null; |
|
194 |
} |
|
195 |
|
|
196 |
public EditableFeature createNewFeature(FeatureType type, |
|
197 |
boolean defaultValues) throws DataException { |
|
198 |
|
|
199 |
return null; |
|
200 |
} |
|
201 |
|
|
202 |
public EditableFeature createNewFeature(boolean defaultValues) |
|
203 |
throws DataException { |
|
204 |
|
|
205 |
return null; |
|
206 |
} |
|
207 |
|
|
208 |
public void delete(Feature feature) throws DataException { |
|
209 |
|
|
210 |
|
|
211 |
} |
|
212 |
|
|
213 |
public void edit() throws DataException { |
|
214 |
|
|
215 |
|
|
216 |
} |
|
217 |
|
|
218 |
public void edit(int mode) throws DataException { |
|
219 |
|
|
220 |
|
|
221 |
} |
|
222 |
|
|
223 |
public void endEditingGroup() throws NeedEditingModeException { |
|
224 |
|
|
225 |
|
|
226 |
} |
|
227 |
|
|
228 |
public void finishEditing() throws DataException { |
|
229 |
|
|
230 |
|
|
231 |
} |
|
232 |
|
|
233 |
public FeatureType getDefaultFeatureType() throws DataException { |
|
234 |
|
|
235 |
return null; |
|
236 |
} |
|
237 |
|
|
238 |
public Envelope getEnvelope() { |
|
239 |
|
|
240 |
return null; |
|
241 |
} |
|
242 |
|
|
243 |
public Feature getFeatureByReference(FeatureReference reference) |
|
244 |
throws DataException { |
|
245 |
|
|
246 |
return null; |
|
247 |
} |
|
248 |
|
|
249 |
public Feature getFeatureByReference(FeatureReference reference, |
|
250 |
FeatureType featureType) throws DataException { |
|
251 |
|
|
252 |
return null; |
|
253 |
} |
|
254 |
|
|
255 |
public FeatureSelection getFeatureSelection() throws DataException { |
|
256 |
|
|
257 |
return null; |
|
258 |
} |
|
259 |
|
|
260 |
public FeatureSet getFeatureSet() throws DataException { |
|
261 |
|
|
262 |
return null; |
|
263 |
} |
|
264 |
|
|
265 |
public FeatureSet getFeatureSet(FeatureQuery featureQuery) |
|
266 |
throws DataException { |
|
267 |
|
|
268 |
return null; |
|
269 |
} |
|
270 |
|
|
271 |
public void getFeatureSet(FeatureQuery featureQuery, Observer observer) |
|
272 |
throws DataException { |
|
273 |
|
|
274 |
|
|
275 |
} |
|
276 |
|
|
277 |
public void getFeatureSet(Observer observer) throws DataException { |
|
278 |
|
|
279 |
|
|
280 |
} |
|
281 |
|
|
282 |
public List getFeatureTypes() throws DataException { |
|
283 |
|
|
284 |
return null; |
|
285 |
} |
|
286 |
|
|
287 |
public FeatureIndexes getIndexes() { |
|
288 |
|
|
289 |
return null; |
|
290 |
} |
|
291 |
|
|
292 |
public FeatureLocks getLocks() throws DataException { |
|
293 |
|
|
294 |
return null; |
|
295 |
} |
|
296 |
|
|
297 |
public DataStoreParameters getParameters() { |
|
298 |
|
|
299 |
return null; |
|
300 |
} |
|
301 |
|
|
302 |
public IProjection getSRSDefaultGeometry() throws DataException { |
|
303 |
|
|
304 |
return null; |
|
305 |
} |
|
306 |
|
|
307 |
public FeatureStoreTransforms getTransforms() { |
|
308 |
|
|
309 |
return null; |
|
310 |
} |
|
311 |
|
|
312 |
public void insert(EditableFeature feature) throws DataException { |
|
313 |
|
|
314 |
|
|
315 |
} |
|
316 |
|
|
317 |
public boolean isAppendModeSupported() { |
|
318 |
|
|
319 |
return false; |
|
320 |
} |
|
321 |
|
|
322 |
public boolean isAppending() { |
|
323 |
|
|
324 |
return false; |
|
325 |
} |
|
326 |
|
|
327 |
public boolean isEditing() { |
|
328 |
|
|
329 |
return false; |
|
330 |
} |
|
331 |
|
|
332 |
public boolean isLocksSupported() { |
|
333 |
|
|
334 |
return false; |
|
335 |
} |
|
336 |
|
|
337 |
|
|
338 |
public void setSelection(FeatureSet selection) throws DataException { |
|
339 |
|
|
340 |
|
|
341 |
} |
|
342 |
public void update(EditableFeatureType featureType) |
|
343 |
throws DataException { |
|
344 |
|
|
345 |
|
|
346 |
} |
|
347 |
|
|
348 |
public void update(EditableFeature feature) throws DataException { |
|
349 |
|
|
350 |
|
|
351 |
} |
|
352 |
|
|
353 |
public void validateFeatures(int mode) throws DataException { |
|
354 |
|
|
355 |
|
|
356 |
} |
|
357 |
|
|
358 |
public DataSet createSelection() throws DataException { |
|
359 |
|
|
360 |
return null; |
|
361 |
} |
|
362 |
|
|
363 |
public void dispose() { |
|
364 |
|
|
365 |
|
|
366 |
} |
|
367 |
|
|
368 |
public Iterator getChildren() { |
|
369 |
|
|
370 |
return null; |
|
371 |
} |
|
372 |
|
|
373 |
public DataSet getDataSet() throws DataException { |
|
374 |
|
|
375 |
return null; |
|
376 |
} |
|
377 |
|
|
378 |
public DataSet getDataSet(DataQuery dataQuery) throws DataException { |
|
379 |
|
|
380 |
return null; |
|
381 |
} |
|
382 |
|
|
383 |
public void getDataSet(Observer observer) throws DataException { |
|
384 |
|
|
385 |
|
|
386 |
} |
|
387 |
|
|
388 |
public void getDataSet(DataQuery dataQuery, Observer observer) |
|
389 |
throws DataException { |
|
390 |
|
|
391 |
|
|
392 |
} |
|
393 |
|
|
394 |
public DataServerExplorer getExplorer() throws DataException { |
|
395 |
|
|
396 |
return null; |
|
397 |
} |
|
398 |
|
|
399 |
public String getName() { |
|
400 |
|
|
401 |
return null; |
|
402 |
} |
|
403 |
|
|
404 |
public DataSet getSelection() throws DataException { |
|
405 |
|
|
406 |
return null; |
|
407 |
} |
|
408 |
|
|
409 |
public void refresh() throws DataException { |
|
410 |
|
|
411 |
|
|
412 |
} |
|
413 |
|
|
414 |
public void setSelection(DataSet selection) throws DataException { |
|
415 |
|
|
416 |
|
|
417 |
} |
|
418 |
|
|
419 |
public void beginComplexNotification() { |
|
420 |
|
|
421 |
|
|
422 |
} |
|
423 |
|
|
424 |
public void disableNotifications() { |
|
425 |
|
|
426 |
|
|
427 |
} |
|
428 |
|
|
429 |
public void enableNotifications() { |
|
430 |
|
|
431 |
|
|
432 |
} |
|
433 |
|
|
434 |
public void endComplexNotification() { |
|
435 |
|
|
436 |
|
|
437 |
} |
|
438 |
|
|
439 |
public void addObserver(Observer o) { |
|
440 |
|
|
441 |
|
|
442 |
} |
|
443 |
|
|
444 |
public void deleteObserver(Observer o) { |
|
445 |
|
|
446 |
|
|
447 |
} |
|
448 |
|
|
449 |
public void deleteObservers() { |
|
450 |
|
|
451 |
|
|
452 |
} |
|
453 |
|
|
454 |
public void saveToState(PersistentState state) |
|
455 |
throws PersistenceException { |
|
456 |
|
|
457 |
|
|
458 |
} |
|
459 |
|
|
460 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
461 |
|
|
462 |
|
|
463 |
} |
|
464 |
|
|
465 |
public FeatureQuery createFeatureQuery() { |
|
466 |
|
|
467 |
return null; |
|
468 |
} |
|
469 |
|
|
470 |
public boolean canRedo() { |
|
471 |
|
|
472 |
return false; |
|
473 |
} |
|
474 |
|
|
475 |
public boolean canUndo() { |
|
476 |
|
|
477 |
return false; |
|
478 |
} |
|
479 |
|
|
480 |
public List getRedoInfos() { |
|
481 |
|
|
482 |
return null; |
|
483 |
} |
|
484 |
|
|
485 |
public List getUndoInfos() { |
|
486 |
|
|
487 |
return null; |
|
488 |
} |
|
489 |
|
|
490 |
public void redo() throws RedoException { |
|
491 |
|
|
492 |
|
|
493 |
} |
|
494 |
|
|
495 |
public void redo(int num) throws RedoException { |
|
496 |
|
|
497 |
|
|
498 |
} |
|
499 |
|
|
500 |
public void undo() throws UndoException { |
|
501 |
|
|
502 |
|
|
503 |
} |
|
504 |
|
|
505 |
public void undo(int num) throws UndoException { |
|
506 |
|
|
507 |
|
|
508 |
} |
|
509 |
|
|
510 |
public FeatureIndex createIndex(FeatureType featureType, |
|
511 |
String attributeName, String indexName, Observer observer) |
|
512 |
throws DataException { |
|
513 |
|
|
514 |
return null; |
|
515 |
} |
|
516 |
|
|
517 |
public Object getMetadataID() { |
|
518 |
|
|
519 |
return null; |
|
520 |
} |
|
521 |
|
|
522 |
public void delegate(DynObject dynObject) { |
|
523 |
|
|
524 |
|
|
525 |
} |
|
526 |
|
|
527 |
public DynClass getDynClass() { |
|
528 |
|
|
529 |
return null; |
|
530 |
} |
|
531 |
|
|
532 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
|
533 |
|
|
534 |
return null; |
|
535 |
} |
|
536 |
|
|
537 |
public boolean hasDynValue(String name) { |
|
538 |
|
|
539 |
return false; |
|
540 |
} |
|
541 |
|
|
542 |
public void implement(DynClass dynClass) { |
|
543 |
|
|
544 |
|
|
545 |
} |
|
546 |
|
|
547 |
public Object invokeDynMethod(String name, DynObject context) |
|
548 |
throws DynMethodException { |
|
549 |
|
|
550 |
return null; |
|
551 |
} |
|
552 |
|
|
553 |
public Object invokeDynMethod(int code, DynObject context) |
|
554 |
throws DynMethodException { |
|
555 |
|
|
556 |
return null; |
|
557 |
} |
|
558 |
|
|
559 |
public void setDynValue(String name, Object value) |
|
560 |
throws DynFieldNotFoundException { |
|
561 |
|
|
562 |
|
|
563 |
} |
|
564 |
|
|
565 |
/* |
|
566 |
* (non-Javadoc) |
|
567 |
* |
|
568 |
* @see org.gvsig.metadata.Metadata#getMetadataChildren() |
|
569 |
*/ |
|
570 |
public Set getMetadataChildren() { |
|
571 |
|
|
572 |
return null; |
|
573 |
} |
|
574 |
|
|
575 |
/* |
|
576 |
* (non-Javadoc) |
|
577 |
* |
|
578 |
* @see org.gvsig.metadata.Metadata#getMetadataName() |
|
579 |
*/ |
|
580 |
public String getMetadataName() { |
|
581 |
|
|
582 |
return null; |
|
583 |
} |
|
584 |
|
|
585 |
public FeatureType getFeatureType(String featureTypeId) |
|
586 |
throws DataException { |
|
587 |
|
|
588 |
return null; |
|
589 |
} |
|
590 |
|
|
591 |
public DataQuery createQuery() { |
|
592 |
|
|
593 |
return null; |
|
594 |
} |
|
595 |
|
|
596 |
public long getFeatureCount() throws DataException { |
|
597 |
|
|
598 |
return 0; |
|
599 |
} |
|
600 |
|
|
601 |
public void accept(Visitor visitor, DataQuery dataQuery) |
|
602 |
throws BaseException { |
|
603 |
} |
|
604 |
|
|
605 |
public void accept(Visitor visitor) throws BaseException { |
|
606 |
} |
|
607 |
|
|
608 |
public void createCache(String name, |
|
609 |
DynObject parameters) throws DataException { |
|
610 |
// Do nothing |
|
611 |
} |
|
612 |
|
|
613 |
public FeatureCache getCache() { |
|
614 |
return null; |
|
615 |
} |
|
616 |
|
|
617 |
public void clear() { |
|
618 |
// Nothing to do |
|
619 |
} |
|
620 |
|
|
621 |
public void export(DataServerExplorer explorer, String provider, |
|
622 |
NewFeatureStoreParameters params) throws DataException { |
|
623 |
// Nothing to do |
|
624 |
} |
|
625 |
|
|
626 |
public String getProviderName() { |
|
627 |
return null; |
|
628 |
} |
|
629 |
|
|
630 |
public String getFullName() { |
|
631 |
// TODO Auto-generated method stub |
|
632 |
return null; |
|
633 |
} |
|
634 |
|
|
635 |
public boolean isKnownEnvelope() { |
|
636 |
// TODO Auto-generated method stub |
|
637 |
return false; |
|
638 |
} |
|
639 |
|
|
640 |
public boolean hasRetrievedFeaturesLimit() { |
|
641 |
// TODO Auto-generated method stub |
|
642 |
return false; |
|
643 |
} |
|
644 |
|
|
645 |
public int getRetrievedFeaturesLimit() { |
|
646 |
// TODO Auto-generated method stub |
|
647 |
return 0; |
|
648 |
} |
|
649 |
} |
|
650 |
|
|
651 |
private static final FInterval interval0=new FInterval(0,2); |
|
652 |
private static final FInterval interval1=new FInterval(3,5); |
|
653 |
private static final FInterval interval2=new FInterval(6,8); |
|
654 |
private static final FInterval interval3=new FInterval(9,11); |
|
655 |
// private static final Value interval4; |
|
656 |
// private static final Value interval5; |
|
657 |
// private static final Value interval6; |
|
658 |
// private static final Value interval7; |
|
659 |
// private static final Value interval8; |
|
660 |
// private static final Value interval9; |
|
661 |
|
|
662 |
Hashtable symTable; |
|
663 |
|
|
664 |
private ISymbol[] symbols; |
|
665 |
private FInterval[] sampleIntervals = new FInterval[] { interval0, interval1, interval2, interval3, }; |
|
666 |
private Feature[] features; |
|
667 |
|
|
668 |
// private FInterval[] intervals = new FInterval[] { |
|
669 |
// interval0, |
|
670 |
// interval1, |
|
671 |
// interval2, |
|
672 |
// interval3, |
|
673 |
// interval4, |
|
674 |
// interval5, |
|
675 |
// interval6, |
|
676 |
// interval7, |
|
677 |
// interval8, |
|
678 |
// interval9, |
|
679 |
// }; |
|
680 |
|
|
681 |
protected void doSetUp() throws Exception { |
|
682 |
features = new Feature[4]; |
|
683 |
|
|
684 |
// initialize test values |
|
685 |
for (int i = 0; i < features.length; i++) { |
|
686 |
|
|
687 |
// create the geometry associated to the feature |
|
688 |
int size = 200; |
|
689 |
Dimension d = new Dimension(size, size); |
|
690 |
Rectangle aShape = new Rectangle(i * size, i * size, d.width, |
|
691 |
d.height); |
|
692 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
693 |
Curve curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
|
694 |
curve.setGeneralPath(new GeneralPathX(aShape.getPathIterator(null))); |
|
695 |
|
|
696 |
/* |
|
697 |
* create a full-featured Feature with randomed values at its fields |
|
698 |
* to avoid testing over the same values each time |
|
699 |
*/ |
|
700 |
//TODO |
|
701 |
// features[i] = new MemoryFeature(geom, featureValues[i], "[" + i |
|
702 |
// + "]"); |
|
703 |
} |
|
704 |
|
|
705 |
// initialize the symbol subset for this test |
|
706 |
TestISymbol.addSymbols(); |
|
707 |
symbols = TestISymbol.getNewSymbolInstances(); |
|
708 |
|
|
709 |
// initialize the legends for this test |
|
710 |
ILegend[] allLegends = TestILegend.getNewLegendInstances(); |
|
711 |
ArrayList intervalLegends = new ArrayList(); |
|
712 |
for (int i = 0; i < allLegends.length; i++) { |
|
713 |
|
|
714 |
if (allLegends[i] instanceof AbstractIntervalLegend) { |
|
715 |
intervalLegends.add(allLegends[i]); |
|
716 |
} |
|
717 |
|
|
718 |
if (allLegends[i] instanceof IClassifiedVectorLegend) { |
|
719 |
IClassifiedVectorLegend cvl = (IClassifiedVectorLegend) allLegends[i]; |
|
720 |
cvl.setClassifyingFieldNames(new String[] { fieldNames[FIELDID] }); |
|
721 |
// cvl.setFeatureStore(mockDataSource); |
|
722 |
|
|
723 |
} |
|
724 |
} |
|
725 |
|
|
726 |
this.intervalLegends = (AbstractIntervalLegend[]) intervalLegends |
|
727 |
.toArray(new AbstractIntervalLegend[intervalLegends.size()]); |
|
728 |
} |
|
729 |
|
|
730 |
/** |
|
731 |
* This method is used to add symbols to a legend.That is, it takes an array |
|
732 |
* of AbstractIntervalLegend which is empty and, using a second array |
|
733 |
* of FIntervals(values), the first one is filled.Also, a hash table is filled |
|
734 |
* using the array of FIntervals (it will be useful in some tests to check |
|
735 |
* that a symbol can be taken using a feature) . |
|
736 |
* |
|
737 |
* @param legend |
|
738 |
* @return |
|
739 |
*/ |
|
740 |
private void fillClassifiedLegend(AbstractIntervalLegend legend, |
|
741 |
FInterval[] values) { |
|
742 |
// initialize the hash table |
|
743 |
symTable = new Hashtable(); |
|
744 |
|
|
745 |
// to add symbols to the legend and the hash table |
|
746 |
for (int j = 0; j < values.length; j++) { |
|
747 |
|
|
748 |
ISymbol sym = symbols[j % symbols.length]; |
|
749 |
legend.addSymbol(values[j], sym); |
|
750 |
symTable.put(values[j], sym); |
|
751 |
} |
|
752 |
} |
|
753 |
|
|
754 |
/** |
|
755 |
* This test ensures that when a legend is filled, the number of symbols |
|
756 |
* added is correct. To do it, is checked that the number of symbols of a |
|
757 |
* legend is the same as the length of the array of example values that we |
|
758 |
* have. |
|
759 |
* |
|
760 |
* @throws ReadDriverException |
|
761 |
*/ |
|
762 |
public void testICLAdittion() throws ReadException { |
|
763 |
|
|
764 |
// Fills the legend |
|
765 |
for (int i = 0; i < intervalLegends.length; i++) { |
|
766 |
fillClassifiedLegend(intervalLegends[i], sampleIntervals); |
|
767 |
} |
|
768 |
|
|
769 |
for (int i = 0; i < intervalLegends.length; i++) { |
|
770 |
assertEquals(intervalLegends[i].getClass().getName() |
|
771 |
+ " fails with the comparation of the number of symbols", |
|
772 |
intervalLegends[i].getSymbols().length, |
|
773 |
sampleIntervals.length); |
|
774 |
} |
|
775 |
|
|
776 |
} |
|
777 |
|
|
778 |
/** |
|
779 |
* This test ensures that the symbols that we have previously added to a |
|
780 |
* legend are accessible using its features.To do it, this test compares the |
|
781 |
* symbol taken from the legend with the symbol taken from the hashTable |
|
782 |
* (using the same feature). |
|
783 |
* @throws Exception |
|
784 |
*/ |
|
785 |
public void testICLCheckValueSymbols() throws Exception { |
|
786 |
|
|
787 |
ISymbol tableSym =null; |
|
788 |
|
|
789 |
// fills the legends |
|
790 |
for (int i = 0; i < intervalLegends.length; i++) { |
|
791 |
fillClassifiedLegend(intervalLegends[i], sampleIntervals); |
|
792 |
} |
|
793 |
|
|
794 |
for (int i = 0; i < intervalLegends.length; i++) { |
|
795 |
// For each feature |
|
796 |
for (int j = 0; j < features.length; j++) { |
|
797 |
Feature myFeature = features[i]; |
|
798 |
// takes the value of the field that identifies the feature |
|
799 |
Object val = myFeature.get(FIELDID); |
|
800 |
// the last value is used to access to the hash table to obtain |
|
801 |
// a symbol |
|
802 |
|
|
803 |
if(interval0.isInInterval(val)) { |
|
804 |
tableSym = (ISymbol) symTable.get(interval0); |
|
805 |
} else if(interval1.isInInterval(val)) { |
|
806 |
tableSym = (ISymbol) symTable.get(interval1); |
|
807 |
} else if(interval2.isInInterval(val)) { |
|
808 |
tableSym = (ISymbol) symTable.get(interval2); |
|
809 |
} else if(interval3.isInInterval(val)) { |
|
810 |
tableSym = (ISymbol) symTable.get(interval3); |
|
811 |
} |
|
812 |
|
|
813 |
AbstractIntervalLegend leg = intervalLegends[i]; |
|
814 |
// takes the symbol from a legend using the feature |
|
815 |
ISymbol legendSym = leg.getSymbolByFeature(myFeature); |
|
816 |
// compares that both symbols are the same |
|
817 |
assertEquals(legendSym.getClass().getName() |
|
818 |
+ " fails with the comparation of the class symbols", |
|
819 |
legendSym, tableSym); |
|
820 |
} |
|
821 |
} |
|
822 |
} |
|
823 |
|
|
824 |
} |
|
825 |
|
|
826 |
|
tags/v2_0_0_Build_2022/extensions/org.gvsig.symbology/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/TestILegend.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.symbology.fmap.mapcontext.rendering.legend; |
|
42 |
|
|
43 |
import java.awt.Color; |
|
44 |
import java.lang.reflect.Field; |
|
45 |
import java.util.ArrayList; |
|
46 |
|
|
47 |
import junit.framework.TestCase; |
|
48 |
|
|
49 |
import org.gvsig.fmap.mapcontext.MapContextException; |
|
50 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend; |
|
51 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
52 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
53 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialIntervalLegend; |
|
54 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend; |
|
55 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.SingleSymbolLegend; |
|
56 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialIntervalLegend; |
|
57 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend; |
|
58 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.SimpleFillSymbol; |
|
59 |
import org.gvsig.utils.XMLException; |
|
60 |
|
|
61 |
/** |
|
62 |
* Integration test to ensure that the legends follow the rules that follow the |
|
63 |
* managing of them by the application. |
|
64 |
* |
|
65 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
66 |
*/ |
|
67 |
public class TestILegend extends TestCase { |
|
68 |
private static ArrayList classesToTest; |
|
69 |
transient private ILegend[] legends; |
|
70 |
|
|
71 |
private static ArrayList getClassesToTest() throws MapContextException { |
|
72 |
if (classesToTest == null) { |
|
73 |
classesToTest = new ArrayList(); |
|
74 |
|
|
75 |
TestILegend.addLegendToTest(VectorialIntervalLegend.class); |
|
76 |
TestILegend.addLegendToTest(VectorialUniqueValueLegend.class); |
|
77 |
TestILegend.addLegendToTest(SingleSymbolLegend.class); |
|
78 |
|
|
79 |
// TestILegend.addLegendToTest(QuantityByCategoryLegend.class); |
|
80 |
// TestILegend.addLegendToTest(DotDensityLegend.class); |
|
81 |
// TestILegend.addLegendToTest(ProportionalSymbolsLegend.class); |
|
82 |
// TestILegend.addLegendToTest(GraduatedSymbolLegend.class); |
|
83 |
|
|
84 |
|
|
85 |
} |
|
86 |
|
|
87 |
return classesToTest; |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* This method fills the attributes of a legend.The purpose is to ensure that the new |
|
92 |
* legend is 'full' and ready to be used for a test. |
|
93 |
* @param le |
|
94 |
* @return |
|
95 |
* @throws MapContextException |
|
96 |
*/ |
|
97 |
|
|
98 |
private static ILegend fillthelegend(ILegend le) throws MapContextException { |
|
99 |
|
|
100 |
SimpleFillSymbol mfs = new SimpleFillSymbol(); |
|
101 |
mfs.setFillColor(Color.ORANGE.darker()); |
|
102 |
mfs.setDescription("hola"); |
|
103 |
mfs.setIsShapeVisible(true); |
|
104 |
String[] cad = new String[] {"Pepe","Juan"}; |
|
105 |
|
|
106 |
if(le instanceof IVectorLegend) { |
|
107 |
IVectorLegend ssl=(IVectorLegend)le; |
|
108 |
ssl.setDefaultSymbol(mfs); |
|
109 |
} |
|
110 |
|
|
111 |
if(le instanceof IVectorialUniqueValueLegend) { |
|
112 |
IVectorialUniqueValueLegend ivuvl= (IVectorialUniqueValueLegend)le; |
|
113 |
ivuvl.setClassifyingFieldNames(cad); |
|
114 |
} |
|
115 |
|
|
116 |
if(le instanceof IVectorialIntervalLegend) { |
|
117 |
IVectorialIntervalLegend ivil=(IVectorialIntervalLegend)le; |
|
118 |
ivil.setClassifyingFieldNames(cad); |
|
119 |
} |
|
120 |
|
|
121 |
if(le instanceof IClassifiedVectorLegend) { |
|
122 |
IClassifiedVectorLegend icvl=(IClassifiedVectorLegend)le; |
|
123 |
icvl.setClassifyingFieldNames(cad); |
|
124 |
} |
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
return le; |
|
129 |
} |
|
130 |
|
|
131 |
|
|
132 |
public static void addLegendToTest(Class legendClass) throws MapContextException { |
|
133 |
try { |
|
134 |
ILegend len = (ILegend) legendClass.newInstance(); |
|
135 |
fillthelegend(len); |
|
136 |
// len.getXMLEntity(); |
|
137 |
|
|
138 |
} catch (InstantiationException e) { |
|
139 |
// TODO Auto-generated catch block |
Also available in: Unified diff