Revision 36104

View differences:

tags/v2_0_0_Build_2031/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" 
6
			  value="${org.gvsig.initial.build.basedir}/.."/>
7
	<property name="build.basedir" 
8
		      value="${workspace.basedir}/org.gvsig.maven.base.build"
9
		      description="Eclipse workspace location"/>
10
	<property name="build.jar.version" 
11
			 	  value="1.0.6-SNAPSHOT" />
12
	<property name="build.jar.file" 
13
		 	  value="org.gvsig.maven.base.build-${build.jar.version}.jar" />
14
	
15
	<target name="check-maven-base-build-available">
16
		<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" 
17
				   property="maven-base-build-available"/>
18
	</target>
19
	
20
	<target name="get-maven-base-build-local" 
21
			depends="check-maven-base-build-available"
22
			if="maven-base-build-available">
23
		<!-- Unzip de build jar file from the maven repository into the workspace root folder -->
24
		<unzip src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}"
25
		       dest="${workspace.basedir}">
26
		    <patternset>
27
		        <exclude name="META-INF/**"/>
28
		    </patternset>
29
		</unzip>	
30
	</target>
31
	
32
	<target name="get-maven-base-build-remote" 
33
			depends="check-maven-base-build-available"
34
			unless="maven-base-build-available">
35
		<!-- Download the build jar file -->
36
		<get src="http://gvsig-desktop.forge.osor.eu/downloads/pub/projects/gvSIG-desktop/maven-repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" 
37
			 dest="target/${build.jar.file}"
38
			 verbose="true"/>
39
		
40
		<!-- Unzip de build jar file into the workspace root folder -->
41
		<unzip src="target/${build.jar.file}"
42
		       dest="${workspace.basedir}">
43
		    <patternset>
44
		        <exclude name="META-INF/**"/>
45
		    </patternset>
46
		</unzip>	
47
	</target>
48
	
49
	<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote">
50
		
51
		<mkdir dir="target"/>
52
	
53
		<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug"/>
54
		
55
		<!-- Copy the maven launchers to the workspace metadata folder -->
56
		<copy todir="${workspace.basedir}/.metadata">
57
		    <fileset dir="${build.basedir}/eclipse-launchers"/>
58
		</copy>
59
		
60
		<!-- Configure the eclipse workspace -->
61
		<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace"/>
62

  
63
		<!-- Configure the gvSIG profile -->
64
		<ant antfile="${build.basedir}/check-gvsig-profile.xml" target="initialize"/>
65

  
66
		<!-- Compile, install and generate eclipse projects -->
67
		<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse"/>
68
		
69
		<echo>INFORMATION!!!</echo>
70
		<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo>
71
		
72
		<!-- TODO: copiar al proyecto de configuración general -->
73
	</target>
74
 	
75
	<target name="clean">
76
		<delete dir="target"/>
77
	</target>
78

  
79
</project>
0 80

  
tags/v2_0_0_Build_2031/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
	<groupId>org.gvsig</groupId>
7
	<artifactId>org.gvsig.symbology</artifactId>
8
	<packaging>pom</packaging>
9
	<version>2.0.0-SNAPSHOT</version>
10
	<name>org.gvsig.symbology</name>
11
	<description>Symbology example project</description>
12
	<url>http://gvsig-desktop.forge.osor.eu/downloads/pub/projects/gvSIG-desktop/docs/reference/org.gvsig.symbology/${project.version}/basic/org.gvsig.symbology</url>
13
	<parent>
14
		<groupId>org.gvsig</groupId>
15
		<artifactId>gvsig-base-library-pom</artifactId>
16
		<version>2.0-SNAPSHOT</version>
17
	</parent>
18

  
19
	<scm>
20
		<connection>scm:svn:https://svn.forge.osor.eu/svn/gvsig-symbology/org.gvsig.symbology/library/trunk</connection>
21
		<developerConnection>scm:svn:https://svn.forge.osor.eu/svn/gvsig-symbology/org.gvsig.symbology/library/trunk</developerConnection>
22
		<url>https://forge.osor.eu/plugins/scmsvn/viewcvs.php/org.gvsig.symbology/library/trunk/?root=gvsig-symbology</url>
23
	</scm>
24

  
25
	<developers>
26
		<developer>
27
			<id>jjdelcerro</id>
28
			<name>Joaqu?n Jos? del Cerro</name>
29
			<email>jjdelcerro@gvsig.org</email>
30
			<roles>
31
				<role>Architect</role>
32
				<role>Developer</role>
33
			</roles>
34
		</developer>
35
		<developer>
36
			<id>jbadia</id>
37
			<name>Jos? Bad?a</name>
38
			<email>badia_jos@gva.es</email>
39
			<roles>
40
				<role>Developer</role>
41
			</roles>
42
		</developer>
43
	</developers>
44

  
45
	<distributionManagement>
46
		<site>
47
			<id>gvsig-repository</id>
