Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

package javaapplication4;

import javafx.animation.FadeTransition;
import javafx.animation.PathTransition;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.util.Duration;
/**
*
* @author Burhan
*/
public class JavaApplication4 extends Application {
boolean a;
@Override
public void start(Stage primaryStage) throws Exception {
Pane pane = new Pane();
double width = 600;
double height = 600;
Scene scene = new Scene(pane, width, height);
double radius = Math.min(width, height) * 0.25;
Circle c = new Circle(width / 2, height / 2, radius, Color.TRANSPARENT);
c.setRotate(180);
Text text = new Text("Burhan G�m�soy");

//Create a path transition.

PathTransition pt = new PathTransition();


//Set the duration of this animation as 10000

pt.setDuration(Duration.millis(10000));
//The path will be the circle
pt.setPath(c);
//The node will be the text
pt.setNode(text);

pt.setOrientation(
PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);

//The animation will cycle indefinite number of cycles


pt.setCycleCount(Timeline.INDEFINITE);
pt.setAutoReverse(false);
pt.play(); // Start animation

//Create a fade transition on the text


//Set the duration of this animation as 5000
FadeTransition ft = new FadeTransition(Duration.millis(5000), text);
//The animation fade value will change from 1.0 to 0.0
ft.setFromValue(1.0);
ft.setToValue(0.0);

//The animationwill automatically reverse


ft.setAutoReverse(true);
//The animation will cycle indefinite number of cycles
ft.setCycleCount(Timeline.INDEFINITE);

ft.play(); // Start animation

//When the mouse is pressed on the pane the animations will pause
// pane.setOnMousePressed(e->{
// text.setText("sdfsdfsdfs");
// //pt.pause();
// //ft.pause();
// });
//pane.setOnMouseReleased(e -> {
// pt.play();
// ft.play();
// });

pane.setOnMouseClicked(e -> {
a=!a;
if(a){
pt.pause();
ft.pause();

}
else{
pt.play();
ft.play();

}
});

//When the mouse is released from the pane the animations will continue to
play

pane.getChildren().addAll(text);
primaryStage.setScene(scene);
primaryStage.setTitle("WEEK 10");
primaryStage.show();
}

public static void main(String[] args) {


Application.launch(args);
}
}

You might also like