javafx.animation.Transition Java Examples

The following examples show how to use javafx.animation.Transition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoadingPane.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create the loading pane.
 */
public LoadingPane() {
    setAlignment(Pos.CENTER);
    VBox content = new VBox();
    content.setAlignment(Pos.CENTER);
    Text text = new Text(LabelGrabber.INSTANCE.getLabel("loading.text") + "...");
    text.setStyle(" -fx-font: bold italic 20pt \"Arial\";");
    FadeTransition textTransition = new FadeTransition(Duration.seconds(1.5), text);
    textTransition.setAutoReverse(true);
    textTransition.setFromValue(0);
    textTransition.setToValue(1);
    textTransition.setCycleCount(Transition.INDEFINITE);
    textTransition.play();
    content.getChildren().add(text);
    bar = new ProgressBar();
    content.getChildren().add(bar);
    getChildren().add(content);
    setOpacity(0);
    setStyle("-fx-background-color: #555555;");
    setVisible(false);
}
 
Example #2
Source File: MainProgramSceneController.java    From Hostel-Management-System with MIT License 6 votes vote down vote up
@FXML
private void shirnkDetailsAction(ActionEvent event)
{
    if ("Cancel".equals(StudentDetailController.editCancelButton.getText()))
    {
        StudentDetailController.editCancelButtonAction(event);
    }

    final Animation animation = new Transition()
    {
        
        {
            setCycleDuration(Duration.millis(800));
        }

        @Override
        protected void interpolate(double frac)
        {
            SplitPaneMain.setDividerPosition(0, SplitPaneMain.getDividerPositions()[0]-frac);
        }
    };
    animation.play();
}
 
Example #3
Source File: TestCaseListCell.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Animation getStatusTransition(TestStatus newStatus) {

        return new Transition() {

            {
                setCycleDuration(Duration.millis(1200));
                setInterpolator(Interpolator.EASE_BOTH);
                setOnFinished(t -> applyCss());
            }


            @Override
            protected void interpolate(double frac) {
                Color vColor = newStatus.getColor().deriveColor(0, 1, 1, clip(map(frac)));
                setBackground(new Background(new BackgroundFill(vColor, CornerRadii.EMPTY, Insets.EMPTY)));
            }

            private double map(double x) {
                return -abs(x - 0.5) + 0.5;
            }

            private double clip(double i) {
                return min(1, max(0, i));
            }
        };
    }
 
Example #4
Source File: CloudFadeOutStep.java    From TweetwallFX with MIT License 6 votes vote down vote up
@Override
public void doStep(final MachineContext context) {
    WordleSkin wordleSkin = (WordleSkin) context.get("WordleSkin");

    List<Transition> fadeOutTransitions = new ArrayList<>();

    Duration defaultDuration = Duration.seconds(1.5);

    // kill the remaining words from the cloud
    wordleSkin.word2TextMap.entrySet().forEach(entry -> {
        Text textNode = entry.getValue();
        FadeTransition ft = new FadeTransition(defaultDuration, textNode);
        ft.setToValue(0);
        ft.setOnFinished(event
                -> wordleSkin.getPane().getChildren().remove(textNode));
        fadeOutTransitions.add(ft);
    });
    wordleSkin.word2TextMap.clear();

    ParallelTransition fadeLOuts = new ParallelTransition();

    fadeLOuts.getChildren().addAll(fadeOutTransitions);
    fadeLOuts.setOnFinished(e -> context.proceed());
    fadeLOuts.play();
}
 
Example #5
Source File: ImageMosaicStep.java    From TweetwallFX with MIT License 5 votes vote down vote up
private Transition createReverseHighlightAndZoomTransition(final int column, final int row) {
    ImageView randomView = rects[column][row];
    randomView.toFront();
    ParallelTransition firstParallelTransition = new ParallelTransition();
    ParallelTransition secondParallelTransition = new ParallelTransition();

    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 5; j++) {
            if ((i == column) && (j == row)) {
                continue;
            }
            FadeTransition ft = new FadeTransition(Duration.seconds(1), rects[i][j]);
            ft.setFromValue(0.3);
            ft.setToValue(1.0);
            firstParallelTransition.getChildren().add(ft);
        }
    }

    double width = pane.getWidth() / 6.0 - 10;
    double height = pane.getHeight() / 5.0 - 8;

    final SizeTransition zoomBox = new SizeTransition(Duration.seconds(2.5), randomView.fitWidthProperty(), randomView.fitHeightProperty())
            .withWidth(randomView.getLayoutBounds().getWidth(), width)
            .withHeight(randomView.getLayoutBounds().getHeight(), height);
    final LocationTransition trans = new LocationTransition(Duration.seconds(2.5), randomView)
            .withX(randomView.getLayoutX(), bounds[column][row].getMinX())
            .withY(randomView.getLayoutY(), bounds[column][row].getMinY());
    secondParallelTransition.getChildren().addAll(trans, zoomBox);

    SequentialTransition seqT = new SequentialTransition();
    seqT.getChildren().addAll(secondParallelTransition, firstParallelTransition);

    secondParallelTransition.setOnFinished(event
            -> randomView.setEffect(null));

    return seqT;
}
 
Example #6
Source File: ImageMosaicStep.java    From TweetwallFX with MIT License 5 votes vote down vote up
private Transition createMosaicTransition(final List<ImageStore> imageStores) {
    final SequentialTransition fadeIn = new SequentialTransition();
    final List<FadeTransition> allFadeIns = new ArrayList<>();
    final double width = pane.getWidth() / 6.0 - 10;
    final double height = pane.getHeight() / 5.0 - 8;
    final List<ImageStore> distillingList = new ArrayList<>(imageStores);

    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 5; j++) {
            int index = RANDOM.nextInt(distillingList.size());
            ImageStore selectedImage = distillingList.remove(index);
            ImageView imageView = new ImageView(selectedImage.getImage());
            imageView.setCache(true);
            imageView.setCacheHint(CacheHint.SPEED);
            imageView.setFitWidth(width);
            imageView.setFitHeight(height);
            imageView.setEffect(new GaussianBlur(0));
            rects[i][j] = imageView;
            bounds[i][j] = new BoundingBox(i * (width + 10) + 5, j * (height + 8) + 4, width, height);
            rects[i][j].setOpacity(0);
            rects[i][j].setLayoutX(bounds[i][j].getMinX());
            rects[i][j].setLayoutY(bounds[i][j].getMinY());
            pane.getChildren().add(rects[i][j]);
            FadeTransition ft = new FadeTransition(Duration.seconds(0.3), imageView);
            ft.setToValue(1);
            allFadeIns.add(ft);
        }
    }
    Collections.shuffle(allFadeIns);
    fadeIn.getChildren().addAll(allFadeIns);
    return fadeIn;
}
 
Example #7
Source File: ImageMosaicStep.java    From TweetwallFX with MIT License 5 votes vote down vote up
private void executeAnimations(final MachineContext context) {
    ImageWallAnimationTransition highlightAndZoomTransition
            = createHighlightAndZoomTransition();
    highlightAndZoomTransition.transition.play();
    highlightAndZoomTransition.transition.setOnFinished(event1 -> {
        Transition revert
                = createReverseHighlightAndZoomTransition(highlightAndZoomTransition.column, highlightAndZoomTransition.row);
        revert.setDelay(Duration.seconds(3));
        revert.play();
        revert.setOnFinished(event -> {
            count++;
            if (count < 3) {
                executeAnimations(context);
            } else {
                count = 0;
                ParallelTransition cleanup = new ParallelTransition();
                for (int i = 0; i < 6; i++) {
                    for (int j = 0; j < 5; j++) {
                        FadeTransition ft = new FadeTransition(Duration.seconds(0.5), rects[i][j]);
                        ft.setToValue(0);
                        cleanup.getChildren().addAll(ft);
                    }
                }
                cleanup.setOnFinished(cleanUpDown -> {
                    for (int i = 0; i < 6; i++) {
                        for (int j = 0; j < 5; j++) {
                            pane.getChildren().remove(rects[i][j]);
                        }
                    }
                    highlightedIndexes.clear();
                    context.proceed();
                });
                cleanup.play();
            }
        });
    });
}
 
Example #8
Source File: ImageMosaicStep.java    From TweetwallFX with MIT License 5 votes vote down vote up
@Override
public void doStep(final MachineContext context) {
    WordleSkin wordleSkin = (WordleSkin) context.get("WordleSkin");
    ImageMosaicDataProvider dataProvider = context.getDataProvider(ImageMosaicDataProvider.class);
    pane = wordleSkin.getPane();
    if (dataProvider.getImages().size() < 35) {
        context.proceed();
    } else {
        Transition createMosaicTransition = createMosaicTransition(dataProvider.getImages());
        createMosaicTransition.setOnFinished(event
                -> executeAnimations(context));

        createMosaicTransition.play();
    }
}
 
Example #9
Source File: CameraController.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
public CameraController(boolean enableTransforms, AnimationPreference movementType) {
    enable = enableTransforms;
    animPref = movementType;
    switch (animPref) {
        case TIMELINE:
            timeline = new Timeline();
            timeline.setCycleCount(Animation.INDEFINITE);
            break;
        case TIMER:
            timer = new AnimationTimer() {
                @Override
                public void handle(long l) {
                    if (enable) {
                        initialize();
                        enable = false;
                    }
                    update();
                }
            };
            break;
        case TRANSITION:
            transition = new Transition() {
                {setCycleDuration(Duration.seconds(1));}
                @Override
                protected void interpolate(double frac) {
                    updateTransition(frac);
                }
            };
            transition.setCycleCount(Animation.INDEFINITE);
            break;
        case ANIMATION:
            
            break;
    }

}
 
Example #10
Source File: CustomSliderSkin.java    From MusicPlayer with MIT License 5 votes vote down vote up
/**
 * Called when ever either min, max or value changes, so thumb's layoutX, Y is recomputed.
 */
private void positionThumb(final boolean animate) {
    Slider s = getSkinnable();
    if (s.getValue() > s.getMax()) return;// this can happen if we are bound to something 
    boolean horizontal = s.getOrientation() == Orientation.HORIZONTAL;
    final double endX = (horizontal) ? trackStart + (((trackLength * ((s.getValue() - s.getMin()) /
            (s.getMax() - s.getMin()))) - thumbWidth/2)) : thumbLeft;
    final double endY = (horizontal) ? thumbTop :
        snappedTopInset() + trackLength - (trackLength * ((s.getValue() - s.getMin()) /
            (s.getMax() - s.getMin()))); //  - thumbHeight/2
    
    if (animate) {
        // lets animate the thumb transition
        final double startX = thumb.getLayoutX();
        final double startY = thumb.getLayoutY();
        Transition transition = new Transition() {
            {
                setCycleDuration(Duration.millis(200));
            }

            @Override protected void interpolate(double frac) {
                if (!Double.isNaN(startX)) {
                    thumb.setLayoutX(startX + frac * (endX - startX));
                }
                if (!Double.isNaN(startY)) {
                    thumb.setLayoutY(startY + frac * (endY - startY));
                }
            }
        };
        transition.play();
    } else {
        thumb.setLayoutX(endX);
        thumb.setLayoutY(endY);
    }
}
 
Example #11
Source File: ArtistsController.java    From MusicPlayer with MIT License 5 votes vote down vote up
@Override
public void scroll(char letter) {
	
	int index = 0;
	double cellHeight = 0;
	ObservableList<Node> children = grid.getChildren();

    for (Node node : children) {

        VBox cell = (VBox) node;
        cellHeight = cell.getHeight();
        Label label = (Label) cell.getChildren().get(1);
        char firstLetter = removeArticle(label.getText()).charAt(0);
        if (firstLetter < letter) {
            index++;
        }
    }
	
	ScrollPane scrollpane = MusicPlayer.getMainController().getScrollPane();
	
	double row = (index / 5) * cellHeight;
	double finalVvalue = row / (grid.getHeight() - scrollpane.getHeight());
	double startVvalue = scrollpane.getVvalue();
	
	Animation scrollAnimation = new Transition() {
        {
            setCycleDuration(Duration.millis(500));
        }
        protected void interpolate(double frac) {
            double vValue = startVvalue + ((finalVvalue - startVvalue) * frac);
            scrollpane.setVvalue(vValue);
        }
    };
    
    scrollAnimation.play();
}
 
Example #12
Source File: AlbumsController.java    From MusicPlayer with MIT License 5 votes vote down vote up
@Override
public void scroll(char letter) {
	
 int index = 0;
	double cellHeight = 0;
	ObservableList<Node> children = grid.getChildren();
	
	for (int i = 0; i < children.size(); i++) {
		
		VBox cell = (VBox) children.get(i);
		cellHeight = cell.getHeight();
		if (cell.getChildren().size() > 1) {
			Label label = (Label) cell.getChildren().get(1);
    		char firstLetter = removeArticle(label.getText()).charAt(0);
    		if (firstLetter < letter) {
    			index++;
    		}	
		}
	}
	
	double row = (index / 5) * cellHeight;
	double finalVvalue = row / (grid.getHeight() - gridBox.getHeight());
	double startVvalue = gridBox.getVvalue();
	
	Animation scrollAnimation = new Transition() {
        {
            setCycleDuration(Duration.millis(500));
        }
        protected void interpolate(double frac) {
            double vValue = startVvalue + ((finalVvalue - startVvalue) * frac);
            gridBox.setVvalue(vValue);
        }
    };
    
    scrollAnimation.play();
}
 