48
			<url>scp://shell.forge.osor.eu/home/groups/gvsig-desktop/www/downloads/pub/projects/gvSIG-desktop/docs/reference/org.gvsig.symbology/${project.version}/basic/org.gvsig.symbology</url>
49
		</site>
50
	</distributionManagement>
51
	<repositories>
52
		<repository>
53
			<id>gvsig-public-http-repository</id>
54
			<name>gvSIG maven public HTTP repository</name>
55
			<url>http://gvsig-desktop.forge.osor.eu/downloads/pub/projects/gvSIG-desktop/maven-repository</url>
56
			<releases>
57
				<enabled>true</enabled>
58
				<updatePolicy>daily</updatePolicy>
59
				<checksumPolicy>warn</checksumPolicy>
60
			</releases>
61
			<snapshots>
62
				<enabled>true</enabled>
63
				<updatePolicy>daily</updatePolicy>
64
				<checksumPolicy>warn</checksumPolicy>
65
			</snapshots>
66
		</repository>
67
	</repositories>
68
	<build>
69
		<plugins>
70
			<plugin>
71
				<groupId>org.apache.maven.plugins</groupId>
72
				<artifactId>maven-release-plugin</artifactId>
73
				<configuration>
74
					<tagBase>https://svn.forge.osor.eu/svn/gvsig-symbology/org.gvsig.symbology/library/tags</tagBase>
75
				</configuration>
76
			</plugin>
77
		</plugins>
78
	</build>
79

  
80
	<dependencies>
81
		<dependency>
82
			<groupId>org.gvsig</groupId>
83
			<artifactId>org.gvsig.tools.lib</artifactId>
84
            <scope>compile</scope>
85
		</dependency>
86
		<dependency>
87
			<groupId>org.gvsig</groupId>
88
			<artifactId>org.gvsig.tools.lib</artifactId>
89
			<type>test-jar</type>
90
		</dependency>	
91
	</dependencies>
92

  
93
	<modules>
94
		<module>org.gvsig.symbology.lib</module>
95
		<module>org.gvsig.symbology.swing</module>
96
		<module>org.gvsig.symbology.main</module>
97
	</modules>
98
	<properties>
99
        <build-dir>${basedir}/../build</build-dir>
100
    </properties>
101
</project>
0 102

  
tags/v2_0_0_Build_2031/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_2031/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
	<properties>
45
        <build-dir>${basedir}/../../build</build-dir>
46
    </properties>
47
	
48
</project>
0 49

  
tags/v2_0_0_Build_2031/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_2031/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_2031/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_2031/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_2031/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
	
21
	<properties>
22
        <build-dir>${basedir}/../../build</build-dir>
23
    </properties>
24
	
25
</project>
0 26

  
tags/v2_0_0_Build_2031/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/impl/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 API default implementation.</p>
11

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

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

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {gvSIG}  {{Task}}
26
 */
27
package org.gvsig.symbology.impl;
28

  
29
import org.gvsig.symbology.SymbologyLibrary;
30
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractClassifiedVectorLegend;
31
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractIntervalLegend;
32
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractLegend;
33
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractVectorialLegend;
34
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.FInterval;
35
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.SingleSymbolLegend;
36
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialIntervalLegend;
37
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend;
38
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy;
39
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.DefaultLabelingMethod;
40
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.LabelClass;
41
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.ZoomConstraintsImpl;
42
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.AbstractFillSymbol;
43
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.MarkerFillSymbol;
44
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.MultiLayerFillSymbol;
45
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.PictureFillSymbol;
46
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.SimpleFillSymbol;
47
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.AbstractSymbol;
48
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.MultiShapeSymbol;
49
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.AbstractLineSymbol;
50
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.MultiLayerLineSymbol;
51
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.PictureLineSymbol;
52
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.SimpleLineSymbol;
53
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.AbstractMarkerSymbol;
54
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.ArrowMarkerSymbol;
55
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.MultiLayerMarkerSymbol;
56
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.PictureMarkerSymbol;
57
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.SimpleMarkerSymbol;
58
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.AbstractStyle;
59
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ArrowDecoratorStyle;
60
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.BackgroundFileStyle;
61
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.DefaultMask;
62
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ImageStyle;
63
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.RemoteFileStyle;
64
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SVGStyle;
65
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleLineStyle;
66
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleMarkerFillPropertiesStyle;
67
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.impl.SimpleTextSymbol;
68
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.warning.impl.WarningSymbol;
69
import org.gvsig.tools.library.AbstractLibrary;
70
import org.gvsig.tools.library.LibraryException;
71
import org.gvsig.tools.util.Caller;
72
import org.gvsig.tools.util.impl.DefaultCaller;
73

  
74
/**
75
 * Library for the Basic Symbology implementation.
76
 * 
77
 * @author gvSIG team
78
 */
