Skip to content

Commit

Permalink
#15: JavaFX eye candy on the remove button
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Geisselmeier committed Sep 18, 2015
1 parent cb52deb commit 2b91c5b
Showing 1 changed file with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

import java.util.stream.Collectors;

import de.jensd.fx.glyphs.GlyphsDude;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import eu.hansolo.enzo.canvasled.Led;
import eu.hansolo.enzo.canvasled.LedBuilder;
import javafx.animation.Animation;
import javafx.animation.FadeTransition;
import javafx.animation.ParallelTransition;
import javafx.animation.RotateTransition;
import javafx.collections.ListChangeListener;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
Expand All @@ -19,10 +26,6 @@
import javafx.scene.paint.Stop;
import javafx.scene.text.Text;
import javafx.util.Duration;
import de.jensd.fx.glyphs.GlyphsDude;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import eu.hansolo.enzo.canvasled.Led;
import eu.hansolo.enzo.canvasled.LedBuilder;

public class StatusControl extends AnchorPane {

Expand Down Expand Up @@ -83,21 +86,36 @@ public StatusControl(ClusterInstance instance, ClusterHealthPaneController contr
private void configureRemoveButton() {
removeBttn.setOpacity(0.0);

final FadeTransition fadeIn = new FadeTransition(Duration.millis(200), removeBttn);
final int removeBttnInvisibleAngle = -60;

final RotateTransition rotateIn = new RotateTransition(Duration.millis(150), removeBttn);
rotateIn.setFromAngle(removeBttnInvisibleAngle);
rotateIn.setToAngle(0);

final FadeTransition fadeIn = new FadeTransition(Duration.millis(100), removeBttn);
fadeIn.setFromValue(0.0);
fadeIn.setToValue(1.0);

final Animation mouseEnterAnimation = new ParallelTransition(rotateIn, fadeIn);

final RotateTransition rotateOut = new RotateTransition(Duration.millis(150), removeBttn);
rotateOut.setFromAngle(0);
rotateOut.setToAngle(removeBttnInvisibleAngle);

final FadeTransition fadeOut = new FadeTransition(Duration.millis(100), removeBttn);
fadeOut.setFromValue(1.0);
fadeOut.setToValue(0.0);

final Animation mouseExitedAnimation = new ParallelTransition(rotateOut, fadeOut);

setOnMouseEntered(evt -> {
fadeOut.stop();
fadeIn.playFromStart();
mouseExitedAnimation.stop();
mouseEnterAnimation.playFromStart();
});

setOnMouseExited(evt -> {
fadeIn.stop();
fadeOut.playFromStart();
mouseEnterAnimation.stop();
mouseExitedAnimation.playFromStart();
});
removeBttn.setOnAction(evt -> controller.removeClusterInstance(this));
removeBttn.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, null, null)));
Expand Down

0 comments on commit 2b91c5b

Please sign in to comment.