Revision 9429

View differences:

org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.api/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/api/UrbanHorizontalSignageManager.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.urbanhorizontalsignage.lib.api;
24

  
25
import org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageLegend;
26
import org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageConfig;
27
import org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData;
28
import org.gvsig.fmap.dal.feature.FeatureSet;
29
import org.gvsig.fmap.dal.feature.FeatureStore;
30
import org.gvsig.fmap.geom.Geometry;
31
import org.gvsig.tools.task.SimpleTaskStatus;
32

  
33

  
34
public interface UrbanHorizontalSignageManager {
35

  
36
    public UrbanHorizontalSignageLegend createUrbanHorizontalSignageLegend();
37

  
38
    public Class<? extends UrbanHorizontalSignageLegend> getUrbanHorizontalSignageLegendClass();
39
    
40
    public UrbanHorizontalSignageData createUrbanHorizontalSignageData();
41
    
42
    public void calculateGeometries(Geometry originalGeometry, UrbanHorizontalSignageData data);
43

  
44
    public void convertLinesToPolygons(UrbanHorizontalSignageConfig config, FeatureSet lines, FeatureStore targetStore, boolean deleteSourceAtFinish, SimpleTaskStatus status);
45

  
46
    public FeatureStore createTemporaryPolygonsFromLines(UrbanHorizontalSignageConfig config, FeatureSet lines, SimpleTaskStatus status);
47
    
48
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.api/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/api/UrbanHorizontalSignageLocator.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.urbanhorizontalsignage.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 UrbanHorizontalSignageLocator extends AbstractLocator {
31

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

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

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

  
48

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

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

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

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

  
79
    /**
80
     * Return a reference to UrbanHorizontalSignageManager.
81
     *
82
     * @return a reference to UrbanHorizontalSignageManager
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 UrbanHorizontalSignageManager getUrbanHorizontalSignageManager() throws LocatorException {
89
        return (UrbanHorizontalSignageManager) getInstance().get(MANAGER_NAME);
90
    }
91

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

  
99
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.api/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/api/UrbanHorizontalSignageLibrary.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.urbanhorizontalsignage.lib.api;
24

  
25
import org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageLegend;
26
import org.gvsig.fmap.mapcontext.MapContextLocator;
27
import org.gvsig.fmap.mapcontext.MapContextManager;
28
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendWriter;
29
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
30
import org.gvsig.symbology.SymbologyLocator;
31
import org.gvsig.symbology.SymbologyManager;
32
import org.gvsig.tools.library.AbstractLibrary;
33
import org.gvsig.tools.library.LibraryException;
34
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
35

  
36

  
37
public class UrbanHorizontalSignageLibrary extends AbstractLibrary {
38

  
39
    @Override
40
    protected void doInitialize() throws LibraryException {
41
        registerAsAPI(UrbanHorizontalSignageLibrary.class);
42
    }
43

  
44
    @Override
45
    protected void doPostInitialize() throws LibraryException {
46
        // Validate there is any implementation registered.
47
        UrbanHorizontalSignageManager manager = UrbanHorizontalSignageLocator.getUrbanHorizontalSignageManager();
48
        if (manager == null) {
49
            throw new ReferenceNotRegisteredException(
50
                UrbanHorizontalSignageLocator.MANAGER_NAME, UrbanHorizontalSignageLocator.getInstance());
51
        }
52

  
53
        SymbologyManager symbolManager = SymbologyLocator.getSymbologyManager();
54
        ILegendWriter legendWriter = symbolManager.getDefaultLegendWriter();
55

  
56
        MapContextManager mcoman = MapContextLocator.getMapContextManager();
57
        mcoman.registerLegendWriter(
58
            UrbanHorizontalSignageLegend.class,
59
            SymbolManager.LEGEND_FILE_EXTENSION.substring(1),
60
            legendWriter.getClass());
61
    }
62

  
63
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.api/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/api/linelegend/UrbanHorizontalSignageLegend.java
1
package org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend;
2

  
3
import org.gvsig.fmap.mapcontext.rendering.legend.ISingleSymbolLegend;
4
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
5

  
6
public interface UrbanHorizontalSignageLegend extends IVectorLegend, ISingleSymbolLegend {
7
    
8
    public UrbanHorizontalSignageConfig getConfig();
9

  
10
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.api/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/api/linelegend/UrbanHorizontalSignageConfig.java
1
package org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend;
2

  
3
import org.gvsig.fmap.dal.feature.Feature;
4
import org.gvsig.tools.persistence.Persistent;
5

  
6
/**
7
 *
8
 * @author fdiaz
9
 */
10
public interface UrbanHorizontalSignageConfig extends Persistent, org.gvsig.tools.lang.Cloneable {
11

  
12
    public static final int DEFAULT_GAP_WIDTH_VALUE = 15;
13

  
14
    public String getWidthFieldName();
15

  
16
    public void setWidthFieldName(String fieldName);
17

  
18
    public String getContinuityFieldName();
19

  
20
    public void setContinuityFieldName(String fieldName);
21

  
22
    public String getSegmentsColorFieldName();
23

  
24
    public void setSegmentsColorFieldName(String fieldName);
25

  
26
    public String getSegmentsLengthFieldName();
27

  
28
    public void setSegmentsLengthFieldName(String fieldName);
29

  
30
    public String getPaintHolesFieldName();
31

  
32
    public void setPaintHolesFieldName(String fieldName);
33

  
34
    public String getHolesColorFieldName();
35

  
36
    public void setHolesColorFieldName(String fieldName);
37

  
38
    public String getHolesLengthFieldName();
39

  
40
    public void setHolesLengthFieldName(String fieldName);
41
    
42
    public String getRoundVertexFieldName();
43

  
44
    public void setRoundVertexFieldName(String fieldName);
45
    
46
    public int getGapWidth();
47

  
48
    public void setGapWith(int fieldName);
49
    
50
    public UrbanHorizontalSignageData getValues(Feature feature);
51
    
52
    public String getTargetColorFieldName();
53

  
54
    public void setTargetColorFieldName(String fieldName);
55
    
56
    public String getTargetLenghtFieldName();
57
    
58
    public void setTargetLenghtFieldName(String fieldName);
59

  
60
    public String getTargetAreaFieldName();
61
    
62
    public void setTargetAreaFieldName(String fieldName);
63

  
64
    @Override
65
    public UrbanHorizontalSignageConfig clone() throws CloneNotSupportedException;
66
    
67
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.api/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/api/linelegend/UrbanHorizontalSignageData.java
1
package org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend;
2

  
3
import java.awt.Color;
4
import org.gvsig.fmap.geom.aggregate.MultiLine;
5
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
6

  
7
public interface UrbanHorizontalSignageData {
8
    
9
    public static final int CONTINUITY_MODE_CONT = 1;       //01
10
    public static final int CONTINUITY_MODE_DISC = 2;       //10
11
    public static final int CONTINUITY_MODE_CONT_CONT = 5;  //0101
12
    public static final int CONTINUITY_MODE_DISC_DISC = 10; //1010
13
    public static final int CONTINUITY_MODE_CONT_DISC = 6;  //0110
14
    public static final int CONTINUITY_MODE_DISC_CONT = 9;  //1001
15
    
16
    public static final double DEFAULT_WIDTH_VALUE = 0.15;
17
    public static final int DEFAULT_CONTINUITY_VALUE = 1;
18
    public static final Color DEFAULT_SEGMENT_COLOR_VALUE = Color.BLUE.darker();
19
    public static final double DEFAULT_SEGMENT_LENGTH_VALUE = 0.5;
20
    public static final Color DEFAULT_HOLES_COLOR_VALUE = Color.BLACK;
21
    public static final double DEFAULT_HOLES_LENGTH_VALUE = 0.5;
22
    public static final boolean DEFAULT_PAINT_HOLES_VALUE = false;
23
    public static final double DEFAULT_GAP_WIDTH_VALUE = 0.15;
24
    public static final boolean DEFAULT_ROUND_VERTEX_VALUE = false;
25

  
26

  
27
    public double getWidth();
28

  
29
    public void setWidth(double value);
30

  
31
    public int getContinuity();
32

  
33
    public void setContinuity(int value);
34

  
35
    public Color getSegmentsColor();
36

  
37
    public void setSegmentsColor(Color value);
38

  
39
    public double getSegmentsLength();
40

  
41
    public void setSegmentsLength(double value);
42

  
43
    public MultiPolygon getSegmentsGeometry();
44

  
45
    public void setSegmentsGeometry(MultiPolygon value);
46

  
47
    public boolean isPaintHoles();
48

  
49
    public void setPaintHoles(boolean value);
50

  
51
    public Color getHolesColor();
52

  
53
    public void setHolesColor(Color value);
54

  
55
    public double getHolesLength();
56

  
57
    public void setHolesLength(double value);
58

  
59
    /**
60
     * Can be null
61
    */
62
    public MultiPolygon getHolesGeometry();
63

  
64
    public void setHolesGeometry(MultiPolygon value);
65
    
66
    public double getGapWidth();
67

  
68
    public void setGapWidth(double value);
69

  
70
    public boolean isRoundVertex();
71

  
72
    public void setRoundVertex(boolean value);
73

  
74
    public MultiLine getLineSegmentsGeometry();
75

  
76
    public void setLineSegmentsGeometry(MultiLine value);
77

  
78
    public MultiLine getLineHolesGeometry();
79

  
80
    public void setLineHolesGeometry(MultiLine value);
81

  
82

  
83
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLibrary
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.api/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.urbanhorizontalsignage.lib.api</artifactId>
5
  <name>org.gvsig.legend.urbanhorizontalsignage.lib.api</name>
6
  <parent>
7
    <groupId>org.gvsig</groupId>
8
    <artifactId>org.gvsig.legend.urbanhorizontalsignage.lib</artifactId>
9
    <version>1.0.87</version>
10
  </parent>
11

  
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
          <!-- Generates a jar file only with the test classes -->
21
          <execution>
22
            <goals>
23
              <goal>test-jar</goal>
24
            </goals>
25
          </execution>
26
        </executions>
27
      </plugin>
28
    </plugins>
29
  </build>
30

  
31
  <dependencies>
32
    <dependency>
33
      <groupId>org.gvsig</groupId>
34
      <artifactId>org.gvsig.tools.lib</artifactId>
35
      <scope>compile</scope>
36
    </dependency>
37
    <dependency>
38
      <groupId>org.gvsig</groupId>
39
      <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
40
      <scope>compile</scope>
41
    </dependency>
42
    <dependency>
43
      <groupId>org.gvsig</groupId>
44
      <artifactId>org.gvsig.symbology.lib.api</artifactId>
45
    </dependency>
46
  </dependencies>
47
</project>
0 48

  
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.legend.urbanhorizontalsignage.lib.impl.UrbanHorizontalSignageLibraryImpl
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/resources/org/gvsig/legend/urbanhorizontalsignage/lib/impl/UrbanHorizontalSignagePersistence.xml
1
<?xml version="1.0"?>
2
<definitions>
3
    <version>1.0.0</version>
4
    <classes>
5
        <class name="DefaultUrbanHorizontalSignageLegend">
6
            <extends>
7
                <class name="VectorialLegend" namespace="persistence"/>
8
            </extends>
9
            <fields>
10
                <field name="config" type="Object" ClassOfValue="org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageConfig" mandatory="false">
11
                    <description></description>
12
                </field>
13
            </fields>
14
        </class>
15
        
16
        <class name="DefaultUrbanHorizontalSignageConfig">
17
            <extends>
18
            </extends>
19
            <fields>
20
                <field name="widthFieldName" type="String" defaultValue="">
21
                    <description></description>
22
                </field>
23
                <field name="continuityFieldName" type="String" defaultValue="">
24
                    <description></description>
25
                </field>
26
                <field name="segmentsColorFieldName" type="String" defaultValue="">
27
                    <description></description>
28
                </field>
29
                <field name="segmentsLengthFieldName" type="String" defaultValue="">
30
                    <description></description>
31
                </field>
32
                <field name="holesLengthFieldName" type="String" defaultValue="">
33
                    <description></description>
34
                </field>
35
                <field name="paintHolesFieldName" type="String" defaultValue="">
36
                    <description></description>
37
                </field>
38
                <field name="holesColorFieldName" type="String" defaultValue="">
39
                    <description></description>
40
                </field>
41
                <field name="roundVertexFieldName" type="String" defaultValue="">
42
                    <description></description>
43
                </field>
44
                <field name="gapWidth" type="Integer" defaultValue="15">
45
                    <description></description>
46
                </field>
47

  
48
            </fields>
49
        </class>
50

  
51

  
52
        <class name="UrbanHorizontalSignageSymbol">
53
            <extends>
54
                <class name="Symbol" namespace="persistence"/>
55
            </extends>
56
            <fields>
57
                <field name="width" type="Double" defaultValue="0.15" mandatory="false">
58
                    <description></description>
59
                </field>
60
                <field name="continuity" type="Integer" defaultValue="1" mandatory="false">
61
                    <description></description>
62
                </field>
63
                <field name="segmentsColor" type="Object" ClassOfValue="java.awt.Color" defaultValue="blue" mandatory="false">
64
                    <description></description>
65
                </field>
66
                <field name="segmentsLength" type="Double" defaultValue="0.5" mandatory="false">
67
                    <description></description>
68
                </field>
69
                <field name="holesColor" type="Object" ClassOfValue="java.awt.Color" defaultValue="black" mandatory="false">
70
                    <description></description>
71
                </field>
72
                <field name="holesLength" type="Double" defaultValue="0.5" mandatory="false">
73
                    <description></description>
74
                </field>
75
                <field name="paintHoles" type="Boolean" defaultValue="false" mandatory="false">
76
                    <description></description>
77
                </field>
78
                <field name="gapWidth" type="Double" defaultValue="0.15" mandatory="false">
79
                    <description></description>
80
                </field>
81
                <field name="roundVertex" type="Boolean" defaultValue="false" mandatory="false">
82
                    <description></description>
83
                </field>
84
                <field name="transparency" type="Double" defaultValue="1.0" mandatory="false">
85
                    <description></description>
86
                </field>
87
                <field name="mustDrawOriginalGeometry" type="Boolean" defaultValue="false" mandatory="false">
88
                    <description></description>
89
                </field>
90
                <field name="colorForOriginalGeometry" type="Object" ClassOfValue="java.awt.Color" defaultValue="yellow" mandatory="false">
91
                    <description></description>
92
                </field>
93
            </fields>
94
        </class>
95

  
96
    </classes>
97
</definitions>
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/impl/UrbanHorizontalSignageLibraryImpl.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.urbanhorizontalsignage.lib.impl;
26

  
27
import org.gvsig.legend.urbanhorizontalsignage.lib.impl.linelegend.DefaultUrbanHorizontalSignageLegend;
28
import org.gvsig.legend.urbanhorizontalsignage.lib.impl.linelegend.UrbanHorizontalSignageSymbol;
29
import org.gvsig.legend.urbanhorizontalsignage.lib.impl.linelegend.DefaultUrbanHorizontalSignageConfig;
30
import java.io.InputStream;
31
import java.util.Map;
32
import org.gvsig.fmap.mapcontext.MapContextLibrary;
33
import org.gvsig.fmap.mapcontext.MapContextLocator;
34
import org.gvsig.fmap.mapcontext.MapContextManager;
35
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLibrary;
36
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLocator;
37
import org.gvsig.symbology.impl.SymbologyDefaultImplLibrary;
38
import org.gvsig.tools.ToolsLocator;
39
import org.gvsig.tools.dynobject.DynStruct;
40
import org.gvsig.tools.library.AbstractLibrary;
41
import org.gvsig.tools.library.LibraryException;
42
import org.gvsig.tools.persistence.PersistenceManager;
43

  
44
public class UrbanHorizontalSignageLibraryImpl extends AbstractLibrary {
45

  
46
    @Override
47
    public void doRegistration() {
48
        registerAsImplementationOf(UrbanHorizontalSignageLibrary.class);
49
        this.require(MapContextLibrary.class);
50
        this.require(SymbologyDefaultImplLibrary.class);
51
    }
52

  
53
    @Override
54
    protected void doInitialize() throws LibraryException {
55
        UrbanHorizontalSignageLocator.registerUrbanHorizontalSignageManager(DefaultUrbanHorizontalSignageManager.class);
56
        MapContextManager mcmanager = MapContextLocator.getMapContextManager();
57
        mcmanager.registerLegend("UrbanHorizontalSignageLegend", DefaultUrbanHorizontalSignageLegend.class);
58
    }
59

  
60
    @Override
61
    protected void doPostInitialize() throws LibraryException {
62
        PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager();
63
        InputStream is = this.getClass().getResourceAsStream("UrbanHorizontalSignagePersistence.xml");
64
        Map<String,DynStruct> definitions;
65
        try {
66
            definitions = ToolsLocator.getDynObjectManager().importDynClassDefinitions(is, this.getClass().getClassLoader());
67
        } catch (Exception ex) {
68
            throw new LibraryException(this.getClass(), ex);
69
        }
70
        
71
        persistenceManager.addDefinition(
72
                DefaultUrbanHorizontalSignageLegend.class,
73
                "DefaultUrbanHorizontalSignageLegend",
74
                definitions,
75
                null,
76
                null);
77
        persistenceManager.addDefinition(
78
                UrbanHorizontalSignageSymbol.class,
79
                "UrbanHorizontalSignageSymbol",
80
                definitions,
81
                null,
82
                null
83
        );
84
        persistenceManager.addDefinition(
85
                DefaultUrbanHorizontalSignageConfig.class,
86
                "DefaultUrbanHorizontalSignageConfig",
87
                definitions,
88
                null,
89
                null
90
        );
91
    }
92

  
93
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/impl/linelegend/UrbanHorizontalSignageSymbol.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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 3
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
package org.gvsig.legend.urbanhorizontalsignage.lib.impl.linelegend;
25

  
26
import java.awt.Color;
27
import java.awt.Graphics2D;
28
import java.awt.Rectangle;
29
import java.awt.Shape;
30
import java.awt.geom.AffineTransform;
31
import java.util.concurrent.Callable;
32
import org.gvsig.compat.print.PrintAttributes;
33
import org.gvsig.fmap.dal.feature.Feature;
34
import org.gvsig.fmap.geom.Geometry;
35
import org.gvsig.fmap.geom.GeometryLocator;
36
import org.gvsig.fmap.geom.GeometryManager;
37
import org.gvsig.fmap.geom.GeometryUtils;
38
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
39
import org.gvsig.fmap.geom.primitive.Envelope;
40
import org.gvsig.fmap.geom.primitive.Line;
41
import org.gvsig.fmap.geom.primitive.Point;
42
import org.gvsig.fmap.mapcontext.MapContext;
43
import org.gvsig.fmap.mapcontext.MapContextLocator;
44
import org.gvsig.fmap.mapcontext.ViewPort;
45
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
46
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol_v2;
47
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException;
48
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
49
import org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData;
50
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.CONTINUITY_MODE_CONT_DISC;
51
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC;
52
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC_CONT;
53
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.CONTINUITY_MODE_DISC_DISC;
54
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLocator;
55
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageManager;
56
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.AbstractSymbol;
57
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.CartographicSupportToolkit;
58
import org.gvsig.tools.persistence.PersistentState;
59
import org.gvsig.tools.persistence.exception.PersistenceException;
60
import org.gvsig.tools.swing.api.TransparencySupport;
61
import org.gvsig.tools.task.Cancellable;
62
import org.slf4j.Logger;
63
import org.slf4j.LoggerFactory;
64

  
65
public class UrbanHorizontalSignageSymbol extends AbstractSymbol implements ISymbol_v2, TransparencySupport {
66

  
67
    private static final Logger LOG = LoggerFactory.getLogger(UrbanHorizontalSignageSymbol.class);
68
    private static final String SYMBOL_NAME = "UrbanHorizontalSignageSymbol";
69
    private static final String URBAN_HORIZONTAL_SIGNAGE_SYMBOL_PERSISTENCE_DEFINITION_NAME = "UrbanHorizontalSignageSymbol";
70
    
71
    private static final String FIELD_WIDTH = "width";
72
    private static final String FIELD_CONTINUITY = "continuity";
73
    private static final String FIELD_SEGMENTS_COLOR = "segmentsColor";
74
    private static final String FIELD_SEGMENTS_LENGTH = "segmentsLength";
75
    private static final String FIELD_HOLES_COLOR = "holesColor";
76
    private static final String FIELD_HOLES_LENGTH = "holesLength";
77
    private static final String FIELD_PAINT_HOLES = "paintHoles";
78
    private static final String FIELD_GAP_WIDTH = "gapWidth";
79
    private static final String FIELD_ROUND_VERTEX = "roundVertex";
80
    private static final String FIELD_SEGMENTS_GEOMETRY = "segmentsGeometry";
81
    private static final String FIELD_HOLES_GEOMETRY = "holesGeometry";
82
    private static final String FIELD_TRANSPARENCY = "transparency";
83
    private static final String FIELD_MUST_DRAW_ORIGINAL_GEOMETRY = "mustDrawOriginalGeometry";
84
    private static final String FIELD_COLOR_FOR_ORIGINAL_GEOMETRY = "colorForOriginalGeometry";
85
    
86

  
87

  
88
//    private static final String FIELD_SYMBOL_FOR_SELECTION = "symbolForSelection";
89
    private UrbanHorizontalSignageData data;
90

  
91
    transient private UrbanHorizontalSignageSymbol symbolForSelection;
92
    
93
    private boolean mustDrawOriginalGeometry;
94
    private Color colorForOriginalGeometry;
95
    private double cartographicSize;
96
    private double transparency; //[0.0, 1.0]
97

  
98
    public UrbanHorizontalSignageSymbol() {
99
        super();
100
        this.mustDrawOriginalGeometry = false;
101
        this.transparency = 1.0;
102
    }
103

  
104
    public void setData(UrbanHorizontalSignageData data) {
105
        this.data = data;
106
    }
107

  
108
    public UrbanHorizontalSignageData getData() {
109
        return data;
110
    }
111

  
112
    /**
113
     * Sets the transparency for symbol. The valid values are in [0.0, 1.0]
114
     * 
115
     * @param transparency 
116
     */
117
    @Override
118
    public void setTransparency(double transparency) {
119
        if(transparency < 0 || transparency > 1.0){
120
            throw new IllegalArgumentException("Transparency value must be in [0.0, 1.0] ("+transparency+")");
121
        }
122
        this.transparency = transparency;
123
    }
124

  
125
    @Override
126
    public double getTransparency() {
127
        return transparency;
128
    }
129
    
130
    @Override
131
    public ISymbol getSymbolForSelection() {
132
        if (symbolForSelection == null) {
133
            symbolForSelection = (UrbanHorizontalSignageSymbol) cloneForSelection();
134
            symbolForSelection.mustDrawOriginalGeometry = true;
135
        } else {
136
            symbolForSelection.setColor(MapContext.getSelectionColor());
137
        }
138
        return symbolForSelection;
139
    }
140

  
141
    @Override
142
    public void draw(Graphics2D g, AffineTransform affineTransform,
143
            Geometry originalGeometry, Feature feature, Cancellable cancel) {
144
        
145
        if (true) {
146
            // Esto deberia ser para optimizar el pintado de 
147
            // geometrias grandes.
148
            try {
149
                Geometry env = originalGeometry.getEnvelope().getGeometry();
150
                env.transform(affineTransform);
151
                Envelope env2 = env.getEnvelope();
152
                if (env2.getLength(0) < 1.5 && env2.getLength(1) < 1.5) {
153
                    Color color = data.getSegmentsColor();
154
                    Color transparentColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int)(transparency*color.getAlpha()));
155
                    g.setColor(transparentColor);
156
                    Point upperCorner = env2.getUpperCorner();
157
                    int x = (int) upperCorner.getX();
158
                    int y = (int) upperCorner.getY();
159
                    g.drawLine(x, y, x, y);
160
                    return;
161
                }
162
            } catch (Exception ex) {
163
                LOG.warn("Error optimizing the drawing of the geometry. Continues with normal drawing.", ex);
164
                // Do nothing, continue with the draw of the original geometry
165
            }
166
        }
167

  
168
        UrbanHorizontalSignageManager uhsManager = UrbanHorizontalSignageLocator.getUrbanHorizontalSignageManager();
169
        uhsManager.calculateGeometries(originalGeometry, data);
170
        
171
        MultiPolygon geom = data.getSegmentsGeometry();
172
        if (geom != null && geom.getPrimitivesNumber() > 0) {
173
            Color color = data.getSegmentsColor();
174
            Shape shape = geom.getShape(affineTransform);
175
            Color transparentColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int)(transparency*color.getAlpha()));
176
            g.setColor(transparentColor);
177
            g.fill(shape);
178
            g.setColor(color.darker());
179
            g.draw(shape);
180
        }
181

  
182
        switch (data.getContinuity()) {
183
            case CONTINUITY_MODE_CONT_DISC:
184
            case CONTINUITY_MODE_DISC_CONT:
185
            case CONTINUITY_MODE_DISC:
186
            case CONTINUITY_MODE_DISC_DISC:
187
                if (data.isPaintHoles()) {
188
                    geom = data.getHolesGeometry();
189
                    if (geom != null && geom.getPrimitivesNumber() > 0) {
190
                        Color color = data.getHolesColor();
191
                        Color transparentColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int)(transparency*color.getAlpha()));
192
                        g.setColor(transparentColor);
193
                        g.fill(geom.getShape(affineTransform));
194
                    }
195
                }
196
        }
197

  
198
        //For debug purposse only
199
        if(mustDrawOriginalGeometry){
200
            g.setColor(getColor());
201
            g.draw(originalGeometry.getShape(affineTransform));
202
        }
203

  
204
    }
