Statistics
| Revision:

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

History | View | Annotate | Download (3.99 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.exception.ReadException;
7
import org.gvsig.tools.persistence.Persistent;
8
import org.gvsig.tools.persistence.PersistentState;
9
import org.gvsig.tools.persistence.exception.PersistenceException;
10

    
11

    
12

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

    
28

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

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

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

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

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

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

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

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

    
101
//        /**
102
//         * Provides persistance to the properties of the HyperLink.
103
//         * @return XMLEntity with the information of the HyperLink
104
//         */
105
//        public XMLEntity getXMLEntity() {
106
//                XMLEntity xml=new XMLEntity();
107
//                xml.putProperty("typeChild","linkProperties");
108
//                xml.putProperty("extName",extName);
109
//                xml.putProperty("fieldName",fieldName);
110
//                xml.putProperty("typeLink",typeLink);
111
//                return xml;
112
//        }
113
//
114
//        /**
115
//         * Sets the properties of the HyperLink using a XMLEntity that contains the information
116
//         * @param XMLEntity
117
//         */
118
//        public void setXMLEntity(XMLEntity xml) {
119
//                extName=xml.getStringProperty("extName");
120
//                fieldName=xml.getStringProperty("fieldName");
121
//                typeLink=xml.getIntProperty("typeLink");
122
//        }
123
        
124
        /**
125
         * Saves the internal state of the object on the provided
126
         * PersistentState object.
127
         * 
128
         * @param state
129
         */
130
        public void saveToState(PersistentState state) throws PersistenceException {
131
                state.set("extName",extName);
132
                state.set("fieldName",fieldName);
133
                state.set("typeLink",typeLink);
134
        }
135

    
136
        /**
137
         * Set the state of the object from the state passed as parameter.
138
         *
139
         * @param state
140
         */
141
        public void loadFromState(PersistentState state) throws PersistenceException {
142
                
143
                extName = state.getString("extName");
144
                fieldName = state.getString("fieldName");
145
                typeLink = state.getInt("typeLink");
146
        }
147
        
148
        
149
}