line.setFill(Color.NONE);
calloutLines.put(i, line);
chart.addSprite(line);
}
final RectangleSprite box;
if (calloutBoxes.get(i) != null) {
box = calloutBoxes.get(i);
box.setHidden(false);
} else {
box = new RectangleSprite();
box.setStroke(RGB.BLACK);
box.setStrokeWidth(1);
box.setFill(Color.NONE);
calloutBoxes.put(i, box);
chart.addSprite(box);
}
sprite.redraw();
PreciseRectangle bbox = sprite.getBBox();
List<PathCommand> commands = new ArrayList<PathCommand>();
commands.add(new MoveTo(x + center.getX(), y + center.getY()));
commands.add(new LineTo(calloutPoint.getX(), calloutPoint.getY()));
commands.add(new LineTo(x > 0 ? 10 : -10, 0, true));
PreciseRectangle rect = new PreciseRectangle(calloutPoint.getX() + (x > 0 ? 10 : -(bbox.getWidth() + 30)),
calloutPoint.getY() + (y > 0 ? (-(bbox.getHeight() - 5)) : (-(bbox.getHeight() - 5))),
bbox.getWidth() + 20, bbox.getHeight() + 20);
PrecisePoint labelPoint = new PrecisePoint(calloutPoint.getX() + (x > 0 ? 20 : -(20 + bbox.getWidth())),
calloutPoint.getY() + (y > 0 ? -bbox.getHeight() / 4.0 : -bbox.getHeight() / 4.0));
if (chart.isAnimated() && line.size() > 0 && !Double.isNaN(box.getX()) && sprite.getTranslation() != null) {
DrawFx.createCommandsAnimator(line, commands).run(chart.getAnimationDuration(), chart.getAnimationEasing());
DrawFx.createRectangleAnimator(box, rect).run(chart.getAnimationDuration(), chart.getAnimationEasing());
DrawFx.createTranslationAnimator(sprite, labelPoint.getX(), labelPoint.getY()).run(
chart.getAnimationDuration(), chart.getAnimationEasing());
} else {
line.setCommands(commands);
line.redraw();
box.setX(rect.getX());
box.setY(rect.getY());
box.setWidth(rect.getWidth());
box.setHeight(rect.getHeight());
box.redraw();
sprite.setTranslation(labelPoint.getX(), labelPoint.getY());
sprite.redraw();
}
} else if (labelPosition == LabelPosition.END) {
rho = Math.sqrt(x * x + y * y) * 2.0;