205

  
206
    @Override
207
    public int getOnePointRgb() {
208
        return data.getSegmentsColor().getRGB();
209
    }
210

  
211
    @Override
212
    public void drawInsideRectangle(Graphics2D g,
213
            AffineTransform scaleInstance, Rectangle r, PrintAttributes properties) throws SymbolDrawingException {
214
        
215
        GeometryManager geomManager = GeometryLocator.getGeometryManager();
216
        
217
        final int hGap = (int) (r.getWidth() * 0.1); // the left and right margins
218
        final int vPos = 1; 						 // the top and bottom margins
219
        final int splitCount = 3; 					 // number of lines
220
        final int splitHSize = (r.width - hGap - hGap) / splitCount;
221
        int hPos = hGap;
222
        boolean swap = false;
223

  
224
        Line geom = GeometryUtils.createLine(Geometry.SUBTYPES.GEOM2D);
225
        geom.addVertex(r.x + hPos, r.y + r.height - vPos);
226

  
227
        for (int i = 0; i < splitCount; i++) {
228
            swap = !swap;
229
            geom.addVertex(r.x + hPos + splitHSize, (swap ? vPos : r.height - vPos) + r.y);
230
            hPos += splitHSize;
231
        }
232

  
233
        try {
234
            if (properties == null) {
235
                draw(g, new AffineTransform(), geom, null, null);
236
            } else {
237
                print(g, new AffineTransform(), geom, properties);
238
            }
239
        } catch (Exception e) {
240
            throw new SymbolDrawingException(SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS);
241
        }
242

  
243
    }
