Revision 39481

View differences:

tags/v2_0_0_Build_2061/libraries/org.gvsig.symbology/prepare-workspace.xml
1
<project name="org.gvsig.initial.build" default="prepare-workspace">
2

  
3
	<dirname property="org.gvsig.initial.build.basedir" file="${ant.file.org.gvsig.initial.build}" />
4

  
5
	<property name="workspace.basedir" value="${org.gvsig.initial.build.basedir}/.." />
6
	<property name="build.basedir" value="${workspace.basedir}/org.gvsig.maven.base.build" description="Eclipse workspace location" />
7
	<property name="build.jar.version" value="1.0.8-SNAPSHOT" />
8
	<property name="build.jar.file" value="org.gvsig.maven.base.build-${build.jar.version}.jar" />
9

  
10
	<property name="ant.libs.dir" location="${build.basedir}" description="Additional ant tasks libs folder" />
11

  
12
	<target name="check-maven-base-build-available">
13
		<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" property="maven-base-build-available" />
14
	</target>
15

  
16
	<target name="get-maven-base-build-local" depends="check-maven-base-build-available" if="maven-base-build-available">
17
		<!-- Unzip de build jar file from the maven repository into the workspace root folder -->
18
		<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false">
19
			<zipfileset src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}">
20
				<patternset>
21
					<exclude name="META-INF/**" />
22
				</patternset>
23
			</zipfileset>
24
		</copy>
25
	</target>
26

  
27
	<target name="get-maven-base-build-remote" depends="check-maven-base-build-available" unless="maven-base-build-available">
28
		<mkdir dir="target" />
29

  
30
		<!-- Download the build jar file -->
31
		<get src="http://devel.gvsig.org/m2repo/j2se/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" dest="target/${build.jar.file}" verbose="true" />
32

  
33
		<!-- Unzip de build jar file into the workspace root folder -->
34
		<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false">
35
			<zipfileset src="target/${build.jar.file}">
36
				<patternset>
37
					<exclude name="META-INF/**" />
38
				</patternset>
39
			</zipfileset>
40
		</copy>
41

  
42
	</target>
43
	
44
	<target name="find.depends.natives.file">
45
	    <condition property="depends.natives.file.exists">
46
            <available file="${org.gvsig.initial.build.basedir}/DEPENDS_ON_NATIVE_LIBRARIES"/>
47
	    </condition>	
48
	</target>
49
	
50
	<target name="find.gvsig.platform.properties.file" 
51
			depends="find.depends.natives.file"
52
			if="depends.natives.file.exists">
53
	    <condition property="gvsig.platform.exists">
54
            <available file="${user.home}/.gvsig.platform.properties"/>
55
	    </condition>	
56
	</target>
57
	
58
	<target name="check.gvsig.platform.properties" 
59
			depends="find.gvsig.platform.properties.file">
60
		<fail if="depends.natives.file.exists" unless="gvsig.platform.exists">
61
ERROR!!
62
	
63
You have to define your gvSIG platform properties, 
64
by creating the file: ${user.home}/.gvsig.platform.properties
65
with the following content:
66

  
67
native_platform=linux
68
native_distribution=all
69
native_compiler=gcc4
70
native_arch=i386
71
native_libraryType=dynamic
72
export native_classifier=${native_platform}-${native_distribution}-${native_compiler}-${native_arch}-${native_libraryType}
73

  
74
Replace the fifth initial variables values with the ones appropiate 
75
to your platform.
76
	
77
If you use maven in the command line, you can use the previous file also
78
to define the MAVEN_OPTS environment variable, by adding to your 
79
.bash_rc file something like this:
80

  
81
if [ -f "${HOME}/.gvsig.platform.properties" ]
82
then
83
    . ${HOME}/.gvsig.platform.properties
84
    export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m -Dnative-classifier=${native_classifier}"
85
else
86
    export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m"
87
fi
88

  
89
It will work if you use the bash shell. In any other case or platform, you'll
90
have to define your MAVEN_OPTS environment variable and set the 
91
"native-classifier" parameter directly.
92
		</fail>			
93
	
94
	</target>
95

  
96
	<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote,check.gvsig.platform.properties">
97

  
98
		<mkdir dir="target" />
99

  
100
		<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug" />
101

  
102
		<!-- Copy the maven launchers to the workspace metadata folder -->
103
		<copy todir="${workspace.basedir}/.metadata">
104
			<fileset dir="${build.basedir}/eclipse-launchers">
105
				<exclude name="**/org.eclipse.jdt.core.prefs" />
106
				<exclude name="**/org.eclipse.core.variables.prefs" />
107
			</fileset>
108
		</copy>
109

  
110
		<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" append="true">
111
			<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.jdt.core.prefs" />
112
		</concat>
113
		<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" append="true">
114
			<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.core.variables.prefs" />
115
		</concat>
116

  
117
		<!-- Configure the eclipse workspace -->
118
		<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace" />
119

  
120
		<!-- Configure the gvSIG profile -->
121
		<ant antfile="${build.basedir}/check-gvsig-profile.xml" />
122

  
123
		<property name="user-settings-file-location" value="${user.home}/.m2/settings.xml" />
124

  
125
		<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask">
126
			<classpath>
127
				<pathelement location="${ant.libs.dir}/com.oopsconsultancy.xmltask-1.16.1.jar" />
