8
8
import edu .wpi .grip .core .util .service .RestartableService ;
9
9
import edu .wpi .grip .core .util .service .SingleActionListener ;
10
10
import edu .wpi .grip .ui .util .DPIUtility ;
11
+ import javafx .animation .FadeTransition ;
12
+ import javafx .animation .Transition ;
11
13
import javafx .application .Platform ;
12
14
import javafx .scene .control .ContentDisplay ;
13
15
import javafx .scene .control .ToggleButton ;
17
19
import javafx .scene .input .MouseEvent ;
18
20
import javafx .scene .layout .HBox ;
19
21
import javafx .scene .layout .Priority ;
22
+ import javafx .util .Duration ;
20
23
21
24
import java .util .Arrays ;
22
25
import java .util .List ;
@@ -90,7 +93,7 @@ private List<String> getCurrentStyleClasses() {
90
93
}
91
94
92
95
/**
93
- * Assigns the state of the button from the {@link StartStoppable }
96
+ * Assigns the state of the button from the {@link RestartableService }
94
97
*/
95
98
private void assignState () {
96
99
setSelected (service .isRunning ());
@@ -104,7 +107,16 @@ private void assignState() {
104
107
* @return The graphic to show on the button.
105
108
*/
106
109
private static ImageView pickGraphic (RestartableService startStoppable ) {
107
- final ImageView icon = startStoppable .isRunning () ? new ImageView (stopImage ) : new ImageView (startImage );
110
+ final boolean running = startStoppable .isRunning ();
111
+ final ImageView icon = running ? new ImageView (stopImage ) : new ImageView (startImage );
112
+ if (!running ) {
113
+ // If we are not running then we want the icon to flash
114
+ final FadeTransition ft = new FadeTransition (Duration .millis (750 ), icon );
115
+ ft .setToValue (0.1 );
116
+ ft .setCycleCount (Transition .INDEFINITE );
117
+ ft .setAutoReverse (true );
118
+ ft .play ();
119
+ }
108
120
icon .setFitHeight (DPIUtility .MINI_ICON_SIZE );
109
121
icon .setFitWidth (DPIUtility .MINI_ICON_SIZE );
110
122
return icon ;
0 commit comments