Statistics
| Revision:

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

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

    
76

    
77
package com.iver.cit.gvsig.fmap.rendering.styling;
78
import com.iver.cit.gvsig.fmap.core.FShape;
79

    
80
/**
81
 * @author  jaume dominguez faus - jaume.dominguez@iver.es
82
 */
83
public abstract class AbstractPlacementConstraints implements Cloneable, IPlacementConstraints {
84
        private int shapeType;
85

    
86
        private int duplicateLabelsMode = ONE_LABEL_PER_FEATURE_PART; // default duplicate treatment
87
        private int placementMode;
88

    
89
        private boolean atTheBeginingOfLine;
90

    
91
        private boolean atTheEndOfLine;
92

    
93
        private boolean bellowTheLine;
94

    
95
        private boolean aboveTheLine;
96

    
97
        private boolean pageOriented;
98

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

    
110
        public void setPlacementMode(int mode) {
111
                switch (shapeType) {
112
                case FShape.POINT:
113
                        if (mode != OFFSET_HORIZONTALY_AROUND_THE_POINT &&
114
                                mode != ON_TOP_OF_THE_POINT &&
115
                                mode != AT_SPECIFIED_ANGLE &&
116
                                mode != AT_ANGLE_SPECIFIED_BY_A_FIELD)
117
                                throw new IllegalArgumentException(
118
                                                "Only OFFSET_HORIZONTALY_AROUND_THE_POINT, " +
119
                                                "ON_TOP_OF_THE_POINT, " +
120
                                                "AT_SPECIFIED_ANGLE " +
121
                                                "or AT_ANGLE_SPECIFIED_BY_A_FIELD allowed for points");
122
                        break;
123
                case FShape.POLYGON:
124
                        if (mode != HORIZONTAL &&
125
                                mode != PARALLEL )
126
                                        throw new IllegalArgumentException(
127
                                                        "Only HORIZONTAL, " +
128
                                                        "or PARALEL allowed for polygons");
129
                        break;
130
                case FShape.LINE:
131
                        if (mode != HORIZONTAL &&
132
                                mode != PARALLEL &&
133
                                mode != FOLLOWING_LINE &&
134
                                mode != PERPENDICULAR)
135
                                throw new IllegalArgumentException(
136
                                                "Only HORIZONTAL, " +
137
                                                "or PARALEL allowed for lines");
138
                        break;
139
                }
140
                this.placementMode = mode;
141
        }
142

    
143
        public boolean isHorizontal() {
144
                return placementMode == HORIZONTAL;
145
        }
146

    
147
        public boolean isPerpendicular() {
148
                return placementMode  == PERPENDICULAR;
149
        }
150

    
151
        public boolean isFollowingLine() {
152
                return placementMode  == FOLLOWING_LINE;
153
        }
154

    
155
        public boolean isParallel() {
156
                return placementMode == PARALLEL;
157
        }
158

    
159
        public int getDuplicateLabelsMode() {
160
                return duplicateLabelsMode;
161
        }
162

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

    
171
        public boolean isAtTheBeginingOfLine() {
172
                return atTheBeginingOfLine;
173
        }
174

    
175
        public boolean isAtTheEndOfLine() {
176
                return atTheEndOfLine;
177
        }
178

    
179
        public boolean isBellowTheLine() {
180
                return bellowTheLine;
181
        }
182

    
183
        public boolean isAboveTheLine() {
184
                return aboveTheLine;
185
        }
186

    
187
        public boolean isPageOriented() {
188
                return pageOriented;
189
        }
190
        public void setPageOriented(boolean b) {
191
                this.pageOriented = pageOriented;
192
        }
193

    
194

    
195
        public void setAtTheBeginingOfLine(boolean b) {
196
                this.atTheBeginingOfLine = b;
197
        }
198

    
199
        public void setAtTheEndOfLine(boolean b) {
200
                this.atTheEndOfLine = b;
201
        }
202

    
203
        public void setBellowTheLine(boolean b) {
204
                this.bellowTheLine = b;
205
        }
206

    
207
        public void setAboveTheLine(boolean b) {
208
                this.aboveTheLine = b;
209
        }
210
}