244

  
245
    @Override
246
    public Object clone() throws CloneNotSupportedException {
247
        UrbanHorizontalSignageSymbol copy = (UrbanHorizontalSignageSymbol) super.clone();
248

  
249
        if (symbolForSelection != null) {
250
            copy.symbolForSelection = (UrbanHorizontalSignageSymbol) symbolForSelection
251
                    .clone();
252
        }
253

  
254
        return copy;
255
    }
256

  
257
    @Override
258
    public void loadFromState(PersistentState state) throws PersistenceException {
259
        // Set parent style properties
260
        super.loadFromState(state);
261
        
262
        UrbanHorizontalSignageData data = new DefaultUrbanHorizontalSignageData();
263
        data.setWidth(state.getDouble(FIELD_WIDTH, UrbanHorizontalSignageData.DEFAULT_WIDTH_VALUE));
264
        data.setContinuity(state.getInt(FIELD_CONTINUITY, UrbanHorizontalSignageData.DEFAULT_CONTINUITY_VALUE));
265
        
266
        Color color = (Color) state.get(FIELD_SEGMENTS_COLOR);
267
        data.setSegmentsColor(color != null ? color : UrbanHorizontalSignageData.DEFAULT_SEGMENT_COLOR_VALUE);
268
        
269
        data.setSegmentsLength(state.getDouble(FIELD_SEGMENTS_LENGTH, UrbanHorizontalSignageData.DEFAULT_SEGMENT_LENGTH_VALUE));
270
        
271
        color = (Color) state.get(FIELD_HOLES_COLOR);
272
        data.setHolesColor(color != null ? color : UrbanHorizontalSignageData.DEFAULT_HOLES_COLOR_VALUE);
273
        
274
        data.setHolesLength(state.getDouble(FIELD_HOLES_LENGTH, UrbanHorizontalSignageData.DEFAULT_HOLES_LENGTH_VALUE));
275
        data.setGapWidth(state.getDouble(FIELD_GAP_WIDTH, UrbanHorizontalSignageData.DEFAULT_GAP_WIDTH_VALUE));
276
        data.setRoundVertex(state.getBoolean(FIELD_ROUND_VERTEX, UrbanHorizontalSignageData.DEFAULT_ROUND_VERTEX_VALUE));
277
        
278
        this.transparency = state.getDouble(FIELD_TRANSPARENCY, 1.0);
279
        this.mustDrawOriginalGeometry = state.getBoolean(FIELD_MUST_DRAW_ORIGINAL_GEOMETRY, false);
280
        color = (Color) state.get(FIELD_COLOR_FOR_ORIGINAL_GEOMETRY);
281
        this.colorForOriginalGeometry = color != null ? color : MapContext.getSelectionColor();
282
        this.data = data;
283

  
284
    }