79
public class SymbologyDefaultImplLibrary extends AbstractLibrary {
80
	
81
    @Override
82
    public void doRegistration() {
83
        registerAsImplementationOf(SymbologyLibrary.class);
84
    }
85

  
86
	protected void doInitialize() throws LibraryException {
87
		Caller caller = new DefaultCaller();
88
		caller.add(new DefaultSymbologyManager.RegisterSymbologyManager());
89
		if (!caller.call()) {
90
			throw new LibraryException(SymbologyDefaultImplLibrary.class,
91
					caller.getExceptions());
92
		}
93
	}
94

  
95
    protected void doPostInitialize() throws LibraryException {
96
        Caller caller = new DefaultCaller();
97

  
98
        /*
99
         * Add registry of symbols 
100
         */
101
        caller.add( new SimpleFillSymbol.RegisterSymbol() );
102
        caller.add( new MultiLayerFillSymbol.RegisterSymbol() );
103
        caller.add( new SimpleLineSymbol.RegisterSymbol() );
104
        caller.add( new MultiLayerLineSymbol.RegisterSymbol() );
105
        caller.add( new SimpleMarkerSymbol.RegisterSymbol() );
106
        caller.add( new MultiLayerMarkerSymbol.RegisterSymbol() );
107
        caller.add( new SimpleTextSymbol.RegisterSymbol() );
108
        caller.add( new MultiShapeSymbol.RegisterSymbol() );
109
        caller.add( new WarningSymbol.RegisterSymbol() );
110

  
111
        caller.add( new PictureFillSymbol.RegisterSymbol() );
112
        caller.add( new PictureLineSymbol.RegisterSymbol() );
113
        caller.add( new PictureMarkerSymbol.RegisterSymbol() );
114

  
115
//        caller.add( new MarkerFillSymbol.RegisterSymbol() );
116

  
117
        /*
118
         * Add registry of legends
119
         */
120
        caller.add( new VectorialUniqueValueLegend.RegisterLegend() );
121
        caller.add( new VectorialIntervalLegend.RegisterLegend() );
122
        caller.add( new SingleSymbolLegend.RegisterLegend() );
123
        
124
        /*
125
         * Add registry of persistent styles
126
         */
127
        caller.add( new AbstractStyle.RegisterPersistence() );
128
        caller.add( new ArrowDecoratorStyle.RegisterPersistence() );
129
        caller.add( new DefaultMask.RegisterPersistence() );
130
        caller.add( new SimpleLineStyle.RegisterPersistence() );
131

  
132
        caller.add( new BackgroundFileStyle.RegisterPersistence() );
133
        caller.add( new ImageStyle.RegisterPersistence() );
134
        caller.add( new RemoteFileStyle.RegisterPersistence() );
135
        caller.add( new SVGStyle.RegisterPersistence() );
136

  
137
        /*
138
         * Add registry of persistent symbols
139
         */
140
        caller.add( new AbstractSymbol.RegisterPersistence() );
141
        caller.add( new AbstractFillSymbol.RegisterPersistence() );
142
        caller.add( new SimpleFillSymbol.RegisterPersistence() );
143
        caller.add( new MultiLayerFillSymbol.RegisterPersistence() );
144
        caller.add( new AbstractLineSymbol.RegisterPersistence() );
145
        caller.add( new SimpleLineSymbol.RegisterPersistence() );
146
        caller.add( new MultiLayerLineSymbol.RegisterPersistence() );
147
        caller.add( new AbstractMarkerSymbol.RegisterPersistence() );
148
        caller.add( new SimpleMarkerSymbol.RegisterPersistence() );
149
        caller.add( new ArrowMarkerSymbol.RegisterPersistence() );
150
        caller.add( new MultiLayerMarkerSymbol.RegisterPersistence() );
151
        caller.add( new SimpleTextSymbol.RegisterPersistence() );
152
        caller.add( new MultiShapeSymbol.RegisterPersistence() );
153
        caller.add( new WarningSymbol.RegisterPersistence() );
154
                
155
        caller.add( new PictureFillSymbol.RegisterPersistence() );
156
        caller.add( new PictureLineSymbol.RegisterPersistence() );
157
        caller.add( new PictureMarkerSymbol.RegisterPersistence() );
158
        caller.add( new MarkerFillSymbol.RegisterPersistence() );
159
        caller.add( new SimpleMarkerFillPropertiesStyle.RegisterPersistence() );
160

  
161

  
162
        /*
163
         * Add registry of persistent legends
164
         */
165
        caller.add(new AbstractLegend.RegisterPersistence());
166
        caller.add(new AbstractVectorialLegend.RegisterPersistence());
167
        caller.add(new AbstractClassifiedVectorLegend.RegisterPersistence());
168
        caller.add(new FInterval.RegisterPersistence());
169
        caller.add(new AbstractIntervalLegend.RegisterPersistence());
170
        caller.add(new VectorialIntervalLegend.RegisterPersistence());
171
        caller.add(new VectorialUniqueValueLegend.RegisterPersistence());
172
        caller.add(new SingleSymbolLegend.RegisterPersistence());
173

  
174
        /*
175
         * Add registry of labeling classes
176
         */
177
        caller.add(new ZoomConstraintsImpl.RegisterPersistence());
178
        caller.add(new LabelClass.RegisterPersistence());
179
        caller.add(new DefaultLabelingMethod.RegisterPersistence());
180
        caller.add(new AttrInTableLabelingStrategy.RegisterPersistence());
181
                 
182
        /*
183
         * Do register of all
184
         */
185
        if( !caller.call() ) {
186
        	throw new LibraryException(SymbologyDefaultImplLibrary.class, caller.getExceptions());
187
        }
188

  
189
    }
190

  
191
}
0 192

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

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {}  {{Task}}
26
*/
27
package org.gvsig.symbology.impl;
28

  
29
import java.io.IOException;
30
import java.net.URL;
31

  
32
import org.gvsig.fmap.mapcontext.rendering.legend.IInterval;
33
import org.gvsig.symbology.SymbologyLocator;
34
import org.gvsig.symbology.SymbologyManager;
35
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.FInterval;
36
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy;
37
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.IAttrInTableLabelingStrategy;
38
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.IMultiShapeSymbol;
39
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IMarkerFillSymbol;
40
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IPictureFillSymbol;
41
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.ISimpleFillSymbol;
42
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.MarkerFillSymbol;
43
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.PictureFillSymbol;
44
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.SimpleFillSymbol;
45
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.MultiShapeSymbol;
46
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.IPictureLineSymbol;
47
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ISimpleLineSymbol;
48
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.PictureLineSymbol;
49
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.SimpleLineSymbol;
50
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IPictureMarkerSymbol;
51
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.ISimpleMarkerSymbol;
52
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.PictureMarkerSymbol;
53
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.SimpleMarkerSymbol;
54
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ArrowDecoratorStyle;
55
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.DefaultMask;
56
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IArrowDecoratorStyle;
57
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IMarkerFillPropertiesStyle;
58
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IMask;
59
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ISimpleLineStyle;
60
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleLineStyle;
61
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleMarkerFillPropertiesStyle;
62
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.ISimpleTextSymbol;
63
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.impl.SimpleTextSymbol;
64
import org.gvsig.tools.util.Callable;
65

  
66
/**
67
 * Default {@link SymbologyManager} implementation.
68
 * 
69
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
70
 */
