當前位置: 首頁>>代碼示例>>Java>>正文


Java TranslateTransition.setOnFinished方法代碼示例

本文整理匯總了Java中javafx.animation.TranslateTransition.setOnFinished方法的典型用法代碼示例。如果您正苦於以下問題:Java TranslateTransition.setOnFinished方法的具體用法?Java TranslateTransition.setOnFinished怎麽用?Java TranslateTransition.setOnFinished使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.animation.TranslateTransition的用法示例。


在下文中一共展示了TranslateTransition.setOnFinished方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: animation

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
public void animation(int cardid){
    TranslateTransition transition = new TranslateTransition();
    transition.setDuration(Duration.millis(150));
    transition.setNode(hash_hhcard.get(cardid));
    transition.setToY(-100);
    transition.setAutoReverse(true);
    transition.setCycleCount(2);

    transition.setOnFinished(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            try {
                playCard(cardid);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    });
    transition.play();

}
 
開發者ID:ESILV-FSociety,項目名稱:CardGame,代碼行數:23,代碼來源:GameOverviewController.java

示例2: deductScoreDeath

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
private void deductScoreDeath() {
    inc("score", -1000);
    set("kills", 0);
    set("multiplier", 1);

    Text bonusText = getUIFactory().newText("-1000", Color.WHITE, 20);
    bonusText.setTranslateX(1100);
    bonusText.setTranslateY(70);

    getGameScene().addUINode(bonusText);

    TranslateTransition tt = new TranslateTransition(Duration.seconds(0.5), bonusText);
    tt.setToY(0);
    tt.setOnFinished(e -> {
        getGameScene().removeUINode(bonusText);
    });
    tt.play();
}
 
開發者ID:AlmasB,項目名稱:FXGLGames,代碼行數:19,代碼來源:GeoWarsApp.java

示例3: HealingNumber

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
public HealingNumber(String text, GameToken parent) {
	this.parent = parent;

	setText(text);
	setFill(Color.GREEN);
	setStyle("-fx-font-size: 28pt; -fx-font-family: \"System\";-fx-font-weight: bolder;-fx-stroke: black;-fx-stroke-width: 2;");

	setCache(true);
	setCacheHint(CacheHint.SPEED);

	parent.getAnchor().getChildren().add(this);

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
	TranslateTransition animation = new TranslateTransition(Duration.seconds(0.5), this);
	animation.setToY(-30);
	animation.setOnFinished(this::onComplete);
	animation.play();
}
 
開發者ID:demilich1,項目名稱:metastone,代碼行數:19,代碼來源:HealingNumber.java

示例4: swipe2Right

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
private void swipe2Right(Region to, Region old) {
        to.setTranslateX(0);
        to.setTranslateY(0);

        TranslateTransition translateTransition = new TranslateTransition(Duration.millis(400), old);

        translateTransition.setFromX(old.getLayoutX());
        translateTransition.setToX(master.getLayoutBounds().getWidth());
        translateTransition.setInterpolator(Interpolator.EASE_OUT);
        translateTransition.setCycleCount(1);
        translateTransition.play();

        translateTransition.setOnFinished(new EventHandler() {
            @Override
            public void handle(Event event) {
                System.out.println("master p" + master.getParent());
                master.getChildren().clear();
                master.getChildren().add(to);
                to.prefWidthProperty().bind(master.prefWidthProperty());
//                LayoutUtils.fix2Parent(to, master);
//                to.prefWidthProperty().bind(master.prefWidthProperty());

            }

        });
    }
 
開發者ID:cosysoft,項目名稱:agile,代碼行數:27,代碼來源:MainView.java

示例5: eval

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
@Override
public Object eval(Environment env) {
    final Object c = ((ASTree) condition()).eval(env);
    if (c instanceof Integer) {
        final Sprite sprite = env.getSprite();
        SequentialTransition st = env.getSequentialTransition();
        TranslateTransition tt
                = new TranslateTransition(Duration.millis(10), sprite);
        tt.setOnFinished(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                sprite.setSpriteCostume((int) c);
            }
        });
        st.getChildren().add(tt);
    }
    return c;
}
 
開發者ID:jointry,項目名稱:jointry,代碼行數:19,代碼來源:CostumeStmnt.java

示例6: eval

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
@Override
public Object eval(Environment env) {
    final Object c = ((ASTree) condition()).eval(env);

    final Sprite sprite = env.getSprite();
    SequentialTransition st = env.getSequentialTransition();
    TranslateTransition tt
                        = new TranslateTransition(Duration.millis(10), sprite);
    tt.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent t) {
            sprite.setSpeechBubble(c.toString());
        }
    });
    st.getChildren().add(tt);

    return c;
}
 
開發者ID:jointry,項目名稱:jointry,代碼行數:19,代碼來源:SpeechStmnt.java

示例7: animate

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
protected void animate(final ModView modView, final int amount) {
	
	 TranslateTransition tt = new TranslateTransition(Duration.millis(80), modView.getContent());
     tt.setByY(amount);
     tt.setCycleCount(1);
     tt.setAutoReverse(false);
     tt.setOnFinished(new EventHandler<ActionEvent>() {
		@Override
		public void handle(ActionEvent e) {
			modView.moving = false;
		}
	});
 
     tt.play();
	
}
 
開發者ID:KrazyTheFox,項目名稱:Starbound-Mod-Manager,代碼行數:17,代碼來源:ModListView.java

示例8: animateMovinement

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
/**
 * 
 * @param direction
 * @param from
 * @param to 
 */
private synchronized void animateMovinement(Direction direction, Tile from, Tile to) {
	TranslateTransition st = new TranslateTransition(Duration.seconds(.3), from);
	st.setFromX(0);
	st.setToX(direction.getX_location());
	st.play();
	st.setOnFinished(e -> {
		to.combine(from);
		this.checkCompletion(to);
		from.remove();
	});
}
 
開發者ID:ShekkarRaee,項目名稱:xpanderfx,代碼行數:18,代碼來源:MainFXMLDocumentController.java

示例9: init

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
public static void init(VBox vbox, Label label) {
    notificationBox = vbox;
    notificationLabel = label;

    transitionIn = new TranslateTransition(TRANSITION_DURATION, notificationBox);
    transitionIn.setToY(0);

    transitionOut = new TranslateTransition(TRANSITION_DURATION, notificationBox);
    transitionOut.setFromY(0);
    transitionOut.setOnFinished((e) -> notificationBox.setVisible(false));
}
 
開發者ID:NoticEditorTeam,項目名稱:NoticEditor,代碼行數:12,代碼來源:Notification.java

示例10: createAndConfigureAnimation

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
private TranslateTransition createAndConfigureAnimation(
		final TableView<Person> sourceTable,
		final TableView<Person> destinationTable,
		final Pane commonTableAncestor, final TableRow<Person> row,
		final ImageView imageView, final Point2D animationStartPoint,
		Point2D animationEndPoint) {
	final TranslateTransition transition = new TranslateTransition(ANIMATION_DURATION, imageView);
	// At end of animation, actually move data, and remove animated image
	transition.setOnFinished(createAnimationFinishedHandler(sourceTable, destinationTable, commonTableAncestor, row.getItem(), imageView));
	// configure transition
	transition.setByX(animationEndPoint.getX() - animationStartPoint.getX()); // absolute translation, computed from coords relative to Scene
	transition.setByY(animationEndPoint.getY() - animationStartPoint.getY()); // absolute translation, computed from coords relative to Scene
	return transition;
}
 
開發者ID:mars-sim,項目名稱:mars-sim,代碼行數:15,代碼來源:AnimatedTableRow.java

示例11: setPagePosition

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
public void setPagePosition(int position) {
    if (animationFinished && (position - currentPosition) != 0) {
        animationFinished = false;
        TranslateTransition transition = new TranslateTransition();
        transition.setByX(((TabTitle) (hBox.getChildren().get(0))).getWidth() * (position - currentPosition));
        transition.setDuration(Duration.millis(150 * Math.abs(position - currentPosition)));
        transition.setInterpolator(Interpolator.LINEAR);
        transition.setNode(line);
        transition.setOnFinished(e -> {
            currentPosition = position;
            animationFinished = true;
        });
        transition.play();
    }
}
 
開發者ID:Tareq-SiSalem,項目名稱:JFXMaterial,代碼行數:16,代碼來源:ActionBar.java

示例12: startOpenAnimation

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
public void startOpenAnimation(boolean finished) {

        TranslateTransition transition = new TranslateTransition();
        transition.setNode(this);
        transition.setDuration(Duration.millis(500));

        if (finished) {
            transition.setToX(0);
            transition.setOnFinished(ev -> {
                drawerOpen = false;
                actionBar.setDrawerOpen(false);
                oldX = 0;
                startX = 0;

            });
        } else {
            transition.setToX(getPrefWidth());
            transition.setOnFinished(ev -> {


                drawerOpen = true;
                actionBar.setDrawerOpen(true);
                oldX = 0;
                startX = 0;

            });
        }
        transition.play();
        animationFinished = false;
    }
 
開發者ID:Tareq-SiSalem,項目名稱:JFXMaterial,代碼行數:31,代碼來源:DrawerLayout.java

示例13: placeDisc

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
private void placeDisc(Disc disc, int column) {
    int row = ROWS - 1;
    do {
        if (!getDisc(column, row).isPresent())
            break;

        row--;
    } while (row >= 0);

    if (row < 0)
        return;

    grid[column][row] = disc;
    discRoot.getChildren().add(disc);
    disc.setTranslateX(column * (TILE_SIZE + 5) + TILE_SIZE / 4);

    final int currentRow = row;

    TranslateTransition animation = new TranslateTransition(Duration.seconds(0.5), disc);
    animation.setToY(row * (TILE_SIZE + 5) + TILE_SIZE / 4);
    animation.setOnFinished(e -> {
        if (gameEnded(column, currentRow)) {
            gameOver();
        }

        redMove = !redMove;
    });
    animation.play();
}
 
開發者ID:AlmasB,項目名稱:FXTutorials,代碼行數:30,代碼來源:Connect4App.java

示例14: moveTo

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
/**
 * Moves this cell to the given x and y coordinates
 * @param x the x coordinate to move to
 * @param y the y coordinate to move to
 * @param animate whether to animate the transition from the old position
 * @param emphasize whether to have the Highlighter class emphasize this cell while it moves
 */
void moveTo(double x, double y, boolean animate, boolean emphasize){
    if(animate && numCellsBeingAnimated < MAX_NUM_CELLS_TO_ANIMATE){
        numCellsBeingAnimated++;

        Shape placeHolder = (Shape) getBaseView();
        placeHolder.setTranslateX(x+TreeLayout.H_PAD);
        placeHolder.setTranslateY(y+BOX_SHIFT);
        placeHolder.setOpacity(0.0);
        ((Pane)(this.getParent())).getChildren().add(placeHolder);

        TranslateTransition t = new TranslateTransition(Duration.millis(3000), this);
        t.setToX(x);
        t.setToY(y+BOX_SHIFT);
        t.setCycleCount(1);
        t.setOnFinished(event -> {
            numCellsBeingAnimated--;
            ((Pane)(this.getParent())).getChildren().remove(placeHolder);
        });
        t.play();

        if(emphasize){
            Highlighter.emphasizeCell(this);
        }
    }else{
        setTranslateX(x);
        setTranslateY(y+BOX_SHIFT);
    }
    this.refLabel.translate(x,y);
    this.hasUpdatedPosition.set(true);
    if (!this.refLabel.isVisible())
        this.refLabel.setVisible(true);
}
 
開發者ID:dmusican,項目名稱:Elegit,代碼行數:40,代碼來源:Cell.java

示例15: applyAnimation

import javafx.animation.TranslateTransition; //導入方法依賴的package包/類
private void applyAnimation(final StackPane group)
 {
  
  DropShadow ds = new DropShadow();
  ds.setOffsetY(3.0f);
  ds.setColor(Color.color(0.4f, 0.4f, 0.4f));
   
  Text t = new Text();
  t.setEffect(ds);
  t.setCache(true);
  t.setFill(Color.BLUE);
  t.setText("JavaFX drop shadow...");
  t.setFont(Font.font(null, FontWeight.BOLD, 32));
  
  final TranslateTransition animation = new TranslateTransition(Duration.millis(2000), t);
     animation.setFromX(-100);
     animation.setToX(100);
     animation.setAutoReverse(true);
     animation.setCycleCount(Animation.INDEFINITE);
    
     TranslateTransition animation1 = new TranslateTransition(Duration.millis(1000), t);
     animation1.setFromX(0);
     animation1.setToX(-100);
     animation1.setAutoReverse(false);
     animation1.setCycleCount(1);
     animation1.setOnFinished(new EventHandler<ActionEvent>() {
	@Override
	public void handle(ActionEvent arg0) {
		 animation.playFromStart();
	}
});
     animation1.playFromStart();
     
     group.getChildren().add(t);
  }
 
開發者ID:SaiPradeepDandem,項目名稱:javafx-demos,代碼行數:36,代碼來源:MarqueTagInJavaFX.java


注:本文中的javafx.animation.TranslateTransition.setOnFinished方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。