285

  
286
    @Override
287
    public void saveToState(PersistentState state) throws PersistenceException {
288
        // Save parent fill symbol properties
289
        super.saveToState(state);
290

  
291
        // Save own properties
292
        
293
        if(data != null){
294
            state.set(FIELD_WIDTH, data.getWidth());
295
            state.set(FIELD_CONTINUITY, data.getContinuity());
296
            state.set(FIELD_SEGMENTS_COLOR, data.getSegmentsColor());
297
            state.set(FIELD_SEGMENTS_LENGTH, data.getSegmentsLength());
298
            state.set(FIELD_HOLES_COLOR, data.getHolesColor());
299
            state.set(FIELD_HOLES_LENGTH, data.getHolesLength());
300
            state.set(FIELD_PAINT_HOLES, data.isPaintHoles());
301
            state.set(FIELD_GAP_WIDTH, data.getGapWidth());
302
            state.set(FIELD_ROUND_VERTEX, data.isRoundVertex());
303
        }
304
        state.set(FIELD_MUST_DRAW_ORIGINAL_GEOMETRY, mustDrawOriginalGeometry);
305
        state.set(FIELD_COLOR_FOR_ORIGINAL_GEOMETRY, colorForOriginalGeometry);
306
        state.set(FIELD_TRANSPARENCY, this.getTransparency());
307
    }
