Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.api / src / main / java / org / gvsig / fmap / mapcontext / layers / AbstractLinkProperties.java @ 40559

History | View | Annotate | Download (5.03 KB)

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.fmap.mapcontext.layers;
25

    
26
import java.awt.geom.Point2D;
27
import java.net.URI;
28

    
29
import org.gvsig.fmap.dal.exception.ReadException;
30
import org.gvsig.tools.persistence.Persistent;
31
import org.gvsig.tools.persistence.PersistentState;
32
import org.gvsig.tools.persistence.exception.PersistenceException;
33

    
34

    
35

    
36
/**
37
 * This is an abstract class to keep the properties of the HyperLink. One layer may have
38
 * one or zero LinkProperties. The properties of a Link are:
39
 * - fieldName, the field?s name of the selected column of the table associated to the
40
 *         layer
41
 * - extName, the name of the extension that the usser indicates
42
 * - typeLink, the type of the Link
43
 * The class implements  'IPersistance' interface to provide persistance to the properties
44
 * of HyperLink
45
 * 
46
 * @deprecated this functionality has extracted of the core in gvSIG 2.0 
47
 */
48
public abstract class AbstractLinkProperties implements Persistent {
49
        private String fieldName;
50
        private String extName;
51
        private int typeLink;
52

    
53

    
54
        /**
55
         * Default constructor
56
         */
57
        public AbstractLinkProperties(){
58
                fieldName=null;
59
                extName=null;
60
                typeLink=-1;
61
        }
62

    
63
        /**
64
         * Provides an array with URIs. Returns one URI by geometry that includes the point
65
         * in its own geometry limits with a allowed tolerance.
66
         * @param layer, the layer
67
         * @param point, the point to check that is contained or not in the geometries in the layer
68
         * @param tolerance, the tolerance allowed. Allowed margin of error to detect if the  point
69
         *                 is contained in some geometries of the layer
70
         * @return
71
         * @throws ReadException
72
         * @throws BehaviorException
73
         */
74
        public abstract URI[] getLink(FLayer layer, Point2D point, double tolerance) throws ReadException;
75

    
76
        /**
77
         * Gets the field?s name of the table that the user has selected
78
         * @return this name of the field
79
         */
80
        public String getField(){
81
                return this.fieldName;
82
        }
83

    
84
        /**
85
         * Sets the field?s name
86
         * @param campo, the field?s name
87
         */
88
        public void setField(String campo){
89
                this.fieldName=campo;
90
        }
91

    
92
        /**
93
         * Gets the type of the HyperLink
94
         * @return the type
95
         */
96
        public int getType(){
97
                return this.typeLink;
98
        }
99

    
100
        /**
101
         * Sets the type of the HyperLink
102
         * @param tipo
103
         */
104
        public void setType(int tipo){
105
                this.typeLink=tipo;
106
        }
107

    
108
        /**
109
         * Gets the extension of the files that the user has indicated like properties of the
110
         * HyperLink, this extension is added to the content of the field selected in the table
111
         *
112
         * @return the extension
113
         */
114
        public String getExt(){
115
                return this.extName;
116
        }
117

    
118
        /**
119
         * Sets the extension
120
         * @param extension, the extension of the files
121
         */
122
        public void setExt(String extension){
123
                this.extName=extension;
124
        }
125

    
126
//        /**
127
//         * Provides persistance to the properties of the HyperLink.
128
//         * @return XMLEntity with the information of the HyperLink
129
//         */
130
//        public XMLEntity getXMLEntity() {
131
//                XMLEntity xml=new XMLEntity();
132
//                xml.putProperty("typeChild","linkProperties");
133
//                xml.putProperty("extName",extName);
134
//                xml.putProperty("fieldName",fieldName);
135
//                xml.putProperty("typeLink",typeLink);
136
//                return xml;
137
//        }
138
//
139
//        /**
140
//         * Sets the properties of the HyperLink using a XMLEntity that contains the information
141
//         * @param XMLEntity
142
//         */
143
//        public void setXMLEntity(XMLEntity xml) {
144
//                extName=xml.getStringProperty("extName");
145
//                fieldName=xml.getStringProperty("fieldName");
146
//                typeLink=xml.getIntProperty("typeLink");
147
//        }
148
        
149
        /**
150
         * Saves the internal state of the object on the provided
151
         * PersistentState object.
152
         * 
153
         * @param state
154
         */
155
        public void saveToState(PersistentState state) throws PersistenceException {
156
                state.set("extName",extName);
157
                state.set("fieldName",fieldName);
158
                state.set("typeLink",typeLink);
159
        }
160

    
161
        /**
162
         * Set the state of the object from the state passed as parameter.
163
         *
164
         * @param state
165
         */
166
        public void loadFromState(PersistentState state) throws PersistenceException {
167
                
168
                extName = state.getString("extName");
169
                fieldName = state.getString("fieldName");
170
                typeLink = state.getInt("typeLink");
171
        }
172
        
173
        
174
}