Revision 43510 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.labeling.app/org.gvsig.labeling.app.mainplugin/src/main/java/org/gvsig/labeling/placements/PolygonPlacementParallel.java
PolygonPlacementParallel.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
2 | 3 |
* |
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
|
4 | 5 |
* |
5 | 6 |
* This program is free software; you can redistribute it and/or |
6 | 7 |
* modify it under the terms of the GNU General Public License |
7 |
* as published by the Free Software Foundation; either version 2
|
|
8 |
* as published by the Free Software Foundation; either version 3
|
|
8 | 9 |
* of the License, or (at your option) any later version. |
9 | 10 |
* |
10 | 11 |
* This program is distributed in the hope that it will be useful, |
... | ... | |
14 | 15 |
* |
15 | 16 |
* You should have received a copy of the GNU General Public License |
16 | 17 |
* 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 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
18 | 20 |
* |
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 |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
40 | 23 |
*/ |
41 | 24 |
package org.gvsig.labeling.placements; |
42 | 25 |
|
... | ... | |
50 | 33 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
51 | 34 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
52 | 35 |
import org.gvsig.fmap.geom.GeometryLocator; |
36 |
import org.gvsig.fmap.geom.GeometryManager; |
|
53 | 37 |
import org.gvsig.fmap.geom.primitive.Point; |
54 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
55 | 38 |
import org.gvsig.fmap.mapcontext.ViewPort; |
56 | 39 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelClass; |
57 | 40 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.IPlacementConstraints; |
... | ... | |
65 | 48 |
private static final Logger logger = LoggerFactory.getLogger( |
66 | 49 |
PolygonPlacementParallel.class); |
67 | 50 |
|
51 |
@Override |
|
68 | 52 |
public ArrayList<LabelLocationMetrics> guess( |
69 | 53 |
ILabelClass lc, Geometry geom, |
70 | 54 |
IPlacementConstraints placementConstraints, |
71 | 55 |
double cartographicSymbolSize, Cancellable cancel, ViewPort vp) { |
72 | 56 |
|
73 |
if (cancel.isCanceled()) return CannotPlaceLabel.NO_PLACES; |
|
57 |
if (cancel.isCanceled()) { |
|
58 |
return CannotPlaceLabel.NO_PLACES; |
|
59 |
} |
|
74 | 60 |
|
75 | 61 |
double theta = 0; |
76 | 62 |
Point start_po = null; |
... | ... | |
82 | 68 |
start_po = geom.centroid(); |
83 | 69 |
} |
84 | 70 |
} catch (Exception exc) { |
85 |
logger.error("While getting centroid/interior point.", exc);
|
|
71 |
logger.warn("While getting centroid/interior point.", exc);
|
|
86 | 72 |
} |
87 | 73 |
|
88 | 74 |
Point2D startingPoint = new Point2D.Double(start_po.getX(), start_po.getY()); |
... | ... | |
166 | 152 |
auxp = GeometryLocator.getGeometryManager().createPoint( |
167 | 153 |
startingPoint.getX(),startingPoint.getY(), SUBTYPES.GEOM2D); |
168 | 154 |
} catch (Exception e) { |
169 |
logger.error("While creating point.", e);
|
|
155 |
logger.warn("While creating point.", e);
|
|
170 | 156 |
} |
171 | 157 |
|
172 | 158 |
auxp.transform(vp.getAffineTransform()); |
... | ... | |
174 | 160 |
new Point2D.Double(auxp.getX(),auxp.getY()), -theta, true)); |
175 | 161 |
return guessed; |
176 | 162 |
} |
163 |
|
|
164 |
@Override |
|
177 | 165 |
public boolean isSuitableFor(IPlacementConstraints placementConstraints, |
178 | 166 |
int shapeType) { |
179 | 167 |
|
180 |
GeometryType gt = null; |
|
181 |
try { |
|
182 |
gt = GeometryLocator.getGeometryManager().getGeometryType( |
|
183 |
shapeType, SUBTYPES.GEOM2D); |
|
184 |
} catch (Exception e) { |
|
185 |
logger.error("While getting geo type.", e); |
|
168 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
169 |
if( geomManager.isSubtype(TYPES.SURFACE, shapeType) || |
|
170 |
geomManager.isSubtype(TYPES.MULTISURFACE, shapeType) ) { |
|
171 |
return placementConstraints != null && placementConstraints.isParallel(); |
|
186 | 172 |
} |
187 |
|
|
188 |
if (gt.isTypeOf(TYPES.SURFACE) || shapeType == TYPES.MULTISURFACE) { |
|
189 |
return placementConstraints.isParallel(); |
|
190 |
} |
|
191 | 173 |
return false; |
192 | 174 |
} |
193 | 175 |
|
Also available in: Unified diff