71
public class DefaultSymbologyManager implements SymbologyManager {
72

  
73
	public IInterval createInterval(double min, double max) {
74
		return new FInterval(min, max);
75
	}
76

  
77
	public static class RegisterSymbologyManager implements Callable {
78

  
79
		public Object call() throws Exception {
80

  
81
			SymbologyLocator.registerSymbologyManager(DefaultSymbologyManager.class);
82
	        
83
			return Boolean.TRUE;
84
		}
85
		
86
	}
87

  
88
	public IArrowDecoratorStyle createArrowDecoratorStyle() {
89
		return new ArrowDecoratorStyle();
90
	}
91
	
92
//	public IMarkerSymbol createMarkerSymbol(){
93
//		return new SimpleMarkerSymbol();
94
//	}
95

  
96
	public ISimpleMarkerSymbol createSimpleMarkerSymbol() {
97
		return new SimpleMarkerSymbol();
98
	}
99

  
100
	public IMask createMask() {
101
		return new DefaultMask();
102
	}
103

  
104
	public IMultiShapeSymbol createMultiShapeSymbol() {
105
		return new MultiShapeSymbol();
106
	}
107

  
108
	public ISimpleFillSymbol createSimpleFillSymbol() {
109
		return new SimpleFillSymbol();
110
	}
111

  
112
	public ISimpleLineSymbol createSimpleLineSymbol() {
113
		return new SimpleLineSymbol();
114
	}
115

  
116
	public ISimpleLineStyle createSimpleLineStyle() {
117
		return new SimpleLineStyle();
118
	}
119

  
120
	public ISimpleTextSymbol createSimpleTextSymbol() {
121
		return new SimpleTextSymbol();
122
	}
123

  
124
	public IMarkerFillPropertiesStyle createSimpleMarkerFillPropertiesStyle() {
125
		return new SimpleMarkerFillPropertiesStyle();
126
	}
127

  
128
	public IPictureFillSymbol createPictureFillSymbol(URL imageURL,
129
			URL selImageURL) throws IOException {
130
		return new PictureFillSymbol(imageURL, selImageURL);
131
	}
132

  
133
	public IPictureLineSymbol createPictureLineSymbol(URL imageURL,
134
			URL selImageURL) throws IOException {
135
		return new PictureLineSymbol(imageURL, selImageURL);
136
	}
137

  
138
	public IPictureMarkerSymbol createPictureMarkerSymbol(URL imageURL,
139
			URL selImageURL) throws IOException {
140
		return new PictureMarkerSymbol(imageURL, selImageURL);
141

  
142
	}
143

  
144
	public IMarkerFillSymbol createMarkerFillSymbol() {
145
		return new MarkerFillSymbol();
146
	}
147

  
148
	public IAttrInTableLabelingStrategy createAttrInTableLabelingStrategy() {
149
		return new AttrInTableLabelingStrategy();
150
	}
151

  
152

  
153
}
0 154

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

  
23
package org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl;
24

  
25
import java.lang.ref.Reference;
26
import java.util.ArrayList;
27
import java.util.List;
28

  
29
import org.gvsig.fmap.mapcontext.MapContextLocator;
30
import org.gvsig.fmap.mapcontext.MapContextManager;
31
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
32
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener;
33
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent;
34
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
35
import org.gvsig.tools.ToolsLocator;
36
import org.gvsig.tools.dynobject.DynStruct;
37
import org.gvsig.tools.observer.Observer;
38
import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable;
39
import org.gvsig.tools.persistence.PersistenceManager;
40
import org.gvsig.tools.persistence.PersistentState;
41
import org.gvsig.tools.persistence.exception.PersistenceException;
42
import org.gvsig.tools.util.Callable;
43
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
45

  
46
/**
47
 * Abstract class that implements the interface for legends.It is considered as
48
 * the father of all XXXLegends and will implement all the methods that these
49
 * classes had not developed.
50
 * 
51
 * @author 2005-2008 jaume dominguez faus - jaume.dominguez@iver.es
52
 * @author 2008 -    pepe vidal salvador - jose.vidal.salvador@iver.es
53
 * @author 2009-     <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
54
 */
