}
List<PathCommand> renderCommands;
if (smooth && lineCommands.size() > 0) {
PathSprite smooth = new PathSprite();
smooth.setCommands(lineCommands);
renderCommands = smooth.copy().toSmooth(segments).getCommands();
} else {
renderCommands = PathSprite.copyCommands(lineCommands);
}
// Correct path if we're animating timeAxis intervals
if (markerIndex > 0 && previousCommands != null && previousCommands.size() > 1) {
previousCommands.remove(1);
line.setCommands(previousCommands);
if (chart.hasShadows()) {
for (int i = 0; i < lineShadows.size(); i++) {
PathSprite shadow = lineShadows.get(i);
shadow.setCommands(previousCommands);
}
}
}
List<PathCommand> dummyCommands = new ArrayList<PathCommand>();
dummyCommands.add(new MoveTo(bbox.getX(), bbox.getY() + bbox.getHeight() / 2.0));
for (int k = 1; k < lineCommands.size(); k++) {
dummyCommands.add(new LineTo(bbox.getX() + bbox.getWidth() / k, bbox.getY() + bbox.getHeight() / 2.0));
}
// Only create a line if one doesn't exist.
if (line == null) {
line = new PathSprite();
line.setStroke(stroke);
chart.addSprite(line);
line.setCommands(dummyCommands);
if (chart.hasShadows()) {
// create shadows
for (int i = 0; i < shadowGroups.size(); i++) {
PathSprite shadow = new PathSprite();
Sprite shadowAttr = shadowAttributes.get(i);
shadow.setStrokeWidth(shadowAttr.getStrokeWidth());
shadow.setStrokeOpacity(shadowAttr.getStrokeOpacity());
shadow.setStroke(shadowAttr.getStroke());
shadow.setTranslation(new Translation(shadowAttr.getTranslation()));
shadow.setFill(Color.NONE);
shadow.setCommands(line.getCommands());
chart.addSprite(shadow);
lineShadows.add(shadow);
}
}
}
if (stroke != null) {
line.setStroke(stroke);
}
if (!Double.isNaN(strokeWidth)) {
line.setStrokeWidth(strokeWidth);
}
line.setFill(Color.NONE);
if (chart.isAnimated() && line.size() > 0) {
if (markerIndex > 0) {
if (smooth) {
renderCommands.remove(1);
} else {
MoveTo move = (MoveTo) renderCommands.get(0);
renderCommands.add(1, new LineTo(move.getX(), move.getY()));
}
previousCommands = renderCommands;
}
DrawFx.createCommandsAnimator(line, renderCommands).run(500);
} else {
line.setCommands(renderCommands);
line.redraw();
}
if (lineRenderer != null) {
lineRenderer.spriteRenderer(line, 0, chart.getStore());
}
if (fill != Color.NONE && fill != null) {
fillCommands.addAll(renderCommands);
fillCommands.add(new LineTo(x, bbox.getY() + bbox.getHeight()));
fillCommands.add(new LineTo(bbox.getX(), bbox.getY() + bbox.getHeight()));
fillCommands.add(new LineTo(bbox.getX(), firstY));
if (fillSprite == null) {
fillSprite = new PathSprite();
fillSprite.setOpacity(0.3);
fillSprite.setFill(fill);
fillSprite.setCommands(dummyCommands);
chart.addSprite(fillSprite);
}
if (chart.isAnimated() && fillSprite.size() > 0) {
DrawFx.createCommandsAnimator(fillSprite, fillCommands).run(chart.getAnimationDuration(),
chart.getAnimationEasing());
} else {
fillSprite.setCommands(fillCommands);
fillSprite.redraw();
}
if (fillRenderer != null) {
fillRenderer.spriteRenderer(fillSprite, 0, chart.getStore());
}
}
if (chart.hasShadows()) {
for (int i = 0; i < lineShadows.size(); i++) {
PathSprite shadow = lineShadows.get(i);
if (!hidden) {
shadow.setHidden(false);
}
if (chart.isAnimated()) {
DrawFx.createCommandsAnimator(shadow, renderCommands).run(chart.getAnimationDuration(),
chart.getAnimationEasing());
} else {
shadow.setCommands(renderCommands);
shadow.redraw();
}
if (shadowRenderer != null) {
shadowRenderer.spriteRenderer(shadow, i, chart.getCurrentStore());
}
}