Example #13
Source File: AlbumsController.java    From MusicPlayer with MIT License 5 votes vote down vote up
private void populateSongTable(VBox cell, Album selectedAlbum) { 	
	// Retrieves albums songs and stores them as an observable list.
	ObservableList<Song> albumSongs = FXCollections.observableArrayList(selectedAlbum.getSongs());
	
    playingColumn.setCellFactory(x -> new PlayingTableCell<Song, Boolean>());
    titleColumn.setCellFactory(x -> new ControlPanelTableCell<Song, String>());
    lengthColumn.setCellFactory(x -> new ClippedTableCell<Song, String>());
    playsColumn.setCellFactory(x -> new ClippedTableCell<Song, Integer>());

    // Sets each column item.
    playingColumn.setCellValueFactory(new PropertyValueFactory<Song, Boolean>("playing"));
    titleColumn.setCellValueFactory(new PropertyValueFactory<Song, String>("title"));
    lengthColumn.setCellValueFactory(new PropertyValueFactory<Song, String>("length"));
    playsColumn.setCellValueFactory(new PropertyValueFactory<Song, Integer>("playCount"));
    
    // Adds songs to table.
    songTable.setItems(albumSongs);
    double height = (albumSongs.size() + 1) * 50 + 2;
    Animation songTableLoadAnimation = new Transition() {
    	{
    		setCycleDuration(Duration.millis(250));
            setInterpolator(Interpolator.EASE_BOTH);
    	}
    	
    	protected void interpolate(double frac) {
    		songTable.setMinHeight(frac * height);
            songTable.setPrefHeight(frac * height);
    	}
    };
    songTableLoadAnimation.play();
}
 
Example #14
Source File: ArtistsMainController.java    From MusicPlayer with MIT License 5 votes vote down vote up
@Override
public void scroll(char letter) {
	
	ObservableList<Artist> artistListItems = artistList.getItems();
	
	int selectedCell = 0;

    for (Artist artist : artistListItems) {
        // Removes article from artist title and compares it to selected letter.
        String artistTitle = artist.getTitle();
        char firstLetter = removeArticle(artistTitle).charAt(0);
        if (firstLetter < letter) {
            selectedCell++;
        }
    }
	
	double startVvalue = artistListScrollPane.getVvalue();
	double finalVvalue = (double) (selectedCell * 50) / (Library.getArtists().size() * 50 - artistListScrollPane.getHeight());
	
	Animation scrollAnimation = new Transition() {
        {
            setCycleDuration(Duration.millis(500));
        }
        protected void interpolate(double frac) {
            double vValue = startVvalue + ((finalVvalue - startVvalue) * frac);
            artistListScrollPane.setVvalue(vValue);
        }
    };
    scrollAnimation.play();
}
 
Example #15
Source File: RadialGlobalMenu.java    From RadialFx with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Transition createOpacityTransition(final Node node,
    final double from, final double to) {
final FadeTransition fadeIn = FadeTransitionBuilder.create().node(node)
	.fromValue(from).toValue(to).duration(Duration.millis(200))
	.build();
backContainer.setOpacity(from);
return fadeIn;

   }
 
Example #16
Source File: IconsController.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private void bindAction(JFXHamburger burger) {
    burger.setOnMouseClicked((e) -> {
        final Transition burgerAnimation = burger.getAnimation();
        burgerAnimation.setRate(burgerAnimation.getRate() * -1);
        burgerAnimation.play();
    });
}
 
Example #17
Source File: FooterController.java    From TerasologyLauncher with Apache License 2.0 4 votes vote down vote up
@FXML
protected void handleSocialButtonMouseEntered(MouseEvent event) {
    final Node source = (Node) event.getSource();
    final Transition t = FXUtils.createScaleTransition(1.2, source);
    t.playFromStart();
}
 