128
			</classpath>
129
		</taskdef>
130

  
131
		<xmltask source="${user-settings-file-location}" dest="${user-settings-file-location}">
132
			<copy path="//:settings/:profiles/:profile[:id/text() = 'gvsig-install']/:properties/:gvsig.install.dir/text()" property="current-gvsig-location" />
133
		</xmltask>
134

  
135
		<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" />
136
		<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" />
137

  
138
		<!-- Compile, install and generate eclipse projects -->
139
		<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse" />
140

  
141
		<echo>INFORMATION!!!</echo>
142
		<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo>
143

  
144
		<!-- TODO: copiar al proyecto de configuración general -->
145
	</target>
146

  
147
	<target name="clean">
148
		<delete dir="target" />
149
	</target>
150
	
151
</project>
0 152

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

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
	<modelVersion>4.0.0</modelVersion>
6
	<artifactId>org.gvsig.symbology</artifactId>
7
	<packaging>pom</packaging>
8
	<version>2.0.0-SNAPSHOT</version>
9
	<name>org.gvsig.symbology</name>
10
	<description>Symbology example project</description>
11
    <parent>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>org.gvsig.maven.base.pom</artifactId>
14
        <version>1.0.8-SNAPSHOT</version>
15
    </parent>
16
    <scm>
17
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/libraries/org.gvsig.symbology</connection>
18
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/libraries/org.gvsig.symbology</developerConnection>
19
        <url>https://devel.gvsig.org/redmine/projects/gvsig-desktop/repository/show/branches/v2_0_0_prep/libraries/org.gvsig.symbology</url>
20
    </scm>
21
	<developers>
22
		<developer>
23
			<id>jjdelcerro</id>
24
			<name>Joaqu?n Jos? del Cerro</name>
25
			<email>jjdelcerro@gvsig.org</email>
26
			<roles>
27
				<role>Architect</role>
28
				<role>Developer</role>
29
			</roles>
30
		</developer>
31
		<developer>
32
			<id>jbadia</id>
33
			<name>Jos? Bad?a</name>
34
			<email>badia_jos@gva.es</email>
35
			<roles>
36
				<role>Developer</role>
37
			</roles>
38
		</developer>
39
	</developers>
40
	<repositories>
41
		<repository>
42
			<id>gvsig-public-http-repository</id>
43
			<name>gvSIG maven public HTTP repository</name>
44
            <url>http://devel.gvsig.org/m2repo/j2se</url>
45
			<releases>
46
				<enabled>true</enabled>
47
				<updatePolicy>daily</updatePolicy>
48
				<checksumPolicy>warn</checksumPolicy>
49
			</releases>
50
			<snapshots>
51
				<enabled>true</enabled>
52
				<updatePolicy>daily</updatePolicy>
53
				<checksumPolicy>warn</checksumPolicy>
54
			</snapshots>
55
		</repository>
56
	</repositories>
57
    <dependencyManagement>
58
        <dependencies>          
59
            <dependency>
60
                <groupId>org.gvsig</groupId>
61
                <artifactId>org.gvsig.core.maven.dependencies</artifactId>
62
                <version>2.0.1-SNAPSHOT</version>
63
                <type>pom</type>
64
                <scope>import</scope>
65
            </dependency>
66
        </dependencies>
67
    </dependencyManagement>
68
	<dependencies>
69
		<dependency>
70
			<groupId>org.gvsig</groupId>
71
			<artifactId>org.gvsig.tools.lib</artifactId>
72
            <scope>compile</scope>
73
		</dependency>
74
		<dependency>
75
			<groupId>org.gvsig</groupId>
76
			<artifactId>org.gvsig.tools.lib</artifactId>
77
			<type>test-jar</type>
78
		</dependency>	
79
	</dependencies>
80

  
81
	<modules>
82
		<module>org.gvsig.symbology.lib</module>
83
		<module>org.gvsig.symbology.swing</module>
84
		<module>org.gvsig.symbology.main</module>
85
	</modules>
86
</project>
0 87

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

  
5
Perform the following steps:
6

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

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

  
17
Those steps are only needed once per workspace.     
18

  
0 19

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

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

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

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.symbology/org.gvsig.symbology.main/src/main/java/org/gvsig/symbology/main/Main.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.symbology.main;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.Dimension;
26
import java.awt.event.ActionEvent;
27

  
28
import javax.swing.AbstractAction;
29
import javax.swing.Action;
30
import javax.swing.JButton;
31
import javax.swing.JFrame;
32
import javax.swing.JMenu;
33
import javax.swing.JMenuBar;
34
import javax.swing.JMenuItem;
35
import javax.swing.JToolBar;
36
import javax.swing.WindowConstants;
37

  
38
import org.gvsig.symbology.SymbologyLocator;
39
import org.gvsig.symbology.SymbologyManager;
40
import org.gvsig.symbology.swing.SymbologySwingLocator;
41
import org.gvsig.symbology.swing.SymbologySwingManager;
42
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
43
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
45

  
46
/**
47
 * Main executable class for testing the Symbology library.
48
 * 
49
 * @author gvSIG Team
50
 * @version $Id$
51
 */
