for (int i = 0; i < markerIndex; i++) {
marker = sprites.get(i);
sprites.remove(i);
sprites.add(marker);
Sprite markerTemp = sprites.get(sprites.size() - 2);
marker.setTranslation(new Translation(markerTemp.getTranslation()));
marker.redraw();
}
}
calculateBounds();
double x = 0;
double y = 0;
boolean gap = false;
for (int i = 0; i < store.size(); i++) {
PrecisePoint point = coordinates.get(i);
if (point != null) {
x = point.getX();
y = point.getY();
} else {
x = y = Double.NaN;
}
if (!Double.isNaN(x) && !Double.isNaN(y)) {
if (onbreak) {
onbreak = false;
}
if (lineCommands.size() > 0 && !gap) {
lineCommands.add(new LineTo(x, y));
} else {
lineCommands.add(new MoveTo(x, y));
gap = false;
}
gapPosition.put(String.valueOf(lineCommands.size() - 1), i);
} else if (!gapless) {
gap = true;
}
if (Double.isNaN(firstY) && !Double.isNaN(y)) {
firstY = y;
}
}
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);
}