Example #18
Source File: RadialMenu.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public void click(final MenuItem CLICKED_ITEM) {
    List<Transition> transitions = new ArrayList<>(items.size() * 2);
    for (Parent node : items.keySet()) {
        if (items.get(node).equals(CLICKED_ITEM)) {
            // Add enlarge transition to selected item
            ScaleTransition enlargeItem = new ScaleTransition(Duration.millis(300), node);
            enlargeItem.setToX(5.0);
            enlargeItem.setToY(5.0);
            transitions.add(enlargeItem);
        } else {
            // Add shrink transition to all other items
            ScaleTransition shrinkItem = new ScaleTransition(Duration.millis(300), node);
            shrinkItem.setToX(0.0);
            shrinkItem.setToY(0.0);
            transitions.add(shrinkItem);
        }
        // Add fade out transition to every node
        FadeTransition fadeOutItem = new FadeTransition(Duration.millis(300), node);
        fadeOutItem.setToValue(0.0);
        transitions.add(fadeOutItem);
    }

    // Add rotate and fade transition to main menu button
    if (options.isButtonHideOnSelect()) {
        RotateTransition rotateMainButton = new RotateTransition(Duration.millis(300), mainMenuButton);
        rotateMainButton.setToAngle(225);
        transitions.add(rotateMainButton);
        FadeTransition fadeOutMainButton = new FadeTransition(Duration.millis(300), mainMenuButton);
        fadeOutMainButton.setToValue(0.0);
        transitions.add(fadeOutMainButton);
        ScaleTransition shrinkMainButton = new ScaleTransition(Duration.millis(300), mainMenuButton);
        shrinkMainButton.setToX(0.0);
        shrinkMainButton.setToY(0.0);
        transitions.add(shrinkMainButton);
    } else {
        RotateTransition rotateBackMainButton = new RotateTransition();
        rotateBackMainButton.setNode(cross);
        rotateBackMainButton.setToAngle(0);
        rotateBackMainButton.setDuration(Duration.millis(200));
        rotateBackMainButton.setInterpolator(Interpolator.EASE_BOTH);
        transitions.add(rotateBackMainButton);
        FadeTransition mainButtonFadeOut = new FadeTransition();
        mainButtonFadeOut.setNode(mainMenuButton);
        mainButtonFadeOut.setDuration(Duration.millis(100));
        mainButtonFadeOut.setToValue(options.getButtonAlpha());
        transitions.add(mainButtonFadeOut);
    }

    // Play all transitions in parallel
    ParallelTransition selectTransition = new ParallelTransition();
    selectTransition.getChildren().addAll(transitions);
    selectTransition.play();

    // Set menu state back to closed
    setState(State.CLOSED);
    mainMenuButton.setOpen(false);
}
 
Example #19
Source File: FooterController.java    From TerasologyLauncher with Apache License 2.0 4 votes vote down vote up
@FXML
protected void handleSocialButtonMouseExited(MouseEvent event) {
    final Node source = (Node) event.getSource();
    final Transition t = FXUtils.createScaleTransition(1, source);
    t.playFromStart();
}
 
Example #20
Source File: FooterController.java    From TerasologyLauncher with Apache License 2.0 4 votes vote down vote up
@FXML
protected void handleSocialButtonMousePressed(MouseEvent event) {
    final Node source = (Node) event.getSource();
    final Transition t = FXUtils.createScaleTransition(0.8, source);
    t.playFromStart();
}
 
Example #21
Source File: FooterController.java    From TerasologyLauncher with Apache License 2.0 4 votes vote down vote up
@FXML
protected void handleSocialButtonMouseReleased(MouseEvent event) {
    final Node source = (Node) event.getSource();
    final Transition t = FXUtils.createScaleTransition(1.2, source);
    t.playFromStart();
}
 
Example #22
Source File: ApplicationController.java    From TerasologyLauncher with Apache License 2.0 4 votes vote down vote up
@FXML
protected void handleControlButtonMouseEntered(MouseEvent event) {
    final Node source = (Node) event.getSource();
    final Transition t = FXUtils.createScaleTransition(1.2, source);
    t.playFromStart();
}
 
Example #23
Source File: ApplicationController.java    From TerasologyLauncher with Apache License 2.0 4 votes vote down vote up
@FXML
protected void handleControlButtonMouseExited(MouseEvent event) {
    final Node source = (Node) event.getSource();
    final Transition t = FXUtils.createScaleTransition(1, source);
    t.playFromStart();
}
 
Example #24
Source File: ImageMosaicStep.java    From TweetwallFX with MIT License 4 votes vote down vote up
public ImageWallAnimationTransition(final Transition transition, final int column, final int row) {
    this.transition = transition;
    this.column = column;
    this.row = row;
}
 