55
public abstract class AbstractLegend implements ILegend {
56

  
57
	public static final String LEGEND_PERSISTENCE_DEFINITION_NAME = "Legend";
58

  
59
//	private static final String FIELD_LISTENERS = "listeners";
60
//
61
//	private static final String FIELD_OBSERVABLE = "observable";
62

  
63
	private static final Logger LOG =
64
			LoggerFactory.getLogger(AbstractLegend.class);
65

  
66
	/**
67
	 * List of LegendContentsChangedListener.
68
	 */
69
	private List<LegendContentsChangedListener> listeners =
70
			new ArrayList<LegendContentsChangedListener>();
71

  
72
	private BaseWeakReferencingObservable delegateDrawingObservable = 
73
			new BaseWeakReferencingObservable();
74
	
75
	private MapContextManager manager = MapContextLocator.getMapContextManager();
76

  
77
	public MapContextManager getManager() {
78
		return manager;
79
	}
80

  
81
	public SymbolManager getSymbolManager() {
82
		return manager.getSymbolManager();
83
	}
84

  
85
	public void addLegendListener(LegendContentsChangedListener listener) {
86
		if (listener != null && !listeners.contains(listener))
87
			listeners.add(listener);
88
	}
89

  
90
	public void removeLegendListener(LegendContentsChangedListener listener) {
91
		listeners.remove(listener);
92
	}
93

  
94
	public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) {
95

  
96
		for (int i = 0; i < listeners.size(); i++) {
97
			((LegendContentsChangedListener) listeners.get(i))
98
					.symbolChanged(event);
99
		}
100
	}
101

  
102
	public LegendContentsChangedListener[] getListeners() {
103
		return (LegendContentsChangedListener[]) listeners
104
				.toArray(new LegendContentsChangedListener[listeners.size()]);
105
	}
106
	
107
	public void addDrawingObserver(Observer observer) {
108
		delegateDrawingObservable.addObserver(observer);
109
	}
110

  
111
	public void deleteDrawingObserver(Observer observer) {
112
		delegateDrawingObservable.deleteObserver(observer);
113
	}
114

  
115
	public void deleteDrawingObservers() {
116
		delegateDrawingObservable.deleteObservers();
117
	}
118

  
119
	public void addObserver(Reference<Observer> ref) {
120
		delegateDrawingObservable.addObserver(ref);
121
	}
122

  
123
	public void beginComplexNotification() {
124
		delegateDrawingObservable.beginComplexNotification();
125
	}
126

  
127
	public int countObservers() {
128
		return delegateDrawingObservable.countObservers();
129
	}
130

  
131
	public void deleteObserver(Reference<Observer> ref) {
132
		delegateDrawingObservable.deleteObserver(ref);
133
	}
134

  
135
	public void disableNotifications() {
136
		delegateDrawingObservable.disableNotifications();
137
	}
138

  
139
	public void enableNotifications() {
140
		delegateDrawingObservable.enableNotifications();
141
	}
142

  
143
	public void endComplexNotification() {
144
		delegateDrawingObservable.endComplexNotification();
145
	}
146

  
147
	public boolean inComplex() {
148
		return delegateDrawingObservable.inComplex();
149
	}
150

  
151
	public boolean isEnabledNotifications() {
152
		return delegateDrawingObservable.isEnabledNotifications();
153
	}
154

  
155
	public void notifyObservers() {
156
		delegateDrawingObservable.notifyObservers();
157
	}
158

  
159
	public void notifyObservers(Object arg) {
160
		delegateDrawingObservable.notifyObservers(arg);
161
	}
162
	
163
	public ILegend cloneLegend() {
164
		try {
165
			return (ILegend) clone();
166
		} catch (CloneNotSupportedException e) {
167
			LOG.error("Error creating the clone of the legend: " + this, e);
168
		}
169
		return null;
170
    }
171

  
172
	public Object clone() throws CloneNotSupportedException {
173
		AbstractLegend legendClone = (AbstractLegend) super.clone();
174

  
175
		return legendClone;
176
	}
177

  
178
	public void loadFromState(PersistentState state)
179
			throws PersistenceException {
180
		// Do nothing
181
	}
182

  
183
	public void saveToState(PersistentState state) throws PersistenceException {
184
		// Do nothing
185
	}
186

  
187
	public static class RegisterPersistence implements Callable {
188

  
189
		public Object call() throws Exception {
190
			PersistenceManager manager = ToolsLocator.getPersistenceManager();
191
			if( manager.getDefinition(LEGEND_PERSISTENCE_DEFINITION_NAME)==null ) {
192
				@SuppressWarnings("unused")
193
				DynStruct definition = manager.addDefinition(
194
						AbstractLegend.class, 
195
						LEGEND_PERSISTENCE_DEFINITION_NAME, 
196
						LEGEND_PERSISTENCE_DEFINITION_NAME + " persistence definition", 
197
						null, 
198
						null
199
					);
200
//					// Listeners
201
//					definition.addDynFieldList(FIELD_LISTENERS)
202
//						.setClassOfItems(LegendContentsChangedListener.class);
203
//					// Observable
204
//					definition.addDynFieldObject(FIELD_OBSERVABLE)
205
//						.setClassOfValue(BaseWeakReferencingObservable.class);
206
			}
207
			return Boolean.TRUE;
208
		}
209
		
210
	}
211

  
212
}
0 213

  
tags/v2_0_0_Build_2031/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/impl/NaturalIntervalGenerator.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.impl;
42

  
43
import java.util.ArrayList;
44
import java.util.List;
45

  
46
import org.gvsig.fmap.dal.exception.DataException;
47
import org.gvsig.tools.dispose.DisposableIterator;
48
import org.gvsig.fmap.dal.feature.Feature;
49
import org.gvsig.fmap.dal.feature.FeatureQuery;
50
import org.gvsig.fmap.dal.feature.FeatureSet;
51
import org.gvsig.fmap.dal.feature.FeatureStore;
52
import org.gvsig.fmap.dal.feature.FeatureType;
53

  
54
/**
55
 * Calcula los intervalos naturales.
56
 *
57
 * @author Vicente Caballero Navarro
58
 */
59
public class NaturalIntervalGenerator {
60
//	private DataSource ds;
61
	private String msFieldName;
62
	private int miNumIntervalosSolicitados;
63
	private int miNumIntervalosGenerados;
64
	private double[] mdaValoresRuptura;
65
	private double[] mdaValInit;
66
	private FeatureStore featureStore;
67

  
68
	/**
69
	 * Crea un nuevo IntervalGenerator.
70
	 *
71
	 * @param layer AlphanumericData
72
	 * @param field Nombre del campo.
73
	 * @param numIntervals N�mero de intervalos.
74
	 */
75
	public NaturalIntervalGenerator(FeatureStore fs, String field,
76
		int numIntervals) {
77
		featureStore = fs;
78
		msFieldName = field;
79
		miNumIntervalosSolicitados = numIntervals;
80
	}
81

  
82
	/**
83
	 * Esta funci�n busca en el vector de datos la posici�n que le corresponde
84
	 * al valor almacenado en vdValor y devuelve dicha posici�n en
85
	 * vdValorAInsertar. Para hallar la posici�n se realiza una b�squeda
86
	 * binaria. Si se trata de un elemento que ya est� en el vector devolvemos
87
	 * el �ndice que le corresponde en rlIndiceCorrespondiente y false en
88
	 * rbNuevoElemento. Si se trata de un nuevo elemento que hay que
89
	 * insertar... devolvemos el �ndice en el que ir�a y True en
90
	 * rbNuevoElemento En caso de que ocurra alg�n error devuelve false
91
	 *
92
	 * @param rVectorDatos ArrayList con los datos.
93
	 * @param vdValorAInsertar Valor a insertar.
94
	 * @param rlIndiceCorrespondiente �ndice.
95
	 * @param rbNuevoElemento True si es un nuevo elemento.
96
	 *
97
	 * @return True si ha conseguido correctamente la posici�n en el vector.
98
	 */
99
	private boolean mbObtenerPosicionEnVector(
100
			List<udtDatosEstudio> rVectorDatos,
101
		double vdValorAInsertar, int[] rlIndiceCorrespondiente,
102
		boolean[] rbNuevoElemento) {
103
		int llIndiceIzq;
104
		int llIndiceDer;
105
		int llMedio;
106

  
107
		double ldValorComparacion;
108

  
109
		rbNuevoElemento[0] = false;
110
		rlIndiceCorrespondiente[0] = -1;
111

  
112
		//'Si el vector estiviese vac�o... (tuviese un s�lo elemento y el n�mero de coincidencias fuese 0)
113
		if (rVectorDatos.size() == 1) {
114
			if (((udtDatosEstudio) rVectorDatos.get(0)).Coincidencias == 0) {
115
				rlIndiceCorrespondiente[0] = 0;
116
				rbNuevoElemento[0] = false; //'No tenemos que a�adir un nuevo elemento al vector
117

  
118
				return true;
119
			}
120
		}
121

  
122
		llIndiceIzq = 0;
123
		llIndiceDer = rVectorDatos.size() - 1;
124
		llMedio = (llIndiceIzq + llIndiceDer) / 2; //'Divisi�n entera!
125

  
126
		while (llIndiceIzq <= llIndiceDer) {
127
			//'Coger el valor situado en la mitad de la zona de b�squeda como valor de comparaci�n
128
			ldValorComparacion = ((udtDatosEstudio) rVectorDatos.get(llMedio)).Valor;
129

  
130
			//'Si el valor a insertar es mayor que el valor de comparaci�n...
131
			if (vdValorAInsertar > ldValorComparacion) {
132
				//      'La zona de b�squeda queda restringida a la parte de la derecha
133
				llIndiceIzq = llMedio + 1;
134
				llMedio = (llIndiceIzq + llIndiceDer) / 2;
135

  
136
				//    'Si el valor a insertar es menor que el valor de comparaci�n...
137
			} else if (vdValorAInsertar < ldValorComparacion) {
138
				//          'La zona de b�squeda queda restringida a la parte de la derecha
139
				llIndiceDer = llMedio - 1;
140
				llMedio = (llIndiceIzq + llIndiceDer) / 2;
141

  
142
				//        'Si el valor de comparaci�n coincide con el valor a insertar
143
			} else if (vdValorAInsertar == ldValorComparacion) {
144
				rlIndiceCorrespondiente[0] = llMedio;
145
				rbNuevoElemento[0] = false;
146

  
147
				return true;
148
			}
149
		}
150

  
151
		//  'Si llegamos a este punto es que no hemos encontrado el valor a insertar en el vector, es decir,
152
		//  'seguro que tendremos que a�adir un nuevo elemento.
153
		rbNuevoElemento[0] = true;
154

  
155
		//  'Nota:
156
		//  'En este caso (cuando en rbNuevoElemento se devuelve True) lo que hay que hacer al salir de esta funci�n
157
		//  'es a�adir un nuevo elemento al vector y desplazar todos los valores correspondientes a partir de rlIndiceCorrespondiente
158
		//  '�D�nde va el nuevo elemento?
159
		//  'El �ltimo sitio estudiado viene dado por el valor de llMedio.
160
		//  'Si el valor a insertar es menor que el valor almacenado en la posici�n llMedio, el nuevo valor deber� ir a su izquierda.
161
		//  'Si fuera mayor deber�a ir a su derecha.
162
		ldValorComparacion = ((udtDatosEstudio) rVectorDatos.get(llMedio)).Valor;
163

  
164
		if (vdValorAInsertar > ldValorComparacion) {
165
			rlIndiceCorrespondiente[0] = llMedio + 1;
166
		} else {
167
			rlIndiceCorrespondiente[0] = llMedio;
168
		}
169

  
170
		return true;
171
	}
172

  
173
	/**
174
	 * M�todo para generar los intervalos.
175
	 *
176
	 * @return true si se han generado correctamente.
177
	 * @throws DataException TODO
178
	 */
179
	public boolean generarIntervalos()
180
		throws DataException {
181
		List<udtDatosEstudio> lVectorDatos;
182
		double[] ldMediaTotal = new double[1];
183
		double[] ldSDAM = new double[1];
184

  
185
		int[] llaIndicesRupturas;
186

  
187
		double[] ldUltimaGVF = new double[1];
188
		double[] ldNuevaGVF = new double[1];
189

  
190
		int i;
191
		int liNumClasesReales;
192
		int llNumElementosPorClase;
193

  
194
		//    'Obtener los datos a estudiar ordenados ascendentemente y obtener la media total
195
		//ReDim lVectorDatos(0)
196
		lVectorDatos = new ArrayList<udtDatosEstudio>();
197

  
198
		lVectorDatos.add(new udtDatosEstudio());
199

  
200
		if (!mbObtenerDatos(lVectorDatos, ldMediaTotal)) {
201
			return false; //SalidaSinMensaje
202
		}
203

  
204
		System.out.println("Analizando datos ...");
205

  
206
		/// Call gEstablecerDescripcionProceso("Analizando datos ...", False)
207
		//  'Calcular la suma de las desviaciones t�picas del total de los datos respecto de la media total
208
		ldSDAM[0] = mbGetSumSquaredDeviationArrayMean(lVectorDatos,
209
				ldMediaTotal[0]);
210

  
211
		///if (lVectorDatos.length==0){
212
		if (lVectorDatos.isEmpty()) {
213
			//      'S�lo se pueden generar dos intervalos -> hay un valor de ruptura
214
			///ReDim mdaValoresRuptura(0)
215
			mdaValoresRuptura[0] = ((udtDatosEstudio) lVectorDatos.get(0)).Valor;
216
			mdaValInit[0] = ((udtDatosEstudio) lVectorDatos.get(0)).Valor;
217
			miNumIntervalosGenerados = 2;
218

  
219
			return true;
220
		}
221

  
222
		//  'Calculamos el n�mero m�ximo de clases reales que podemos generar.
223
		//  'Este n�mero ser�a igual al n� de elementos que tenga el vector de datos.
224
		if (miNumIntervalosSolicitados > (lVectorDatos.size())) {
225
			liNumClasesReales = lVectorDatos.size() + 1;
226
		} else {
227
			liNumClasesReales = miNumIntervalosSolicitados;
228
		}
229

  
230
		//  'Establecemos las clases iniciales especificando unos �ndices de ruptura en ppo. equidistantes
231
		llaIndicesRupturas = new int[liNumClasesReales - 1];
232
		llNumElementosPorClase = (lVectorDatos.size()) / liNumClasesReales;
233

  
234
		for (i = 0; i < llaIndicesRupturas.length; i++) {
235
			if (i == 0) {
236
				llaIndicesRupturas[i] = llNumElementosPorClase - 1;
237
			} else {
238
				llaIndicesRupturas[i] = llaIndicesRupturas[i - 1] +
239
					llNumElementosPorClase;
240
			}
241
		}
242

  
243
		udtDatosClase[] ldaSDCM_Parciales = new udtDatosClase[llaIndicesRupturas.length +
244
			1];
245
		udtDatosClase[] ldaSDCM_Validos = new udtDatosClase[llaIndicesRupturas.length +
246
			1];
247

  
248
		///ReDim ldaSDCM_Parciales(UBound(llaIndicesRupturas()) + 1)
249
		///ReDim ldaSDCM_Validos(UBound(ldaSDCM_Parciales()) + 1)
250
		if (llaIndicesRupturas.length == 0) {
251
			return true;
252
		}
253

  
254
		//  'Calcular la bondad inicial
255
		if (!mbCalcularGVF(lVectorDatos, ldaSDCM_Parciales, llaIndicesRupturas,
256
					ldSDAM[0], ldUltimaGVF, -1, false)) {
257
//			JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"el_numero_maximo_de_intervalos_para_este_campo_es")+": "+lVectorDatos.size());
258
			miNumIntervalosSolicitados=lVectorDatos.size();
259
			generarIntervalos();
260
			return false;
261
		}
262

  
263
		ldaSDCM_Validos = getArray(ldaSDCM_Parciales);
264

  
265
		boolean lbMoverADerecha;
266
		boolean lbMoverAIzquierda;
267
		boolean lbIntentarDesplazamiento;
268
		int llIndiceRupturaOriginal;
269

  
270
		long k;
271
		double ldGVFentrepasadas;
272

  
273
		ldGVFentrepasadas = ldUltimaGVF[0];
274

  
275
		//'liNumClasesReales no ser� muy grande (11 es el m�ximo)
276
		for (k = 1; k <= 100; k++) {
277
			//      'Para cada �ndice de ruptura...
278
			for (i = 0; i < (llaIndicesRupturas.length); i++) {
279
				lbMoverADerecha = false;
280
				lbMoverAIzquierda = false;
281
				llIndiceRupturaOriginal = llaIndicesRupturas[i];
282
				ldaSDCM_Validos = getArray(ldaSDCM_Parciales);
283

  
284
				//'Hay que decidir hacia donde hay que desplazar el �ndice de ruptura
285
				//'Probamos moviendo a derecha (si se puede)
286
				lbIntentarDesplazamiento = false;
287

  
288
				if (i == (llaIndicesRupturas.length - 1)) {
289
					if ((llaIndicesRupturas[i] + 1) < lVectorDatos.size()) {
290
						lbIntentarDesplazamiento = true;
291
					}
292
				} else {
293
					if ((llaIndicesRupturas[i] + 1) < llaIndicesRupturas[i + 1]) {
294
						lbIntentarDesplazamiento = true;
295
					} //'If (llaIndicesRupturas(i) + 1) < llaIndicesRupturas(i + 1) Then
296
				} //'If i = UBound(llaIndicesRupturas) Then
297

  
298
				if (lbIntentarDesplazamiento) {
299
					llaIndicesRupturas[i] = llaIndicesRupturas[i] + 1;
300

  
301
					if (!mbCalcularGVF(lVectorDatos, ldaSDCM_Parciales,
302
								llaIndicesRupturas, ldSDAM[0], ldNuevaGVF, i,
303
								false)) {
304
						return false;
305
					}
306

  
307
					if (ldNuevaGVF[0] > ldUltimaGVF[0]) {
308
						lbMoverADerecha = true;
309
						ldaSDCM_Validos = getArray(ldaSDCM_Parciales);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff