Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / styling / AbstractPlacementConstraints.java @ 11199

History | View | Annotate | Download (5.89 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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

    
42
/* CVS MESSAGES:
43
*
44
* $Id: AbstractPlacementConstraints.java 11199 2007-04-13 12:46:40Z jaume $
45
* $Log$
46
* Revision 1.6  2007-04-13 12:42:45  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.5  2007/04/13 11:59:30  jaume
50
* *** empty log message ***
51
*
52
* Revision 1.4  2007/04/12 16:01:11  jaume
53
* *** empty log message ***
54
*
55
* Revision 1.3  2007/04/11 16:01:08  jaume
56
* maybe a label placer refactor
57
*
58
* Revision 1.2  2007/03/09 08:33:43  jaume
59
* *** empty log message ***
60
*
61
* Revision 1.1.2.2  2007/02/15 16:23:44  jaume
62
* *** empty log message ***
63
*
64
* Revision 1.1.2.1  2007/02/09 07:47:05  jaume
65
* Isymbol moved
66
*
67
* Revision 1.1.2.3  2007/02/02 16:21:24  jaume
68
* start commiting labeling stuff
69
*
70
* Revision 1.1.2.2  2007/02/01 11:42:47  jaume
71
* *** empty log message ***
72
*
73
* Revision 1.1.2.1  2007/01/30 18:10:45  jaume
74
* start commiting labeling stuff
75
*
76
* Revision 1.1.2.1  2007/01/26 13:49:03  jaume
77
* *** empty log message ***
78
*
79
*
80
*/
81

    
82

    
83
package com.iver.cit.gvsig.fmap.rendering.styling;
84
import com.iver.cit.gvsig.fmap.core.FShape;
85
import com.iver.utiles.XMLEntity;
86

    
87
/**
88
 * @author  jaume dominguez faus - jaume.dominguez@iver.es
89
 */
90
public abstract class AbstractPlacementConstraints implements Cloneable, IPlacementConstraints {
91
        private int shapeType;
92

    
93
        private int duplicateLabelsMode = ONE_LABEL_PER_FEATURE_PART; // default duplicate treatment
94
        private int placementMode;
95
        private boolean bellowTheLine;
96
        private boolean aboveTheLine;
97
        private boolean onTheLine;
98
        private boolean pageOriented;
99
        private int locationAlongLine;
100

    
101
        public void setDuplicateLabelsMode(int mode) {
102
                if (mode != REMOVE_DUPLICATE_LABELS &&
103
                        mode != ONE_LABEL_PER_FEATURE &&
104
                        mode != ONE_LABEL_PER_FEATURE_PART)
105
                        throw new IllegalArgumentException(
106
                                        "Only REMOVE_DUPLICATE_LABELS, " +
107
                                        "ONE_LABEL_PER_FEATURE " +
108
                                        "or ONE_LABEL_PER_FEATURE_PARTS allowed");
109
                this.duplicateLabelsMode = mode;
110
        }
111

    
112
        public void setPlacementMode(int mode) {
113
                if (this instanceof PointPlacementConstraints) {
114
                        if (mode != OFFSET_HORIZONTALY_AROUND_THE_POINT &&
115
                                mode != ON_TOP_OF_THE_POINT &&
116
                                mode != AT_SPECIFIED_ANGLE &&
117
                                mode != AT_ANGLE_SPECIFIED_BY_A_FIELD)
118
                                throw new IllegalArgumentException(
119
                                                "Only OFFSET_HORIZONTALY_AROUND_THE_POINT, " +
120
                                                "ON_TOP_OF_THE_POINT, " +
121
                                                "AT_SPECIFIED_ANGLE " +
122
                                                "or AT_ANGLE_SPECIFIED_BY_A_FIELD allowed for points");
123
                }
124

    
125
                if (this instanceof PolygonPlacementConstraints) {
126
                        if (mode != HORIZONTAL &&
127
                                mode != PARALLEL )
128
                                        throw new IllegalArgumentException(
129
                                                        "Only HORIZONTAL, " +
130
                                                        "or PARALEL allowed for polygons");
131
                }
132

    
133
                if (this instanceof LinePlacementConstraints) {
134
                                        if (mode != HORIZONTAL &&
135
                                mode != PARALLEL &&
136
                                mode != FOLLOWING_LINE &&
137
                                mode != PERPENDICULAR)
138
                                throw new IllegalArgumentException(
139
                                                "Only HORIZONTAL, " +
140
                                                "or PARALEL allowed for lines");
141
                }
142
                this.placementMode = mode;
143
        }
144

    
145
        public boolean isHorizontal() {
146
                return placementMode == HORIZONTAL;
147
        }
148

    
149
        public boolean isPerpendicular() {
150
                return placementMode  == PERPENDICULAR;
151
        }
152

    
153
        public boolean isFollowingLine() {
154
                return placementMode  == FOLLOWING_LINE;
155
        }
156

    
157
        public boolean isParallel() {
158
                return placementMode == PARALLEL;
159
        }
160

    
161
        public int getDuplicateLabelsMode() {
162
                return duplicateLabelsMode;
163
        }
164

    
165
        /**
166
         * Tells if the place mode selected is to put the label over the <b>POINT</b>
167
         * @return boolean
168
         */
169
        public boolean isOnTopOfThePoint() {
170
                return placementMode == ON_TOP_OF_THE_POINT;
171
        }
172

    
173
        public boolean isBellowTheLine() {
174
                return bellowTheLine;
175
        }
176

    
177
        public boolean isAboveTheLine() {
178
                return aboveTheLine;
179
        }
180

    
181
        public boolean isOnTheLine() {
182
                return onTheLine;
183
        }
184

    
185
        public boolean isPageOriented() {
186
                return pageOriented;
187
        }
188

    
189
        public void setOnTheLine(boolean b) {
190
                this.onTheLine = b;
191
        }
192

    
193
        public void setPageOriented(boolean b) {
194
                this.pageOriented = b;
195
        }
196

    
197
        public void setBellowTheLine(boolean b) {
198
                this.bellowTheLine = b;
199
        }
200

    
201
        public void setAboveTheLine(boolean b) {
202
                this.aboveTheLine = b;
203
        }
204

    
205
        public boolean isAtTheEndOfLine() {
206
                return locationAlongLine == AT_THE_END_OF_THE_LINE;
207
        }
208

    
209

    
210
        public boolean isAtTheBeginingOfLine() {
211
                return locationAlongLine == AT_THE_BEGINING_OF_THE_LINE;
212
        }
213

    
214
        public void setLocationAlongTheLine(int location) {
215
                if (location != IPlacementConstraints.AT_THE_MIDDLE_OF_THE_LINE
216
                        && location != IPlacementConstraints.AT_THE_BEGINING_OF_THE_LINE
217
                        && location != IPlacementConstraints.AT_THE_END_OF_THE_LINE) {
218
                        throw new IllegalArgumentException("Only IPlacementConstraints.AT_THE_MIDDLE_OF_THE_LINE, " +
219
                                        "IPlacementConstraints.AT_THE_BEGINING_OF_THE_LINE, or " +
220
                                        "IPlacementConstraints.AT_THE_END_OF_THE_LINE values are allowed");
221
                }
222
                this.locationAlongLine = location;
223
        }
224

    
225
        public XMLEntity getXMLEntity() {
226
                XMLEntity xml = new XMLEntity();
227
                return xml;
228
        }
229

    
230
        public void setXMLEntity(XMLEntity xml) {
231

    
232
        }
233
}