Revision 2091

View differences:

org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.app/pom.xml
1
<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">
2
  <modelVersion>4.0.0</modelVersion>
3
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.legend.heatmapcomparison</artifactId>
6
    <version>1.0.14</version>
7
  </parent>
8
  <groupId>org.gvsig</groupId>
9
  <artifactId>org.gvsig.legend.heatmapcomparison.app</artifactId>
10
  <packaging>pom</packaging>
11
  <name>org.gvsig.legend.heatmapcomparison.app</name>
12

  
13
  <modules>
14
    <module>org.gvsig.legend.heatmapcomparison.app.mainplugin</module>
15
  </modules>
16

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

  
29
  <fileSets>
30
    <fileSet>
31
      <directory>src/main/resources-plugin</directory>
32
      <outputDirectory>.</outputDirectory>
33
    </fileSet>
34
  </fileSets>
35

  
36

  
37
  <dependencySets>
38
    <dependencySet>
39
      <useProjectArtifact>false</useProjectArtifact>
40
      <useTransitiveDependencies>false</useTransitiveDependencies>
41
      <outputDirectory>lib</outputDirectory>
42
      <includes>
43
        <include>org.gvsig:org.gvsig.legend.heatmapcomparison.lib.api</include>
44
        <include>org.gvsig:org.gvsig.legend.heatmapcomparison.lib.impl</include>
45
        <include>org.gvsig:org.gvsig.legend.heatmapcomparison.swing.api</include>
46
        <include>org.gvsig:org.gvsig.legend.heatmapcomparison.swing.impl</include>
47
      </includes>
48
    </dependencySet>
49
  </dependencySets>
50

  
51
</assembly>
52

  
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.app/org.gvsig.legend.heatmapcomparison.app.mainplugin/src/main/java/org/gvsig/legend/heatmapcomparison/app/HeatmapComparisonLegendExtension.java
1

  
2
package org.gvsig.legend.heatmapcomparison.app;
3

  
4
import org.gvsig.andami.IconThemeHelper;
5
import org.gvsig.andami.plugins.Extension;
6

  
7

  
8
public class HeatmapComparisonLegendExtension extends Extension {
9

  
10
    @Override
11
    public void initialize() {
12
        IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-heatmapcomparison", this);
13
    }
14

  
15
    @Override
16
    public void execute(String string) {
17
    }
18

  
19
    @Override
20
    public boolean isEnabled() {
21
        return true;
22
    }
23

  
24
    @Override
25
    public boolean isVisible() {
26
        return true;
27
    }
28
    
29
}
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.app/org.gvsig.legend.heatmapcomparison.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 gvSIG
3
  Association. This program is free software; you can redistribute it and/or modify
4
  it under the terms of the GNU General Public License as published by the Free Software
5
  Foundation; either version 3 of the License, or (at your option) any later version.
6
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
7
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8
  PURPOSE. See the GNU General Public License for more details. You should have received
9
  a copy of the GNU General Public License along with this program; if not, write to
10
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
11
  USA. For any additional information, do not hesitate to contact us at info AT gvsig.com,
12
  or visit our website www.gvsig.com. -->
13
<plugin-config>
14
  <depends plugin-name="org.gvsig.app.mainplugin" />
15
  <resourceBundle name="text" />
16
  <libraries library-dir="lib" />
17
  <extensions>
18
    <extension class-name="org.gvsig.legend.heatmapcomparison.app.HeatmapComparisonLegendExtension"
19
      description="" active="true" priority="1">
20

  
21
    </extension>
22

  
23
  </extensions>
24
</plugin-config>
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.app/org.gvsig.legend.heatmapcomparison.app.mainplugin/src/main/resources-plugin/plugin-persistence.def
1
<?xml version="1.0"?>
2
<!--
3
Definitions of plugin persistence org.gvsig.legend.heatmapcomparison.app.mainplugin
4
 -->
5
<definitions>
6
  <version>1.0.0</version>
7
  <classes>
8
    <class name="org.gvsig.legend.heatmapcomparison.app.mainplugin">
9
      <extends>
10
      </extends>
11
      <description>Persistence of the legend of heatmap comparison</description>
12
      <fields>
13
      </fields>
14
    </class>
15
  </classes>
16
</definitions>  
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.app/org.gvsig.legend.heatmapcomparison.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
1
_Heatmap_comparison_legend_description=Heat map for representing the difference between dots density in a map.
2
_Heatmap_comparison_legend=Heat map comparison
3
_Distance=Distance
4
pixels=pixels
5
_Use_color_ramp=Use a color ramp
6
_Number_of_colors=Number of colors
7
_Hot_color=Hot color
8
Alpha=Alpha
9
_Cold_color=Cold color
10
_Use_color_table=Use a color table
11
_Color_table=Color table
12
_Use_transparency=Use transparencia
13
_Hot_color_transparency=Hot color transparency
14
_Cold_color_transparency=Cold color transparency
15
_Use_a_field_to_weight_the_heat_map=Use a field to weight the heat map
16
_Hot_filter=Hot filter
17
_Cold_filter=Cold filter
18
_Mid_color=Mid color
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.app/org.gvsig.legend.heatmapcomparison.app.mainplugin/src/main/resources-plugin/i18n/text.properties
1
_Heatmap_comparison_legend_description=Mapa de calor comparado que representa la diferencia entre densidad de puntos en un mapa.
2
_Heatmap_comparison_legend=Mapa de calor comparado
3
_Distance=Distancia
4
pixels=pixels
5
_Use_color_ramp=Usar un gradiente de color
6
_Number_of_colors=Numero de colores
7
_Hot_color=Color caliente
8
Alpha=Alpha
9
_Cold_color=Color frio
10
_Use_color_table=Usar tabla de color
11
_Color_table=Tabla de color
12
_Use_transparency=Usar transparencia
13
_Hot_color_transparency=Transparencia del color caliente
14
_Cold_color_transparency=Transparencia del color frio
15
_Use_a_field_to_weight_the_heat_map=Usar un campo para ponderar el mapa de calor
16
_Hot_filter=Filtro caliente
17
_Cold_filter=Filtro frio
18
_Mid_color=Color medio
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.app/org.gvsig.legend.heatmapcomparison.app.mainplugin/pom.xml
1
<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">
2
  <modelVersion>4.0.0</modelVersion>
3
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.legend.heatmapcomparison.app</artifactId>
6
    <version>1.0.14</version>
7
  </parent>
8
  <groupId>org.gvsig</groupId>
9
  <artifactId>org.gvsig.legend.heatmapcomparison.app.mainplugin</artifactId>
10
  <version>1.0.14</version>
11
  <name>org.gvsig.legend.heatmapcomparison.app.mainplugin</name>
12

  
13
    <properties>
14
    <!-- Package info property values -->
15
    <gvsig.package.info.state>testing</gvsig.package.info.state>
16
    <gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.4.0-A</gvsig.package.info.dependencies>
17
    <gvsig.package.info.official>true</gvsig.package.info.official>
18
    <gvsig.package.info.name>Vector legend: heat map comparison</gvsig.package.info.name>
19
    <gvsig.package.info.description>Legend for aggregate text symbols that are near.</gvsig.package.info.description>
20
    <gvsig.package.info.categories>View,Vector,Symbology</gvsig.package.info.categories>
21
    <gvsig.package.info.javaVM>j1_7</gvsig.package.info.javaVM>
22
    <gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-base-legends/pool</gvsig.package.info.poolURL>
23
  </properties>
24

  
25
  <dependencies>
26
    <dependency>
27
      <groupId>org.gvsig</groupId>
28
      <artifactId>org.gvsig.andami</artifactId>
29
      <scope>compile</scope>
30
    </dependency>
31
    <dependency>
32
      <groupId>org.gvsig</groupId>
33
      <artifactId>org.gvsig.legend.heatmapcomparison.swing.api</artifactId>
34
      <scope>compile</scope>
35
    </dependency>
36
    <dependency>
37
      <groupId>org.gvsig</groupId>
38
      <artifactId>org.gvsig.legend.heatmapcomparison.lib.api</artifactId>
39
      <scope>compile</scope>
40
    </dependency>
41
    <dependency>
42
      <groupId>org.gvsig</groupId>
43
      <artifactId>org.gvsig.legend.heatmapcomparison.lib.impl</artifactId>
44
      <scope>runtime</scope>
45
    </dependency>
46
    <dependency>
47
      <groupId>org.gvsig</groupId>
48
      <artifactId>org.gvsig.legend.heatmapcomparison.swing.impl</artifactId>
49
      <scope>runtime</scope>
50
    </dependency>
51
    <dependency>
52
      <groupId>org.gvsig</groupId>
53
      <artifactId>org.gvsig.app.mainplugin</artifactId>
54
      <scope>compile</scope>
55
    </dependency>
56
  </dependencies>
57
</project>
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.app/org.gvsig.legend.heatmapcomparison.app.mainplugin/buildNumber.properties
1
#Fri Jul 31 23:44:07 CEST 2020
2
buildNumber=15
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/pom.xml
1
<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">
2
  <modelVersion>4.0.0</modelVersion>
3
  <groupId>org.gvsig</groupId>
4
  <artifactId>org.gvsig.legend.heatmapcomparison</artifactId>
5
  <version>1.0.14</version>
6
  <packaging>pom</packaging>
7
  <name>${project.artifactId}</name>
8
  <description>Legend for heat maps.</description>
9
  <parent>
10
    <groupId>org.gvsig</groupId>
11
    <artifactId>org.gvsig.desktop</artifactId>
12
    <version>2.0.287</version>
13
  </parent>
14

  
15
  <url>https://devel.gvsig.org/sites/org.gvsig.legend.heatmapcomparison/${project.version}</url>
16
  <scm>
17
    <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14</connection>
18
    <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14</developerConnection>
19
    <url>https://devel.gvsig.org/redmine/projects/gvsig-projects-pool/repository/show/org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14</url>
20
  </scm>
21
  <repositories>
22
    <repository>
23
      <id>gvsig-public-http-repository</id>
24
      <name>gvSIG maven public HTTP repository</name>
25
      <url>http://devel.gvsig.org/m2repo/j2se</url>
26
      <releases>
27
        <enabled>true</enabled>
28
        <updatePolicy>daily</updatePolicy>
29
        <checksumPolicy>warn</checksumPolicy>
30
      </releases>
31
      <snapshots>
32
        <enabled>true</enabled>
33
        <updatePolicy>daily</updatePolicy>
34
        <checksumPolicy>warn</checksumPolicy>
35
      </snapshots>
36
    </repository>
37
  </repositories>
38

  
39
  <distributionManagement>
40
    <site>
41
      <id>gvsig-repository</id>
42
      <url>dav:https://devel.gvsig.org/download/projects/gvsig-projects-pool/pool/${project.artifactId}/${project.version}</url>
43
    </site>
44
  </distributionManagement>
45

  
46
  <build>
47
    <plugins>
48
      <plugin>
49
        <groupId>org.apache.maven.plugins</groupId>
50
        <artifactId>maven-release-plugin</artifactId>
51
        <configuration>
52
          <tagBase>https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.legend.heatmapcomparison/tags</tagBase>
53
        </configuration>
54
      </plugin>
55
    </plugins>
56
  </build>
57

  
58

  
59

  
60
  <dependencyManagement>
61
    <dependencies>
62
      <dependency>
63
        <groupId>org.gvsig</groupId>
64
        <artifactId>org.gvsig.legend.heatmapcomparison.lib.api</artifactId>
65
        <version>1.0.14</version>
66
      </dependency>
67
      <dependency>
68
        <groupId>org.gvsig</groupId>
69
        <artifactId>org.gvsig.legend.heatmapcomparison.lib.impl</artifactId>
70
        <version>1.0.14</version>
71
      </dependency>
72
      <dependency>
73
        <groupId>org.gvsig</groupId>
74
        <artifactId>org.gvsig.legend.heatmapcomparison.swing.api</artifactId>
75
        <version>1.0.14</version>
76
      </dependency>
77
      <dependency>
78
        <groupId>org.gvsig</groupId>
79
        <artifactId>org.gvsig.legend.heatmapcomparison.swing.impl</artifactId>
80
        <version>1.0.14</version>
81
      </dependency>
82
      <dependency>
83
        <groupId>org.gvsig</groupId>
84
        <artifactId>org.gvsig.legend.heatmapcomparison.app.mainplugin</artifactId>
85
        <version>1.0.14</version>
86
      </dependency>
87
    </dependencies>
88
  </dependencyManagement>
89
  <modules>
90
    <module>org.gvsig.legend.heatmapcomparison.lib</module>
91
    <module>org.gvsig.legend.heatmapcomparison.swing</module>
92
    <module>org.gvsig.legend.heatmapcomparison.app</module>
93
  </modules>
94
</project>
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.lib/org.gvsig.legend.heatmapcomparison.lib.impl/pom.xml
1
<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">
2
  <modelVersion>4.0.0</modelVersion>
3
  <artifactId>org.gvsig.legend.heatmapcomparison.lib.impl</artifactId>
4
  <name>org.gvsig.legend.heatmapcomparison.lib.impl</name>
5
  <parent>
6
    <groupId>org.gvsig</groupId>
7
    <artifactId>org.gvsig.legend.heatmapcomparison.lib</artifactId>
8
    <version>1.0.14</version>
9
  </parent>
10
  <groupId>org.gvsig</groupId>
11
  <dependencies>
12
    <dependency>
13
      <groupId>org.gvsig</groupId>
14
      <artifactId>org.gvsig.legend.heatmapcomparison.lib.api</artifactId>
15
      <scope>compile</scope>
16
    </dependency>
17
    <dependency>
18
      <groupId>org.gvsig</groupId>
19
      <artifactId>org.gvsig.fmap.dal.api</artifactId>
20
      <scope>compile</scope>
21
    </dependency>
22
    <dependency>
23
      <groupId>org.gvsig</groupId>
24
      <artifactId>org.gvsig.symbology.lib.impl</artifactId>
25
      <scope>compile</scope>
26
    </dependency>
27
    <dependency>
28
      <groupId>org.gvsig</groupId>
29
      <artifactId>org.gvsig.ui</artifactId>
30
      <scope>compile</scope>
31
    </dependency>
32
  </dependencies>
33
</project>
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.lib/org.gvsig.legend.heatmapcomparison.lib.impl/src/main/java/org/gvsig/legend/heatmapcomparison/lib/impl/DefaultHeatmapComparisonLegendManager.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.legend.heatmapcomparison.lib.impl;
24

  
25
import org.gvsig.fmap.dal.feature.FeatureStore;
26
import org.gvsig.legend.heatmapcomparison.lib.api.HeatmapComparisonLegend;
27
import org.gvsig.legend.heatmapcomparison.lib.api.HeatmapComparisonLegendManager;
28

  
29

  
30
public class DefaultHeatmapComparisonLegendManager implements HeatmapComparisonLegendManager {
31

  
32
    @Override
33
    public HeatmapComparisonLegend create() {
34
        return new DefaultHeatmapComparisonLegend();
35
    }
36

  
37
    @Override
38
    public Class<? extends HeatmapComparisonLegend> getLegendClass() {
39
        return DefaultHeatmapComparisonLegend.class;
40
    }
41

  
42
}
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.lib/org.gvsig.legend.heatmapcomparison.lib.impl/src/main/java/org/gvsig/legend/heatmapcomparison/lib/impl/DefaultHeatmapComparisonLegend.java
1
package org.gvsig.legend.heatmapcomparison.lib.impl;
2

  
3
import java.awt.Color;
4
import java.awt.Graphics2D;
5
import java.awt.Image;
6
import java.awt.image.BufferedImage;
7
import java.util.ArrayList;
8
import java.util.Map;
9

  
10
import org.apache.commons.lang3.StringUtils;
11
import org.cresques.cts.ICoordTrans;
12
import org.gvsig.compat.print.PrintAttributes;
13
import org.gvsig.expressionevaluator.Expression;
14
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
15
import org.gvsig.expressionevaluator.MutableSymbolTable;
16
import org.gvsig.fmap.dal.DALLocator;
17

  
18
import org.gvsig.fmap.dal.exception.DataException;
19
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable;
20
import org.gvsig.fmap.dal.feature.Feature;
21
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
22
import org.gvsig.fmap.dal.feature.FeatureQuery;
23
import org.gvsig.fmap.dal.feature.FeatureSelection;
24
import org.gvsig.fmap.dal.feature.FeatureSet;
25
import org.gvsig.fmap.dal.feature.FeatureStore;
26
import org.gvsig.fmap.dal.feature.FeatureType;
27
import org.gvsig.fmap.geom.Geometry;
28
import org.gvsig.fmap.geom.GeometryUtils;
29
import org.gvsig.fmap.geom.primitive.Point;
30
import org.gvsig.fmap.mapcontext.MapContextException;
31
import org.gvsig.fmap.mapcontext.ViewPort;
32
import org.gvsig.fmap.mapcontext.layers.operations.IHasImageLegend;
33
import org.gvsig.fmap.mapcontext.rendering.legend.LegendException;
34
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent;
35
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
36
import org.gvsig.gui.ColorTablePainter;
37
import org.gvsig.gui.DefaultColorTablePainter;
38
import org.gvsig.legend.heatmapcomparison.lib.api.HeatmapComparisonLegend;
39
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractVectorialLegend;
40
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.DefaultFeatureDrawnNotification;
41
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.impl.SimpleTextSymbol;
42
import org.gvsig.tools.exception.BaseException;
43
import org.gvsig.tools.persistence.PersistentState;
44
import org.gvsig.tools.persistence.exception.PersistenceException;
45
import org.gvsig.tools.swing.api.ToolsSwingLocator;
46
import org.gvsig.tools.swing.api.ToolsSwingManager;
47
import org.gvsig.tools.task.Cancellable;
48
import org.gvsig.tools.visitor.VisitCanceledException;
49
import org.gvsig.tools.visitor.Visitor;
50

  
51
public class DefaultHeatmapComparisonLegend extends AbstractVectorialLegend implements HeatmapComparisonLegend, IHasImageLegend {
52

  
53
    private ISymbol defaultSymbol;
54
    private DensityAlgorithm algorithm;
55
    private String fieldName;
56
    private Color rampColdColor;
57
    private Color rampMidColor;
58
    private Color rampHotColor;
59
    private int rampNumColors;
60
    private Geometry roi;
61
    private Image imageLegend;
62
    private HeatmapColorTable hmColorTable;
63
    private Expression hotFilter;
64
    private Expression coldFilter;
65
    private boolean useWeight;
66

  
67
    public DefaultHeatmapComparisonLegend() {
68

  
69
        this.defaultSymbol = new SimpleTextSymbol();
70
        this.algorithm = new DensityAlgorithm(30);
71
        this.fieldName = null;
72
        this.useWeight = false;
73
        this.setColorTable(10, Color.BLUE, new Color(255, 255, 0, 30), Color.RED);
74
    }
75

  
76
    @Override
77
    protected String[] getRequiredFeatureAttributeNames(FeatureStore featureStore) throws DataException {
78
        //TODO optimize required features
79
        FeatureType ftype = featureStore.getDefaultFeatureType();
80
//        String[] allAttributes = new String[ftype.getAttributeDescriptors().length];
81
        ArrayList<String> arrayAttributes = new ArrayList<>();
82
        for (FeatureAttributeDescriptor attributeDescriptor : ftype.getAttributeDescriptors()) {
83
            arrayAttributes.add(attributeDescriptor.getName());
84
        }
85
        String[] a = arrayAttributes.toArray(new String[arrayAttributes.size()]);
86
        return a;
87
//        if (StringUtils.isEmpty(this.fieldName)) {
88
//            return new String[]{
89
//                ftype.getDefaultGeometryAttributeName()
90
//            };
91
//        }
92
//        return new String[]{
93
//            ftype.getDefaultGeometryAttributeName(),
94
//            this.fieldName
95
//        };
96
    }
97

  
98
    @Override
99
    public ISymbol getDefaultSymbol() {
100
        return this.defaultSymbol;
101
    }
102

  
103
    @Override
104
    public void setDefaultSymbol(ISymbol is) {
105
    }
106

  
107
    @Override
108
    public ISymbol getSymbolByFeature(Feature ftr) throws MapContextException {
109
        return this.defaultSymbol;
110
    }
111

  
112
    @Override
113
    public int getShapeType() {
114
        return Geometry.TYPES.GEOMETRY;
115
    }
116

  
117
    @Override
118
    public void setShapeType(int i) {
119
    }
120

  
121
    @Override
122
    public boolean isUseDefaultSymbol() {
123
        return true;
124
    }
125

  
126
    @Override
127
    public void useDefaultSymbol(boolean bln) {
128
    }
129

  
130
    @Override
131
    public boolean isSuitableForShapeType(int shapeType) {
132
        return true;
133
    }
134

  
135
    @Override
136
    protected void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, Map queryParameters, ICoordTrans coordTrans, FeatureStore featureStore, FeatureQuery featureQuery, double dpi) throws LegendException {
137
        int saved_distance = this.algorithm.getDistance();
138
        try {
139
            int distance = (int) (this.algorithm.getDistance() * (dpi / 72));
140
            Geometry theROI = null;
141
            if (this.roi != null) {
142
                theROI = this.roi.cloneGeometry();
143
                theROI.transform(viewPort.getAffineTransform());
144
            }
145
            this.algorithm.setDistance(distance);
146
            this.algorithm.init(image.getWidth(), image.getHeight());
147
            super.draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans, featureStore, featureQuery, dpi);
148
            if (!cancel.isCanceled()) {
149
                this.algorithm.drawWithOpaqueColors(image, g, this.getHeatMapColorTable().getColorTable(), cancel, theROI);
150
            }
151
        } finally {
152
            this.algorithm.setDistance(saved_distance);
153

  
154
        }
155
    }
156

  
157
    @Override
158
    public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
159
            double scale, Map queryParameters, ICoordTrans coordTrans,
160
            FeatureStore featureStore, FeatureQuery featureQuery, PrintAttributes properties)
161
            throws LegendException {
162

  
163
        int saved_distance = this.algorithm.getDistance();
164
        try {
165
            double dpi = viewPort.getDPI();
166
            // Ver CartographicSupportToolkit.getCartographicLength
167
            int distance = (int) (this.algorithm.getDistance() * (dpi / 72));
168
            Geometry theROI = null;
169
            if (this.roi != null) {
170
                theROI = this.roi.cloneGeometry();
171
                theROI.transform(viewPort.getAffineTransform());
172
            }
173
            this.algorithm.setDistance(distance);
174
            this.algorithm.init(viewPort.getImageWidth(), viewPort.getImageHeight());
175
            BufferedImage image = new BufferedImage(viewPort.getImageWidth(), viewPort.getImageHeight(), BufferedImage.TYPE_INT_ARGB);
176
            super.draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans, featureStore, featureQuery, dpi);
177
            if (!cancel.isCanceled()) {
178
                this.algorithm.drawWithAlphaColors(image, g, this.getHeatMapColorTable().getColorTable(), cancel, theROI);
179
                g.drawImage(image, 0, 0, null);
180
            }
181
        } finally {
182
            this.algorithm.setDistance(saved_distance);
183

  
184
        }
185
    }
186

  
187
    @Override
188
    protected void drawFeatures(
189
            BufferedImage image,
190
            Graphics2D g,
191
            final ViewPort viewPort,
192
            final Cancellable cancel,
193
            final ICoordTrans coordTrans,
194
            double dpi,
195
            DefaultFeatureDrawnNotification drawnNotification,
196
            FeatureSet featureSet,
197
            FeatureSelection selection
198
    ) throws BaseException {
199
        int x = -1;
200
        if (!StringUtils.isEmpty(this.fieldName)) {
201
            x = featureSet.getDefaultFeatureType().getIndex(this.fieldName);
202
        }
203
        final int n = x;
204

  
205
        MutableSymbolTable s = ExpressionEvaluatorLocator.getManager().createSymbolTable();
206
        FeatureSymbolTable fst = DALLocator.getDataManager().createFeatureSymbolTable();
207
        s.addSymbolTable(fst);
208

  
209
        featureSet.accept(new Visitor() {
210
            @Override
211
            public void visit(Object o) throws VisitCanceledException, BaseException {
212
                if (cancel.isCanceled()) {
213
                    throw new VisitCanceledException();
214
                }
215
                Feature feature = (Feature) o;
216
                Geometry geom = feature.getDefaultGeometry();
217
                if (geom != null) {
218
                    Point pointGeo = geom.centroid();
219
                    if (coordTrans != null) {
220
                        pointGeo.reProject(coordTrans);
221
                    }
222
                    Point pointPixels = (Point) pointGeo.cloneGeometry();
223
                    pointPixels.transform(viewPort.getAffineTransform());
224

  
225
                    double value = 0;
226
                    try {
227
                        fst.setFeature(feature);
228
                        if (useWeight == true) {
229
                            if (n > 0) {
230
                                value = feature.getDouble(n);
231
                            }
232
                            fillAlgorithmHot(s, hotFilter, pointPixels, value);
233
                            fillAlgorithmCold(s, coldFilter, pointPixels, value);
234
                        } else {
235
                            fillAlgorithmHot(s, hotFilter, pointPixels, 1.0);
236
                            fillAlgorithmCold(s, coldFilter, pointPixels, 1.0);
237
                        }
238
                    } catch (Exception ex) {
239
                    }
240

  
241
                }
242
            }
243
        }
244
        );
245
    }
246

  
247
    protected void fillAlgorithmCold(MutableSymbolTable s, Expression filter, Point pointPixels, Double value) {
248
        Object boolResult = filter.execute(s);
249
        if (boolResult instanceof Boolean) {
250
            boolean hbool = (Boolean) boolResult;
251
            if (hbool) {
252
                algorithm.addCold((int) pointPixels.getX(), (int) pointPixels.getY(), value);
253
            }
254
        }
255
    }
256

  
257
    protected void fillAlgorithmHot(MutableSymbolTable s, Expression filter, Point pointPixels, Double value) {
258
        Object boolResult = filter.execute(s);
259
        if (boolResult instanceof Boolean) {
260
            boolean hbool = (Boolean) boolResult;
261
            if (hbool) {
262
                algorithm.addHot((int) pointPixels.getX(), (int) pointPixels.getY(), value);
263
            }
264
        }
265
    }
266

  
267
    /**
268
     * @return the distance
269
     */
270
    @Override
271

  
272
    public int getDistance() {
273
        return this.algorithm.getDistance();
274
    }
275

  
276
    /**
277
     * @param distance the distance to set
278
     */
279
    @Override
280
    public void setDistance(int distance) {
281
        this.algorithm.setDistance(distance);
282
    }
283

  
284
    @Override
285
    public void setColorTable(int numColors, Color coldColor, Color midColor, Color hotColor) {
286
        this.rampColdColor = coldColor;
287
        this.rampMidColor = midColor;
288
        this.rampHotColor = hotColor;
289
        this.rampNumColors = numColors;
290
        this.imageLegend = null;
291
        this.hmColorTable = null;
292
        this.fireDefaultSymbolChangedEvent(new SymbolLegendEvent(null, null));
293
    }
294

  
295
//    @Override
296
//    public Color[] getSourceColorTable() {
297
//        return this.sourceColorTable;
298
//    }
299
    @Override
300
    public String getFieldName() {
301
        return this.fieldName;
302
    }
303

  
304
    @Override
305
    public void setFieldName(String fieldName) {
306
        this.fieldName = fieldName;
307
    }
308

  
309
    @Override
310
    public void setROI(Geometry roi) {
311
        this.roi = roi;
312
    }
313

  
314
    @Override
315
    public Geometry getROI() {
316
        return this.roi;
317
    }
318

  
319
    @Override
320
    public Image getImageLegend() {
321
        if (this.imageLegend == null) {
322
            BufferedImage img = new BufferedImage(80, 20, BufferedImage.TYPE_INT_RGB);
323
            ColorTablePainter painter = new DefaultColorTablePainter(this.getTargetColorTable(), "");
324
            Graphics2D g = img.createGraphics();
325
            g.setClip(0, 0, 80, 20);
326
            g.setBackground(Color.WHITE);
327
            g.fillRect(0, 0, 80, 20);
328
            painter.paint(g, false);
329
            this.imageLegend = img;
330
        }
331
        return this.imageLegend;
332
    }
333

  
334
    @Override
335
    public Color[] getTargetColorTable() {
336
        return this.getHeatMapColorTable().getColorTable();
337
    }
338

  
339
    @Override
340
    public String getPathImage() {
341
        return null;
342
    }
343

  
344
    private HeatmapColorTable getHeatMapColorTable() {
345
        if (this.hmColorTable == null) {
346
            this.hmColorTable = new HeatmapColorTable(this.rampColdColor, this.rampMidColor, this.rampHotColor, this.rampNumColors);
347
        }
348
        return this.hmColorTable;
349
    }
350

  
351
    @Override
352
    public void loadFromState(PersistentState state) throws PersistenceException {
353
        this.defaultSymbol = new SimpleTextSymbol();
354
        this.imageLegend = null;
355
        super.loadFromState(state);
356
        this.fieldName = state.getString("fieldName");
357
        int distance = state.getInt("distance");
358
        this.algorithm.setDistance(distance);
359
        this.rampNumColors = state.getInt("rampNumColors");
360
        this.rampColdColor = (Color) state.get("rampColdColor");
361
        this.rampMidColor = (Color) state.get("rampMidColor");
362
        this.rampHotColor = (Color) state.get("rampHotColor");
363
        this.useWeight = (boolean) state.get("useWeight");
364
        this.coldFilter = (Expression) state.get("coldFilter");
365
        this.hotFilter = (Expression) state.get("hotFilter");
366
    }
367

  
368
    @Override
369
    public int getRampNumColors() {
370
        return this.rampNumColors;
371
    }
372

  
373
    @Override
374
    public Color getRampColdColor() {
375
        return this.rampColdColor;
376
    }
377

  
378
    @Override
379
    public Color getRampMidColor() {
380
        return this.rampMidColor;
381
    }
382

  
383
    @Override
384
    public Color getRampHotColor() {
385
        return this.rampHotColor;
386
    }
387

  
388
    @Override
389
    public void saveToState(PersistentState state) throws PersistenceException {
390
        super.saveToState(state);
391
        state.set("fieldName", fieldName);
392
        state.set("distance", algorithm.distance);
393
        state.set("rampNumColors", rampNumColors);
394
        state.set("rampColdColor", rampColdColor);
395
        state.set("rampMidColor", rampMidColor);
396
        state.set("rampHotColor", rampHotColor);
397
        state.set("useWeight", useWeight);
398
        state.set("coldFilter", coldFilter);
399
        state.set("hotFilter", hotFilter);
400
    }
401

  
402
    @Override
403
    public void setHotFilter(Expression hotFilter) {
404
        this.hotFilter = hotFilter;
405
    }
406

  
407
    @Override
408
    public void setColdFilter(Expression coldFilter) {
409
        this.coldFilter = coldFilter;
410
    }
411

  
412
    @Override
413
    public Expression getColdFilter() {
414
        return this.coldFilter;
415
    }
416

  
417
    @Override
418
    public Expression getHotFilter() {
419
        return this.hotFilter;
420
    }
421

  
422
    @Override
423
    public boolean getUseWeight() {
424
        return this.useWeight;
425
    }
426

  
427
    public void setUseWeight(boolean useWeight) {
428
        this.useWeight = useWeight;
429
    }
430

  
431
    private class DensityAlgorithm {
432

  
433
        private double[][] gridHot;
434
        private double[][] gridCold;
435
        private double[][] kernel;
436
        private int distance;
437
        private int height;
438
        private int with;
439
        private double maxValue;
440
        private double minValue;
441
        private final String HOT = "hot-value";
442
        private final String COLD = "cold-value";
443

  
444
        public DensityAlgorithm(int distance) {
445
            this.setDistance(distance);
446
        }
447

  
448
        public void setDistance(int distance) {
449
            if (this.distance == distance) {
450
                return;
451
            }
452
            this.distance = distance;
453
            this.kernel = new double[2 * this.distance + 1][2 * this.distance + 1];
454
            double powDistance = Math.pow(this.distance, 2); // * this.distance;
455
            for (int y = -this.distance; y < this.distance + 1; y++) {
456
                for (int x = -this.distance; x < this.distance + 1; x++) {
457
                    final double dDist = Math.sqrt(x * x + y * y);
458
                    if (dDist < this.distance) {
459
                        this.kernel[x + this.distance][y + this.distance] = Math.pow(1 - Math.pow(dDist, 2) / powDistance, 2);
460
                    } else {
461
                        this.kernel[x + this.distance][y + this.distance] = 0;
462
                    }
463
                }
464
            }
465
        }
466

  
467
        public int getDistance() {
468
            return this.distance;
469
        }
470

  
471
        public void init(int with, int height) {
472
            this.with = with;
473
            this.height = height;
474
            this.gridHot = new double[with][height];
475
            this.gridCold = new double[with][height];
476
            this.maxValue = 0;
477
            this.minValue = 0;
478
        }
479

  
480
        public void addHot(int px, int py) {
481
            addHot(px, py, 1);
482
        }
483

  
484
        public void addHot(int px, int py, double value) {
485
            add(px, py, value, this.HOT);
486
        }
487

  
488
        public void addCold(int px, int py) {
489
            addCold(px, py, 1);
490
        }
491

  
492
        public void addCold(int px, int py, double value) {
493
            add(px, py, value, this.COLD);
494
        }
495

  
496
        public void add(int px, int py, double value, String grid) {
497
            for (int y = -this.distance; y < this.distance + 1; y++) {
498
                for (int x = -this.distance; x < this.distance + 1; x++) {
499
                    if (this.kernel[x + this.distance][y + this.distance] != 0) {
500
                        addValue(px + x, py + y, value * this.kernel[x + this.distance][y + this.distance], grid);
501
                    }
502
                }
503
            }
504
        }
505

  
506
        private void addValue(int px, int py, double value, String grid) {
507
            if (px < 0 || py < 0 || px >= with || py >= height) {
508
                return;
509
            }
510
            if (grid == this.HOT) {
511
                value += this.gridHot[px][py];
512
                this.gridHot[px][py] = value;
513
                if (value > this.maxValue) {
514
                    this.maxValue = value;
515
                }
516
            }
517
            if (grid == this.COLD) {
518
                value += this.gridCold[px][py];
519
                this.gridCold[px][py] = value;
520
                if (-value < this.minValue) {
521
                    this.minValue = -value;
522
                }
523
            }
524

  
525
        }
526

  
527
        public void drawWithOpaqueColors(BufferedImage img, Graphics2D g, Color[] colorTable, Cancellable cancel, Geometry roi) {
528
            try {
529
                ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
530
                Color c;
531
                for (int x = 0; x < with; x++) {
532
                    for (int y = 0; y < height; y++) {
533
                        if (cancel.isCanceled()) {
534
                            return;
535
                        }
536
                        if (roi != null) {
537
                            Point point = GeometryUtils.createPoint(x, y);
538
                            if (!roi.intersects(point)) {
539
                                continue;
540
                            }
541
                        }
542
                        double value = this.getResultGrid(x, y);
543

  
544
                        int icolor = this.calculateIndexColorNotEqual(value, colorTable);
545
                        if (value==0.0) {
546
                            continue;
547
                        }
548
                        c = toolsSwingManager.alphaBlendingWithOpaqueBackground(
549
                                new Color(img.getRGB(x, y)),
550
                                colorTable[icolor]
551
                        );
552
                        img.setRGB(x, y, c.getRGB());
553
                    }
554
                }
555
            } catch (Exception ex) {
556
                LOG.warn("Problems drawing heatmap", ex);
557
            }
558
        }
559

  
560
        public void drawWithAlphaColors(BufferedImage img, Graphics2D g, Color[] colorTable, Cancellable cancel, Geometry roi) {
561
            try {
562
                Color c;
563
                ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
564
                for (int x = 0; x < with; x++) {
565
                    for (int y = 0; y < height; y++) {
566
                        if (cancel.isCanceled()) {
567
                            return;
568
                        }
569
                        if (roi != null) {
570
                            Point point = GeometryUtils.createPoint(x, y);
571
                            if (!roi.intersects(point)) {
572
                                continue;
573
                            }
574
                        }
575
                         double value = this.getResultGrid(x, y);
576

  
577
                        int icolor = this.calculateIndexColorNotEqual(value, colorTable);
578
                        if (value==0.0) {
579
                            continue;
580
                        }
581
                        c = colorTable[icolor];
582
                        img.setRGB(x, y, c.getRGB());
583
                    }
584
                }
585
            } catch (Exception ex) {
586
                LOG.warn("Problems printing heatmap", ex);
587
            }
588
        }
589

  
590
        private double getResultGrid(int x, int y) {
591
            double valueHot = this.gridHot[x][y];
592
            double valueCold = this.gridCold[x][y];
593
            return valueHot - valueCold;
594
        }
595

  
596
        private int calculateIndexColorNotEqual(double value, Color[] colorTable) {
597
            int midTable = (colorTable.length) / 2;
598
            if (value < 0) {
599
                int icolor = (int) (value * (midTable - 1) / minValue);
600
                int coldIndex = midTable - icolor - 1;
601
                return coldIndex;
602
            } else if (value > 0) {
603
                int icolor = (int) (value * (midTable - 1) / maxValue);
604
                int hotIndex = midTable + icolor + 1;
605
                return hotIndex;
606
            }
607
            return midTable;
608
        }
609

  
610
    }
