private void addAnimation(ArrayList<KeyFrame> keyFrames, final AnimationPartBase annimation, long minTime){
long startTimeMs = annimation.startTime-minTime;
long endTimeMs = annimation.endTime-minTime;
final Node node = annimation.createVisualRepresentation();
KeyValue keyValueStartX = new KeyValue(node.translateXProperty(), annimation.startx);
KeyValue keyValueStartY = new KeyValue(node.translateYProperty(), annimation.starty);
KeyValue keyValueEndX = new KeyValue(node.translateXProperty(),annimation.endx);
KeyValue keyValueEndY = new KeyValue(node.translateYProperty(), annimation.endy);
KeyFrame keyFrame1 = new KeyFrame(Duration.millis(startTimeMs),
new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event) {
animationPane.getChildren().add(node);
}
},new KeyValue(node.opacityProperty(), 0));
KeyFrame keyFrame2 = new KeyFrame(Duration.millis(startTimeMs), keyValueStartX, keyValueStartY);
KeyFrame keyFrame3 = new KeyFrame(Duration.millis(startTimeMs+FADEDURATION),new KeyValue(node.opacityProperty(), 1));
KeyFrame keyFrame4 = new KeyFrame(Duration.millis(startTimeMs+FADEDURATION), keyValueStartX, keyValueStartY);
KeyFrame keyFrame5 = new KeyFrame(Duration.millis(endTimeMs-FADEDURATION),keyValueEndX,keyValueEndY);
KeyFrame keyFrame6 = new KeyFrame(Duration.millis(endTimeMs-FADEDURATION), new KeyValue(node.opacityProperty(), 1));
KeyFrame keyFrame7 = new KeyFrame(Duration.millis(endTimeMs),
new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event) {
animationPane.getChildren().remove(node);
}
},new KeyValue(node.opacityProperty(), 0));
keyFrames.add(keyFrame1);
keyFrames.add(keyFrame2);
keyFrames.add(keyFrame3);