52
public class Main {
53

  
54
    private static final Logger LOG = LoggerFactory.getLogger(Main.class);
55

  
56
    private SymbologyManager manager;
57
    private SymbologySwingManager swingManager;
58

  
59
    public static void main(String args[]) {
60
        new DefaultLibrariesInitializer().fullInitialize();
61
        Main main = new Main();
62
        main.show();
63
    }
64

  
65
    @SuppressWarnings("serial")
66
    public void show() {
67
        manager = SymbologyLocator.getSymbologyManager();
68
        swingManager = SymbologySwingLocator.getSwingManager();
69

  
70
        Action showCookie = new AbstractAction("Get a Symbology") {
71

  
72
            public void actionPerformed(ActionEvent e) {
73
                showSymbology(manager);
74
            }
75
        };
76

  
77
        Action exit = new AbstractAction("Exit") {
78

  
79
            public void actionPerformed(ActionEvent e) {
80
                System.exit(0);
81
            }
82
        };
83

  
84
        JFrame frame = new JFrame("Symbology example app");
85
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
86

  
87
        // Create the menu bar.
88
        JMenuBar menuBar = new JMenuBar();
89

  
90
        // Build the menu.
91
        JMenu menuFile = new JMenu("File");
92
        menuFile.add(new JMenuItem(showCookie));
93
        menuFile.add(new JMenuItem(exit));
94

  
95
        menuBar.add(menuFile);
96

  
97
        JToolBar toolBar = new JToolBar();
98
        toolBar.add(new JButton(showCookie));
99
        toolBar.add(new JButton(exit));
100

  
101
        frame.setPreferredSize(new Dimension(200, 100));
102
        frame.setJMenuBar(menuBar);
103
        frame.add(toolBar, BorderLayout.PAGE_START);
104

  
105
        // Display the window.
106
        frame.pack();
107
        frame.setVisible(true);
108
    }
109

  
110
    public void showSymbology(SymbologyManager manager) {
111
//        try {
112
//            SymbologyService service =
113
//                (SymbologyService) manager.getSymbologyService();
114
//            JSymbologyServicePanel panel =
115
//                swingManager.createSymbology(service);
116
//            swingManager.getWindowManager().showWindow(panel, "Symbology",
117
//                SymbologyWindowManager.MODE_WINDOW);
118
//
119
//        } catch (ServiceException e) {
120
//            LOG.error("Error showing a Symbology", e);
121
//        }
122
    }
123

  
124
}
0 125

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

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

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

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

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

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

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

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

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.symbology/org.gvsig.symbology.main/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.symbology.main</artifactId>
6
	<packaging>jar</packaging>
7
	<name>org.gvsig.symbology.main</name>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.symbology</artifactId>
11
		<version>2.0.0-SNAPSHOT</version>
12
	</parent>
13
	<dependencies>
14
		<dependency>
15
			<groupId>org.gvsig</groupId>
16
			<artifactId>org.gvsig.symbology.lib.api</artifactId>
17
			<version>2.0.0-SNAPSHOT</version>
18
            <scope>compile</scope>
19
		</dependency>
20
		<dependency>
21
			<groupId>org.gvsig</groupId>
22
			<artifactId>org.gvsig.symbology.lib.impl</artifactId>
23
			<version>2.0.0-SNAPSHOT</version>
24
			<scope>runtime</scope>
25
		</dependency>
26
		<dependency>
27
			<groupId>org.gvsig</groupId>
28
			<artifactId>org.gvsig.symbology.swing.api</artifactId>
29
			<version>2.0.0-SNAPSHOT</version>
30
            <scope>compile</scope>
31
		</dependency>
32
		<dependency>
33
			<groupId>org.gvsig</groupId>
34
			<artifactId>org.gvsig.symbology.swing.impl</artifactId>
35
			<version>2.0.0-SNAPSHOT</version>
36
			<scope>runtime</scope>
37
		</dependency>
38
        <dependency>
39
            <groupId>org.slf4j</groupId>
40
            <artifactId>slf4j-api</artifactId>
41
            <scope>compile</scope>
42
        </dependency>
43
	</dependencies>
44
</project>
0 45

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4
		 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5

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

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

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/test/java/org/gvsig/symbology/impl/DefaultSymbologyManagerTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.symbology.impl;
23

  
24
import org.gvsig.symbology.SymbologyManager;
25
import org.gvsig.symbology.SymbologyManagerTest;
26

  
27
/**
28
 * {@link SymbologyManager} API compatibility tests for the
29
 * {@link DefaultSymbologyManager} implementation.
30
 * 
31
 * @author gvSIG Team
32
 * @version $Id$
33
 */
34
public class DefaultSymbologyManagerTest extends SymbologyManagerTest {
35

  
36
    // Nothing to add
37
}
0 38

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/symbol/TestISymbol.java
1
package org.gvsig.symbology.fmap.mapcontext.rendering.symbol;
2

  
3
import java.awt.Color;
4
import java.lang.reflect.Field;
5
import java.util.ArrayList;
6
import java.util.Random;
7

  
8
import junit.framework.TestSuite;
9

  
10
import org.gvsig.fmap.geom.Geometry;
11
import org.gvsig.fmap.geom.GeometryLocator;
12
import org.gvsig.fmap.geom.GeometryManager;
13
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
14
import org.gvsig.fmap.geom.Geometry.TYPES;
15
import org.gvsig.fmap.geom.exception.CreateGeometryException;
16
import org.gvsig.fmap.geom.primitive.Curve;
17
import org.gvsig.fmap.geom.primitive.GeneralPathX;
18
import org.gvsig.fmap.geom.primitive.Point;
19
import org.gvsig.fmap.geom.primitive.Surface;
20
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
21
import org.gvsig.fmap.mapcontext.rendering.symbols.ITextSymbol;
22
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
23
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
24
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
25
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
26

  
27
/**
28
 * Integration test to ensure that the symbols follow the rules that follow the
29
 * managing of them by the application.
30
 *
31
 * @author jaume dominguez faus - jaume.dominguez@iver.es
32
 */
