Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_2_Build_1044 / prototypes / VectorialAvanzado / extensions / extGraph / src / com / iver / cit / gvsig / graph / core / GvFlag.java @ 20099

History | View | Annotate | Download (4.88 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.graph.core;
42

    
43
import java.awt.geom.Point2D;
44

    
45
public class GvFlag {
46
        /*
47
         * Indexes of flag features' fields.
48
         * 
49
         * */
50
        public static final int ID_FLAG_INDEX = 0;
51
        public static final int ID_ARC_INDEX = 1;
52
        public static final int PCT_INDEX = 2;
53
        public static final int COST_INDEX = 3;
54
        public static final int DIREC_INDEX = 4;
55
        public static final int DESCRIPTION_INDEX = 5;
56
        
57
        
58
        
59
        
60
        
61
        public final static int DIGIT_DIRECTION = 1;
62
        public final static int INVERSE_DIGIT_DIRECTION = -1;
63
        public final static int BOTH_DIRECTIONS = 0;
64

    
65

    
66
        private int idArc;
67
        private int direc;
68
        private double pct;
69
        private int idFlag;
70
        private Point2D originalPoint;
71
        private String description;
72
        private boolean enabled = true;
73
        private double cost = -1;
74
        private double accumulatedLength;
75
        private static int flagNumber = 0;
76

    
77
        public GvFlag(double x, double y) {
78
                this.originalPoint = new Point2D.Double(x, y);
79
//                this.description = PluginServices.getText(this, "new_flag")+flagNumber++;
80
                this.description = "flag"+flagNumber++;
81
        }
82

    
83
        public GvFlag(double x, double y, double cost) {
84
                this.originalPoint = new Point2D.Double(x, y);
85
//                this.description = PluginServices.getText(this, "new_flag")+flagNumber++;
86
                this.description = "flag"+flagNumber++;
87
                this.cost = cost;
88
        }
89

    
90

    
91
        public GvFlag(double x, double y, String description) {
92
                this.originalPoint = new Point2D.Double(x, y);
93
                this.description = description;
94
        }
95

    
96

    
97
        public GvFlag(double x, double y, String description, double cost) {
98
                this.originalPoint = new Point2D.Double(x, y);
99
                this.description = description;
100
                this.cost = cost;
101
        }
102

    
103
        /**
104
         * Returns the cost for this flag. The cost represents the amount of resource of
105
         * the user's cost unit required to reach this flag from the previous one in
106
         * the route.
107
         * @return
108
         */
109
        public double getCost() {
110
                return cost;
111
        }
112

    
113
        /**
114
         * Sets the cost of this flag. The cost represents the amount of resource of
115
         * the user's cost unit required to reach this flag from the previous one in
116
         * the route.
117
         * @param cost
118
         */
119
        public void setCost(double cost) {
120
                this.cost = cost;
121
        }
122

    
123
        /**
124
         * Returns a human-readable description of this flag. This is typically a name
125
         * for this marker.
126
         * @return
127
         */
128
        public String getDescription() {
129
                return description;
130
        }
131

    
132
        /**
133
         * Sets the description of this flag. The description should be a human readable
134
         * description for this flag such is street name or something like that. But
135
         * it can be whatever.
136
         *
137
         * @param description
138
         */
139
        public void setDescription(String description) {
140
                this.description = description;
141
        }
142

    
143
        /**
144
         * Tells if this flag is being taken in account when calculating the route.
145
         * @return
146
         */
147
        public boolean isEnabled() {
148
                return enabled;
149
        }
150

    
151
        /**
152
         * Enables or disables this flag. A disabled flag is not taken in account to
153
         * compute the route.
154
         * @param enabled
155
         */
156
        public void setEnabled(boolean enabled) {
157
                this.enabled = enabled;
158
        }
159

    
160
        public int getIdArc() {
161
                return idArc;
162
        }
163

    
164
        public void setIdArc(int idArc) {
165
                this.idArc = idArc;
166
        }
167

    
168
        public int getDirec() {
169
                return direc;
170
        }
171

    
172
        public void setDirec(int sense) {
173
                this.direc = sense;
174
        }
175

    
176
        public double getPct() {
177
                return pct;
178
        }
179

    
180
        public void setPct(double pct) {
181
                this.pct = pct;
182
        }
183

    
184
        public void setIdFlag(int i) {
185
                idFlag = i;
186
        }
187

    
188
        public int getIdFlag() {
189
                return idFlag;
190
        }
191

    
192
        public Point2D getOriginalPoint() {
193
                return originalPoint;
194
        }
195

    
196
        public String toString() {
197
                return description;
198
        }
199

    
200
        public void setOriginalPoint(double x, double y) {
201
                originalPoint.setLocation(x, y);
202
                
203
        }
204

    
205
        public void setAccumulatedLength(double accumulatedLength) {
206
                this.accumulatedLength = accumulatedLength;
207
                
208
        }
209

    
210
        public double getAccumulatedLength() {
211
                return accumulatedLength;
212
        }
213

    
214
}
215

    
216