308

  
309
    @Override
310
    public void getPixExtentPlus(Geometry geom, float[] distances, ViewPort viewPort, int dpi) {
311
        float cs = (float) getCartographicSize(viewPort, dpi, geom);
312
        // TODO and add the line offset
313
        distances[0] = cs;
314
        distances[1] = cs;
315
    }
316

  
317
    @Override
318
    public int getSymbolType() {
319
        return Geometry.TYPES.CURVE;
320
    }
321

  
322
    @Override
323
    public boolean isSuitableFor(Geometry geom) {
324
        return geom.getGeometryType().isTypeOf(Geometry.TYPES.CURVE);
325
    }
326

  
327
    @Override
328
    public Color getColor() {
329
        return this.colorForOriginalGeometry;
330
    }
331

  
332
    @Override
333
    public void setColor(Color color) {
334
        this.colorForOriginalGeometry = color;
335
    }
336

  
337
    @Override
338
    public void print(Graphics2D g, AffineTransform at, Geometry shape, PrintAttributes properties) {
339
        draw(g, at, shape, null, null);
340
//		double originalSize = getLineWidth();
341
//		double size=originalSize;
342
//		// scale it to size
343
//		int pq = properties.getPrintQuality();
344
//		if (pq == PrintAttributes.PRINT_QUALITY_NORMAL){
345
//			size *= (double) 300/72;
346
//		}else if (pq == PrintAttributes.PRINT_QUALITY_HIGH){
347
//			size *= (double) 600/72;
348
//		}else if (pq == PrintAttributes.PRINT_QUALITY_DRAFT){
349
//			// size *= 72/72; // (which is the same than doing nothing)
350
//		}
351
//		setLineWidth(size);
352
//		draw(g,at,geom,null, null);
353
//		setLineWidth(originalSize);
354
    }
