package MyApp; import java.io.IOException; import java.net.URL; import java.util.ResourceBundle; import javafx.animation.RotateTransition; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.BorderPane; import javafx.util.Duration; public class uiController { String user_name; String user_password; Boolean isAdmin= null; Boolean isLogged= false; private Boolean isWiggling= false; private String signalType= "main"; @FXML private ResourceBundle resources; @FXML private URL location; @FXML private AnchorPane anchorHerbarium; @FXML private AnchorPane anchorIdealEnv; @FXML private AnchorPane anchorIdealPlant; @FXML private BorderPane borderPane; @FXML private Button buttonHerbarium; @FXML private Button buttonIdealEnv; @FXML private Button buttonIdealPlant; @FXML private Button buttonLogo; @FXML private Button buttonMainMenu; @FXML private Button buttonSignOut; @FXML private ImageView imgView_logo; @FXML public Label labelUserName; @FXML public Label labelUserType; @FXML void btnClick_buttonLogo(ActionEvent event) { createWiggleEffect(imgView_logo); labelUserType.setText("oğuzhan"); } @FXML void btnClick_buttonMainMenu(ActionEvent event) throws IOException { AnchorPane view = FXMLLoader.load(getClass().getResource("pageMain.fxml")); borderPane.setCenter(view); AnchorPane root = (AnchorPane)FXMLLoader.load(getClass().getResource("ui.fxml")); signalType= "main"; } @FXML void initialize() { if (labelUserName != null) { labelUserName.setText("labelUserName null değil"); } else { System.out.println("labelUserName null"); } } public void setUserNName() { if(this.isAdmin==true) { labelUserName.setText("Admin Kullanıcı"); } else{ labelUserType.setText("Normal Kullanıcı"); } } public void setUser(String user_name, String user_password, Integer isAdmin) { this.user_name = user_name; this.user_password = user_password; if (isAdmin==0) { this.isAdmin = false; } else if (isAdmin==1) { this.isAdmin= true; } this.isLogged=true; setUserNName(); } void createWiggleEffect(ImageView imageView) { if (isWiggling==false) { // Wiggle loopunu engelleme double wiggleAngle = 5.0; // Dönüş açısı int totalDuration = 300; // Saniye (milisaniye) int wiggleDuration = totalDuration / 2; // Saniyede kaç dönüş olacak? RotateTransition rotateTransition = new RotateTransition(Duration.millis(wiggleDuration), imageView); rotateTransition.setByAngle(wiggleAngle); // Dönüş açısını ayarlama rotateTransition.setAutoReverse(true); // oto dönüş rotateTransition.setCycleCount(4); // sağ sol yap (wiggle animasyonu için) rotateTransition.setOnFinished(event -> { imageView.setRotate(0); isWiggling=false; }); rotateTransition.play(); isWiggling=true; } } }