Example #25
Source File: FadeInCloudStep.java    From TweetwallFX with MIT License 4 votes vote down vote up
@Override
public void doStep(final MachineContext context) {
    List<Word> sortedWords = context.getDataProvider(TagCloudDataProvider.class).getWords();

    if (sortedWords.isEmpty()) {
        return;
    }

    WordleSkin wordleSkin = (WordleSkin) context.get("WordleSkin");
    List<Word> limitedWords = sortedWords.stream().limit(wordleSkin.getDisplayCloudTags()).collect(Collectors.toList());
    limitedWords.sort(Comparator.reverseOrder());

    Bounds layoutBounds = wordleSkin.getPane().getLayoutBounds();

    WordleLayout.Configuration configuration = new WordleLayout.Configuration(limitedWords, wordleSkin.getFont(), wordleSkin.getFontSizeMax(), layoutBounds);
    if (null != wordleSkin.getLogo()) {
        configuration.setBlockedAreaBounds(wordleSkin.getLogo().getBoundsInParent());
    }
    if (null != wordleSkin.getSecondLogo()) {
        configuration.setBlockedAreaBounds(wordleSkin.getSecondLogo().getBoundsInParent());
    }
    WordleLayout cloudWordleLayout = WordleLayout.createWordleLayout(configuration);
    Duration defaultDuration = Duration.seconds(1.5);

    List<Transition> fadeOutTransitions = new ArrayList<>();
    List<Transition> moveTransitions = new ArrayList<>();
    List<Transition> fadeInTransitions = new ArrayList<>();

    cloudWordleLayout.getWordLayoutInfo().entrySet().stream().forEach(entry -> {
        Word word = entry.getKey();
        Bounds bounds = entry.getValue();
        Text textNode = cloudWordleLayout.createTextNode(word);
        wordleSkin.word2TextMap.put(word, textNode);
        textNode.setLayoutX(bounds.getMinX() + layoutBounds.getWidth() / 2d);
        textNode.setLayoutY(bounds.getMinY() + layoutBounds.getHeight() / 2d + bounds.getHeight() / 2d);
        textNode.setOpacity(0);
        wordleSkin.getPane().getChildren().add(textNode);
        FadeTransition ft = new FadeTransition(defaultDuration, textNode);
        ft.setToValue(1);
        fadeInTransitions.add(ft);
    });

    ParallelTransition fadeOuts = new ParallelTransition();
    fadeOuts.getChildren().addAll(fadeOutTransitions);
    ParallelTransition moves = new ParallelTransition();
    moves.getChildren().addAll(moveTransitions);
    ParallelTransition fadeIns = new ParallelTransition();
    fadeIns.getChildren().addAll(fadeInTransitions);
    SequentialTransition morph = new SequentialTransition(fadeOuts, moves, fadeIns);

    morph.setOnFinished(e -> context.proceed());
    morph.play();
}
 