355

  
356
    @Override
357
    public double toCartographicSize(ViewPort viewPort, double dpi, Geometry geom) {
358
        double oldSize = getData().getWidth();
359
        setCartographicSize(getCartographicSize(
360
                viewPort,
361
                dpi,
362
                geom),
363
                geom);
364
        return oldSize;
365

  
366
//        return 0;
367
    }
368

  
369
    @Override
370
    public void setCartographicSize(double cartographicSize, Geometry geom) {
371
        //DO NOTHING
372
        this.getData().setWidth(cartographicSize);
373
    }
374

  
375
    @Override
376
    public double getCartographicSize(ViewPort viewPort, double dpi, Geometry geom) {
377
        return CartographicSupportToolkit.getCartographicLength(
378
                this,
379
                getData().getWidth(),
380
                viewPort,
381
                dpi
382
        );
383

  
384
//        return 0;
385
    }
386

  
387
//    public static class RegisterPersistence implements Callable {
388
//
389
//        @Override
390
//        public Object call() throws Exception {
391
//            PersistenceManager manager = ToolsLocator.getPersistenceManager();
392
//            if (manager.getDefinition(URBAN_HORIZONTAL_SIGNAGE_SYMBOL_PERSISTENCE_DEFINITION_NAME) == null) {
393
//                DynStruct definition = manager.addDefinition(
394
//                        UrbanHorizontalSignageSymbol.class,
395
//                        URBAN_HORIZONTAL_SIGNAGE_SYMBOL_PERSISTENCE_DEFINITION_NAME,
396
//                        URBAN_HORIZONTAL_SIGNAGE_SYMBOL_PERSISTENCE_DEFINITION_NAME + " Persistence definition",
397
//                        null,
398
//                        null
399
//                );
400
//                // Extend the LineSymbol base definition
401
//                definition.extend(manager.getDefinition(AbstractSymbol.SYMBOL_PERSISTENCE_DEFINITION_NAME));
402
//                
403
//                definition.addDynFieldDouble(FIELD_WIDTH).setMandatory(false);
404
//                definition.addDynFieldInt(FIELD_CONTINUITY).setMandatory(false);
405
//                definition.addDynFieldObject(FIELD_SEGMENTS_COLOR).setClassOfValue(Color.class).setMandatory(false);
406
//                definition.addDynFieldDouble(FIELD_SEGMENTS_LENGTH).setMandatory(false);
407
//                definition.addDynFieldObject(FIELD_HOLES_COLOR).setClassOfValue(Color.class).setMandatory(false);
408
//                definition.addDynFieldDouble(FIELD_HOLES_LENGTH).setMandatory(false);
409
//                definition.addDynFieldBoolean(FIELD_PAINT_HOLES).setMandatory(false);
410
//                definition.addDynFieldDouble(FIELD_GAP_WIDTH).setMandatory(false);
411
//                definition.addDynFieldBoolean(FIELD_ROUND_VERTEX).setMandatory(false);
412
//                definition.addDynFieldDouble(FIELD_TRANSPARENCY).setMandatory(false);
413
//                definition.addDynFieldBoolean(FIELD_MUST_DRAW_ORIGINAL_GEOMETRY).setMandatory(false);
414
//                definition.addDynFieldObject(FIELD_COLOR_FOR_ORIGINAL_GEOMETRY).setClassOfValue(Color.class).setMandatory(false);
415
//            }
416
//            return Boolean.TRUE;
417
//        }
418
//
419
//    }
420

  
421
    public static class RegisterSymbol implements Callable {
422

  
423
        @Override
424
        public Object call() throws Exception {
425
            int[] shapeTypes;
426
            SymbolManager manager = MapContextLocator.getSymbolManager();
427

  
428
            shapeTypes = new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.ARC,
429
                Geometry.TYPES.MULTICURVE, Geometry.TYPES.CIRCUMFERENCE,
430
                Geometry.TYPES.PERIELLIPSE, Geometry.TYPES.SPLINE,
431
                Geometry.TYPES.LINE, Geometry.TYPES.MULTILINE};
432
            manager.registerSymbol(SYMBOL_NAME,
433
                    shapeTypes,
434
                    UrbanHorizontalSignageSymbol.class);
435

  
436
            return Boolean.TRUE;
437
        }
438

  
439
    }
440

  
441
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/impl/linelegend/DefaultUrbanHorizontalSignageConfig.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.legend.urbanhorizontalsignage.lib.impl.linelegend;
7

  
8
import java.awt.Color;
9
import org.gvsig.fmap.dal.feature.Feature;
10
import org.gvsig.fmap.dal.feature.FeatureType;
11
import org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageConfig;
12
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageConfig.DEFAULT_GAP_WIDTH_VALUE;
13
import org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData;
14
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.DEFAULT_CONTINUITY_VALUE;
15
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.DEFAULT_HOLES_COLOR_VALUE;
16
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.DEFAULT_HOLES_LENGTH_VALUE;
17
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.DEFAULT_PAINT_HOLES_VALUE;
18
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.DEFAULT_ROUND_VERTEX_VALUE;
19
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.DEFAULT_SEGMENT_COLOR_VALUE;
20
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.DEFAULT_SEGMENT_LENGTH_VALUE;
21
import static org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData.DEFAULT_WIDTH_VALUE;
22
import org.gvsig.tools.ToolsLocator;
23
import org.gvsig.tools.dataTypes.DataTypesManager;
24
import org.gvsig.tools.persistence.PersistentState;
25
import org.gvsig.tools.persistence.exception.PersistenceException;
26
import org.gvsig.tools.swing.api.DataTypes;
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29

  
30
/**
31
 *
32
 * @author fdiaz
33
 */
