Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/ShapeRenderer.java @ 3164:6d0567a8387d
Label more points in FixingsKMChartService
flys-artifacts/trunk@4776 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 25 Jun 2012 13:15:35 +0000 |
parents | 0d8146989012 |
children | 0cf647fe2a96 |
comparison
equal
deleted
inserted
replaced
3163:dad513d5ce37 | 3164:6d0567a8387d |
---|---|
291 g2.setFont(labelFont); | 291 g2.setFont(labelFont); |
292 g2.setPaint(paint); | 292 g2.setPaint(paint); |
293 | 293 |
294 String label = generator.generateLabel(dataset, series, item); | 294 String label = generator.generateLabel(dataset, series, item); |
295 | 295 |
296 // get the label position.. | 296 ATTEMPS: for (int attempt = 0; attempt < 2; ++attempt) { |
297 ItemLabelPosition position = null; | 297 // get the label position.. |
298 if (!negative) { | 298 ItemLabelPosition position = null; |
299 position = getPositiveItemLabelPosition(series, item); | 299 |
300 } | 300 boolean pos; |
301 else { | 301 switch (attempt) { |
302 position = getNegativeItemLabelPosition(series, item); | 302 case 0: pos = negative; break; |
303 } | 303 case 1: pos = !negative; break; |
304 | 304 default: break ATTEMPS; |
305 // work out the label anchor point... | 305 } |
306 Point2D anchorPoint = calculateLabelAnchorPoint( | 306 |
307 position.getItemLabelAnchor(), x, y, orientation); | 307 if (pos) { |
308 | 308 position = getNegativeItemLabelPosition(series, item); |
309 Shape labelShape = TextUtilities.calculateRotatedStringBounds( | 309 } |
310 label, g2, | 310 else { |
311 (float)anchorPoint.getX(), (float)anchorPoint.getY(), | 311 position = getPositiveItemLabelPosition(series, item); |
312 position.getTextAnchor(), position.getAngle(), | 312 } |
313 position.getRotationAnchor()); | 313 |
314 | 314 // work out the label anchor point... |
315 Rectangle2D bbox = labelShape.getBounds2D(); | 315 Point2D anchorPoint = calculateLabelAnchorPoint( |
316 | 316 position.getItemLabelAnchor(), x, y, orientation); |
317 Point2D shift = shiftBox(bbox); | 317 |
318 | 318 Shape labelShape = TextUtilities.calculateRotatedStringBounds( |
319 bbox = new Rectangle2D.Double( | 319 label, g2, |
320 bbox.getX() + shift.getX(), | 320 (float)anchorPoint.getX(), (float)anchorPoint.getY(), |
321 bbox.getY() + shift.getY(), | 321 position.getTextAnchor(), position.getAngle(), |
322 bbox.getWidth(), | 322 position.getRotationAnchor()); |
323 bbox.getHeight()); | 323 |
324 | 324 Rectangle2D bbox = labelShape.getBounds2D(); |
325 if (labelBoundingBoxes != null) { | 325 |
326 for (Rectangle2D old: labelBoundingBoxes) { | 326 Point2D shift = shiftBox(bbox); |
327 if (old.intersects(bbox)) { | 327 |
328 return; | 328 bbox = new Rectangle2D.Double( |
329 bbox.getX() + shift.getX(), | |
330 bbox.getY() + shift.getY(), | |
331 bbox.getWidth(), | |
332 bbox.getHeight()); | |
333 | |
334 if (labelBoundingBoxes != null) { | |
335 for (Rectangle2D old: labelBoundingBoxes) { | |
336 if (old.intersects(bbox)) { | |
337 continue ATTEMPS; | |
338 } | |
329 } | 339 } |
340 labelBoundingBoxes.add(bbox); | |
330 } | 341 } |
331 labelBoundingBoxes.add(bbox); | 342 |
332 } | 343 TextUtilities.drawRotatedString( |
333 | 344 label, g2, |
334 TextUtilities.drawRotatedString( | 345 (float)(anchorPoint.getX() + shift.getX()), |
335 label, g2, | 346 (float)(anchorPoint.getY() + shift.getY()), |
336 (float)(anchorPoint.getX() + shift.getX()), | 347 position.getTextAnchor(), position.getAngle(), |
337 (float)(anchorPoint.getY() + shift.getY()), | 348 position.getRotationAnchor()); |
338 position.getTextAnchor(), position.getAngle(), | 349 break; |
339 position.getRotationAnchor()); | 350 } |
340 } | 351 } |
341 } | 352 } |
342 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 353 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |