|
17 | 17 |
|
18 | 18 | package javafxlibrary.testapps.controllers; |
19 | 19 |
|
20 | | -import javafx.animation.*; |
21 | 20 | import javafx.fxml.FXML; |
22 | 21 | import javafx.fxml.Initializable; |
23 | 22 | import javafx.scene.control.Label; |
24 | | -import javafx.scene.effect.BoxBlur; |
25 | 23 | import javafx.scene.input.MouseEvent; |
26 | | -import javafx.util.Duration; |
27 | 24 | import java.net.URL; |
28 | 25 | import java.util.ResourceBundle; |
29 | 26 |
|
30 | 27 | public class TestPointLocationController implements Initializable { |
31 | 28 |
|
32 | 29 | private @FXML Label locationLabel; |
33 | | - private SequentialTransition textTransition; |
34 | | - private BoxBlur blur; |
35 | | - private double blurAmount = 5.0; |
36 | 30 |
|
37 | 31 | @Override |
38 | 32 | public void initialize(URL location, ResourceBundle resources) { |
39 | 33 | locationLabel.setText("- | -"); |
40 | | - textTransition = new SequentialTransition(); |
41 | | - textTransition.getChildren().addAll(zoomIn(), zoomOut()); |
42 | | - blur = new BoxBlur(5.0, 5.0, 1); |
43 | 34 | } |
44 | 35 |
|
45 | 36 | public void mouseListener(MouseEvent event) { |
46 | 37 | int x = (int) event.getSceneX(); |
47 | 38 | int y = (int) event.getSceneY(); |
48 | 39 | locationLabel.setText(x + " | " + y); |
49 | | - if(textTransition.getStatus() != Animation.Status.RUNNING) |
50 | | - textTransition.play(); |
51 | | - locationLabel.setEffect(blur); |
52 | | - blurAmount = 5.0; |
53 | | - |
54 | | - AnimationTimer timer = new AnimationTimer() { |
55 | | - @Override |
56 | | - public void handle(long now) { |
57 | | - blurAmount -= 0.01; |
58 | | - locationLabel.setEffect(new BoxBlur(blurAmount, blurAmount, 1)); |
59 | | - if(blurAmount <= 0.0) { |
60 | | - stop(); |
61 | | - } |
62 | | - } |
63 | | - }; |
64 | | - |
65 | | - timer.start(); |
66 | 40 | } |
67 | 41 |
|
68 | 42 | public void mouseExitedListener() { |
69 | 43 | locationLabel.setText("- | -"); |
70 | 44 | } |
71 | | - |
72 | | - public ScaleTransition zoomIn() { |
73 | | - ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(10), locationLabel); |
74 | | - scaleTransition.setToX(1.75f); |
75 | | - scaleTransition.setToY(1.75f); |
76 | | - scaleTransition.setCycleCount(1); |
77 | | - return scaleTransition; |
78 | | - } |
79 | | - |
80 | | - public ScaleTransition zoomOut() { |
81 | | - ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(10), locationLabel); |
82 | | - scaleTransition.setToX(1f); |
83 | | - scaleTransition.setToY(1f); |
84 | | - scaleTransition.setCycleCount(1); |
85 | | - return scaleTransition; |
86 | | - } |
87 | 45 | } |
0 commit comments