34
public class DefaultUrbanHorizontalSignageConfig implements UrbanHorizontalSignageConfig {
35

  
36
    private static final Logger LOGGER = LoggerFactory.getLogger(DefaultUrbanHorizontalSignageConfig.class);
37

  
38
    private String widthFieldName;
39
    private String continuityFieldName;
40
    private String holesLengthFieldName;
41
    private String holesColorFieldName;
42
    private String paintHolesFieldName;
43
    private String segmentsLengthFieldName;
44
    private String segmentsColorFieldName;
45
    private String roundVertexFieldName;
46
    private int gapWidth;
47
    private String targetColorFieldName;
48
    private String targetLenghtFieldName;
49
    private String targetAreaFieldName;
50
    
51
    public DefaultUrbanHorizontalSignageConfig() {
52
        this.gapWidth = DEFAULT_GAP_WIDTH_VALUE;
53
    }
54

  
55
    @Override
56
    public void loadFromState(PersistentState state) throws PersistenceException {
57

  
58
        this.widthFieldName = state.getString("widthFieldName");
59
        this.continuityFieldName = state.getString("continuityFieldName");
60
        this.holesLengthFieldName = state.getString("holesLengthFieldName");
61
        this.holesColorFieldName = state.getString("holesColorFieldName");
62
        this.paintHolesFieldName = state.getString("paintHolesFieldName");
63
        this.segmentsLengthFieldName = state.getString("segmentsLengthFieldName");
64
        this.segmentsColorFieldName = state.getString("segmentsColorFieldName");
65
        this.roundVertexFieldName = state.getString("roundVertexFieldName");
66
        this.gapWidth = state.getInt("gapWidth", DEFAULT_GAP_WIDTH_VALUE);
67
    }
68

  
69
    @Override
70
    public void saveToState(PersistentState state) throws PersistenceException {
71
        state.set("widthFieldName", this.widthFieldName);
72
        state.set("continuityFieldName", this.continuityFieldName);
73
        state.set("holesLengthFieldName", this.holesLengthFieldName);
74
        state.set("holesColorFieldName", this.holesColorFieldName);
75
        state.set("paintHolesFieldName", this.paintHolesFieldName);
76
        state.set("segmentsLengthFieldName", this.segmentsLengthFieldName);
77
        state.set("segmentsColorFieldName", this.segmentsColorFieldName);
78
        state.set("roundVertexFieldName", this.roundVertexFieldName);
79
        state.set("gapWidth", this.gapWidth);
80
    }
81

  
82
    @Override
83
    public String getWidthFieldName() {
84
        return this.widthFieldName;
85
    }
86

  
87
    @Override
88
    public void setWidthFieldName(String fieldName) {
89
        this.widthFieldName = fieldName;
90
    }
91

  
92
    @Override
93
    public String getContinuityFieldName() {
94
        return this.continuityFieldName;
95
    }
96

  
97
    @Override
98
    public void setContinuityFieldName(String fieldName) {
99
        this.continuityFieldName = fieldName;
100
    }
101

  
102
    @Override
103
    public String getSegmentsColorFieldName() {
104
        return this.segmentsColorFieldName;
105
    }
106

  
107
    @Override
108
    public void setSegmentsColorFieldName(String fieldName) {
109
        this.segmentsColorFieldName = fieldName;
110
    }
111

  
112
    @Override
113
    public String getSegmentsLengthFieldName() {
114
        return this.segmentsLengthFieldName;
115
    }
116

  
117
    @Override
118
    public void setSegmentsLengthFieldName(String fieldName) {
119
        this.segmentsLengthFieldName = fieldName;
120
    }
121

  
122
    @Override
123
    public String getPaintHolesFieldName() {
124
        return this.paintHolesFieldName;
125
    }
126

  
127
    @Override
128
    public void setPaintHolesFieldName(String fieldName) {
129
        this.paintHolesFieldName = fieldName;
130
    }
131

  
132
    @Override
133
    public String getHolesColorFieldName() {
134
        return this.holesColorFieldName;
135
    }
136

  
137
    @Override
138
    public void setHolesColorFieldName(String fieldName) {
139
        this.holesColorFieldName = fieldName;
140
    }
141

  
142
    @Override
143
    public String getHolesLengthFieldName() {
144
        return this.holesLengthFieldName;
145
    }
146

  
147
    @Override
148
    public void setHolesLengthFieldName(String fieldName) {
149
        this.holesLengthFieldName = fieldName;
150
    }
151
    
152
    @Override
153
    public String getRoundVertexFieldName() {
154
        return this.roundVertexFieldName;
155
    }
156

  
157
    @Override
158
    public void setRoundVertexFieldName(String fieldName) {
159
        this.roundVertexFieldName = fieldName;
160
    }
161
    
162
    @Override
163
    public int getGapWidth() {
164
        return this.gapWidth;
165
    }
166

  
167
    @Override
168
    public void setGapWith(int value) {
169
        this.gapWidth = value;
170
    }
171

  
172
    @Override
173
    public UrbanHorizontalSignageData getValues(Feature feature) {
174
        UrbanHorizontalSignageData data = new DefaultUrbanHorizontalSignageData();
175
        DataTypesManager manager = ToolsLocator.getDataTypesManager();
176
        FeatureType ftype = feature.getType();
177
        double valueDouble = feature.getIntOrDefault( this.widthFieldName, (int)DEFAULT_WIDTH_VALUE*100 )/100.0;
178
        data.setWidth(valueDouble);
179
        int valueInt = feature.getIntOrDefault( this.continuityFieldName, DEFAULT_CONTINUITY_VALUE );
180
        data.setContinuity(valueInt);
181
        Color valueColor = (Color)feature.getOrDefault( this.segmentsColorFieldName, DataTypes.COLOR, DEFAULT_SEGMENT_COLOR_VALUE );
182
        data.setSegmentsColor(valueColor);
183
        valueDouble = feature.getIntOrDefault( this.segmentsLengthFieldName, (int)DEFAULT_SEGMENT_LENGTH_VALUE*100 )/100.0;
184
        data.setSegmentsLength(valueDouble);
185
        valueDouble = feature.getIntOrDefault( this.holesLengthFieldName, (int)DEFAULT_HOLES_LENGTH_VALUE*100 )/100.0;
186
        data.setHolesLength(valueDouble);
187
        boolean valueBoolean = feature.getBooleanOrDefault( this.paintHolesFieldName, DEFAULT_PAINT_HOLES_VALUE );
188
        data.setPaintHoles(valueBoolean);
189
        valueColor = (Color) feature.getOrDefault( this.holesColorFieldName, DataTypes.COLOR, DEFAULT_HOLES_COLOR_VALUE );
190
        data.setHolesColor(valueColor);
191
        valueBoolean = feature.getBooleanOrDefault( this.roundVertexFieldName, DEFAULT_ROUND_VERTEX_VALUE );
192
        data.setRoundVertex(valueBoolean);
193

  
194
        data.setGapWidth(this.getGapWidth()/100.0);
195
        
196
        return data;
197
    }
198

  
199
    @Override
200
    public String getTargetColorFieldName() {
201
        return this.targetColorFieldName;
202
    }
203

  
204
    @Override
205
    public void setTargetColorFieldName(String fieldName) {
206
        this.targetColorFieldName = fieldName;
207
    }
208

  
209
    @Override
210
    public String getTargetLenghtFieldName() {
211
        return this.targetLenghtFieldName;
212
    }
213

  
214
    @Override
215
    public void setTargetLenghtFieldName(String fieldName) {
216
        this.targetLenghtFieldName = fieldName;
217
    }
218

  
219
    @Override
220
    public String getTargetAreaFieldName() {
221
        return this.targetAreaFieldName;
222
    }
223

  
224
    @Override
225
    public void setTargetAreaFieldName(String fieldName) {
226
        this.targetAreaFieldName = fieldName;
227
    }
228

  
229
    @Override
230
    public UrbanHorizontalSignageConfig clone() throws CloneNotSupportedException {
231
        return (UrbanHorizontalSignageConfig) super.clone(); 
232
    }
233

  
234
}
org.gvsig.legend.urbanhorizontalsignage/tags/org.gvsig.legend.urbanhorizontalsignage-1.0.87/org.gvsig.legend.urbanhorizontalsignage.lib/org.gvsig.legend.urbanhorizontalsignage.lib.impl/src/main/java/org/gvsig/legend/urbanhorizontalsignage/lib/impl/linelegend/DefaultUrbanHorizontalSignageData.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.legend.urbanhorizontalsignage.lib.impl.linelegend;
7

  
8
import java.awt.Color;
9
import org.gvsig.fmap.geom.Geometry;
10
import org.gvsig.fmap.geom.aggregate.MultiLine;
11
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
12
import org.gvsig.legend.urbanhorizontalsignage.lib.api.linelegend.UrbanHorizontalSignageData;
13

  
14
/**
15
 *
16
 * @author fdiaz
17
 */
