Revision 19934
trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/labeling/placements/LinePlacementConstraints.java | ||
---|---|---|
85 | 85 |
|
86 | 86 |
import com.iver.cit.gvsig.fmap.core.FShape; |
87 | 87 |
import com.iver.cit.gvsig.fmap.core.TextPath; |
88 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.IPlacementConstraints; |
|
88 | 89 |
import com.iver.utiles.XMLEntity; |
89 | 90 |
/** |
90 | 91 |
* |
... | ... | |
98 | 99 |
public LinePlacementConstraints() { |
99 | 100 |
super(); |
100 | 101 |
setPlacementMode(PARALLEL); |
102 |
setLocationAlongTheLine(IPlacementConstraints.AT_THE_MIDDLE_OF_THE_LINE); |
|
101 | 103 |
} |
102 | 104 |
|
103 | 105 |
public String getClassName() { |
trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/labeling/placements/MultiShapePlacementConstraints.java | ||
---|---|---|
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 |
package org.gvsig.symbology.fmap.labeling.placements; |
|
42 |
|
|
43 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.IPlacementConstraints; |
|
44 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelingFactory; |
|
45 |
import com.iver.utiles.XMLEntity; |
|
46 |
|
|
47 |
/** |
|
48 |
* |
|
49 |
* MultiShapePlacementConstraints.java |
|
50 |
* |
|
51 |
* |
|
52 |
* @author jaume dominguez faus - jaume.dominguez@iver.es Apr 1, 2008 |
|
53 |
* |
|
54 |
*/ |
|
55 |
public class MultiShapePlacementConstraints extends AbstractPlacementConstraints { |
|
56 |
|
|
57 |
private IPlacementConstraints polygonConstraints; |
|
58 |
private IPlacementConstraints lineConstraints; |
|
59 |
private IPlacementConstraints pointConstraints; |
|
60 |
|
|
61 |
|
|
62 |
public MultiShapePlacementConstraints() { } |
|
63 |
|
|
64 |
public MultiShapePlacementConstraints( |
|
65 |
IPlacementConstraints pointConstraints, |
|
66 |
IPlacementConstraints lineConstraints, |
|
67 |
IPlacementConstraints polygonConstraints) { |
|
68 |
this.pointConstraints = pointConstraints; |
|
69 |
this.lineConstraints = lineConstraints; |
|
70 |
this.polygonConstraints = polygonConstraints; |
|
71 |
|
|
72 |
} |
|
73 |
|
|
74 |
public void setPolygonConstraints(IPlacementConstraints polygonConstraints) { |
|
75 |
this.polygonConstraints = polygonConstraints; |
|
76 |
} |
|
77 |
|
|
78 |
public void setLineConstraints(IPlacementConstraints lineConstraints) { |
|
79 |
this.lineConstraints = lineConstraints; |
|
80 |
} |
|
81 |
|
|
82 |
public void setPointConstraints(IPlacementConstraints pointConstraints) { |
|
83 |
this.pointConstraints = pointConstraints; |
|
84 |
} |
|
85 |
|
|
86 |
public IPlacementConstraints getPolygonConstraints() { |
|
87 |
return polygonConstraints; |
|
88 |
} |
|
89 |
|
|
90 |
public IPlacementConstraints getLineConstraints() { |
|
91 |
return lineConstraints; |
|
92 |
} |
|
93 |
|
|
94 |
public IPlacementConstraints getPointConstraints() { |
|
95 |
return pointConstraints; |
|
96 |
} |
|
97 |
|
|
98 |
|
|
99 |
@Override |
|
100 |
public boolean isAboveTheLine() { |
|
101 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
102 |
} |
|
103 |
|
|
104 |
@Override |
|
105 |
public boolean isAroundThePoint() { |
|
106 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
107 |
} |
|
108 |
|
|
109 |
@Override |
|
110 |
public boolean isAtBestOfLine() { |
|
111 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
112 |
} |
|
113 |
|
|
114 |
@Override |
|
115 |
public boolean isAtTheBeginingOfLine() { |
|
116 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public boolean isAtTheEndOfLine() { |
|
121 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
122 |
} |
|
123 |
|
|
124 |
@Override |
|
125 |
public boolean isBelowTheLine() { |
|
126 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
127 |
} |
|
128 |
|
|
129 |
@Override |
|
130 |
public boolean isFitInsidePolygon() { |
|
131 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
132 |
} |
|
133 |
|
|
134 |
@Override |
|
135 |
public boolean isFollowingLine() { |
|
136 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
137 |
} |
|
138 |
|
|
139 |
@Override |
|
140 |
public boolean isHorizontal() { |
|
141 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
142 |
} |
|
143 |
|
|
144 |
@Override |
|
145 |
public boolean isInTheMiddleOfLine() { |
|
146 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
147 |
} |
|
148 |
|
|
149 |
@Override |
|
150 |
public boolean isOnTheLine() { |
|
151 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
152 |
} |
|
153 |
|
|
154 |
@Override |
|
155 |
public boolean isOnTopOfThePoint() { |
|
156 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
157 |
} |
|
158 |
|
|
159 |
@Override |
|
160 |
public boolean isPageOriented() { |
|
161 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
162 |
} |
|
163 |
|
|
164 |
@Override |
|
165 |
public boolean isParallel() { |
|
166 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
167 |
} |
|
168 |
|
|
169 |
@Override |
|
170 |
public boolean isPerpendicular() { |
|
171 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
172 |
} |
|
173 |
|
|
174 |
@Override |
|
175 |
public void setAboveTheLine(boolean b) { |
|
176 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
177 |
} |
|
178 |
|
|
179 |
@Override |
|
180 |
public void setBelowTheLine(boolean b) { |
|
181 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
182 |
} |
|
183 |
|
|
184 |
|
|
185 |
@Override |
|
186 |
public void setFitInsidePolygon(boolean b) { |
|
187 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
188 |
} |
|
189 |
|
|
190 |
@Override |
|
191 |
public void setLocationAlongTheLine(int location) { |
|
192 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
193 |
} |
|
194 |
|
|
195 |
@Override |
|
196 |
public void setOnTheLine(boolean b) { |
|
197 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
198 |
} |
|
199 |
|
|
200 |
@Override |
|
201 |
public void setPageOriented(boolean b) { |
|
202 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
203 |
} |
|
204 |
|
|
205 |
@Override |
|
206 |
public void setPlacementMode(int mode) { |
|
207 |
throw new Error("Operation delegated to its members. Access them directly"); |
|
208 |
} |
|
209 |
|
|
210 |
public String getClassName() { |
|
211 |
return getClass().getName(); |
|
212 |
} |
|
213 |
|
|
214 |
public XMLEntity getXMLEntity() { |
|
215 |
XMLEntity xml = new XMLEntity(); |
|
216 |
xml.putProperty("className", getClassName()); |
|
217 |
|
|
218 |
// point constraints |
|
219 |
if (pointConstraints != null) { |
|
220 |
XMLEntity points = pointConstraints.getXMLEntity(); |
|
221 |
points.putProperty("id", "PointConstraints"); |
|
222 |
xml.addChild(points); |
|
223 |
} |
|
224 |
|
|
225 |
// line constraints |
|
226 |
if (lineConstraints != null) { |
|
227 |
XMLEntity lines = lineConstraints.getXMLEntity(); |
|
228 |
lines.putProperty("id", "LineConstraints"); |
|
229 |
xml.addChild(lines); |
|
230 |
} |
|
231 |
|
|
232 |
// point constraints |
|
233 |
if (polygonConstraints != null) { |
|
234 |
XMLEntity polygons = polygonConstraints.getXMLEntity(); |
|
235 |
polygons.putProperty("id", "PolygonCostraints"); |
|
236 |
xml.addChild(polygons); |
|
237 |
} |
|
238 |
|
|
239 |
return xml; |
|
240 |
} |
|
241 |
|
|
242 |
public void setXMLEntity(XMLEntity xml) { |
|
243 |
XMLEntity aux; |
|
244 |
|
|
245 |
// points |
|
246 |
if ( ((aux = xml.firstChild("id", "PointConstraints")) != null) ) { |
|
247 |
pointConstraints = LabelingFactory.createPlacementConstraintsFromXML(aux); |
|
248 |
} |
|
249 |
|
|
250 |
// lines |
|
251 |
if ( ((aux = xml.firstChild("id", "LineConstraints")) != null) ) { |
|
252 |
pointConstraints = LabelingFactory.createPlacementConstraintsFromXML(aux); |
|
253 |
} |
|
254 |
|
|
255 |
// polygons |
|
256 |
if ( ((aux = xml.firstChild("id", "PloygonConstraints")) != null) ) { |
|
257 |
pointConstraints = LabelingFactory.createPlacementConstraintsFromXML(aux); |
|
258 |
} |
|
259 |
|
|
260 |
} |
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
} |
trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/labeling/placements/MultiShapePlacement.java | ||
---|---|---|
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 |
package org.gvsig.symbology.fmap.labeling.placements; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
|
|
45 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
46 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.IPlacementConstraints; |
|
47 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelClass; |
|
48 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelLocationMetrics; |
|
49 |
import com.iver.utiles.swing.threads.Cancellable; |
|
50 |
|
|
51 |
/** |
|
52 |
* |
|
53 |
* MultiShapePlacementConstraints.java |
|
54 |
* |
|
55 |
* |
|
56 |
* @author jaume dominguez faus - jaume.dominguez@iver.es Apr 1, 2008 |
|
57 |
* |
|
58 |
*/ |
|
59 |
public class MultiShapePlacement implements ILabelPlacement { |
|
60 |
private ILabelPlacement pointPlacement; |
|
61 |
private ILabelPlacement linePlacement; |
|
62 |
private ILabelPlacement polygonPlacement; |
|
63 |
|
|
64 |
|
|
65 |
/** |
|
66 |
* Creates a new instance of MultiShapePlacement initializing the respective |
|
67 |
* placements to those passed as parameters. Null values are allowed for |
|
68 |
* the parameters and will cause that no label will be placed when the |
|
69 |
* geometry belongs to such null values. |
|
70 |
* |
|
71 |
* @param pointPlacement, the placement for points |
|
72 |
* @param linePlacement, the placement for lines |
|
73 |
* @param polygonPlacement, the placement for polygons |
|
74 |
*/ |
|
75 |
public MultiShapePlacement( |
|
76 |
ILabelPlacement pointPlacement, |
|
77 |
ILabelPlacement linePlacement, |
|
78 |
ILabelPlacement polygonPlacement) { |
|
79 |
this.pointPlacement = pointPlacement; |
|
80 |
this.linePlacement = linePlacement; |
|
81 |
this.polygonPlacement = polygonPlacement; |
|
82 |
} |
|
83 |
|
|
84 |
public ArrayList<LabelLocationMetrics> guess(LabelClass lc, FShape shp, |
|
85 |
IPlacementConstraints placementConstraints, |
|
86 |
double cartographicSymbolSize, Cancellable cancel) { |
|
87 |
|
|
88 |
MultiShapePlacementConstraints pc = (MultiShapePlacementConstraints) placementConstraints; |
|
89 |
switch (shp.getShapeType()) { |
|
90 |
case FShape.POINT: |
|
91 |
if (pointPlacement != null) { |
|
92 |
return pointPlacement.guess(lc, shp, pc.getPointConstraints(), cartographicSymbolSize, cancel); |
|
93 |
} |
|
94 |
break; |
|
95 |
case FShape.LINE: |
|
96 |
if (linePlacement != null) { |
|
97 |
return linePlacement.guess(lc, shp, pc.getLineConstraints(), cartographicSymbolSize, cancel); |
|
98 |
} |
|
99 |
break; |
|
100 |
case FShape.POLYGON: |
|
101 |
if (polygonPlacement != null) { |
|
102 |
return polygonPlacement.guess(lc, shp, pc.getPolygonConstraints(), cartographicSymbolSize, cancel); |
|
103 |
} |
|
104 |
break; |
|
105 |
} |
|
106 |
return CannotPlaceLabel.NO_PLACES; |
|
107 |
} |
|
108 |
|
|
109 |
public boolean isSuitableFor(IPlacementConstraints placementConstraints, |
|
110 |
int shapeType) { |
|
111 |
|
|
112 |
return shapeType == FShape.MULTI; |
|
113 |
} |
|
114 |
|
|
115 |
|
|
116 |
} |
trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/labeling/placements/PolygonPlacementOnCentroid.java | ||
---|---|---|
51 | 51 |
import com.iver.utiles.swing.threads.Cancellable; |
52 | 52 |
import com.vividsolutions.jts.geom.Geometry; |
53 | 53 |
import com.vividsolutions.jts.geom.Point; |
54 |
|
|
54 |
/** |
|
55 |
* |
|
56 |
* PolygonPlacementOnCentroid.java |
|
57 |
* |
|
58 |
* |
|
59 |
* @author jaume dominguez faus - jaume.dominguez@iver.es Apr 1, 2008 |
|
60 |
* |
|
61 |
*/ |
|
55 | 62 |
public class PolygonPlacementOnCentroid extends MarkerCenteredAtPoint implements ILabelPlacement { |
56 | 63 |
|
57 | 64 |
public ArrayList<LabelLocationMetrics> guess(LabelClass lc, FShape shp, |
Also available in: Unified diff