33

  
34

  
35
public class TestISymbol extends AbstractLibraryAutoInitTestCase {
36
    private static ArrayList classesToTest;//<AbstractSymbolTestCase>
37
    transient private ISymbol[] symbols;
38

  
39
    public static TestSuite suite() {
40
    	TestSuite suite = new TestSuite("Integration test for com.iver.cit.gvsig.fmap.core.ISymbol");
41
        suite.addTestSuite(TestISymbol.class);
42
        suite.addTestSuite(TestDrawMarkers.class);
43
        suite.addTestSuite(TestDrawLines.class);
44
        suite.addTestSuite(TestDrawFills.class);
45

  
46
        return suite;
47
    }
48

  
49
    protected void doSetUp() throws Exception {
50
    	addSymbols();
51
    	symbols = getNewSymbolInstances();
52
    }
53
    
54
    public static void addSymbols() {    	
55
    	addSymbolTest(new SimpleFillSymbolTest());
56
    	addSymbolTest(new SimpleLineSymbolTest());
57
    	addSymbolTest(new SimpleMarkerSymbolTest());
58
    	addSymbolTest(new SimpleTextSymbolTest());
59
    }
60
    
61

  
62
    public static void addSymbolTest(AbstractSymbolTestCase symbolTestClass) {
63
    	if (classesToTest == null) classesToTest = new ArrayList(); //<AbstractSymbolTestCase>
64

  
65
    	classesToTest.add(symbolTestClass);
66
    }
67

  
68
    public static ISymbol[] getNewSymbolInstances() {
69
        ISymbol[] symbols = new ISymbol[classesToTest.size()];
70
        for (int i = 0; i < symbols.length; i++) {
71
        	symbols[i] = (ISymbol)((AbstractSymbolTestCase)classesToTest.get(i)).newInstance();
72
        }
73
        return symbols;
74
    }
75

  
76
    public void testPointSuitability() throws InstantiationException, IllegalAccessException, CreateGeometryException {
77
    	GeometryManager geomManager = GeometryLocator.getGeometryManager();
78
    	Point point = (Point)geomManager.create(TYPES.POINT, SUBTYPES.GEOM2D);
79
    	final Geometry dummyPointGeom = point;
80
        for (int i = 0; i < symbols.length; i++) {
81
            // text symbols are suitable for everything
82
            if (symbols[i] instanceof ITextSymbol) {
83
                assertTrue(symbols[i].getClass().getName()+" should be suitable for "+dummyPointGeom,
84
                        symbols[i].isSuitableFor(dummyPointGeom));
85
            } else
86

  
87
            // marker symbols are suitable for points
88
            if (symbols[i] instanceof IMarkerSymbol) {
89
                assertTrue(symbols[i].getClass().getName()+" should be suitable for "+dummyPointGeom,
90
                        symbols[i].isSuitableFor(dummyPointGeom));
91
            } else {
92
                assertFalse(symbols[i].getClass().getName()+" should NOT be suitable for "+dummyPointGeom,
93
                        symbols[i].isSuitableFor(dummyPointGeom));
94
            }
95
        }
96
    }
97

  
98
    public void testLineSuitability() throws InstantiationException, IllegalAccessException, CreateGeometryException {
99
    	GeometryManager geomManager = GeometryLocator.getGeometryManager();
100
    	Curve curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
101
		curve.setGeneralPath(new GeneralPathX());
102
    	final Geometry dummyLineGeom = curve;
103
        for (int i = 0; i < symbols.length; i++) {
104
            // text symbols are suitable for everything
105
            if (symbols[i] instanceof ITextSymbol) {
106
                assertTrue(symbols[i].getClass().getName()+" should be suitable for "+dummyLineGeom,
107
                        symbols[i].isSuitableFor(dummyLineGeom));
108
            } else
109

  
110
            // line symbols are suitable for line
111
            if (symbols[i] instanceof ILineSymbol) {
112
                assertTrue(symbols[i].getClass().getName()+" should be suitable for "+dummyLineGeom,
113
                        symbols[i].isSuitableFor(dummyLineGeom));
114
            } else {
115
                assertFalse(symbols[i].getClass().getName()+" should NOT be suitable for "+dummyLineGeom,
116
                        symbols[i].isSuitableFor(dummyLineGeom));
117
            }
118
        }
119
    }
120

  
121
    public void testPolygonSuitability() throws InstantiationException, IllegalAccessException, CreateGeometryException {
122
    	GeometryManager geomManager = GeometryLocator.getGeometryManager();
123
    	Surface surface = (Surface)geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
124
    	surface.setGeneralPath(new GeneralPathX());
125
        final Geometry dummyPolygonGeom = surface;
126
        for (int i = 0; i < symbols.length; i++) {
127

  
128
            // text symbols are suitable for everything
129
            if (symbols[i] instanceof ITextSymbol) {
130
                assertTrue(symbols[i].getClass().getName()+" should be suitable for "+dummyPolygonGeom,
131
                        symbols[i].isSuitableFor(dummyPolygonGeom));
132
            } else
133

  
134
            // fill symbols are suitable for polygons
135
            if (symbols[i] instanceof IFillSymbol) {
136
                assertTrue(symbols[i].getClass().getName()+" should be suitable for "+dummyPolygonGeom,
137
                        symbols[i].isSuitableFor(dummyPolygonGeom));
138
            } else {
139
                assertFalse(symbols[i].getClass().getName()+" should NOT be suitable for "+dummyPolygonGeom,
140
                        symbols[i].isSuitableFor(dummyPolygonGeom));
141
            }
142
        }
143
    }
144

  
145
    /**
146
     * tests whether the symbols were correctly configured to work with
147
     * different kinds of shapes.
148
     */
149
    public void testGeneralSuitability() {
150

  
151
        for (int i = 0; i < symbols.length; i++) {
152
            // text symbols are suitable for everything
153
            if (symbols[i] instanceof ITextSymbol) {
154
                assertTrue(symbols[i].getClass().getName()+" should be suitable for "+null,
155
                        symbols[i].isSuitableFor(null));
156
            } else {
157
                try {
158
                    symbols[i].isSuitableFor(null);
159
                    fail("Exception was not thrown");
160

  
161
                } catch (NullPointerException npEx) {
162
                    // this is correct!
163
                }
164
            }
165
        }
166
    }
167

  
168
    /**
169
     * ensures that symbols defined which can of FShape is the symbol
170
     */
171
    public void testSymbolTypeDefinition() {
172
        for (int i = 0; i < symbols.length; i++) {
173
            assertFalse("Symbol no. "+i+" '"+symbols[i].getClass().getName()+"'",
174
                        symbols[i].getSymbolType() == 0);
175

  
176
        }
177
    }
178

  
179
    /**
180
     * ensures that any symbol that is suitable for markers declares its type
181
     * as FShape.POINT or FShape.MULTI
182
     *
183
     */
184
    public void testMarkerSymbolTypeDefinition() {
185
        for (int i = 0; i < symbols.length; i++) {
186
            if (symbols[i] instanceof IMarkerSymbol) {
187
                assertTrue("Symbol no. "+i+" '"+symbols[i].getClass().getName()+"'",
188
                        symbols[i].getSymbolType() == Geometry.TYPES.POINT
189
                        || symbols[i].getSymbolType() == Geometry.TYPES.GEOMETRY);
190
            }
191
        }
192
    }
193

  
194
    /**
195
     * ensures that any symbol that is suitable for lines declares its type
196
     * as FShape.LINE or FShape.MULTI
197
     *
198
     */
199
    public void testLineSymbolTypeDefinition() {
200
        for (int i = 0; i < symbols.length; i++) {
201
            if (symbols[i] instanceof ILineSymbol) {
202
                assertTrue("Symbol no. "+i+" '"+symbols[i].getClass().getName()+"'",
203
                        symbols[i].getSymbolType() == Geometry.TYPES.CURVE
204
                        || symbols[i].getSymbolType() == Geometry.TYPES.GEOMETRY);
205
            }
206
        }
207
    }
208

  
209
    /**
210
     * ensures that any symbol that is suitable for fills declares its type
211
     * as POLYGON or Geometry.TYPES.GEOMETRY
212
     *
213
     */
214
    public void testFillSymbolTypeDefinition() {
215
        for (int i = 0; i < symbols.length; i++) {
216
            if (symbols[i] instanceof IFillSymbol) {
217
                assertTrue("Symbol no. "+i+" '"+symbols[i].getClass().getName()+"'",
218
                        symbols[i].getSymbolType() == Geometry.TYPES.SURFACE
219
                        || symbols[i].getSymbolType() == Geometry.TYPES.GEOMETRY);
220
            }
221
        }
222
    }
223

  
224
//    /**
225
//     * ensures that any symbol has a description in its persistence
226
//     * (very important)
227
//     */
228
//    public void testDescription() {
229
//        for (int i = 0; i < symbols.length; i++) {
230
//            try {
231
//				assertTrue(symbols[i].getClass().getName() + " does not declare a description in its XMLEntity",
232
//				        symbols[i].getXMLEntity().contains("desc"));
233
//			} catch (XMLException e) {
234
//				// TODO Auto-generated catch block
235
//				e.printStackTrace();
236
//			}
237
//        }
238
//    }
239

  
240
//    /**
241
//     * ensures that any symbol has an isShapeVisible field in its persistence
242
//     * (very important)
243
//     */
244
//    public void testIsShapeVisible() {
245
//        for (int i = 0; i < symbols.length; i++) {
246
//            try {
247
//				assertTrue(symbols[i].getClass().getName() + " does not declare the isShapeVisible field in its XMLEntity",
248
//				        symbols[i].getXMLEntity().contains("isShapeVisible"));
249
//			} catch (XMLException e) {
250
//				// TODO Auto-generated catch block
251
//				e.printStackTrace();
252
//			}
253
//        }
254
//    }
255

  
256
    /**
257
     * ensures that the symbol is self-defining
258
     * @throws Exception 
259
     */
260
    public void testSymbolSelfDefinition() throws Exception {
261
        for (int i = 0; i < symbols.length; i++) {
262
            final ISymbol theSymbol = symbols[i];
263
            ISymbol cloneSymbol= (ISymbol) theSymbol.clone();
264
				//cloneSymbol = SymbologyFactory.createSymbolFromXML(theSymbol.getXMLEntity(), null);
265
            
266
            assertTrue(theSymbol.getClass().getName()+ " wrong class name declaration in getXMLEntity() ",
267
                    cloneSymbol.getClass().equals(theSymbol.getClass()));
268
            final Field[] theSymbolFields = theSymbol.getClass().getFields();
269
            for (int j = 0; j < theSymbolFields.length; j++) {
270
                final Field fi = theSymbolFields[j];
271
                final boolean wasAccessible = fi.isAccessible();
272
                fi.setAccessible(true);
273

  
274
                try {
275
                    assertTrue(theSymbol.getClass().getName() + " fails or misses clonning the field " +fi.getName(),
276
                            fi.get(theSymbol).equals(fi.get(cloneSymbol)));
277
                } catch (IllegalArgumentException e) {
278
                    fail();
279
                } catch (IllegalAccessException e) {
280
                    fail();
281
                }
282
                fi.setAccessible(wasAccessible);
283
            }
284
        }
285
    }
286

  
287
    /**
288
     * Check one pixel acceleration consistency. Checks that the color returned
289
     * in RGB matches the color of the symbol set.
290
     *
291
     */
292
    public void testOnePointRGB() {
293
    	Random random = new Random(System.currentTimeMillis());
294

  
295
        for (int i = 0; i < symbols.length; i++) {
296
            if (symbols[i] instanceof IMarkerSymbol) {
297
                IMarkerSymbol marker = (IMarkerSymbol) symbols[i];
298
                marker.setColor(new Color(random.nextInt()>>8));
299
                assertTrue("Symbol no. "+i+" '"+symbols[i].getClass().getName()+"' RGB value mismatch for getOnePointRBG() and getColor().getRGB()",
300
                        symbols[i].getOnePointRgb() == marker.getColor().getRGB());
301

  
302
            }
303

  
304
            if (symbols[i] instanceof ILineSymbol) {
305
                ILineSymbol line = (ILineSymbol) symbols[i];
306
                line.setLineColor(new Color(random.nextInt()>>8));
307
                assertTrue("Symbol no. "+i+" '"+symbols[i].getClass().getName()+"' RGB value mismatch for getOnePointRBG() and getColor().getRGB()",
308
                        symbols[i].getOnePointRgb() == line.getColor().getRGB());
309
            }
310

  
311
            if (symbols[i] instanceof IFillSymbol) {
312
                IFillSymbol fill = (IFillSymbol) symbols[i];
313
                boolean outlined = fill.getOutline() != null;
314
                if (!outlined)
315
                	fill.setFillColor(new Color(random.nextInt()>>8));
316
                else
317
                	fill.getOutline().setLineColor(new Color(random.nextInt()>>8));
318
                assertTrue("Symbol no. "+i+" '"+symbols[i].getClass().getName()+"' RGB value mismatch for getOnePointRBG() and getColor().getRGB()",
319
                        symbols[i].getOnePointRgb() == ((outlined) ? fill.getOutline().getColor().getRGB() : fill.getFillColor().getRGB()));
320
            }
321

  
322
            if (symbols[i] instanceof ITextSymbol) {
323
            	ITextSymbol text = (ITextSymbol) symbols[i];
324
            	text.setTextColor(new Color(random.nextInt()>>8));
325
                assertTrue("Symbol no. "+i+" '"+symbols[i].getClass().getName()+"' RGB value mismatch for getOnePointRBG() and getColor().getRGB()",
326
                        symbols[i].getOnePointRgb() == text.getTextColor().getRGB());
327
            }
328

  
329
        }
330
    }
331

  
332
    /**
333
     * ensures that any symbol provides a version of itself to use when the
334
     * feature is selected
335
     *
336
     */
337
    public void testSymbolForSelection() {
338
    	for (int i = 0; i < symbols.length; i++) {
339
			assertNotNull("Symbol no. "+i+" '"+symbols[i].getClass().getName()+" does not define any derived symbol for selection", symbols[i].getSymbolForSelection());
340
		}
341
    }
342
}
0 343

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/symbol/SimpleMarkerSymbolTest.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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.symbol;
42

  
43
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.SimpleMarkerSymbol;
44

  
45
public class SimpleMarkerSymbolTest extends AbstractSymbolTestCase{
46
	public SimpleMarkerSymbolTest() {
47
		super(SimpleMarkerSymbol.class);
48
	}
49
}
0 50

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/symbol/TestDrawMarkers.java
1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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.symbol;
42

  
43
import java.awt.Color;
44
import java.awt.Dimension;
45
import java.awt.Graphics2D;
46
import java.awt.Rectangle;
47
import java.awt.geom.AffineTransform;
48
import java.awt.geom.Point2D;
49
import java.awt.image.BufferedImage;
50
import java.util.ArrayList;
51
import java.util.Random;
52

  
53
import org.gvsig.compat.CompatLocator;
54
import org.gvsig.fmap.geom.GeometryLocator;
55
import org.gvsig.fmap.geom.GeometryManager;
56
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
57
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
58
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
59
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
60
import org.slf4j.Logger;
61
import org.slf4j.LoggerFactory;
62

  
63
/**
64
 * Integration test to test that Marker symbols always draw in the same
65
 * place respecting size constraints.
66
 *
67
 * @author jaume dominguez faus - jaume.dominguez@iver.es
68
 */
69
public class TestDrawMarkers extends AbstractLibraryAutoInitTestCase {
70
	private GeometryManager geomManager;
71
	private static final Logger logger = LoggerFactory.getLogger(TestDrawMarkers.class);
72
	private IMarkerSymbol[] symbols;
73
	private final Dimension sz = new Dimension(400, 400);
74
	private org.gvsig.fmap.geom.primitive.Point centerP = null;
75
	private static final int OUTTER_TOLERANCE = 1;
76
	private static final int INNER_TOLERANCE = 1;
77

  
78
	private static final double sizes[] = new double[] {
79
		200,
80
		100,
81
		50,
82
		30,
83
		16,
84
		5,
85
		3,
86
		2,
87
		// smaller sizes don't make any sense
88

  
89
	};
90

  
91
	protected void doSetUp() throws Exception {
92
		geomManager = GeometryLocator.getGeometryManager();
93

  
94
		centerP = geomManager.createPoint(sz.width/2, sz.height/2, SUBTYPES.GEOM2D);
95
		
96
		ISymbol[] allSymbols = TestISymbol.getNewSymbolInstances();
97
		// Filter the marker ones
98
		ArrayList symbols = new ArrayList();
99

  
100
		for (int i = 0; i < allSymbols.length; i++) {
101
			if (allSymbols[i] instanceof IMarkerSymbol) {
102
				IMarkerSymbol sym = (IMarkerSymbol) allSymbols[i];
103
				symbols.add(sym);
104

  
105
			}
106
		}
107
		this.symbols = (IMarkerSymbol[]) symbols.toArray(new IMarkerSymbol[symbols.size()]);
108
	}
109

  
110
	public void testDrawingSize() {
111
		for (int i = 0; i < symbols.length; i++) {
112
			for (int j = 0; j < sizes.length; j++) {
113
				// new blank buffered image
114
				BufferedImage bi = CompatLocator.getGraphicsUtils().createBufferedImage(sz.width, sz.height, BufferedImage.TYPE_INT_ARGB);
115

  
116
				// the graphics for the image, so we can draw onto the buffered image
117
				Graphics2D g = bi.createGraphics();
118

  
119
				IMarkerSymbol testSymbol = symbols[i];
120
				testSymbol.setColor(Color.YELLOW);
121
				testSymbol.setSize(sizes[j]);
122
				String name = testSymbol.getClass().getName().substring(
123
						testSymbol.getClass().getName().lastIndexOf('.')+1,
124
						testSymbol.getClass().getName().length());
125

  
126
				testSymbol.draw(g, new AffineTransform(), centerP, null, null);
127

  
128
				Rectangle wrappingRect = new Rectangle(
129
						(int) (centerP.getX()-sizes[j]/2),
130
						(int) (centerP.getY()-sizes[j]/2),
131
						(int) (sizes[j]),
132
						(int) (sizes[j]));
133

  
134
//				if (testSymbol instanceof CharacterMarkerSymbol)
135
//					continue;
136

  
137

  
138

  
139

  
140
				assertFalse("fails sizing marker, too big ("+name+", "+sizes[j]+"px)", isOutsideRect(bi, wrappingRect, OUTTER_TOLERANCE ));
141
				assertTrue("fails sizing marker, too small ("+name+", "+sizes[j]+"px) \n" +
142
						"\t - forgot to enable ANTIALIASING?", fitsInsideRect(bi, wrappingRect, INNER_TOLERANCE));
143

  
144

  
145
			}
146
		}
147
	}
148

  
149
	public void testDrawingOffset() {
150
		// TODO: uncomment this test and make it run successfully
151
//		Random random = new Random(System.currentTimeMillis());
152
//		for (int i = 0; i < symbols.length; i++) {
153
//			for (int j = 0; j < sizes.length; j++) {
154
//				// new blank buffered image
155
//				BufferedImage bi = CompatLocator.getGraphicsUtils().createBufferedImage(sz.width, sz.height, BufferedImage.TYPE_INT_ARGB);
156
//
157
//
158
//				// the graphics for the image, so we can draw onto the buffered image
159
//				Graphics2D g = bi.createGraphics();
160
//
161
//				IMarkerSymbol testSymbol = symbols[i];
162
//				testSymbol.setColor(Color.YELLOW);
163
//				testSymbol.setSize(sizes[j]);
164
//
165
//				String name = testSymbol.getClass().getName().substring(
166
//						testSymbol.getClass().getName().lastIndexOf('.')+1,
167
//						testSymbol.getClass().getName().length());
168
//
169
//				double xOffset = (random.nextDouble()-0.5)*sz.width;
170
//				double yOffset = (random.nextDouble()-0.5)*sz.height;
171
//
172
//				testSymbol.setOffset(new Point2D.Double(xOffset, yOffset));
173
//
174
//				Rectangle wrappingRect = new Rectangle(
175
//						(int) ((centerP.getX()-sizes[j]/2) + xOffset),
176
//						(int) ((centerP.getY()-sizes[j]/2) + yOffset),
177
//						(int) (sizes[j]),
178
//						(int) (sizes[j]));
179
//
180
////				if (testSymbol instanceof CharacterMarkerSymbol)
181
////					continue;
182
//
183
//
184
//
185
//				testSymbol.draw(g, new AffineTransform(), centerP, null, null);
186
//				assertFalse("fails sizing marker, too big ("+name+", "+sizes[j]+"px)", isOutsideRect(bi, wrappingRect, OUTTER_TOLERANCE ));
187
//				assertTrue("fails sizing marker, too small ("+name+", "+sizes[j]+"px) \n" +
188
//						"\t - forgot to enable ANTIALIASING?", fitsInsideRect(bi, wrappingRect, INNER_TOLERANCE));
189
//
190
//			}
191
//		}
192
	}
193

  
194
	public void testDrawingRotation() {
195
		// TODO implement it
196

  
197
	}
198

  
199
	private boolean fitsInsideRect(BufferedImage bi, Rectangle wrappingRect, int tolerance) {
200
		int myTolerance = Math.min(tolerance, wrappingRect.width);
201
		Rectangle myRect;
202
		if (myTolerance >= INNER_TOLERANCE) {
203
			myRect = new Rectangle(
204
					wrappingRect.x+myTolerance,
205
					wrappingRect.y+myTolerance,
206
					wrappingRect.width-myTolerance-myTolerance,
207
					wrappingRect.height-myTolerance-myTolerance);
208
		} else {
209
			myRect = new Rectangle(-1, -1, 0, 0); // just ensure it does not disturb the check
210
		}
211

  
212
		for (int i = 0; i < bi.getWidth(); i++) {
213
			for (int j = 0; j < bi.getHeight(); j++) {
214
				if (wrappingRect.contains(i,j)
215
						&& !myRect.contains(i,j)) {
216

  
217
					if (bi.getRGB(i,j) != 0)
218
						return true;
219
				}
220
			}
221
		}
222
		return false;
223
	}
224

  
225
	private boolean isOutsideRect(BufferedImage bi, Rectangle wrappingRect, int tolerance) {
226
		Rectangle myRect = new Rectangle(
227
				wrappingRect.x-tolerance,
228
				wrappingRect.y-tolerance,
229
				wrappingRect.width+tolerance+tolerance,
230
				wrappingRect.height+tolerance+tolerance);
231
		for (int i = 0; i < bi.getWidth(); i++) {
232
			for (int j = 0; j < bi.getHeight(); j++) {
233
				if (!myRect.contains(i,j))
234
					continue;
235

  
236
				if (bi.getRGB(i,j) != 0) return false;
237
			}
238
		}
239
		return true;
240
	}
241
}
242

  
243
/// paste this piece of code to produce some png files to check visually what is happening
244
//g.setColor(Color.BLUE);
245
//Rectangle myRect = new Rectangle(
246
//		wrappingRect.x+INNER_TOLERANCE,
247
//		wrappingRect.y+INNER_TOLERANCE,
248
//		wrappingRect.width-INNER_TOLERANCE-INNER_TOLERANCE,
249
//		wrappingRect.height-INNER_TOLERANCE-INNER_TOLERANCE);
250
//
251
//g.draw(myRect);
252
//g.setColor(Color.RED);
253
//g.draw(wrappingRect);
254
//try {
255
//
256
//	File dstDir = new File (System.getProperty("java.io.tmpdir")+"/prova-imatges/");
257
//	if (!dstDir.exists()) dstDir.mkdir();
258
//	ImageIO.write(bi, "png",
259
//			new File(dstDir.getAbsoluteFile()+File.separator+
260
//					name+"_size_"+sizes[j]
261
//					                    +".png"));
262
//} catch (IOException e) {
263
//	e.printStackTrace();
264
//	fail();
265
//}
266
///
0 267

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/symbol/IDrawFillSymbol.java
1
package org.gvsig.symbology.fmap.mapcontext.rendering.symbol;
2

  
3
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
4

  
5
public interface IDrawFillSymbol {
6

  
7
	IFillSymbol makeSymbolTransparent(IFillSymbol newSymbol);
8

  
9
	boolean isSuitableFor(IFillSymbol newSymbol);
10

  
11
}
0 12

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/symbol/SimpleTextSymbolTest.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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.symbol;
42

  
43
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.impl.SimpleTextSymbol;
44

  
45
public class SimpleTextSymbolTest extends AbstractSymbolTestCase{
46
	public SimpleTextSymbolTest() {
47
		super(SimpleTextSymbol.class);
48
	}
49
}
0 50

  
tags/v2_0_0_Build_2061/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/symbol/AbstractSymbolTestCase.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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.symbol;
42

  
43
import junit.framework.TestCase;
44

  
45
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
46

  
47

  
48
public abstract class AbstractSymbolTestCase extends TestCase {
49
	protected Class symClazz;
50

  
51
	public AbstractSymbolTestCase(Class symClazz) {
52
		this.symClazz = symClazz;
53
	}
54

  
55
	public ISymbol newInstance() {
56
		try {
57
			return (ISymbol) symClazz.newInstance();
58
		} catch (Exception e) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff