Revision 31456 trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/labeling/GeneralLabelingStrategy.java
GeneralLabelingStrategy.java | ||
---|---|---|
221 | 221 |
} |
222 | 222 |
public void draw(BufferedImage mapImage, Graphics2D mapGraphics, |
223 | 223 |
ViewPort viewPort, Cancellable cancel, double dpi) throws ReadDriverException { |
224 |
|
|
224 |
int x=(int)viewPort.getOffset().getX(); |
|
225 |
int y=(int)viewPort.getOffset().getY(); |
|
225 | 226 |
// boolean bVisualFXEnabled = false; // if true, the user can see how the labeling is drawing up |
226 | 227 |
|
227 | 228 |
|
... | ... | |
278 | 279 |
BufferedImage overlapDetectImage = null; |
279 | 280 |
Graphics2D overlapDetectGraphics = null; |
280 | 281 |
if (bLabelsReallocatable) { |
282 |
int width = viewPort.getImageWidth()+x; |
|
283 |
if(width<0){ |
|
284 |
width = 1; |
|
285 |
} |
|
286 |
int height = viewPort.getImageHeight()+y; |
|
287 |
if(height<0){ |
|
288 |
height = 1; |
|
289 |
} |
|
290 |
|
|
281 | 291 |
overlapDetectImage = new BufferedImage( |
282 |
viewPort.getImageWidth()+(int)viewPort.getOffset().getX(),
|
|
283 |
viewPort.getImageHeight()+(int)viewPort.getOffset().getY(),
|
|
292 |
mapImage.getWidth(),
|
|
293 |
mapImage.getHeight(),
|
|
284 | 294 |
BufferedImage.TYPE_INT_ARGB |
285 | 295 |
); |
286 | 296 |
overlapDetectGraphics = overlapDetectImage.createGraphics(); |
... | ... | |
289 | 299 |
if (bLabelsReallocatable) { |
290 | 300 |
targetBI = overlapDetectImage; |
291 | 301 |
targetGr = overlapDetectGraphics; |
302 |
targetGr.translate(-x, -y); |
|
292 | 303 |
} else { |
293 | 304 |
targetBI = mapImage; |
294 | 305 |
targetGr = mapGraphics; |
295 | 306 |
} |
296 | 307 |
|
297 |
|
|
298 |
|
|
299 | 308 |
while ( !cancel.isCanceled() && it.hasNext()) { |
300 | 309 |
IFeature feat = it.next(); |
301 | 310 |
IGeometry geom = feat.getGeometry(); |
... | ... | |
320 | 329 |
notPlacedCount++; |
321 | 330 |
if(geom.getGeometryType() != FShape.POINT){ |
322 | 331 |
// FJP: Cambiamos la uni?n por una comprobaci?n de longitud, por ejemplo. |
323 |
// La geometr?a con mayor longitud del bounding box ser? la que etiquetamos.
|
|
332 |
// La geometr?a con mayor longitud del bounding box ser? la que etiquetamos. |
|
324 | 333 |
// Ser? inexacto, pero m?s r?pido. Solo lo queremos para saber qu? entidad etiquetamos |
325 | 334 |
// El problema con la uni?n es que para l?neas va muy mal (no sabes lo que te va |
326 | 335 |
// a etiquetar, y para pol?gonos ser? muy lenta. De todas formas, habr?a que evitar |
... | ... | |
330 | 339 |
// CoordinateSequence cs = ((LineString) (jtsGeom)).getCoordinateSequence(); |
331 | 340 |
// CoordinateSequences.reverse(cs); |
332 | 341 |
// jtsGeom = new LineString(cs, null); |
333 |
// }
|
|
342 |
// } |
|
334 | 343 |
// item.geom = FConverter.jts_to_igeometry(jtsGeom); |
335 |
|
|
344 |
|
|
336 | 345 |
Rectangle2D auxBox = geom.getBounds2D(); |
337 | 346 |
double perimeterAux = 2*auxBox.getWidth() + 2*auxBox.getHeight(); |
338 |
if (perimeterAux > item.savedPerimeter) {
|
|
347 |
if (perimeterAux > item.savedPerimeter) { |
|
339 | 348 |
item.geom = geom; //FConverter.jts_to_igeometry(jtsGeom); |
340 | 349 |
item.savedPerimeter = perimeterAux; |
341 | 350 |
} |
... | ... | |
382 | 391 |
} |
383 | 392 |
|
384 | 393 |
if (bLabelsReallocatable) { |
385 |
mapGraphics.drawImage(overlapDetectImage, null, null); |
|
394 |
targetGr.translate(x, y); |
|
395 |
((Graphics2D)mapImage.getGraphics()).drawImage(overlapDetectImage, null, null); |
|
396 |
// mapGraphics.drawImage(targetBI, null, null); |
|
386 | 397 |
} |
387 | 398 |
|
388 | 399 |
|
... | ... | |
489 | 500 |
case FShape.POLYGON: |
490 | 501 |
pc = mpc.getPolygonConstraints(); |
491 | 502 |
break; |
492 |
}
|
|
503 |
} |
|
493 | 504 |
} |
494 |
|
|
505 |
|
|
495 | 506 |
/* |
496 | 507 |
* Ver comentario en el metodo drawLabelInGeom |
497 | 508 |
*/ |
... | ... | |
589 | 600 |
Cancellable cancel, String[] usedFields, ViewPort viewPort, |
590 | 601 |
double dpi, int duplicateMode){//, TreeSet<?> placedLabels) { |
591 | 602 |
|
592 |
Value[] vv = feat.getAttributes(); |
|
603 |
// Value[] vv = feat.getAttributes();
|
|
593 | 604 |
String expr = lc.getStringLabelExpression(); |
594 | 605 |
|
595 | 606 |
long pt1 = System.currentTimeMillis(); |
Also available in: Unified diff