@Override
    public void setTimelineEvent(){
        KeyFrame kf = new KeyFrame(Duration.millis(10), new EventHandler<ActionEvent>() {                   
            @Override
            public void handle(ActionEvent actionEvent){
                time+=1;
                switch(switchInt){
                    case 1: if(Double.parseDouble(df_2.
                            format(line_pendulum.getStartX())) == 500){
                                switchInt = 2;
                                break;
                            }
                            line_pendulum.setStartY(line_pendulum.getStartY()+1);
                            line_pendulum.setStartX(pivotX + 
                                    Math.sqrt(Math.pow(currentLength,2) 
                                    - Math.pow(stringY,2)));
                            break;
                    case 2: if(line_pendulum.getStartY() == highestY){
                                switchInt = 3;
                                break;
                            }
                            line_pendulum.setStartY(line_pendulum.getStartY()-1);
                            line_pendulum.setStartX(pivotX 
                                    - Math.sqrt(Math.pow(currentLength,2)
                                    - Math.pow(stringY,2)));                             
                            break;
                    case 3: if(line_pendulum.getStartX() == 500){
                                switchInt = 4;
                                break;
                            }
                            line_pendulum.setStartY(line_pendulum.getStartY()+1);
                            line_pendulum.setStartX(pivotX 
                                    - Math.sqrt(Math.pow(currentLength,2)
                                    - Math.pow(stringY,2)));
                            break;
                    case 4: if(line_pendulum.getStartY() == highestY){
                                switchInt = 1;
                                break;
                            }
                            line_pendulum.setStartY(line_pendulum.getStartY()-1);
                            line_pendulum.setStartX(pivotX 
                                    + Math.sqrt(Math.pow(currentLength,2)
                                    - Math.pow(stringY,2)));
                            break;
                }

                stringY = line_pendulum.getStartY()-pivotY;
                circle_pendulum.setCenterX(line_pendulum.getStartX());
                circle_pendulum.setCenterY(line_pendulum.getStartY());

                    potentialE = (zeroPosition-line_pendulum.getStartY())
                                *(mass/1000)*ACCELERATION;
                    kinecticE = mechanicalE - potentialE;
                    graphK.addDataToSeries(time, kinecticE, 1);                  
                    graphP.addDataToSeries(time, potentialE, 1);  

            }
        });
        
        pendulumAnimationTimeline.setCycleCount(Timeline.INDEFINITE);
        pendulumAnimationTimeline.getKeyFrames().add(kf);        
    }