611

  
612
    private static class HeatmapColorTable {
613

  
614
        private Color coldColor = null;
615
        private Color midColor = null;
616
        private Color hotColor = null;
617
        private Color[] targetColorTable = null;
618
        private int length = -1;
619

  
620
        public HeatmapColorTable(Color coldColor, Color midColor, Color hotColor, int length) {
621
            this.coldColor = coldColor;
622
            this.midColor = midColor;
623
            this.hotColor = hotColor;
624
            this.length = length;
625
        }
626

  
627
        public Color[] getColorTable() {
628
            if (targetColorTable == null) {
629
                targetColorTable = new Color[length * 2 + 1];
630

  
631
                double deltaRed = (midColor.getRed() - coldColor.getRed()) / length;
632
                double deltaGreen = (midColor.getGreen() - coldColor.getGreen()) / length;
633
                double deltaBlue = (midColor.getBlue() - coldColor.getBlue()) / length;
634
                double deltaAlpha = (midColor.getAlpha() - coldColor.getAlpha()) / length;
635

  
636
                for (int i = 0; i < length; i++) {
637
                    targetColorTable[i]
638
                            = new Color(
639
                                    (int) (coldColor.getRed() + i * deltaRed),
640
                                    (int) (coldColor.getGreen() + i * deltaGreen),
641
                                    (int) (coldColor.getBlue() + i * deltaBlue),
642
                                    (int) (coldColor.getAlpha() + i * deltaAlpha));
643
                }
644
                targetColorTable[length] =new Color(midColor.getRed(), midColor.getGreen(), midColor.getBlue(), midColor.getTransparency());
645

  
646
                double deltaRedCold = (hotColor.getRed() - midColor.getRed()) / length;
647
                double deltaGreenCold = (hotColor.getGreen() - midColor.getGreen()) / length;
648
                double deltaBlueCold = (hotColor.getBlue() - midColor.getBlue()) / length;
649
                double deltaAlphaCold = (hotColor.getAlpha() - midColor.getAlpha()) / length;
650
                for (int i = 1; i < length+1; i++) {
651
                    int fixi = length + i;
652
                    targetColorTable[fixi]
653
                            = new Color(
654
                                    (int) (midColor.getRed() + i * deltaRedCold),
655
                                    (int) (midColor.getGreen() + i * deltaGreenCold),
656
                                    (int) (midColor.getBlue() + i * deltaBlueCold),
657
                                    (int) (midColor.getAlpha() + i * deltaAlphaCold));
658
                }
659
            }
660

  
661
            return targetColorTable;
662
        }
663

  
664
//        private double getDelta(int x1, int x2, int lenght) {
665
//            return (x2 - x1) / ((double) lenght - 1);
666
//        }
667
    }
668
}
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.lib/org.gvsig.legend.heatmapcomparison.lib.impl/src/main/java/org/gvsig/legend/heatmapcomparison/lib/impl/HeatmapComparisonLegendLibraryImpl.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2015 gvSIG Association
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.legend.heatmapcomparison.lib.impl;
26

  
27
import org.gvsig.fmap.mapcontext.MapContextLibrary;
28
import org.gvsig.fmap.mapcontext.MapContextLocator;
29
import org.gvsig.fmap.mapcontext.MapContextManager;
30
import org.gvsig.legend.heatmapcomparison.lib.api.HeatmapComparisonLegendLibrary;
31
import org.gvsig.legend.heatmapcomparison.lib.api.HeatmapComparisonLegendLocator;
32
import org.gvsig.symbology.impl.SymbologyDefaultImplLibrary;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.library.AbstractLibrary;
35
import org.gvsig.tools.library.LibraryException;
36
import org.gvsig.tools.persistence.PersistenceManager;
37

  
38
public class HeatmapComparisonLegendLibraryImpl extends AbstractLibrary {
39

  
40
    @Override
41
    public void doRegistration() {
42
        registerAsImplementationOf(HeatmapComparisonLegendLibrary.class);
43
        this.require(MapContextLibrary.class);
44
        this.require(SymbologyDefaultImplLibrary.class);
45
    }
46

  
47
    @Override
48
    protected void doInitialize() throws LibraryException {
49
        HeatmapComparisonLegendLocator.registerHeatmapComparisonLegendManager(DefaultHeatmapComparisonLegendManager.class);
50
        MapContextManager mcmanager = MapContextLocator.getMapContextManager();
51
        mcmanager.registerLegend("HeatmapComparisonLegend", DefaultHeatmapComparisonLegend.class);
52
    }
53

  
54
    @Override
55
    protected void doPostInitialize() throws LibraryException {
56
        PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager();
57
        persistenceManager.addDefinition(
58
            DefaultHeatmapComparisonLegend.class, 
59
            "DefaultHeatmapComparisonLegend", 
60
            "/org/gvsig/legend/heatmapcomparison/lib/impl/DefaultHeatmapComparisonLegend.persistence.xml"
61
        );
62
    }
63

  
64
}
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.lib/org.gvsig.legend.heatmapcomparison.lib.impl/src/main/resources/org/gvsig/legend/heatmapcomparison/lib/impl/DefaultHeatmapComparisonLegend.persistence.xml
1
<?xml version="1.0"?>
2
<definitions>
3
    <version>1.0.0</version>
