Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / layers / AbstractLinkProperties.java @ 24494

History | View | Annotate | Download (3.23 KB)

1
package org.gvsig.fmap.mapcontext.layers;
2

    
3
import java.awt.geom.Point2D;
4
import java.net.URI;
5

    
6
import org.gvsig.fmap.dal.exceptions.ReadException;
7

    
8

    
9
import com.iver.utiles.IPersistence;
10
import com.iver.utiles.XMLEntity;
11

    
12
/**
13
 * This is an abstract class to keep the properties of the HyperLink. One layer may have
14
 * one or zero LinkProperties. The properties of a Link are:
15
 * - fieldName, the field?s name of the selected column of the table associated to the
16
 *         layer
17
 * - extName, the name of the extension that the usser indicates
18
 * - typeLink, the type of the Link
19
 * The class implements  'IPersistance' interface to provide persistance to the properties
20
 * of HyperLink
21
 */
22
public abstract class AbstractLinkProperties implements IPersistence{
23
        private String fieldName;
24
        private String extName;
25
        private int typeLink;
26

    
27

    
28
        /**
29
         * Default constructor
30
         */
31
        public AbstractLinkProperties(){
32
                fieldName=null;
33
                extName=null;
34
                typeLink=-1;
35
        }
36

    
37
        /**
38
         * Provides an array with URIs. Returns one URI by geometry that includes the point
39
         * in its own geometry limits with a allowed tolerance.
40
         * @param layer, the layer
41
         * @param point, the point to check that is contained or not in the geometries in the layer
42
         * @param tolerance, the tolerance allowed. Allowed margin of error to detect if the  point
43
         *                 is contained in some geometries of the layer
44
         * @return
45
         * @throws ReadException
46
         * @throws BehaviorException
47
         */
48
        public abstract URI[] getLink(FLayer layer, Point2D point, double tolerance) throws ReadException;
49

    
50
        /**
51
         * Gets the field?s name of the table that the user has selected
52
         * @return this name of the field
53
         */
54
        public String getField(){
55
                return this.fieldName;
56
        }
57

    
58
        /**
59
         * Sets the field?s name
60
         * @param campo, the field?s name
61
         */
62
        public void setField(String campo){
63
                this.fieldName=campo;
64
        }
65

    
66
        /**
67
         * Gets the type of the HyperLink
68
         * @return the type
69
         */
70
        public int getType(){
71
                return this.typeLink;
72
        }
73

    
74
        /**
75
         * Sets the type of the HyperLink
76
         * @param tipo
77
         */
78
        public void setType(int tipo){
79
                this.typeLink=tipo;
80
        }
81

    
82
        /**
83
         * Gets the extension of the files that the user has indicated like properties of the
84
         * HyperLink, this extension is added to the content of the field selected in the table
85
         *
86
         * @return the extension
87
         */
88
        public String getExt(){
89
                return this.extName;
90
        }
91

    
92
        /**
93
         * Sets the extension
94
         * @param extension, the extension of the files
95
         */
96
        public void setExt(String extension){
97
                this.extName=extension;
98
        }
99

    
100
        /**
101
         * Provides persistance to the properties of the HyperLink.
102
         * @return XMLEntity with the information of the HyperLink
103
         */
104
        public XMLEntity getXMLEntity() {
105
                XMLEntity xml=new XMLEntity();
106
                xml.putProperty("typeChild","linkProperties");
107
                xml.putProperty("extName",extName);
108
                xml.putProperty("fieldName",fieldName);
109
                xml.putProperty("typeLink",typeLink);
110
                return xml;
111
        }
112

    
113
        /**
114
         * Sets the properties of the HyperLink using a XMLEntity that contains the information
115
         * @param XMLEntity
116
         */
117
        public void setXMLEntity(XMLEntity xml) {
118
                extName=xml.getStringProperty("extName");
119
                fieldName=xml.getStringProperty("fieldName");
120
                typeLink=xml.getIntProperty("typeLink");
121

    
122
        }
123
}