root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / styling / AbstractPlacementConstraints.java @ 11138
History | View | Annotate | Download (4.57 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 11138 2007-04-11 16:01:08Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.3 2007-04-11 16:01:08 jaume
|
47 |
* maybe a label placer refactor
|
48 |
*
|
49 |
* Revision 1.2 2007/03/09 08:33:43 jaume
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.1.2.2 2007/02/15 16:23:44 jaume
|
53 |
* *** empty log message ***
|
54 |
*
|
55 |
* Revision 1.1.2.1 2007/02/09 07:47:05 jaume
|
56 |
* Isymbol moved
|
57 |
*
|
58 |
* Revision 1.1.2.3 2007/02/02 16:21:24 jaume
|
59 |
* start commiting labeling stuff
|
60 |
*
|
61 |
* Revision 1.1.2.2 2007/02/01 11:42:47 jaume
|
62 |
* *** empty log message ***
|
63 |
*
|
64 |
* Revision 1.1.2.1 2007/01/30 18:10:45 jaume
|
65 |
* start commiting labeling stuff
|
66 |
*
|
67 |
* Revision 1.1.2.1 2007/01/26 13:49:03 jaume
|
68 |
* *** empty log message ***
|
69 |
*
|
70 |
*
|
71 |
*/
|
72 |
|
73 |
|
74 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
75 |
import com.iver.cit.gvsig.fmap.core.FShape; |
76 |
|
77 |
/**
|
78 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
79 |
*/
|
80 |
public abstract class AbstractPlacementConstraints implements Cloneable, IPlacementConstraints { |
81 |
private int shapeType; |
82 |
|
83 |
private int duplicateLabelsMode = ONE_LABEL_PER_FEATURE_PART; // default duplicate treatment |
84 |
private int placementMode; |
85 |
|
86 |
public void setDuplicateLabelsMode(int mode) { |
87 |
if (mode != REMOVE_DUPLICATE_LABELS &&
|
88 |
mode != ONE_LABEL_PER_FEATURE && |
89 |
mode != ONE_LABEL_PER_FEATURE_PART) |
90 |
throw new IllegalArgumentException( |
91 |
"Only REMOVE_DUPLICATE_LABELS, " +
|
92 |
"ONE_LABEL_PER_FEATURE " +
|
93 |
"or ONE_LABEL_PER_FEATURE_PARTS allowed");
|
94 |
this.duplicateLabelsMode = mode;
|
95 |
} |
96 |
|
97 |
public void setPlacementMode(int mode) { |
98 |
switch (shapeType) {
|
99 |
case FShape.POINT:
|
100 |
if (mode != OFFSET_HORIZONTALY_AROUND_THE_POINT &&
|
101 |
mode != ON_TOP_OF_THE_POINT && |
102 |
mode != AT_SPECIFIED_ANGLE && |
103 |
mode != AT_ANGLE_SPECIFIED_BY_A_FIELD) |
104 |
throw new IllegalArgumentException( |
105 |
"Only OFFSET_HORIZONTALY_AROUND_THE_POINT, " +
|
106 |
"ON_TOP_OF_THE_POINT, " +
|
107 |
"AT_SPECIFIED_ANGLE " +
|
108 |
"or AT_ANGLE_SPECIFIED_BY_A_FIELD allowed for points");
|
109 |
break;
|
110 |
case FShape.POLYGON:
|
111 |
if (mode != HORIZONTAL &&
|
112 |
mode != PARALLEL ) |
113 |
throw new IllegalArgumentException( |
114 |
"Only HORIZONTAL, " +
|
115 |
"or PARALEL allowed for polygons");
|
116 |
break;
|
117 |
case FShape.LINE:
|
118 |
if (mode != HORIZONTAL &&
|
119 |
mode != PARALLEL && |
120 |
mode != FOLLOWING_LINE && |
121 |
mode != PERPENDICULAR) |
122 |
throw new IllegalArgumentException( |
123 |
"Only HORIZONTAL, " +
|
124 |
"or PARALEL allowed for lines");
|
125 |
break;
|
126 |
} |
127 |
this.placementMode = mode;
|
128 |
} |
129 |
|
130 |
public boolean isHorizontal() { |
131 |
return placementMode % 100 == HORIZONTAL; |
132 |
} |
133 |
|
134 |
public boolean isPerpendicular() { |
135 |
return placementMode % 100 == PERPENDICULAR; |
136 |
} |
137 |
|
138 |
public boolean isFollowingLine() { |
139 |
return placementMode % 100 == FOLLOWING_LINE; |
140 |
} |
141 |
|
142 |
public boolean isParallel() { |
143 |
return placementMode % 100 == PARALLEL; |
144 |
} |
145 |
|
146 |
public int getDuplicateLabelsMode() { |
147 |
return duplicateLabelsMode;
|
148 |
} |
149 |
|
150 |
/**
|
151 |
* Tells if the place mode selected is to put the label over the <b>POINT</b>
|
152 |
* @return boolean
|
153 |
*/
|
154 |
public boolean isOnTopOfThePoint() { |
155 |
return placementMode == ON_TOP_OF_THE_POINT;
|
156 |
} |
157 |
|
158 |
public boolean isAtTheBeginingOfLine() { |
159 |
return placementMode / 10000 == 1; |
160 |
} |
161 |
|
162 |
public boolean isAtTheEndOfLine() { |
163 |
return placementMode / 10000 == 2; |
164 |
} |
165 |
|
166 |
public boolean isBellowTheLine() { |
167 |
return placementMode / 1000 == 12; |
168 |
} |
169 |
|
170 |
public boolean isAboveTheLine() { |
171 |
return placementMode / 100 == 10; |
172 |
} |
173 |
|
174 |
public boolean isPageOriented() { |
175 |
return placementMode / 100000 == 1; |
176 |
} |
177 |
|
178 |
public boolean isLineOriented() { |
179 |
return placementMode / 100000 == 2; |
180 |
} |
181 |
} |