4
    <classes>
5
        <class name="DefaultHeatmapComparisonLegend">
6
            <extends>
7
                <class>VectorialLegend</class>
8
            </extends>
9
            <fields>
10
                <field name="useWeight" type="boolean" defaultValue="false">
11
                    <description></description>
12
                </field>
13
                <field name="distance" type="integer" defaultValue="30">
14
                    <description></description>
15
                </field>
16
                <field name="fieldName" type="String" defaultValue="">
17
                    <description></description>
18
                </field>
19
                <field name="rampColdColor" type="Object" classOfValue="java.awt.Color">
20
                    <description></description>
21
                </field>
22
                <field name="rampMidColor" type="Object" classOfValue="java.awt.Color">
23
                    <description></description>
24
                </field>
25
                <field name="rampHotColor" type="Object" classOfValue="java.awt.Color">
26
                    <description></description>
27
                </field>
28
                <field name="rampNumColors" type="integer" defaultValue="10">
29
                    <description></description>
30
                </field>
31
                <field name="hotFilter" type="Object" classOfValue="org.gvsig.expressionevaluator.Expression">
32
                    <description></description>
33
                </field>
34
                <field name="coldFilter" type="Object" classOfValue="org.gvsig.expressionevaluator.Expression">
35
                    <description></description>
36
                </field>
37
            </fields>
38
        </class>
39

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

  
25
import org.gvsig.fmap.dal.feature.FeatureStore;
26

  
27

  
28
public interface HeatmapComparisonLegendManager {
29

  
30
    /**
31
     * Creates an aggregate legend
32
     *
33
     * @return the aggregate legend
34
     */
35
    public HeatmapComparisonLegend create();
36

  
37
    public Class<? extends HeatmapComparisonLegend> getLegendClass();
38
}
org.gvsig.legend.heatmapcomparison/tags/org.gvsig.legend.heatmapcomparison-1.0.14/org.gvsig.legend.heatmapcomparison.lib/org.gvsig.legend.heatmapcomparison.lib.api/src/main/java/org/gvsig/legend/heatmapcomparison/lib/api/HeatmapComparisonLegend.java
1
package org.gvsig.legend.heatmapcomparison.lib.api;
2

  
3
import java.awt.Color;
4
import org.gvsig.expressionevaluator.Expression;
5
import org.gvsig.fmap.geom.Geometry;
6
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
7

  
8
public interface HeatmapComparisonLegend extends IVectorLegend {
9

  
10
    public int getDistance();
11

  
12
    public void setDistance(int distance);
13

  
14
    public void setColorTable(int numColors, Color coldColor, Color midColor, Color hotColor);
15

  
16
    public Color[] getTargetColorTable();
17
    
18
    public Geometry getROI();
19
    
20
    public void setROI(Geometry roi);
21

  
22
    public String getFieldName();
23

  
24
    public void setFieldName(String fieldName);
25

  
26
    public int getRampNumColors();
27

  
28
    public Color getRampColdColor();
29
    
30
    public Color getRampMidColor();
31

  
32
    public Color getRampHotColor();
33

  
34
    public void setHotFilter(Expression hotFilter);
35

  
36
    public void setColdFilter(Expression coldFilter);
37
    
38
    public Expression getColdFilter();
39
    
40
    public Expression getHotFilter();
41
    
42
    public boolean getUseWeight();
43

  
44
    public void setUseWeight(boolean useWeight);
45

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

  
25
import org.gvsig.tools.locator.AbstractLocator;
26
import org.gvsig.tools.locator.Locator;
27
import org.gvsig.tools.locator.LocatorException;
28

  
29

  
30
public class HeatmapComparisonLegendLocator extends AbstractLocator {
31

  
32
    /**
33
     * HeatmapLegend locator name
34
     */
35
    private static final String LOCATOR_NAME = "HeatmapComparisonLegendLocator";
36

  
37
    /**
38
     * HeatmapLegend manager name
39
     */
40
    public static final String MANAGER_NAME = "HeatmapComparisonLegendManager";
41

  
42
    /**
43
     * HeatmapLegend manager description
44
     */
45
    private static final String MANAGER_DESCRIPTION =
46
        "HeatmapComparisonLegend Manager of gvSIG";
47

  
48

  
49
    /**
50
     * Unique instance
51
     */
52
    private static final HeatmapComparisonLegendLocator instance = new HeatmapComparisonLegendLocator();
53

  
54
    @Override
55
    public String getLocatorName() {
56
        return LOCATOR_NAME;
57
    }
58

  
59
    /**
60
     * Registers the Class implementing the HeatmapLegendManager interface.
61
     *
62
     * @param clazz
63
     *            implementing the HeatmapLegendManager interface
64
     */
65
    public static void registerHeatmapComparisonLegendManager(Class clazz){
66
        getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
67
    }
68

  
69
    /**
70
     * Registers the default Class implementing the HeatmapLegendManager interface
71
     *
72
     * @param clazz
73
     *            implementing the HeatmapLegendManager interface
74
     */
75
    public static void registerDefaultHeatmapComparisonLegendManager(Class clazz){
76
        getInstance().registerDefault(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
77
    }
78

  
79
    /**
80
     * Return a reference to HeatmapLegendManager.
81
     *
82
     * @return a reference to HeatmapLegendManager
83
     * @throws LocatorException
84
     *             if there is no access to the class or the class
85
     *             cannot be instantiated
86
     * @see Locator#get(String)
87
     */
88
    public static HeatmapComparisonLegendManager getHeatmapComparisonLegendManager() throws LocatorException {
89
        return (HeatmapComparisonLegendManager) getInstance().get(MANAGER_NAME);
90
    }
91

  
92
    /**
93
     * @return
94
     */
95
    public static Locator getInstance() {
96
        return instance;
97
    }
98

  
99
}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff