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


Java Group.getTranslateX方法代碼示例

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


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

示例1: playIndicatorAnimations

import javafx.scene.Group; //導入方法依賴的package包/類
private void playIndicatorAnimations(final Location.Type type, final Group container) {
    final Timeline moveAnimation = new Timeline();
    final Timeline disappearAnimation = new Timeline();

    final double startX = container.getTranslateX();
    final double startY = container.getTranslateY();

    final Interpolator interpolator = Interpolator.SPLINE(0.645, 0.045, 0.355, 1);

    double otherX = 0, otherY = 0;

    if(type.equals(Location.Type.INITIAL))
    {
        otherX = startX + 2 * GRID_SIZE;
        otherY = startY + 2 * GRID_SIZE;
    } else {
        otherX = startX - 2 * GRID_SIZE;
        otherY = startY - 2 * GRID_SIZE;
    }

    final KeyValue kvx1 = new KeyValue(container.translateXProperty(), otherX, interpolator);
    final KeyValue kvx2 = new KeyValue(container.translateXProperty(), startX, interpolator);

    final KeyValue kvy1 = new KeyValue(container.translateYProperty(), otherY, interpolator);
    final KeyValue kvy2 = new KeyValue(container.translateYProperty(), startY, interpolator);

    final List<KeyFrame> frames = new ArrayList<>();

    frames.add(new KeyFrame(millis(400), kvx2, kvy2));

    for(int i = 1; i < 6; i ++) {
        if(i % 2 == 1) {
            frames.add(new KeyFrame(millis(400 * (i + 1)), kvx2, kvy2));
        } else {
            frames.add(new KeyFrame(millis(400 * (i + 1)), kvx1, kvy1));
        }
    }

    moveAnimation.getKeyFrames().addAll(frames);

    final KeyValue kvPresent = new KeyValue(container.opacityProperty(), 1, interpolator);
    final KeyValue kvGone = new KeyValue(container.opacityProperty(), 0, interpolator);
    final KeyFrame kf1 = new KeyFrame(millis(5000), kvPresent);
    final KeyFrame kf2 = new KeyFrame(millis(5500), kvGone);
    disappearAnimation.getKeyFrames().addAll(kf1, kf2);


    moveAnimation.play();
    disappearAnimation.play();
}
 
開發者ID:ulriknyman,項目名稱:H-Uppaal,代碼行數:51,代碼來源:ComponentPresentation.java


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