Statistics
| Revision:

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

History | View | Annotate | Download (5.68 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 11192 2007-04-13 11:59:30Z jaume $
45
* $Log$
46
* Revision 1.5  2007-04-13 11:59:30  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.4  2007/04/12 16:01:11  jaume
50
* *** empty log message ***
51
*
52
* Revision 1.3  2007/04/11 16:01:08  jaume
53
* maybe a label placer refactor
54
*
55
* Revision 1.2  2007/03/09 08:33:43  jaume
56
* *** empty log message ***
57
*
58
* Revision 1.1.2.2  2007/02/15 16:23:44  jaume
59
* *** empty log message ***
60
*
61
* Revision 1.1.2.1  2007/02/09 07:47:05  jaume
62
* Isymbol moved
63
*
64
* Revision 1.1.2.3  2007/02/02 16:21:24  jaume
65
* start commiting labeling stuff
66
*
67
* Revision 1.1.2.2  2007/02/01 11:42:47  jaume
68
* *** empty log message ***
69
*
70
* Revision 1.1.2.1  2007/01/30 18:10:45  jaume
71
* start commiting labeling stuff
72
*
73
* Revision 1.1.2.1  2007/01/26 13:49:03  jaume
74
* *** empty log message ***
75
*
76
*
77
*/
78

    
79

    
80
package com.iver.cit.gvsig.fmap.rendering.styling;
81
import com.iver.cit.gvsig.fmap.core.FShape;
82
import com.iver.utiles.XMLEntity;
83

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

    
90
        private int duplicateLabelsMode = ONE_LABEL_PER_FEATURE_PART; // default duplicate treatment
91
        private int placementMode;
92
        private boolean bellowTheLine;
93
        private boolean aboveTheLine;
94
        private boolean pageOriented;
95
        private int locationAlongLine;
96

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

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

    
121
                if (this instanceof PolygonPlacementConstraints) {
122
                        if (mode != HORIZONTAL &&
123
                                mode != PARALLEL )
124
                                        throw new IllegalArgumentException(
125
                                                        "Only HORIZONTAL, " +
126
                                                        "or PARALEL allowed for polygons");
127
                }
128

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

    
141
        public boolean isHorizontal() {
142
                return placementMode == HORIZONTAL;
143
        }
144

    
145
        public boolean isPerpendicular() {
146
                return placementMode  == PERPENDICULAR;
147
        }
148

    
149
        public boolean isFollowingLine() {
150
                return placementMode  == FOLLOWING_LINE;
151
        }
152

    
153
        public boolean isParallel() {
154
                return placementMode == PARALLEL;
155
        }
156

    
157
        public int getDuplicateLabelsMode() {
158
                return duplicateLabelsMode;
159
        }
160

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

    
169
        public boolean isBellowTheLine() {
170
                return bellowTheLine;
171
        }
172

    
173
        public boolean isAboveTheLine() {
174
                return aboveTheLine;
175
        }
176

    
177
        public boolean isPageOriented() {
178
                return pageOriented;
179
        }
180

    
181
        public void setPageOriented(boolean b) {
182
                this.pageOriented = b;
183
        }
184

    
185
        public void setBellowTheLine(boolean b) {
186
                this.bellowTheLine = b;
187
        }
188

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

    
193
        public boolean isAtTheEndOfLine() {
194
                return locationAlongLine == AT_THE_END_OF_THE_LINE;
195
        }
196

    
197

    
198
        public boolean isAtTheBeginingOfLine() {
199
                return locationAlongLine == AT_THE_BEGINING_OF_THE_LINE;
200
        }
201

    
202
        public void setLocationAlongTheLine(int location) {
203
                if (location != IPlacementConstraints.AT_THE_MIDDLE_OF_THE_LINE
204
                        && location != IPlacementConstraints.AT_THE_BEGINING_OF_THE_LINE
205
                        && location != IPlacementConstraints.AT_THE_END_OF_THE_LINE) {
206
                        throw new IllegalArgumentException("Only IPlacementConstraints.AT_THE_MIDDLE_OF_THE_LINE, " +
207
                                        "IPlacementConstraints.AT_THE_BEGINING_OF_THE_LINE, or " +
208
                                        "IPlacementConstraints.AT_THE_END_OF_THE_LINE values are allowed");
209
                }
210
                this.locationAlongLine = location;
211
        }
212

    
213
        public XMLEntity getXMLEntity() {
214
                XMLEntity xml = new XMLEntity();
215
                return xml;
216
        }
217

    
218
        public void setXMLEntity(XMLEntity xml) {
219

    
220
        }
221
}