Example #26
Source File: MainPresenter.java    From clarity-analyzer with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void initialize(java.net.URL location, java.util.ResourceBundle resources) {
    preferences = Preferences.userNodeForPackage(this.getClass());
    replayController = new ReplayController(slider);

    BooleanBinding runnerIsNull = Bindings.createBooleanBinding(() -> replayController.getRunner() == null, replayController.runnerProperty());
    buttonPlay.disableProperty().bind(runnerIsNull.or(replayController.playingProperty()));
    buttonPause.disableProperty().bind(runnerIsNull.or(replayController.playingProperty().not()));
    slider.disableProperty().bind(runnerIsNull);

    labelTick.textProperty().bind(replayController.tickProperty().asString());
    labelLastTick.textProperty().bind(replayController.lastTickProperty().asString());

    TableColumn<ObservableEntity, String> entityTableIdColumn = (TableColumn<ObservableEntity, String>) entityTable.getColumns().get(0);
    entityTableIdColumn.setCellValueFactory(param -> param.getValue() != null ? param.getValue().indexProperty() : new ReadOnlyStringWrapper(""));
    TableColumn<ObservableEntity, String> entityTableNameColumn = (TableColumn<ObservableEntity, String>) entityTable.getColumns().get(1);
    entityTableNameColumn.setCellValueFactory(param -> param.getValue() != null ? param.getValue().nameProperty() : new ReadOnlyStringWrapper(""));
    entityTable.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        log.info("entity table selection from {} to {}", oldValue, newValue);
        detailTable.setItems(newValue);
    });

    TableColumn<ObservableEntityProperty, String> idColumn =
        (TableColumn<ObservableEntityProperty, String>) detailTable.getColumns().get(0);
    idColumn.setCellValueFactory(param -> param.getValue().indexProperty());
    TableColumn<ObservableEntityProperty, String> nameColumn =
        (TableColumn<ObservableEntityProperty, String>) detailTable.getColumns().get(1);
    nameColumn.setCellValueFactory(param -> param.getValue().nameProperty());
    TableColumn<ObservableEntityProperty, String> valueColumn =
        (TableColumn<ObservableEntityProperty, String>) detailTable.getColumns().get(2);
    valueColumn.setCellValueFactory(param -> param.getValue().valueProperty());

    valueColumn.setCellFactory(v -> new TableCell<ObservableEntityProperty, String>() {
        final Animation animation = new Transition() {
            {
                setCycleDuration(Duration.millis(500));
                setInterpolator(Interpolator.EASE_OUT);
            }
            @Override
            protected void interpolate(double frac) {
                Color col = Color.YELLOW.interpolate(Color.WHITE, frac);
                getTableRow().setStyle(String.format(
                        "-fx-control-inner-background: #%02X%02X%02X;",
                        (int)(col.getRed() * 255),
                        (int)(col.getGreen() * 255),
                        (int)(col.getBlue() * 255)
                ));
            }
        };
        @Override
        protected void updateItem(String item, boolean empty) {
            super.updateItem(item, empty);
            setText(item);
            ObservableEntityProperty oep = (ObservableEntityProperty) getTableRow().getItem();
            if (oep != null) {
                animation.stop();
                animation.playFrom(Duration.millis(System.currentTimeMillis() - oep.getLastChangedAt()));
            }
        }
    });

    detailTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    detailTable.setOnKeyPressed(e -> {
        KeyCombination ctrlC = new KeyCodeCombination(KeyCode.C, KeyCodeCombination.CONTROL_DOWN);
        if (ctrlC.match(e)) {
            ClipboardContent cbc = new ClipboardContent();
            cbc.putString(detailTable.getSelectionModel().getSelectedIndices().stream()
                    .map(i -> detailTable.getItems().get(i))
                    .map(p -> String.format("%s %s %s", p.indexProperty().get(), p.nameProperty().get(), p.valueProperty().get()))
                    .collect(Collectors.joining("\n"))
            );
            Clipboard.getSystemClipboard().setContent(cbc);
        }
    });


    entityNameFilter.textProperty().addListener(observable -> {
        if (filteredEntityList != null) {
            filteredEntityList.setPredicate(allFilterFunc);
            filteredEntityList.setPredicate(filterFunc);
        }
    });

    mapControl = new MapControl();
    mapCanvasPane.getChildren().add(mapControl);

    mapCanvasPane.setTopAnchor(mapControl, 0.0);
    mapCanvasPane.setBottomAnchor(mapControl, 0.0);
    mapCanvasPane.setLeftAnchor(mapControl, 0.0);
    mapCanvasPane.setRightAnchor(mapControl, 0.0);
    mapCanvasPane.widthProperty().addListener(evt -> resizeMapControl());
    mapCanvasPane.heightProperty().addListener(evt -> resizeMapControl());

}
 
Example #27
Source File: ArtistsMainController.java    From MusicPlayer with MIT License 4 votes vote down vote up
private void showAllSongs(Artist artist, boolean fromMainController) {

        ObservableList<Album> albums = FXCollections.observableArrayList();
        ObservableList<Song> songs = FXCollections.observableArrayList();

        for (Album album : artist.getAlbums()) {

            albums.add(album);

            songs.addAll(album.getSongs());
        }

        Collections.sort(songs, (first, second) -> {

            Album firstAlbum = albums.stream().filter(x -> x.getTitle().equals(first.getAlbum())).findFirst().get();
            Album secondAlbum = albums.stream().filter(x -> x.getTitle().equals(second.getAlbum())).findFirst().get();
            if (firstAlbum.compareTo(secondAlbum) != 0) {
                return firstAlbum.compareTo(secondAlbum);
            } else {
                return first.compareTo(second);
            }
        });

        Collections.sort(albums);

        if (selectedSong != null) {
        	selectedSong.setSelected(false);
        }
        selectedSong = null;
    	selectedAlbum = null;
        albumList.getSelectionModel().clearSelection();
        albumList.setItems(albums);
        songTable.setItems(songs);
        songTable.getSelectionModel().clearSelection();
        scrollPane.setVvalue(0);
        albumLabel.setText("All Songs");
        songTable.setMinHeight(0);
        songTable.setPrefHeight(0);
        songTable.setVisible(true);
        double height = (songs.size() + 1) * 50 + 2;
        Animation songTableLoadAnimation = new Transition() {
        	{
        		setCycleDuration(Duration.millis(250));
                setInterpolator(Interpolator.EASE_BOTH);
        	}
        	
        	protected void interpolate(double frac) {
        		songTable.setMinHeight(frac * height);
                songTable.setPrefHeight(frac * height);
        	}
        };
        
        songTableLoadAnimation.setOnFinished(x -> loadedLatch.countDown());
        
        new Thread(() -> {
        	try {
        		if (fromMainController) {
        			MusicPlayer.getMainController().getLatch().await();
        			MusicPlayer.getMainController().resetLatch();
        		} else {
        			loadedLatch.await();
        			loadedLatch = new CountDownLatch(1);
        		}
			} catch (Exception e) {
				e.printStackTrace();
			}
			songTableLoadAnimation.play();
        }).start();
    }
 
Example #28
Source File: ArtistsMainController.java    From MusicPlayer with MIT License 4 votes vote down vote up
void selectAlbum(Album album) {

        if (selectedAlbum == album) {

            albumList.getSelectionModel().clearSelection();
            showAllSongs(artistList.getSelectionModel().getSelectedItem(), false);

        } else {
        	
        	if (selectedSong != null) {
        		selectedSong.setSelected(false);
        	}
        	selectedSong = null;
            selectedAlbum = album;
            albumList.getSelectionModel().select(selectedAlbum);
            ObservableList<Song> songs = FXCollections.observableArrayList();
            songs.addAll(album.getSongs());
            Collections.sort(songs);
            songTable.getSelectionModel().clearSelection();
            songTable.setItems(songs);
            scrollPane.setVvalue(0);
            albumLabel.setText(album.getTitle());
            songTable.setMinHeight(0);
            songTable.setPrefHeight(0);
            songTable.setVisible(true);
            double height = (songs.size() + 1) * 50 + 2;
            Animation songTableLoadAnimation = new Transition() {
            	{
            		setCycleDuration(Duration.millis(250));
                    setInterpolator(Interpolator.EASE_BOTH);
            	}
            	
            	protected void interpolate(double frac) {
            		songTable.setMinHeight(frac * height);
                    songTable.setPrefHeight(frac * height);
            	}
            };
            new Thread(() -> {
            	try {
					loadedLatch.await();
					loadedLatch = new CountDownLatch(1);
				} catch (Exception e) {
					e.printStackTrace();
				}
            	songTableLoadAnimation.play();
            }).start();
        }
    }
 
Example #29
Source File: JFXHamburger.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * @return the current animation of the hamburger
 */
public Transition getAnimation() {
    return animation;
}
 
Example #30
Source File: JFXDialog.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/***************************************************************************
 *                                                                         *
 * Transitions                                                             *
 *                                                                         *
 **************************************************************************/

private Transition getShowAnimation(DialogTransition transitionType) {
    Transition animation = null;
    if (contentHolder != null) {
        switch (transitionType) {
            case LEFT:
                contentHolder.setScaleX(1);
                contentHolder.setScaleY(1);
                contentHolder.setTranslateX(-offsetX);
                animation = new LeftTransition();
                break;
            case RIGHT:
                contentHolder.setScaleX(1);
                contentHolder.setScaleY(1);
                contentHolder.setTranslateX(offsetX);
                animation = new RightTransition();
                break;
            case TOP:
                contentHolder.setScaleX(1);
                contentHolder.setScaleY(1);
                contentHolder.setTranslateY(-offsetY);
                animation = new TopTransition();
                break;
            case BOTTOM:
                contentHolder.setScaleX(1);
                contentHolder.setScaleY(1);
                contentHolder.setTranslateY(offsetY);
                animation = new BottomTransition();
                break;
            case CENTER:
                contentHolder.setScaleX(0);
                contentHolder.setScaleY(0);
                animation = new CenterTransition();
                break;
            default:
                animation = null;
                contentHolder.setScaleX(1);
                contentHolder.setScaleY(1);
                contentHolder.setTranslateX(0);
                contentHolder.setTranslateY(0);
                break;
        }
    }
    if (animation != null) {
        animation.setOnFinished(finish ->
            Event.fireEvent(JFXDialog.this, new JFXDialogEvent(JFXDialogEvent.OPENED)));
    }
    return animation;
}