18
public class DefaultUrbanHorizontalSignageData implements UrbanHorizontalSignageData {
19
    
20
    private double width;
21
    private int continuity;
22
    private Color segmentsColor;
23
    private double segmentsLength;
24
    private MultiPolygon segmentsGeometry;
25
    private boolean isPaintHoles;
26
    private Color holesColor;
27
    private double holesLength;
28
    private MultiPolygon holesGeometry;
29
    private double gapWidth;
30
    private Geometry originalGeometry;
31
    private boolean roundVertex;
32
    private MultiLine lineSegmentsGeometry;
33
    private MultiLine lineHolesGeometry;
34

  
35
    public DefaultUrbanHorizontalSignageData() {
36
        width = DEFAULT_WIDTH_VALUE;
37
        continuity = DEFAULT_CONTINUITY_VALUE;
38
        segmentsColor = DEFAULT_SEGMENT_COLOR_VALUE;
39
        segmentsLength = DEFAULT_SEGMENT_LENGTH_VALUE;
40
        isPaintHoles = DEFAULT_PAINT_HOLES_VALUE;
41
        holesColor = DEFAULT_HOLES_COLOR_VALUE;
42
        holesLength = DEFAULT_HOLES_LENGTH_VALUE;
43
        gapWidth = DEFAULT_GAP_WIDTH_VALUE;
44
        roundVertex = DEFAULT_ROUND_VERTEX_VALUE;
45
    }
46

  
47
    @Override
48
    public double getWidth() {
49
        return this.width;
50
    }
51

  
52
    @Override
53
    public void setWidth(double value) {
54
        this.width = value;
55
    }
56

  
57
    @Override
58
    public int getContinuity() {
59
        return this.continuity;
60
    }
61

  
62
    @Override
63
    public void setContinuity(int value) {
64
        this.continuity = value;
65
    }
66

  
67
    @Override
68
    public Color getSegmentsColor() {
69
        return this.segmentsColor;
70
    }
71

  
72
    @Override
73
    public void setSegmentsColor(Color value) {
74
        this.segmentsColor = value;
75
    }
76

  
77
    @Override
78
    public double getSegmentsLength() {
79
        return this.segmentsLength;
80
    }
81

  
82
    @Override
83
    public void setSegmentsLength(double value) {
84
        this.segmentsLength = value;
85
    }
86

  
87
    @Override
88
    public MultiPolygon getSegmentsGeometry() {
89
        return this.segmentsGeometry;
90
    }
91

  
92
    @Override
93
    public void setSegmentsGeometry(MultiPolygon value) {
94
        this.segmentsGeometry = value;
95
    }
96

  
97
    @Override
98
    public boolean isPaintHoles() {
99
        return this.isPaintHoles;
100
    }
101

  
102
    @Override
103
    public void setPaintHoles(boolean value) {
104
        this.isPaintHoles = value;
105
    }
106

  
107
    @Override
108
    public Color getHolesColor() {
109
        return this.holesColor;
110
    }
111

  
112
    @Override
113
    public void setHolesColor(Color value) {
114
        this.holesColor = value;
115
    }
116

  
117
    @Override
118
    public double getHolesLength() {
119
        return this.holesLength;
120
    }
121

  
122
    @Override
123
    public void setHolesLength(double value) {
124
        this.holesLength = value;
125
    }
126

  
127
    @Override
128
    public MultiPolygon getHolesGeometry() {
129
        return this.holesGeometry;
130
    }
131

  
132
    @Override
133
    public void setHolesGeometry(MultiPolygon value) {
134
        this.holesGeometry = value;
135
    }
136

  
137
    @Override
138
    public double getGapWidth() {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff