Revision 964

View differences:

org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
  <modelVersion>4.0.0</modelVersion>
4
  <artifactId>org.gvsig.sldconverter</artifactId>
5
  
6
  <packaging>pom</packaging>
7
  <name>${project.artifactId}</name>
8
  <description>This library maps objects in SLD object model to/from gvSIG symbology/legend objects.</description>
9
  
10
	<parent>
11
		<groupId>org.gvsig</groupId>
12
		<artifactId>org.gvsig.sld</artifactId>
13
		<version>2.0.183</version>
14
	</parent>
15
	
16
  <url>https://devel.gvsig.org/redmine/projects/gvsig-sldtools</url>
17
  
18
    <scm>
19
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-sldtools/org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter</connection>
20
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-sldtools/org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter</developerConnection>
21
        <url>scm:svn:https://devel.gvsig.org/svn/gvsig-sldtools/org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter</url>
22
    </scm>
23
    
24
	<build>
25
		<plugins>
26
			<plugin>
27
				<groupId>org.apache.maven.plugins</groupId>
28
				<artifactId>maven-release-plugin</artifactId>
29
				<configuration>
30
					<tagBase>https://devel.gvsig.org/svn/gvsig-sldtools/org.gvsig.sldconverter/tags/</tagBase>
31
					<goals>deploy</goals>
32
				</configuration>
33
			</plugin>
34
		</plugins>
35
	</build>
36
	
37
		
38
    
39

  
40
  <modules>
41
    <module>org.gvsig.sldconverter.lib</module>
42
  </modules>
43
    
44
  <groupId>org.gvsig</groupId>
45
</project>
46

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

  
4
  <modelVersion>4.0.0</modelVersion>
5
  <artifactId>org.gvsig.sldconverter.lib</artifactId>
6
  <packaging>pom</packaging>
7
  <name>${project.artifactId}</name>
8
  <parent>
9
    <groupId>org.gvsig</groupId>
10
    <artifactId>org.gvsig.sldconverter</artifactId>
11
    <version>2.0.183</version>
12
  </parent>
13

  
14
  <modules>
15
    <module>org.gvsig.sldconverter.lib.api</module>
16
    <module>org.gvsig.sldconverter.lib.impl</module>
17
  </modules>
18
</project>
19

  
20

  
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
  <modelVersion>4.0.0</modelVersion>
4
  <artifactId>org.gvsig.sldconverter.lib.api</artifactId>
5
  <packaging>jar</packaging>
6
  <name>${project.artifactId}</name>
7
  <parent>
8
    <groupId>org.gvsig</groupId>
9
    <artifactId>org.gvsig.sldconverter.lib</artifactId>
10
    <version>2.0.183</version>
11
  </parent>
12

  
13
  <dependencies>
14

  
15
    <dependency>
16
      	<groupId>org.gvsig</groupId>
17
      	<artifactId>org.gvsig.symbology.lib.api</artifactId>
18
      	<scope>compile</scope>
19
    </dependency>
20
    
21
    <dependency>
22
      	<groupId>org.gvsig</groupId>
23
      	<artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
24
      	<scope>compile</scope>
25
    </dependency>
26
    
27
    <dependency>
28
    	<groupId>org.gvsig</groupId>
29
    	<artifactId>org.gvsig.sldsupport.lib.api</artifactId>
30
    	<scope>compile</scope>
31
    </dependency>
32
      
33
  </dependencies>
34
  
35
  
36
</project>
37

  
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/SLDConverterLibrary.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter;
27

  
28
import org.gvsig.tools.library.AbstractLibrary;
29
import org.gvsig.tools.library.LibraryException;
30
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
31

  
32
public class SLDConverterLibrary extends AbstractLibrary {
33

  
34
	protected void doInitialize() throws LibraryException {
35
		registerAsAPI(SLDConverterLibrary.class);
36
	}
37

  
38
	protected void doPostInitialize() throws LibraryException {
39

  
40
		// Check that there is a  manager
41
		SLDConverterManager mana = null;
42
		mana = SLDConverterLocator.getInstance().getSLDConverterManager();
43
		if (mana == null) {
44
			throw new ReferenceNotRegisteredException(
45
					SLDConverterLocator.SLD_CONVERTER_MANAGER_NAME,
46
					SLDConverterLocator.getInstance());
47
		}
48
		
49
	}
50

  
51
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/SLDConverterManager.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter;
27

  
28
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
29
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
30
import org.gvsig.sldconverter.exception.UnsupportedLegendException;
31
import org.gvsig.sldconverter.exception.UnsupportedSymbolException;
32
import org.gvsig.sldconverter.legend.LegendToSLDConverterFactory;
33
import org.gvsig.sldconverter.legend.SLDToLegendConverterFactory;
34
import org.gvsig.sldconverter.symbol.SLDToSymbolConverterFactory;
35
import org.gvsig.sldconverter.symbol.SymbolToSLDConverterFactory;
36
import org.gvsig.sldsupport.exception.UnsupportedSLDObjectException;
37
import org.gvsig.sldsupport.sld.layer.SLDLayer;
38
import org.gvsig.sldsupport.sld.symbol.SLDSymbol;
39

  
40
public interface SLDConverterManager {
41
	
42
	public static final int CAN_NOT_CONVERT = 0;
43
	public static final int CAN_CONVERT_PARTIALLY = 50;
44
	public static final int CAN_CONVERT_FULLY = 100;
45
	
46
	public SLDSymbol toSLDSymbol(ISymbol sym) throws UnsupportedSymbolException;
47
	public ISymbol toSymbol(SLDSymbol sldSym) throws UnsupportedSLDObjectException;
48

  
49
	public SLDLayer toSLDLayer(ILegend legend) throws
50
	UnsupportedLegendException, UnsupportedSymbolException;
51
	
52
	public 	ILegend toLegend(SLDLayer sldLayer) throws UnsupportedSLDObjectException;
53

  
54
	public void registerSLDToSymbolConverter(SLDToSymbolConverterFactory fact);
55
	public void registerSymbolToSLDConverter(SymbolToSLDConverterFactory fact);
56

  
57
	public void registerSLDToLegendConverter(SLDToLegendConverterFactory fact);
58
	public void registerLegendToSLDConverter(LegendToSLDConverterFactory fact);
59

  
60
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/symbol/SLDToSymbolConverterFactory.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.symbol;
27

  
28
import org.gvsig.sldsupport.sld.symbol.SLDSymbol;
29

  
30
public interface SLDToSymbolConverterFactory {
31

  
32
	public int canConvert(SLDSymbol sldSym);
33
	public SLDToSymbolConverter createSLDToSymbolConverter();
34
	
35
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/symbol/SymbolToSLDConverterFactory.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.symbol;
27

  
28
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
29

  
30
public interface SymbolToSLDConverterFactory {
31
	
32
	public int canConvert(ISymbol sym);
33
	public SymbolToSLDConverter createSymbolToSLDConverter();
34

  
35
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/symbol/SLDToSymbolConverter.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.symbol;
27

  
28
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
29
import org.gvsig.sldsupport.exception.UnsupportedSLDObjectException;
30
import org.gvsig.sldsupport.sld.symbol.SLDSymbol;
31

  
32
public interface SLDToSymbolConverter {
33
	
34
	public ISymbol convert(SLDSymbol sldSym) throws UnsupportedSLDObjectException;
35
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/symbol/SymbolToSLDConverter.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.symbol;
27

  
28
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
29
import org.gvsig.sldconverter.exception.UnsupportedSymbolException;
30
import org.gvsig.sldsupport.sld.symbol.SLDSymbol;
31

  
32
public interface SymbolToSLDConverter {
33
	
34
	public SLDSymbol convert(ISymbol sym) throws UnsupportedSymbolException;
35

  
36
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/SLDConverterLocator.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter;
27

  
28
import org.gvsig.tools.locator.BaseLocator;
29
import org.gvsig.tools.locator.LocatorException;
30

  
31
public class SLDConverterLocator extends BaseLocator {
32
	
33
	public static final String SLD_CONVERTER_MANAGER_NAME =
34
			"SLDConverterManager";
35
	private static final String SLD_CONVERTER_MANAGER_DESCRIPTION =
36
			"Manager to map SLD objects to/from gvSIG legend/symbol objects";
37
	
38
	/**
39
	 * Unique instance.
40
	 */
41
	private static final SLDConverterLocator instance = new SLDConverterLocator();
42

  
43
	/**
44
	 * Return the singleton instance.
45
	 * 
46
	 * @return the singleton instance
47
	 */
48
	public static SLDConverterLocator getInstance() {
49
		return instance;
50
	}
51

  
52
	/**
53
	 * Return a reference to the SLD conversion manager
54
	 */
55
	public SLDConverterManager getSLDConverterManager()
56
			throws LocatorException {
57
		return (SLDConverterManager) getInstance().get(SLD_CONVERTER_MANAGER_NAME);
58
	}
59

  
60
	public void registerSLDConverterManager(
61
			Class<? extends SLDConverterManager> clazz) {
62
		
63
		getInstance().register(
64
				SLD_CONVERTER_MANAGER_NAME,
65
				SLD_CONVERTER_MANAGER_DESCRIPTION,
66
				clazz);
67
	}
68
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/exception/UnsupportedLegendException.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.exception;
27

  
28
import org.gvsig.sldsupport.exception.SLDException;
29

  
30
public class UnsupportedLegendException extends SLDException {
31
	
32

  
33
	/**
34
	 * 
35
	 */
36
	private static final long serialVersionUID = 2854198480865912162L;
37

  
38
	public UnsupportedLegendException(
39
			String className,
40
			String detail) {
41
		super("Unsupported Legend: " + className + "; Detail: " + detail, 
42
				"_Unsupported_Legend",
43
				serialVersionUID);
44
	}
45

  
46

  
47
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/exception/UnsupportedSymbolException.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.exception;
27

  
28
import org.gvsig.sldsupport.exception.SLDException;
29

  
30
public class UnsupportedSymbolException extends SLDException {
31
	
32

  
33
	/**
34
	 * 
35
	 */
36
	private static final long serialVersionUID = -3109057062774551705L;
37

  
38
	public UnsupportedSymbolException(
39
			String className,
40
			String detail) {
41
		super("Unsupported Symbol: " + className + "; Detail: " + detail, 
42
				"_Unsupported_Symbol",
43
				serialVersionUID);
44
	}
45

  
46

  
47
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/legend/LegendToSLDConverter.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.legend;
27

  
28
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
29
import org.gvsig.sldconverter.exception.UnsupportedLegendException;
30
import org.gvsig.sldconverter.exception.UnsupportedSymbolException;
31
import org.gvsig.sldsupport.sld.layer.SLDLayer;
32

  
33
public interface LegendToSLDConverter {
34
	
35
	public SLDLayer convert(ILegend legend) throws
36
	UnsupportedLegendException, UnsupportedSymbolException;
37
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/legend/SLDToLegendConverter.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.legend;
27

  
28
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
29
import org.gvsig.sldsupport.exception.UnsupportedSLDObjectException;
30
import org.gvsig.sldsupport.sld.layer.SLDLayer;
31

  
32
public interface SLDToLegendConverter {
33
	
34
	public ILegend convert(SLDLayer sldLay) throws UnsupportedSLDObjectException;
35

  
36
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/legend/LegendToSLDConverterFactory.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.legend;
27

  
28
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
29

  
30
public interface LegendToSLDConverterFactory {
31
	
32
	public int canConvert(ILegend legend);
33
	public LegendToSLDConverter createLegendToSLDConverter();
34

  
35
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/java/org/gvsig/sldconverter/legend/SLDToLegendConverterFactory.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.legend;
27

  
28
import org.gvsig.sldsupport.sld.layer.SLDLayer;
29

  
30
public interface SLDToLegendConverterFactory {
31
	
32
	public int canConvert(SLDLayer sldLay);
33
	public SLDToLegendConverter createSLDToLegendConverter();
34

  
35
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.sldconverter.SLDConverterLibrary
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

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

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<!-- 
30
Log4J configuration file for unit tests execution.
31
 -->
32
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
33

  
34
	<!-- Appender configuration to show logging messages through the console -->
35
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
36
		<layout class="org.apache.log4j.PatternLayout">
37
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
38
		</layout>
39
	</appender>
40

  
41
	<!-- 
42
	Activate logging messages of DEBUG level of higher only for the
43
	org.gvsig.tools packages.
44
	You can put full classes names or packages instead, to configure
45
	logging for all the classes and subpackages of the package.
46
	-->
47
	<category name="org.gvsig.tools">
48
		<priority value="DEBUG" />
49
	</category>
50
	<category name="org.gvsig.symbology">
51
		<priority value="DEBUG" />
52
	</category>
53

  
54
	<!-- 
55
	By default, show only logging messages of INFO level or higher, 
56
	through the previously configured CONSOLE appender. 
57
	-->
58
	<root>
59
		<priority value="INFO" />
60
		<appender-ref ref="CONSOLE" />
61
	</root>
62
</log4j:configuration>
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.sldconverter.impl.SLDConverterDefaultLibrary
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/main/java/org/gvsig/sldconverter/impl/SLDConverterDefaultLibrary.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.impl;
27

  
28
import org.gvsig.sldconverter.SLDConverterLibrary;
29
import org.gvsig.sldconverter.SLDConverterLocator;
30
import org.gvsig.sldconverter.SLDConverterManager;
31
import org.gvsig.sldconverter.impl.legend.BasicLegendConverterFactory;
32
import org.gvsig.sldconverter.impl.symbol.BasicSymbolConverterFactory;
33
import org.gvsig.tools.library.AbstractLibrary;
34
import org.gvsig.tools.library.LibraryException;
35

  
36
public class SLDConverterDefaultLibrary extends AbstractLibrary {
37

  
38
	public void doRegistration() {
39
        registerAsImplementationOf(SLDConverterLibrary.class);
40
    }
41
	
42
	protected void doInitialize() throws LibraryException {
43
		
44
		SLDConverterLocator.getInstance().registerSLDConverterManager(
45
				DefaultSLDConverterManager.class);
46
		
47
	}
48

  
49

  
50
	protected void doPostInitialize() throws LibraryException {
51
		
52
		SLDConverterManager mana =
53
				SLDConverterLocator.getInstance().getSLDConverterManager();
54
		
55
		/*
56
		 * Register conversors...
57
		 */
58
		BasicLegendConverterFactory basicLegConvFact = new BasicLegendConverterFactory(); 
59
		mana.registerSLDToLegendConverter(basicLegConvFact);
60
		mana.registerLegendToSLDConverter(basicLegConvFact);
61
		
62
		BasicSymbolConverterFactory basicSymConvFact = new BasicSymbolConverterFactory(); 
63
		mana.registerSLDToSymbolConverter(basicSymConvFact);
64
		mana.registerSymbolToSLDConverter(basicSymConvFact);
65
		
66
	}
67

  
68
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/main/java/org/gvsig/sldconverter/impl/symbol/PointSymbolUtils.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.impl.symbol;
27

  
28
import java.awt.Color;
29
import java.net.URL;
30
import java.util.List;
31

  
32
import org.gvsig.fmap.geom.Geometry;
33
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol;
34
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
35
import org.gvsig.sldconverter.exception.UnsupportedSymbolException;
36
import org.gvsig.sldconverter.impl.util.BasicUtils;
37
import org.gvsig.sldsupport.exception.UnsupportedSLDObjectException;
38
import org.gvsig.sldsupport.sld.filter.expression.operator.SLDLiteral;
39
import org.gvsig.sldsupport.sld.graphic.SLDExternalGraphic;
40
import org.gvsig.sldsupport.sld.graphic.SLDGraphic;
41
import org.gvsig.sldsupport.sld.graphic.SLDGraphicStackElement;
42
import org.gvsig.sldsupport.sld.graphic.SLDMark;
43
import org.gvsig.sldsupport.sld.symbol.SLDPointSymbol;
44
import org.gvsig.sldsupport.sld.symbol.misc.SLDFill;
45
import org.gvsig.sldsupport.sld.symbol.misc.SLDParameterValue;
46
import org.gvsig.sldsupport.sld.symbol.misc.SLDStroke;
47
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
48
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IPictureMarkerSymbol;
49
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.ISimpleMarkerSymbol;
50

  
51
public class PointSymbolUtils {
52
	
53
	public static ISymbol toMarkerSymbol(SLDPointSymbol sym)
54
			throws UnsupportedSLDObjectException {
55
		
56
		SLDGraphic gra = sym.getGraphic();
57
		List<SLDGraphicStackElement> list = gra.getElementStack();
58
		if (list.size() == 1) {
59
			
60
			Integer alpha = BasicUtils.getAlphaValue(gra.getOpacity());
61
			Double sz = BasicUtils.getDouble(gra.getSize());
62
			IMarkerSymbol msym = toMarkerSymbol(list.get(0));
63
			if (alpha != null) {
64
				msym.setAlpha(alpha.intValue());
65
			}
66
			if (sz != null) {
67
				msym.setSize(sz.doubleValue());
68
			}
69
			return msym;
70
		} else {
71

  
72
			IMultiLayerSymbol resp = BasicUtils.syMan().createMultiLayerSymbol(
73
					Geometry.TYPES.POINT);
74
			for (int i=0; i<list.size(); i++) {
75
				resp.addLayer(toMarkerSymbol(list.get(i)));
76
			}
77
			return resp;
78
		}
79
	}
80
	
81
	
82
	private static IMarkerSymbol toMarkerSymbol(SLDExternalGraphic extgra)
83
			throws UnsupportedSLDObjectException {
84

  
85
		if (extgra.isOnlineResource()) {
86
			URL u = null;
87
			IPictureMarkerSymbol pms = null;
88
			try {
89
				u = new URL(extgra.getOnlineResource()); 
90
				pms = BasicUtils.symMan().createPictureMarkerSymbol(u,u);
91
			} catch (Exception exc) {
92
				throw new UnsupportedSLDObjectException(exc,
93
						"SLDExternalGraphic", "Creating picture marker symbol from URL");
94
			}
95
			return pms;
96
		} else {
97
			// TODO Not supported yet
98
			throw new UnsupportedSLDObjectException(
99
					"SLDExternalGraphic",
100
					"Inline content not supported.");
101
		}
102
	}
103

  
104
	private static IMarkerSymbol toMarkerSymbol(SLDGraphicStackElement elem)
105
			throws UnsupportedSLDObjectException {
106
		
107
		if (elem == null) {
108
			throw new UnsupportedSLDObjectException("SLDGraphicStackElement", "Null");
109
		}
110
		
111
		if (elem instanceof SLDExternalGraphic) {
112
			return toMarkerSymbol((SLDExternalGraphic) elem);
113
		} else {
114
			if (elem instanceof SLDMark) {
115
				return toMarkerSymbol((SLDMark) elem);
116
			} else {
117
				throw new UnsupportedSLDObjectException(
118
						"SLDGraphicStackElement",
119
						"Unexpected class: " + elem.getClass().getName());
120
			}
121
		}
122
	}
123
	
124
	
125
	private static IMarkerSymbol toMarkerSymbol(SLDMark mk)
126
			throws UnsupportedSLDObjectException {
127

  
128
		switch (mk.getMarkType()) {
129
		case SLDMark.MARK_TYPE_INLINE_CONTENT:
130
			throw new UnsupportedSLDObjectException(
131
					"SLDMark",
132
					"Inline content not supported.");
133
			// ============================================
134
		case SLDMark.MARK_TYPE_ONLINE_RESOURCE:
135
			URL u = null;
136
			IPictureMarkerSymbol pms = null;
137
			try {
138
				u = new URL(mk.getOnlineResource()); 
139
				pms = BasicUtils.symMan().createPictureMarkerSymbol(u,u);
140
			} catch (Exception exc) {
141
				throw new UnsupportedSLDObjectException(exc, "SLDMark",
142
						"Creating picture marker symbol from URL");
143
			}
144
			return pms;			
145
			// ============================================
146
		case SLDMark.MARK_TYPE_WELL_KNOWN_NAME:
147
			String wkn = mk.getWellKnownName();
148
			int t = getMarkerSymbolType(wkn);
149
			ISimpleMarkerSymbol resp = BasicUtils.symMan().createSimpleMarkerSymbol();
150
			resp.setStyle(t);
151
			
152
			SLDFill fill = mk.getFill();
153
			Color co = null;
154
			Double dob = null;
155
			if (fill != null) {
156
				co = BasicUtils.toColor(fill.getFillColor());
157
				if (co != null) {
158
					resp.setColor(co);
159
				}
160
			}
161
			SLDStroke stro = mk.getStroke();
162
			if (stro != null) {
163
				co = BasicUtils.toColor(stro.getColor());
164
				if (co != null) {
165
					resp.setOutlineColor(co);
166
				}
167
				dob = BasicUtils.toDouble(stro.getWidth());
168
				if (dob != null) {
169
					resp.setOutlineSize(dob.doubleValue());
170
				}
171
			}
172
			return resp;
173
			// ============================================
174
		default:
175
			IMarkerSymbol ms = BasicUtils.symMan().createSimpleMarkerSymbol();
176
			SLDStroke str = mk.getStroke();
177
			Color col = BasicUtils.getColor(str.getColor());
178
			if (col != null) {
179
				ms.setColor(col);
180
			}
181
			Double sz = BasicUtils.toDouble(str.getWidth());
182
			if (sz != null) {
183
				ms.setSize(sz.doubleValue());
184
			}
185
			return ms;
186
		}
187

  
188
	}
189
	
190
	private static int getMarkerSymbolType(String wkn) {
191
		
192
		if (wkn.compareToIgnoreCase("circle") == 0)
193
			return IMarkerSymbol.CIRCLE_STYLE;
194
		else if (wkn.compareToIgnoreCase("x") == 0)
195
			return IMarkerSymbol.X_STYLE;
196
		else if (wkn.compareToIgnoreCase("cross") == 0)
197
			return IMarkerSymbol.CROSS_STYLE;
198
		else if (wkn.compareToIgnoreCase("triangle") == 0)
199
			return IMarkerSymbol.TRIANGLE_STYLE;
200
		else if (wkn.compareToIgnoreCase("star") == 0)
201
			return IMarkerSymbol.STAR_STYLE;
202
		return IMarkerSymbol.SQUARE_STYLE;
203
	}
204

  
205
	public static ISymbol toMarkerSymbol(SLDGraphic gra) 
206
			throws UnsupportedSLDObjectException {
207
		
208
		IMarkerSymbol resp = null;
209
		List<SLDGraphicStackElement> list = gra.getElementStack();
210
		
211
		Integer alpha = BasicUtils.getAlphaValue(gra.getOpacity());
212
		Double sz = BasicUtils.getDouble(gra.getSize());
213

  
214
		if (list.size() == 0) {
215
			// Get data from css/svg params
216
			ISimpleMarkerSymbol sms = BasicUtils.symMan().createSimpleMarkerSymbol();
217
			if (alpha != null) {
218
				sms.setAlpha(alpha.intValue());
219
			}
220
			if (sz != null) {
221
				sms.setSize(sz.doubleValue());
222
			}
223
			// color? default?
224
			return sms;
225

  
226
		} else {
227
			
228
			if (list.size() == 1) {
229
				IMarkerSymbol msym = toMarkerSymbol(list.get(0));
230
				if (alpha != null) {
231
					msym.setAlpha(alpha.intValue());
232
				}
233
				if (sz != null) {
234
					msym.setSize(sz.doubleValue());
235
				}
236
				return msym;
237
			} else {
238
				
239
				IMultiLayerSymbol mls = BasicUtils.syMan().createMultiLayerSymbol(Geometry.TYPES.POINT);
240
				for (int i=0; i<list.size(); i++) {
241
					mls.addLayer(toMarkerSymbol(list.get(i)));
242
				}
243
				return mls;
244
			}
245
		}
246
	}
247
	
248
	
249
	
250
	private static String getMarkWellKnownName(int style) {
251
		
252
		if (style == IMarkerSymbol.CIRCLE_STYLE)
253
			return "circle";
254
		else if (style == IMarkerSymbol.CROSS_STYLE)
255
			return "cross";
256
		else if (style == IMarkerSymbol.SQUARE_STYLE)
257
			return "square";
258
		else if (style == IMarkerSymbol.TRIANGLE_STYLE)
259
			return "triangle";
260
		else if (style == IMarkerSymbol.STAR_STYLE)
261
			return "star";
262
		else if (style == IMarkerSymbol.X_STYLE)
263
			return "x";
264
		
265
		return "square";	
266
	}	
267
	
268
	public static SLDPointSymbol toSLDPointSymbol(IMarkerSymbol sym)
269
			throws UnsupportedSymbolException {
270
		
271
		if (sym instanceof IPictureMarkerSymbol) {
272
			
273
			IPictureMarkerSymbol aux = (IPictureMarkerSymbol) sym;
274
			SLDExternalGraphic egra = new SLDExternalGraphic();
275
			egra.setIsOnline(true);
276
			egra.setOnlineResource(aux.getSource().toString());
277
			egra.setFormat(BasicUtils.getFormat(aux.getSource()));
278
			SLDGraphic gra = new SLDGraphic();
279
			gra.getElementStack().add(egra);
280
			SLDPointSymbol resp = new SLDPointSymbol();
281
			resp.setGraphic(gra);
282
			return resp;
283
			
284
		} else {
285
			if (sym instanceof ISimpleMarkerSymbol) {
286
				
287
				ISimpleMarkerSymbol aux = (ISimpleMarkerSymbol) sym;
288
				
289
				SLDMark mark = new SLDMark();
290
				mark.setMarkType(SLDMark.MARK_TYPE_WELL_KNOWN_NAME);
291
				String wkn = getMarkWellKnownName(aux.getStyle());
292
				mark.setWellKnownName(wkn);
293
				
294
				Color fillColor = aux.getColor();
295
				Color borderColor = aux.getOutlineColor();
296
				double size = aux.getSize();
297
				double borderw = aux.getOutlineSize();
298
				double rot = aux.getRotation();
299
				// from (radians,anticlockwise) to (degrees,clockwise) 
300
				rot = -rot * 180.0 / Math.PI;
301
				// ===============
302
				SLDFill fill = new SLDFill();
303
				if (fillColor == null) {
304
					fillColor = SLDFill.DEFAULT_FILL_COLOR;
305
				}
306

  
307
				fill.setFillColor(fillColor);
308
				mark.setFill(fill);
309
				// ===
310
				SLDStroke stro = new SLDStroke();
311
				stro.setColor(borderColor);
312
				
313
				stro.setWidth(new SLDLiteral(BasicUtils.df.format(borderw)));
314
				mark.setStroke(stro);
315
				// ===============
316
				SLDGraphic gra = new SLDGraphic();
317
				// ===============
318
				SLDParameterValue pv = new SLDParameterValue();
319
				pv.getExpressionList().add(new SLDLiteral(BasicUtils.df.format(size)));
320
				gra.setSize(pv);
321
				// ===
322
				pv = new SLDParameterValue();
323
				pv.getExpressionList().add(new SLDLiteral(BasicUtils.df.format(rot)));
324
				gra.setRotation(pv);
325
				// ===============
326
				gra.getElementStack().add(mark);
327
				SLDPointSymbol resp = new SLDPointSymbol();
328
				resp.setGraphic(gra);
329
				return resp;
330
				
331
			} else {
332
				throw new UnsupportedSymbolException(
333
						sym.getClass().getName(),
334
						"Unsupported class for conversion to SLD");
335
			}
336
		}
337
	}
338
	
339
	
340
	
341
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/main/java/org/gvsig/sldconverter/impl/symbol/BasicSymbolConverterFactory.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.impl.symbol;
27

  
28
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
29
import org.gvsig.sldconverter.SLDConverterManager;
30
import org.gvsig.sldconverter.symbol.SLDToSymbolConverter;
31
import org.gvsig.sldconverter.symbol.SLDToSymbolConverterFactory;
32
import org.gvsig.sldconverter.symbol.SymbolToSLDConverter;
33
import org.gvsig.sldconverter.symbol.SymbolToSLDConverterFactory;
34
import org.gvsig.sldsupport.sld.symbol.SLDLineSymbol;
35
import org.gvsig.sldsupport.sld.symbol.SLDPointSymbol;
36
import org.gvsig.sldsupport.sld.symbol.SLDPolygonSymbol;
37
import org.gvsig.sldsupport.sld.symbol.SLDSymbol;
38
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
39
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IMultiLayerFillSymbol;
40
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
41
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.IMultiLayerLineSymbol;
42
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
43
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMultiLayerMarkerSymbol;
44

  
45
public class BasicSymbolConverterFactory
46
implements SymbolToSLDConverterFactory, SLDToSymbolConverterFactory {
47

  
48
	public int canConvert(SLDSymbol sldSym) {
49
		
50
		if (sldSym instanceof SLDPointSymbol
51
				|| sldSym instanceof SLDLineSymbol
52
				|| sldSym instanceof SLDPolygonSymbol) {
53
			
54
			/*
55
			 * This allows precedence of specific conversors
56
			 */
57
			return SLDConverterManager.CAN_CONVERT_PARTIALLY;
58
		} else {
59
			/*
60
			 * SLDRasterSymbol
61
			 * SLDTextSymbol
62
			 * SLDMappedColorSymbol
63
			 */
64
			return SLDConverterManager.CAN_NOT_CONVERT;
65
		}
66
		
67
	}
68

  
69
	public SLDToSymbolConverter createSLDToSymbolConverter() {
70
		return new BasicSymbolConverter();
71
	}
72
	
73
	// ======================================
74

  
75
	public int canConvert(ISymbol sym) {
76
		
77
		if (sym instanceof IMultiLayerMarkerSymbol
78
				|| sym instanceof IMultiLayerLineSymbol
79
				|| sym instanceof IMultiLayerFillSymbol
80
				|| sym instanceof IMarkerSymbol
81
				|| sym instanceof ILineSymbol
82
				|| sym instanceof IFillSymbol) {
83
			
84
			
85
			return SLDConverterManager.CAN_CONVERT_PARTIALLY;
86
		} else {
87
			return SLDConverterManager.CAN_NOT_CONVERT;
88
		}
89
	}
90

  
91
	public SymbolToSLDConverter createSymbolToSLDConverter() {
92
		return new BasicSymbolConverter();
93
	}
94

  
95
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/main/java/org/gvsig/sldconverter/impl/symbol/LineSymbolUtils.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.impl.symbol;
27

  
28
import java.awt.Color;
29

  
30
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
31
import org.gvsig.sldconverter.exception.UnsupportedSymbolException;
32
import org.gvsig.sldconverter.impl.util.BasicUtils;
33
import org.gvsig.sldsupport.exception.UnsupportedSLDObjectException;
34
import org.gvsig.sldsupport.sld.filter.expression.operator.SLDLiteral;
35
import org.gvsig.sldsupport.sld.symbol.SLDLineSymbol;
36
import org.gvsig.sldsupport.sld.symbol.misc.SLDStroke;
37
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
38

  
39
public class LineSymbolUtils {
40
	
41
	public static ISymbol toLineSymbol(SLDLineSymbol sym) 
42
			throws UnsupportedSLDObjectException {
43
		
44
		ILineSymbol resp = BasicUtils.symMan().createSimpleLineSymbol();
45
		SLDStroke stro = sym.getStroke();
46
		
47
		Color col = BasicUtils.toColor(stro.getColor());
48
		if (col != null) {
49
			resp.setColor(col);
50
		}
51
		Double wi = BasicUtils.toDouble(stro.getWidth());
52
		if (wi != null) {
53
			resp.setLineWidth(wi);
54
		}
55
		return resp;
56
	}
57
	
58
	
59
	public static SLDLineSymbol toSLDLineSymbol(ILineSymbol sym)
60
			throws UnsupportedSymbolException {
61
		
62
		Color bcolor = sym.getColor();
63
		double bw = sym.getLineWidth();
64
		
65
		SLDStroke stro = new SLDStroke();
66
		stro.setColor(bcolor);
67
		stro.setWidth(new SLDLiteral(BasicUtils.df.format(bw)));
68
		
69
		SLDLineSymbol resp = new SLDLineSymbol();
70
		resp.setStroke(stro);
71
		return resp;
72
	}
73
	
74
	
75
}
org.gvsig.sld/tags/org.gvsig.sld-2.0.183/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/main/java/org/gvsig/sldconverter/impl/symbol/PolygonSymbolUtils.java
1
/*******************************************************************************
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff