Revision 827
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.api/src/test/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.construc"> |
|
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 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.api/src/test/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 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.complexlegend.ComplexLegendLibrary |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.api/src/main/java/org/gvsig/complexlegend/ComplexLegendLibrary.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.complexlegend; |
|
23 |
|
|
24 |
import org.gvsig.fmap.dal.DALLibrary; |
|
25 |
import org.gvsig.fmap.geom.GeometryLibrary; |
|
26 |
import org.gvsig.symbology.SymbologyLibrary; |
|
27 |
import org.gvsig.tools.ToolsLibrary; |
|
28 |
import org.gvsig.tools.library.AbstractLibrary; |
|
29 |
import org.gvsig.tools.library.LibraryException; |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* Library for API initialization and configuration. |
|
34 |
* |
|
35 |
* @author gvSIG team |
|
36 |
* @version $Id$ |
|
37 |
*/ |
|
38 |
public class ComplexLegendLibrary extends AbstractLibrary { |
|
39 |
|
|
40 |
@Override |
|
41 |
public void doRegistration() { |
|
42 |
registerAsAPI(ComplexLegendLibrary.class); |
|
43 |
this.require(ToolsLibrary.class); |
|
44 |
this.require(GeometryLibrary.class); |
|
45 |
this.require(SymbologyLibrary.class); |
|
46 |
} |
|
47 |
|
|
48 |
|
|
49 |
@Override |
|
50 |
protected void doInitialize() throws LibraryException { |
|
51 |
// Do nothing |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
protected void doPostInitialize() throws LibraryException { |
|
56 |
|
|
57 |
} |
|
58 |
|
|
59 |
} |
|
0 | 60 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.api/src/main/java/org/gvsig/complexlegend/ComplexLegendItem.java | ||
---|---|---|
1 |
package org.gvsig.complexlegend; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
4 |
|
|
5 |
public interface ComplexLegendItem { |
|
6 |
|
|
7 |
public ILegend getLegend(); |
|
8 |
public void setLegend(ILegend legend); |
|
9 |
|
|
10 |
public double getMaxScale(); |
|
11 |
public void setMaxScale(double maxScale); |
|
12 |
|
|
13 |
public double getMinScale(); |
|
14 |
public void setMinScale(double maxScale); |
|
15 |
|
|
16 |
public String toString(); |
|
17 |
} |
|
0 | 18 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.api/src/main/java/org/gvsig/complexlegend/VectorComplexLegend.java | ||
---|---|---|
1 |
package org.gvsig.complexlegend; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend; |
|
6 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
7 |
|
|
8 |
public interface VectorComplexLegend extends IVectorLegend, IClassifiedLegend{ |
|
9 |
|
|
10 |
public List<ComplexLegendItem> getLegends(); |
|
11 |
|
|
12 |
public boolean add(ComplexLegendItem legend); |
|
13 |
public boolean remove(ComplexLegendItem legend); |
|
14 |
|
|
15 |
public boolean isOverlapped(ComplexLegendItem legend); |
|
16 |
public ComplexLegendItem getLegend(double scale); |
|
17 |
} |
|
0 | 18 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.api/src/main/java/org/gvsig/complexlabel/ComplexLabelClass.java | ||
---|---|---|
1 |
package org.gvsig.complexlabel; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelClass; |
|
4 |
|
|
5 |
public interface ComplexLabelClass extends ILabelClass{ |
|
6 |
|
|
7 |
public double getMinScale(); |
|
8 |
|
|
9 |
public double getMaxScale(); |
|
10 |
|
|
11 |
public void setMinScale(double scale); |
|
12 |
|
|
13 |
public void setMaxScale(double scale); |
|
14 |
|
|
15 |
} |
|
0 | 16 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.api/src/main/java/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.landregistryviewer package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>LandRegistryViewer library API.</p> |
|
11 |
|
|
12 |
<p> |
|
13 |
It allows to get new LandRegistryViewer and get their text. |
|
14 |
</p> |
|
15 |
|
|
16 |
</body> |
|
17 |
</html> |
|
0 | 18 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.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.complexlegend.lib.api</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>org.gvsig.complexlegend.lib.api</name> |
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.complexlegend.lib</artifactId> |
|
10 |
<version>1.0.30</version> |
|
11 |
</parent> |
|
12 |
<dependencies> |
|
13 |
<dependency> |
|
14 |
<groupId>org.gvsig</groupId> |
|
15 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
16 |
<scope>compile</scope> |
|
17 |
</dependency> |
|
18 |
<dependency> |
|
19 |
<groupId>org.gvsig</groupId> |
|
20 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
21 |
<scope>compile</scope> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.symbology.lib.api</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
</dependencies> |
|
34 |
<build> |
|
35 |
<plugins> |
|
36 |
<plugin> |
|
37 |
<groupId>org.apache.maven.plugins</groupId> |
|
38 |
<artifactId>maven-jar-plugin</artifactId> |
|
39 |
<configuration> |
|
40 |
</configuration> |
|
41 |
<executions> |
|
42 |
<!-- Generates a jar file only with the test classes --> |
|
43 |
<execution> |
|
44 |
<goals> |
|
45 |
<goal>test-jar</goal> |
|
46 |
</goals> |
|
47 |
</execution> |
|
48 |
</executions> |
|
49 |
</plugin> |
|
50 |
</plugins> |
|
51 |
</build> |
|
52 |
|
|
53 |
</project> |
|
0 | 54 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.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.complexlegend.lib</artifactId> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<name>org.gvsig.complexlegend.lib</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.complexlegend</artifactId> |
|
11 |
<version>1.0.30</version> |
|
12 |
</parent> |
|
13 |
<dependencies> |
|
14 |
</dependencies> |
|
15 |
<modules> |
|
16 |
<module>org.gvsig.complexlegend.lib.api</module> |
|
17 |
<module>org.gvsig.complexlegend.lib.impl</module> |
|
18 |
</modules> |
|
19 |
</project> |
|
0 | 20 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.impl/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.complexlegend.lib.impl</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>org.gvsig.complexlegend.lib.impl</name> |
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.complexlegend.lib</artifactId> |
|
10 |
<version>1.0.30</version> |
|
11 |
</parent> |
|
12 |
|
|
13 |
<dependencies> |
|
14 |
<dependency> |
|
15 |
<groupId>org.gvsig</groupId> |
|
16 |
<artifactId>org.gvsig.complexlegend.lib.api</artifactId> |
|
17 |
<scope>compile</scope> |
|
18 |
</dependency> |
|
19 |
<dependency> |
|
20 |
<groupId>org.gvsig</groupId> |
|
21 |
<artifactId>org.gvsig.symbology.lib.api</artifactId> |
|
22 |
<scope>compile</scope> |
|
23 |
</dependency> |
|
24 |
<dependency> |
|
25 |
<groupId>org.gvsig</groupId> |
|
26 |
<artifactId>org.gvsig.symbology.lib.impl</artifactId> |
|
27 |
<scope>compile</scope> |
|
28 |
</dependency> |
|
29 |
<dependency> |
|
30 |
<groupId>org.gvsig</groupId> |
|
31 |
<artifactId>org.gvsig.symbology.swing.api</artifactId> |
|
32 |
<scope>compile</scope> |
|
33 |
</dependency> |
|
34 |
<dependency> |
|
35 |
<groupId>org.gvsig</groupId> |
|
36 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
37 |
<scope>compile</scope> |
|
38 |
</dependency> |
|
39 |
<dependency> |
|
40 |
<groupId>org.gvsig</groupId> |
|
41 |
<artifactId> org.gvsig.app.mainplugin</artifactId> |
|
42 |
<scope>compile</scope> |
|
43 |
</dependency> |
|
44 |
</dependencies> |
|
45 |
</project> |
|
0 | 46 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.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. |
|
0 | 9 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.impl/src/test/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.chart"> |
|
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="DEBUG" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
|
0 | 38 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.complexlegend.impl.DefaultComplexLegendLibrary |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.impl/src/main/java/org/gvsig/complexlegend/impl/ComplexLegendUtils.java | ||
---|---|---|
1 |
package org.gvsig.complexlegend.impl; |
|
2 |
|
|
3 |
import java.util.Iterator; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.gvsig.app.project.documents.view.legend.gui.AbstractParentPanel; |
|
7 |
import org.gvsig.app.project.documents.view.legend.gui.ILegendPanel; |
|
8 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
9 |
import org.gvsig.symbology.swing.SymbologySwingLocator; |
|
10 |
|
|
11 |
public class ComplexLegendUtils { |
|
12 |
|
|
13 |
public static ILegendPanel getLegendPanel(ILegend legend){ |
|
14 |
List panels = SymbologySwingLocator.getSwingManager().getLegendEditorClasses(); |
|
15 |
Iterator it = panels.iterator(); |
|
16 |
while(it.hasNext()){ |
|
17 |
Class panelClass = (Class) it.next(); |
|
18 |
ILegendPanel panel; |
|
19 |
try { |
|
20 |
panel = (ILegendPanel) panelClass.newInstance(); |
|
21 |
if(!(panel instanceof AbstractParentPanel)){ |
|
22 |
if(panel.getLegendClass().equals(legend.getClass())){ |
|
23 |
return panel; |
|
24 |
} |
|
25 |
} |
|
26 |
} catch (Exception e) { |
|
27 |
return null; |
|
28 |
} |
|
29 |
} |
|
30 |
return null; |
|
31 |
} |
|
32 |
|
|
33 |
} |
|
0 | 34 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.impl/src/main/java/org/gvsig/complexlegend/impl/DefaultComplexLegendItem.java | ||
---|---|---|
1 |
package org.gvsig.complexlegend.impl; |
|
2 |
|
|
3 |
import java.text.NumberFormat; |
|
4 |
|
|
5 |
import org.gvsig.app.project.documents.view.legend.gui.ILegendPanel; |
|
6 |
import org.gvsig.complexlegend.ComplexLegendItem; |
|
7 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
8 |
import org.gvsig.tools.ToolsLocator; |
|
9 |
import org.gvsig.tools.dynobject.DynStruct; |
|
10 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
11 |
import org.gvsig.tools.persistence.Persistent; |
|
12 |
import org.gvsig.tools.persistence.PersistentState; |
|
13 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
14 |
import org.gvsig.tools.util.Callable; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 |
|
|
18 |
public class DefaultComplexLegendItem implements ComplexLegendItem, Persistent{ |
|
19 |
|
|
20 |
public static final Logger logger = LoggerFactory.getLogger(DefaultComplexLegendItem.class); |
|
21 |
public static final String COMPLEX_LEGEND_ITEM_PERSISTENCE_DEFINITION_NAME = "ComplexLegendItem"; |
|
22 |
private ILegend legend; |
|
23 |
private double maxScale; |
|
24 |
private double minScale; |
|
25 |
|
|
26 |
public ILegend getLegend() { |
|
27 |
return legend; |
|
28 |
} |
|
29 |
|
|
30 |
public void setLegend(ILegend legend) { |
|
31 |
this.legend = legend; |
|
32 |
} |
|
33 |
|
|
34 |
public double getMaxScale() { |
|
35 |
return maxScale; |
|
36 |
} |
|
37 |
|
|
38 |
public void setMaxScale(double maxScale) { |
|
39 |
this.maxScale = maxScale; |
|
40 |
} |
|
41 |
|
|
42 |
public double getMinScale() { |
|
43 |
return minScale; |
|
44 |
} |
|
45 |
|
|
46 |
public void setMinScale(double minScale) { |
|
47 |
this.minScale = minScale; |
|
48 |
} |
|
49 |
|
|
50 |
public String toString(){ |
|
51 |
|
|
52 |
String panel = ""; |
|
53 |
if(legend != null){ |
|
54 |
ILegendPanel legPanel = ComplexLegendUtils.getLegendPanel(legend); |
|
55 |
if(legPanel != null){ |
|
56 |
panel = " "+ legPanel.getTitle(); |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
Double mind = (Double) getMinScale(); |
|
61 |
String min = "0"; |
|
62 |
if(mind >= 0){ |
|
63 |
int mini = mind.intValue(); |
|
64 |
min = NumberFormat.getIntegerInstance().format(mini); |
|
65 |
} |
|
66 |
|
|
67 |
Double maxd = (Double) getMaxScale(); |
|
68 |
String max = "inf"; |
|
69 |
if(maxd >= 0){ |
|
70 |
int maxi = maxd.intValue(); |
|
71 |
max = NumberFormat.getIntegerInstance().format(maxi); |
|
72 |
} |
|
73 |
return "[1:"+min+" - 1:"+max+"]"+ panel; |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
public void loadFromState(PersistentState state) |
|
78 |
throws PersistenceException { |
|
79 |
// Set own properties |
|
80 |
setLegend((ILegend) state.get("legend")); |
|
81 |
setMinScale(state.getDouble("minScale")); |
|
82 |
setMaxScale(state.getDouble("maxScale")); |
|
83 |
} |
|
84 |
|
|
85 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
86 |
// Save own properties |
|
87 |
state.set("legend", getLegend()); |
|
88 |
state.set("minScale", getMinScale()); |
|
89 |
state.set("maxScale", getMaxScale()); |
|
90 |
} |
|
91 |
|
|
92 |
|
|
93 |
public static class RegisterPersistence implements Callable { |
|
94 |
|
|
95 |
public Object call() throws Exception { |
|
96 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
97 |
if( manager.getDefinition( |
|
98 |
COMPLEX_LEGEND_ITEM_PERSISTENCE_DEFINITION_NAME)==null ) { |
|
99 |
DynStruct definition = manager.addDefinition( |
|
100 |
DefaultComplexLegendItem.class, |
|
101 |
COMPLEX_LEGEND_ITEM_PERSISTENCE_DEFINITION_NAME, |
|
102 |
COMPLEX_LEGEND_ITEM_PERSISTENCE_DEFINITION_NAME + |
|
103 |
" Persistence definition", |
|
104 |
null, |
|
105 |
null |
|
106 |
); |
|
107 |
|
|
108 |
definition.addDynFieldObject("legend").setMandatory(true) |
|
109 |
.setClassOfValue(ILegend.class); |
|
110 |
definition.addDynFieldDouble("minScale").setMandatory(true); |
|
111 |
definition.addDynFieldDouble("maxScale").setMandatory(true); |
|
112 |
} |
|
113 |
return Boolean.TRUE; |
|
114 |
} |
|
115 |
|
|
116 |
} |
|
117 |
|
|
118 |
} |
|
0 | 119 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.impl/src/main/java/org/gvsig/complexlegend/impl/DefaultVectorComplexLegend.java | ||
---|---|---|
1 |
package org.gvsig.complexlegend.impl; |
|
2 |
|
|
3 |
import java.awt.Graphics2D; |
|
4 |
import java.awt.image.BufferedImage; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.Collections; |
|
7 |
import java.util.Comparator; |
|
8 |
import java.util.Iterator; |
|
9 |
import java.util.List; |
|
10 |
import java.util.Map; |
|
11 |
|
|
12 |
import org.cresques.cts.ICoordTrans; |
|
13 |
import org.gvsig.compat.print.PrintAttributes; |
|
14 |
import org.gvsig.complexlegend.ComplexLegendItem; |
|
15 |
import org.gvsig.complexlegend.VectorComplexLegend; |
|
16 |
import org.gvsig.fmap.dal.exception.DataException; |
|
17 |
import org.gvsig.fmap.dal.feature.Feature; |
|
18 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
19 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
20 |
import org.gvsig.fmap.geom.Geometry; |
|
21 |
import org.gvsig.fmap.mapcontext.MapContextException; |
|
22 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
23 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
24 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
25 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend; |
|
26 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
27 |
import org.gvsig.fmap.mapcontext.rendering.legend.LegendException; |
|
28 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent; |
|
29 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
30 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
|
31 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractVectorialLegend; |
|
32 |
import org.gvsig.tools.ToolsLocator; |
|
33 |
import org.gvsig.tools.dynobject.DynStruct; |
|
34 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
35 |
import org.gvsig.tools.persistence.Persistent; |
|
36 |
import org.gvsig.tools.persistence.PersistentState; |
|
37 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
38 |
import org.gvsig.tools.task.Cancellable; |
|
39 |
import org.gvsig.tools.util.Callable; |
|
40 |
|
|
41 |
public class DefaultVectorComplexLegend extends AbstractVectorialLegend implements VectorComplexLegend, Persistent{ |
|
42 |
|
|
43 |
public static final String COMPLEX_LEGEND_PERSISTENCE_DEFINITION_NAME = "ComplexLegendPersistence"; |
|
44 |
public static final String COMPLEX_LEGEND_NAME = "ComplexLegend"; |
|
45 |
public static final String COMPLEX_LEGEND_FIELD = "Legends"; |
|
46 |
private List<ComplexLegendItem> legends; |
|
47 |
private boolean useDefault; |
|
48 |
private int shapeType; |
|
49 |
private ISymbol defaultSymbol; |
|
50 |
private IVectorLegend currentLegend; |
|
51 |
|
|
52 |
public DefaultVectorComplexLegend() { |
|
53 |
super(); |
|
54 |
SymbolManager manager = MapContextLocator.getSymbolManager(); |
|
55 |
this.defaultSymbol = manager.createSymbol( Geometry.TYPES.SURFACE); |
|
56 |
} |
|
57 |
|
|
58 |
public List<ComplexLegendItem> getLegends() { |
|
59 |
if(legends == null){ |
|
60 |
legends = new ArrayList<ComplexLegendItem>(); |
|
61 |
} |
|
62 |
return Collections.unmodifiableList(legends); |
|
63 |
} |
|
64 |
|
|
65 |
public List<ComplexLegendItem> getEditedLegends() { |
|
66 |
if(legends == null){ |
|
67 |
legends = new ArrayList<ComplexLegendItem>(); |
|
68 |
} |
|
69 |
return legends; |
|
70 |
} |
|
71 |
|
|
72 |
public boolean isOverlapped(ComplexLegendItem legend) { |
|
73 |
Iterator it = getLegends().iterator(); |
|
74 |
while(it.hasNext()){ |
|
75 |
ComplexLegendItem aux = (ComplexLegendItem) it.next(); |
|
76 |
if((aux.getMinScale()==-1 && |
|
77 |
aux.getMaxScale()>legend.getMinScale())){ |
|
78 |
return true; |
|
79 |
} |
|
80 |
if((aux.getMaxScale()==-1 && |
|
81 |
aux.getMinScale()<legend.getMaxScale())){ |
|
82 |
return true; |
|
83 |
} |
|
84 |
if(!(aux.getMinScale()>=legend.getMaxScale() || |
|
85 |
aux.getMaxScale()<=legend.getMinScale())){ |
|
86 |
return true; |
|
87 |
} |
|
88 |
} |
|
89 |
return false; |
|
90 |
} |
|
91 |
|
|
92 |
public boolean add(ComplexLegendItem legend) { |
|
93 |
if(legends == null){ |
|
94 |
getLegends(); |
|
95 |
} |
|
96 |
|
|
97 |
boolean result = legends.add(legend); |
|
98 |
Collections.sort(legends, new Comparator<ComplexLegendItem>(){ |
|
99 |
public int compare(ComplexLegendItem o1, ComplexLegendItem o2){ |
|
100 |
if(o1.getMinScale() == o2.getMinScale()) |
|
101 |
return 0; |
|
102 |
return o1.getMinScale() < o2.getMinScale() ? -1 : 1; |
|
103 |
} |
|
104 |
}); |
|
105 |
return result; |
|
106 |
} |
|
107 |
|
|
108 |
public boolean remove(ComplexLegendItem legend) { |
|
109 |
if(legends == null){ |
|
110 |
getLegends(); |
|
111 |
} |
|
112 |
return legends.remove(legend); |
|
113 |
} |
|
114 |
|
|
115 |
public ComplexLegendItem getLegend(double scale) { |
|
116 |
Iterator<ComplexLegendItem> it = getLegends().iterator(); |
|
117 |
while(it.hasNext()){ |
|
118 |
ComplexLegendItem cleg = (ComplexLegendItem) it.next(); |
|
119 |
if(cleg.getMinScale() == -1 && |
|
120 |
cleg.getMaxScale() >= scale){ |
|
121 |
return cleg; |
|
122 |
} |
|
123 |
if(cleg.getMinScale() <= scale && |
|
124 |
cleg.getMaxScale() >= scale){ |
|
125 |
return cleg; |
|
126 |
} |
|
127 |
if(cleg.getMinScale() <= scale && |
|
128 |
cleg.getMaxScale() == -1){ |
|
129 |
return cleg; |
|
130 |
} |
|
131 |
} |
|
132 |
return null; |
|
133 |
} |
|
134 |
|
|
135 |
|
|
136 |
@Override |
|
137 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
|
138 |
double scale, Map queryParameters, ICoordTrans coordTrans, |
|
139 |
FeatureStore featureStore, FeatureQuery fquery, |
|
140 |
PrintAttributes properties) throws LegendException { |
|
141 |
ComplexLegendItem legend = getLegend(scale); |
|
142 |
if(legend != null){ |
|
143 |
if(legend.getLegend() != null && |
|
144 |
legend.getLegend() instanceof AbstractVectorialLegend){ |
|
145 |
setCurrentLegend((IVectorLegend)legend.getLegend()); |
|
146 |
((AbstractVectorialLegend) legend.getLegend()).print(g, viewPort, cancel, scale, queryParameters, coordTrans, |
|
147 |
featureStore, fquery, properties); |
|
148 |
} |
|
149 |
} |
|
150 |
} |
|
151 |
|
|
152 |
@Override |
|
153 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
|
154 |
double scale, Map queryParameters, ICoordTrans coordTrans, |
|
155 |
FeatureStore featureStore, PrintAttributes properties) |
|
156 |
throws LegendException { |
|
157 |
print(g, viewPort, cancel, scale, queryParameters, coordTrans, |
|
158 |
featureStore, null, properties); |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
163 |
Cancellable cancel, double scale, Map queryParameters, |
|
164 |
ICoordTrans coordTrans, FeatureStore featureStore) |
|
165 |
throws LegendException { |
|
166 |
ComplexLegendItem legend = getLegend(scale); |
|
167 |
if(legend != null){ |
|
168 |
if(legend.getLegend() != null && |
|
169 |
legend.getLegend() instanceof AbstractVectorialLegend){ |
|
170 |
setCurrentLegend((IVectorLegend)legend.getLegend()); |
|
171 |
((AbstractVectorialLegend) legend.getLegend()).draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans, |
|
172 |
featureStore); |
|
173 |
} |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
@Override |
|
178 |
protected void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
179 |
Cancellable cancel, double scale, Map queryParameters, |
|
180 |
ICoordTrans coordTrans, FeatureStore featureStore, |
|
181 |
FeatureQuery featureQuery, double dpi) throws LegendException { |
|
182 |
ComplexLegendItem legend = getLegend(scale); |
|
183 |
if(legend != null){ |
|
184 |
if(legend.getLegend() != null && |
|
185 |
legend.getLegend() instanceof AbstractVectorialLegend){ |
|
186 |
setCurrentLegend((IVectorLegend)legend.getLegend()); |
|
187 |
((AbstractVectorialLegend) legend.getLegend()).draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans, |
|
188 |
featureStore, featureQuery); |
|
189 |
} |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
|
|
194 |
private void setCurrentLegend(IVectorLegend legend) { |
|
195 |
boolean changed = this.currentLegend != legend; |
|
196 |
this.currentLegend = legend; |
|
197 |
|
|
198 |
if(changed){ |
|
199 |
fireDefaultSymbolChangedEvent(new ComplexLegendChangedEvent()); |
|
200 |
} |
|
201 |
//this.currentLegend.setShapeType(this.getShapeType()); |
|
202 |
} |
|
203 |
|
|
204 |
|
|
205 |
public static class RegisterPersistence implements Callable { |
|
206 |
|
|
207 |
public Object call() throws Exception { |
|
208 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
209 |
if (manager.getDefinition( |
|
210 |
COMPLEX_LEGEND_PERSISTENCE_DEFINITION_NAME) == null) { |
|
211 |
DynStruct definition = manager |
|
212 |
.addDefinition(DefaultVectorComplexLegend.class, |
|
213 |
COMPLEX_LEGEND_PERSISTENCE_DEFINITION_NAME, |
|
214 |
COMPLEX_LEGEND_PERSISTENCE_DEFINITION_NAME |
|
215 |
+ " Persistence definition", null, null); |
|
216 |
|
|
217 |
definition.extend(manager.getDefinition( |
|
218 |
AbstractVectorialLegend.VECTORIAL_LEGEND_PERSISTENCE_DEFINITION_NAME)); |
|
219 |
|
|
220 |
definition.addDynFieldList(COMPLEX_LEGEND_FIELD).setClassOfItems(DefaultComplexLegendItem.class); |
|
221 |
} |
|
222 |
return Boolean.TRUE; |
|
223 |
} |
|
224 |
|
|
225 |
} |
|
226 |
|
|
227 |
public void loadFromState(PersistentState state) |
|
228 |
throws PersistenceException { |
|
229 |
super.loadFromState(state); |
|
230 |
setLegends(state.getList(COMPLEX_LEGEND_FIELD)); |
|
231 |
} |
|
232 |
|
|
233 |
private void setLegends(List list) { |
|
234 |
this.legends = list; |
|
235 |
} |
|
236 |
|
|
237 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
238 |
super.saveToState(state); |
|
239 |
state.set(COMPLEX_LEGEND_FIELD, getEditedLegends()); |
|
240 |
} |
|
241 |
|
|
242 |
public static class RegisterLegend implements Callable { |
|
243 |
|
|
244 |
public Object call() throws Exception { |
|
245 |
MapContextManager manager = MapContextLocator.getMapContextManager(); |
|
246 |
|
|
247 |
manager.registerLegend( |
|
248 |
COMPLEX_LEGEND_NAME, |
|
249 |
DefaultVectorComplexLegend.class); |
|
250 |
|
|
251 |
return Boolean.TRUE; |
|
252 |
} |
|
253 |
|
|
254 |
} |
|
255 |
|
|
256 |
public ISymbol getSymbolByFeature(Feature feat) throws MapContextException { |
|
257 |
if(this.currentLegend != null |
|
258 |
&& this.currentLegend instanceof IVectorLegend){ |
|
259 |
return ((IVectorLegend)this.currentLegend).getSymbolByFeature(feat); |
|
260 |
} |
|
261 |
return null; |
|
262 |
} |
|
263 |
|
|
264 |
public int getShapeType() { |
|
265 |
return this.shapeType; |
|
266 |
} |
|
267 |
|
|
268 |
public void setShapeType(int shapeType) { |
|
269 |
this.shapeType = shapeType; |
|
270 |
SymbolManager manager = MapContextLocator.getSymbolManager(); |
|
271 |
this.defaultSymbol = manager.createSymbol(shapeType); |
|
272 |
} |
|
273 |
|
|
274 |
public void setDefaultSymbol(ISymbol s) { |
|
275 |
this.defaultSymbol = s; |
|
276 |
} |
|
277 |
|
|
278 |
public boolean isUseDefaultSymbol() { |
|
279 |
return useDefault; |
|
280 |
} |
|
281 |
|
|
282 |
public void useDefaultSymbol(boolean b) { |
|
283 |
this.useDefault = b; |
|
284 |
} |
|
285 |
|
|
286 |
public boolean isSuitableForShapeType(int shapeType) { |
|
287 |
return true; |
|
288 |
} |
|
289 |
|
|
290 |
public ISymbol getDefaultSymbol() { |
|
291 |
return defaultSymbol; |
|
292 |
} |
|
293 |
|
|
294 |
@Override |
|
295 |
protected String[] getRequiredFeatureAttributeNames( |
|
296 |
FeatureStore featureStore) throws DataException { |
|
297 |
// TODO Auto-generated method stub |
|
298 |
return null; |
|
299 |
} |
|
300 |
|
|
301 |
public String[] getDescriptions() { |
|
302 |
if(currentLegend instanceof IClassifiedLegend){ |
|
303 |
return ((IClassifiedLegend) currentLegend).getDescriptions(); |
|
304 |
} |
|
305 |
return new String[]{""}; |
|
306 |
} |
|
307 |
|
|
308 |
public ISymbol[] getSymbols() { |
|
309 |
if(currentLegend instanceof IClassifiedLegend){ |
|
310 |
return ((IClassifiedLegend) currentLegend).getSymbols(); |
|
311 |
} |
|
312 |
if(currentLegend == null){ |
|
313 |
if(getDefaultSymbol() != null){ |
|
314 |
return new ISymbol[]{getDefaultSymbol()}; |
|
315 |
} |
|
316 |
SymbolManager manager = MapContextLocator.getSymbolManager(); |
|
317 |
return new ISymbol[]{manager.createSymbol(shapeType)}; |
|
318 |
} |
|
319 |
return new ISymbol[]{currentLegend.getDefaultSymbol()}; |
|
320 |
} |
|
321 |
|
|
322 |
public Object[] getValues() { |
|
323 |
if(currentLegend instanceof IClassifiedLegend){ |
|
324 |
return ((IClassifiedLegend) currentLegend).getValues(); |
|
325 |
} |
|
326 |
return new String[]{""}; |
|
327 |
} |
|
328 |
|
|
329 |
private static class ComplexLegendChangedEvent extends SymbolLegendEvent{ |
|
330 |
|
|
331 |
public ComplexLegendChangedEvent() { |
|
332 |
super(null, null); |
|
333 |
} |
|
334 |
|
|
335 |
@Override |
|
336 |
public int getEventType() { |
|
337 |
return SymbolLegendEvent.LEGEND_VALUE_CHANGED; |
|
338 |
} |
|
339 |
} |
|
340 |
|
|
341 |
} |
|
0 | 342 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.impl/src/main/java/org/gvsig/complexlegend/impl/DefaultComplexLegendLibrary.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.complexlegend.impl; |
|
23 |
|
|
24 |
|
|
25 |
import org.gvsig.complexlabel.impl.ComplexLabelClassFactory; |
|
26 |
import org.gvsig.complexlabel.impl.DefaultComplexLabelClass; |
|
27 |
import org.gvsig.complexlegend.ComplexLegendLibrary; |
|
28 |
import org.gvsig.complexlegend.VectorComplexLegend; |
|
29 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
30 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
31 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
|
32 |
import org.gvsig.symbology.SymbologyLocator; |
|
33 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.driver.impl.PersistenceBasedLegendWriter; |
|
34 |
import org.gvsig.tools.library.AbstractLibrary; |
|
35 |
import org.gvsig.tools.library.LibraryException; |
|
36 |
import org.gvsig.tools.util.Caller; |
|
37 |
import org.gvsig.tools.util.impl.DefaultCaller; |
|
38 |
|
|
39 |
/** |
|
40 |
* Library for default implementation initialization and configuration. |
|
41 |
* This default implementation will be based in JFreeChart library. |
|
42 |
* |
|
43 |
* @author gvSIG team |
|
44 |
* @version $Id$ |
|
45 |
*/ |
|
46 |
public class DefaultComplexLegendLibrary extends AbstractLibrary { |
|
47 |
|
|
48 |
@Override |
|
49 |
public void doRegistration() { |
|
50 |
registerAsImplementationOf(ComplexLegendLibrary.class); |
|
51 |
} |
|
52 |
|
|
53 |
|
|
54 |
@Override |
|
55 |
protected void doInitialize() throws LibraryException { |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
protected void doPostInitialize() throws LibraryException { |
|
60 |
Caller caller = new DefaultCaller(); |
|
61 |
caller.add(new DefaultVectorComplexLegend.RegisterLegend()); |
|
62 |
caller.add(new DefaultVectorComplexLegend.RegisterPersistence()); |
|
63 |
caller.add(new DefaultComplexLegendItem.RegisterPersistence()); |
|
64 |
caller.add(new DefaultComplexLabelClass.RegisterPersistence()); |
|
65 |
|
|
66 |
if( !caller.call() ) { |
|
67 |
throw new LibraryException(DefaultComplexLegendLibrary.class, caller.getExceptions()); |
|
68 |
} |
|
69 |
|
|
70 |
MapContextManager mcoman = MapContextLocator.getMapContextManager(); |
|
71 |
mcoman.registerLegendWriter( |
|
72 |
VectorComplexLegend.class, |
|
73 |
SymbolManager.LEGEND_FILE_EXTENSION.substring(1), |
|
74 |
PersistenceBasedLegendWriter.class); |
|
75 |
|
|
76 |
SymbologyLocator.getSymbologyManager().registerLabelClass(new ComplexLabelClassFactory()); |
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
} |
|
0 | 81 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.impl/src/main/java/org/gvsig/complexlabel/impl/ComplexLabelClassFactory.java | ||
---|---|---|
1 |
package org.gvsig.complexlabel.impl; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelClass; |
|
4 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelClassFactory; |
|
5 |
import org.gvsig.tools.ToolsLocator; |
|
6 |
import org.gvsig.tools.i18n.I18nManager; |
|
7 |
|
|
8 |
public class ComplexLabelClassFactory implements ILabelClassFactory { |
|
9 |
|
|
10 |
public static final String FACTORY_ID = "MultipleLabelByScale"; |
|
11 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
12 |
|
|
13 |
|
|
14 |
public ILabelClass create() { |
|
15 |
return new DefaultComplexLabelClass(); |
|
16 |
} |
|
17 |
|
|
18 |
public String getID() { |
|
19 |
return FACTORY_ID; |
|
20 |
} |
|
21 |
|
|
22 |
public String getName() { |
|
23 |
return i18nManager.getTranslation("multiple_label_by_scale"); |
|
24 |
} |
|
25 |
|
|
26 |
public String toString() { |
|
27 |
return this.getName(); |
|
28 |
} |
|
29 |
} |
|
0 | 30 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.impl/src/main/java/org/gvsig/complexlabel/impl/DefaultComplexLabelClass.java | ||
---|---|---|
1 |
package org.gvsig.complexlabel.impl; |
|
2 |
|
|
3 |
|
|
4 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.LabelClass; |
|
5 |
import org.gvsig.tools.ToolsLocator; |
|
6 |
import org.gvsig.tools.dynobject.DynStruct; |
|
7 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
8 |
import org.gvsig.tools.persistence.Persistent; |
|
9 |
import org.gvsig.tools.persistence.PersistentState; |
|
10 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
11 |
import org.gvsig.tools.util.Callable; |
|
12 |
|
|
13 |
public class DefaultComplexLabelClass extends LabelClass implements Persistent{ |
|
14 |
|
|
15 |
public static final String COMPLEXLABELCLASS_PERSISTENCE_DEFINITION_NAME = "Complex.label.class"; |
|
16 |
|
|
17 |
private double minScale; |
|
18 |
private double maxScale; |
|
19 |
|
|
20 |
public double getMinScale() { |
|
21 |
return minScale; |
|
22 |
} |
|
23 |
|
|
24 |
public void setMinScale(double minScale) { |
|
25 |
this.minScale = minScale; |
|
26 |
} |
|
27 |
|
|
28 |
public double getMaxScale() { |
|
29 |
return maxScale; |
|
30 |
} |
|
31 |
|
|
32 |
public void setMaxScale(double maxScale) { |
|
33 |
this.maxScale = maxScale; |
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public boolean isVisible() { |
|
38 |
return super.isVisible(); |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public boolean isVisible(double scale) { |
|
43 |
if(getMaxScale() > scale && getMinScale() < scale){ |
|
44 |
return true; |
|
45 |
} |
|
46 |
return false; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public void loadFromState(PersistentState state) |
|
51 |
throws PersistenceException { |
|
52 |
super.loadFromState(state); |
|
53 |
setMinScale(state.getDouble("MinScale")); |
|
54 |
setMaxScale(state.getDouble("MaxScale")); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
59 |
super.saveToState(state); |
|
60 |
state.set("MinScale", getMinScale()); |
|
61 |
state.set("MaxScale", getMaxScale()); |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public Object clone() throws CloneNotSupportedException { |
|
66 |
DefaultComplexLabelClass cloned = (DefaultComplexLabelClass) super.clone(); |
|
67 |
cloned.setMaxScale(this.getMaxScale()); |
|
68 |
cloned.setMinScale(this.getMinScale()); |
|
69 |
return cloned; |
|
70 |
} |
|
71 |
|
|
72 |
public static class RegisterPersistence implements Callable { |
|
73 |
|
|
74 |
public Object call() throws Exception { |
|
75 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
76 |
if( manager.getDefinition(COMPLEXLABELCLASS_PERSISTENCE_DEFINITION_NAME)==null ) { |
|
77 |
DynStruct definition = manager.addDefinition( |
|
78 |
DefaultComplexLabelClass.class, |
|
79 |
COMPLEXLABELCLASS_PERSISTENCE_DEFINITION_NAME, |
|
80 |
COMPLEXLABELCLASS_PERSISTENCE_DEFINITION_NAME+" Persistence definition", |
|
81 |
null, |
|
82 |
null |
|
83 |
); |
|
84 |
|
|
85 |
definition.extend(manager.getDefinition( |
|
86 |
"LabelClass")); |
|
87 |
|
|
88 |
definition.addDynFieldDouble("MaxScale").setMandatory(true); |
|
89 |
definition.addDynFieldDouble("MinScale").setMandatory(true); |
|
90 |
} |
|
91 |
return Boolean.TRUE; |
|
92 |
} |
|
93 |
|
|
94 |
} |
|
95 |
} |
|
0 | 96 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.lib/org.gvsig.complexlegend.lib.impl/src/main/java/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.landregistryviewer package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>LandRegistryViewer library API default implementation.</p> |
|
11 |
|
|
12 |
</body> |
|
13 |
</html> |
|
0 | 14 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.swing/org.gvsig.complexlegend.swing.api/src/main/java/org/gvsig/complexlegend/swing/ComplexLegendPanel.java | ||
---|---|---|
1 |
package org.gvsig.complexlegend.swing; |
|
2 |
|
|
3 |
import javax.swing.ImageIcon; |
|
4 |
import javax.swing.JPanel; |
|
5 |
|
|
6 |
import org.gvsig.app.project.documents.view.legend.gui.ILegendPanel; |
|
7 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
8 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
9 |
|
|
10 |
public interface ComplexLegendPanel extends ILegendPanel{ |
|
11 |
|
|
12 |
|
|
13 |
} |
|
0 | 14 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.swing/org.gvsig.complexlegend.swing.api/src/main/java/org/gvsig/complexlegend/swing/ComplexLegendSwingLibrary.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.complexlegend.swing; |
|
23 |
|
|
24 |
import org.gvsig.app.project.documents.view.legend.gui.LegendManager; |
|
25 |
import org.gvsig.complexlegend.ComplexLegendLibrary; |
|
26 |
import org.gvsig.tools.library.AbstractLibrary; |
|
27 |
import org.gvsig.tools.library.LibraryException; |
|
28 |
|
|
29 |
/** |
|
30 |
* Library for Swing API initialization and configuration. |
|
31 |
* |
|
32 |
* @author gvSIG team |
|
33 |
* @version $Id$ |
|
34 |
*/ |
|
35 |
public class ComplexLegendSwingLibrary extends AbstractLibrary { |
|
36 |
|
|
37 |
@Override |
|
38 |
public void doRegistration() { |
|
39 |
registerAsAPI(ComplexLegendSwingLibrary.class); |
|
40 |
this.require(ComplexLegendLibrary.class); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
protected void doInitialize() throws LibraryException { |
|
45 |
// Do nothing |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
protected void doPostInitialize() throws LibraryException { |
|
50 |
// IconThemeHelper.registerIcon("legend", |
|
51 |
// "legend-overview-dot-density", this); |
|
52 |
// IconThemeHelper.registerIcon("legend", |
|
53 |
// "legend-dot-density-low-density-sample", this); |
|
54 |
// IconThemeHelper.registerIcon("legend", |
|
55 |
// "legend-dot-density-medium-density-sample", this); |
|
56 |
// IconThemeHelper.registerIcon("legend", |
|
57 |
// "legend-dot-density-high-density-sample", this); |
|
58 |
} |
|
59 |
|
|
60 |
} |
|
0 | 61 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.swing/org.gvsig.complexlegend.swing.api/src/main/java/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.landregistryviewer package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>LandRegistryViewer swing library API.</p> |
|
11 |
|
|
12 |
<p> |
|
13 |
It allows to get swing panels to show LandRegistryViewer, and to include them in windows. |
|
14 |
</p> |
|
15 |
|
|
16 |
</body> |
|
17 |
</html> |
|
0 | 18 |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.swing/org.gvsig.complexlegend.swing.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.complexlegend.swing.ComplexLegendSwingLibrary |
org.gvsig.complexlegend/tags/org.gvsig.complexlegend-1.0.30/org.gvsig.complexlegend/org.gvsig.complexlegend.swing/org.gvsig.complexlegend.swing.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.complexlegend.swing.api</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>org.gvsig.complexlegend.swing.api</name> |
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.complexlegend.swing</artifactId> |
|
10 |
<version>1.0.30</version> |
|
11 |
</parent> |
|
12 |
<build> |
|
13 |
<plugins> |
|
14 |
<plugin> |
|
15 |
<groupId>org.apache.maven.plugins</groupId> |
|
16 |
<artifactId>maven-jar-plugin</artifactId> |
|
17 |
<configuration> |
|
18 |
</configuration> |
|
19 |
<executions> |
|
20 |
<!-- |
|
21 |
Generates a jar file only with the test classes |
|
22 |
--> |
|
23 |
<execution> |
|
24 |
<goals> |
|
25 |
<goal>test-jar</goal> |
|
26 |
</goals> |
|
27 |
</execution> |
|
28 |
</executions> |
|
29 |
</plugin> |
|
30 |
</plugins> |
|
31 |
</build> |
|
32 |
<dependencies> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.complexlegend.lib.api</artifactId> |
|
36 |
</dependency> |
|
37 |
<dependency> |
|
38 |
<groupId>org.gvsig</groupId> |
|
39 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
|
40 |
</dependency> |
|
41 |
</dependencies> |
|
42 |
</project> |
|
0 | 43 |
Also available in: Unified diff