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


Java Timeline.setAutoReverse方法代碼示例

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


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

示例1: animiereRechteck

import javafx.animation.Timeline; //導入方法依賴的package包/類
public static Pane animiereRechteck() {

        Random random = new Random();

        Pane animationPane = new Pane();
        animationPane.setPrefSize(500,200);

        Rectangle rect = new Rectangle(75, 75, 100, 50);
        animationPane.getChildren().add(rect);

        Timeline timeline = new Timeline();
        timeline.setCycleCount(Timeline.INDEFINITE);
        timeline.setAutoReverse(true);

        KeyValue kVMoveX = new KeyValue(rect.xProperty(), random.nextInt(200) + 200);
        KeyValue kVRotate = new KeyValue(rect.rotateProperty(), random.nextInt(360) + 180);
        KeyValue kVArcHeight = new KeyValue(rect.arcHeightProperty(), 60);
        KeyValue kVArcWidth = new KeyValue(rect.arcWidthProperty(), 60);
        
        KeyFrame keyFrame = new KeyFrame(Duration.millis(random.nextInt(2000) + 2000), kVMoveX, kVRotate, kVArcHeight, kVArcWidth);

        timeline.getKeyFrames().add(keyFrame);
        timeline.play();

        return animationPane;
    }
 
開發者ID:CAPTNCAPS,項目名稱:java.IF17wi,代碼行數:27,代碼來源:Rechteck.java

示例2: TimelineSample

import javafx.animation.Timeline; //導入方法依賴的package包/類
public TimelineSample() {
    super(280,120);

    //create a circle
    final Circle circle = new Circle(25,25, 20,  Color.web("1c89f4"));
    circle.setEffect(new Lighting());

    //create a timeline for moving the circle
    timeline = new Timeline();        
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);

    //one can start/pause/stop/play animation by
    //timeline.play();
    //timeline.pause();
    //timeline.stop();
    //timeline.playFromStart();
    
    //add the following keyframes to the timeline
    timeline.getKeyFrames().addAll
        (new KeyFrame(Duration.ZERO,
                      new KeyValue(circle.translateXProperty(), 0)),
         new KeyFrame(new Duration(4000),
                      new KeyValue(circle.translateXProperty(), 205)));


    getChildren().add(createNavigation());
    getChildren().add(circle);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Timeline rate", timeline.rateProperty(), -4d, 4d)
            //TODO it is possible to do it for integer?
    );
    // END REMOVE ME
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:36,代碼來源:TimelineSample.java

示例3: Metronome

import javafx.animation.Timeline; //導入方法依賴的package包/類
public Metronome() {
    // création du fond du métronome
    ImageView fond_metronome = new ImageView(
            new Image(Metronome.class.getResourceAsStream("images/metronome.png")));
    fond_metronome.setFitHeight(40);
    fond_metronome.setPreserveRatio(true);

    // création de l'aiguille du métronome
    ImageView aiguille = new ImageView(new Image(Metronome.class.getResourceAsStream("images/aiguille.png")));
    aiguille.setFitHeight(32);
    aiguille.setPreserveRatio(true);
    aiguille.setTranslateX(16);
    aiguille.setTranslateY(2);

    // on applique une transformation à l'aiguille
    Rotate rotation = new Rotate(0, 3, 29);
    aiguille.getTransforms().add(rotation);

    // création de l'animation de l'aiguille
    Timeline timeline = new Timeline();
    timeline.getKeyFrames().addAll(new KeyFrame(Duration.ZERO, new KeyValue(rotation.angleProperty(), 45)),
            new KeyFrame(new Duration(1000), new KeyValue(rotation.angleProperty(), -45)));
    timeline.setAutoReverse(true);
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.play();

    this.getChildren().add(fond_metronome);
    this.getChildren().add(aiguille);
    this.setTranslateX(400);
    this.setTranslateY(200);
}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:32,代碼來源:Metronome.java

示例4: animateGraph

import javafx.animation.Timeline; //導入方法依賴的package包/類
private void animateGraph(long timeMillis) {
    Timeline beat = new Timeline(
        new KeyFrame(Duration.millis(timeMillis),         event -> animationStep(timeMillis))
    );
    beat.setAutoReverse(true);
    beat.setCycleCount(1);
    beat.play();
}
 
開發者ID:katharinebeaumont,項目名稱:Cluster,代碼行數:9,代碼來源:Cluster.java

示例5: init

import javafx.animation.Timeline; //導入方法依賴的package包/類
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(root, 260,100));
    //create a circle with effect
    final Circle circle = new Circle(20,  Color.rgb(156,216,255));
    circle.setEffect(new Lighting());
    //create a text inside a circle
    final Text text = new Text (i.toString());
    text.setStroke(Color.BLACK);
    //create a layout for circle with text inside
    final StackPane stack = new StackPane();
    stack.getChildren().addAll(circle, text);
    stack.setLayoutX(30);
    stack.setLayoutY(30);

    //create a timeline for moving the circle

    timeline = new Timeline();
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);

    //one can add a specific action when each frame is started. There are one or more frames during
    // executing one KeyFrame depending on set Interpolator.
    timer = new AnimationTimer() {
        @Override
        public void handle(long l) {
            text.setText(i.toString());
            i++;
        }

    };

    //create a keyValue with factory: scaling the circle 2times
    KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2);
    KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2);

    //create a keyFrame, the keyValue is reached at time 2s
    Duration duration = Duration.seconds(2);
    //one can add a specific action when the keyframe is reached
    EventHandler<ActionEvent> onFinished = new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
             stack.setTranslateX(java.lang.Math.random()*200);
             //reset counter
             i = 0;
        }
    };

    KeyFrame keyFrame = new KeyFrame(duration, onFinished , keyValueX, keyValueY);

    //add the keyframe to the timeline
    timeline.getKeyFrames().add(keyFrame);

    root.getChildren().add(stack);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:56,代碼來源:TimelineEvents.java

示例6: TimelineEventsSample

import javafx.animation.Timeline; //導入方法依賴的package包/類
public TimelineEventsSample() {
    super(70,70);
    //create a circle with effect
    final Circle circle = new Circle(20,  Color.rgb(156,216,255));
    circle.setEffect(new Lighting());
    //create a text inside a circle
    final Text text = new Text (i.toString());
    text.setStroke(Color.BLACK);
    //create a layout for circle with text inside
    final StackPane stack = new StackPane();
    stack.getChildren().addAll(circle, text);
    stack.setLayoutX(30);
    stack.setLayoutY(30);

    //create a timeline for moving the circle

    timeline = new Timeline();
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);

    //one can add a specific action when each frame is started. There are one or more frames during
    // executing one KeyFrame depending on set Interpolator.
    timer = new AnimationTimer() {
        @Override
        public void handle(long l) {
            text.setText(i.toString());
            i++;
        }

    };

    //create a keyValue with factory: scaling the circle 2times
    KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2);
    KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2);

    //create a keyFrame, the keyValue is reached at time 2s
    Duration duration = Duration.seconds(2);
    //one can add a specific action when the keyframe is reached
    EventHandler<ActionEvent> onFinished = new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
             stack.setTranslateX(java.lang.Math.random()*200-100);
             //reset counter
             i = 0;
        }
    };

    KeyFrame keyFrame = new KeyFrame(duration, onFinished , keyValueX, keyValueY);

    //add the keyframe to the timeline
    timeline.getKeyFrames().add(keyFrame);

    getChildren().add(stack);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:54,代碼來源:TimelineEventsSample.java

示例7: setAnimation

import javafx.animation.Timeline; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
private void setAnimation(){
	// Initially hiding the Top Pane
	clipRect = new Rectangle();
	clipRect.setWidth(boxBounds.getWidth());
	clipRect.setHeight(0);
	clipRect.translateYProperty().set(boxBounds.getWidth());
	laytable.setClip(clipRect);
	laytable.translateYProperty().set(-boxBounds.getWidth());

	// Animation for bouncing effect.
	final Timeline timelineBounce = new Timeline();
	timelineBounce.setCycleCount(2);
	timelineBounce.setAutoReverse(true);
	final KeyValue kv1 = new KeyValue(clipRect.heightProperty(), (boxBounds.getHeight()-15));
	final KeyValue kv2 = new KeyValue(clipRect.translateYProperty(), 15);
	final KeyValue kv3 = new KeyValue(laytable.translateYProperty(), -15);
	final KeyFrame kf1 = new KeyFrame(Duration.millis(100), kv1, kv2, kv3);
	timelineBounce.getKeyFrames().add(kf1);

	// Event handler to call bouncing effect after the scroll down is finished.
	EventHandler onFinished = new EventHandler() {
		@Override
		public void handle(Event event) {
			timelineBounce.play();
		}
	};

	timelineDown = new Timeline();
	timelineUp = new Timeline();

	// Animation for scroll down.
	timelineDown.setCycleCount(1);
	timelineDown.setAutoReverse(true);
	final KeyValue kvDwn1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
	final KeyValue kvDwn2 = new KeyValue(clipRect.translateYProperty(), 0);
	final KeyValue kvDwn3 = new KeyValue(laytable.translateYProperty(), 0);
	final KeyFrame kfDwn = new KeyFrame(Duration.millis(1000), onFinished, kvDwn1, kvDwn2, kvDwn3);
	timelineDown.getKeyFrames().add(kfDwn);

	// Animation for scroll up.
	timelineUp.setCycleCount(1); 
	timelineUp.setAutoReverse(true);
	final KeyValue kvUp1 = new KeyValue(clipRect.heightProperty(), 0);
	final KeyValue kvUp2 = new KeyValue(clipRect.translateYProperty(), boxBounds.getHeight());
	final KeyValue kvUp3 = new KeyValue(laytable.translateYProperty(), -boxBounds.getHeight());
	final KeyFrame kfUp = new KeyFrame(Duration.millis(1000), kvUp1, kvUp2, kvUp3);
	timelineUp.getKeyFrames().add(kfUp);

}
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:51,代碼來源:AllAttendance.java

示例8: setAnimation

import javafx.animation.Timeline; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
private void setAnimation(){
	  // Initially hiding the Top Pane
	  clipRect = new Rectangle();
	  clipRect.setWidth(boxBounds.getWidth());
	  clipRect.setHeight(0);
	  clipRect.translateYProperty().set(boxBounds.getWidth());
	  laytable.setClip(clipRect);
	  laytable.translateYProperty().set(-boxBounds.getWidth());
	 
	  // Animation for bouncing effect.
	  final Timeline timelineBounce = new Timeline();
	  timelineBounce.setCycleCount(2);
	  timelineBounce.setAutoReverse(true);
	  final KeyValue kv1 = new KeyValue(clipRect.heightProperty(), (boxBounds.getHeight()-15));
	  final KeyValue kv2 = new KeyValue(clipRect.translateYProperty(), 15);
	  final KeyValue kv3 = new KeyValue(laytable.translateYProperty(), -15);
	  final KeyFrame kf1 = new KeyFrame(Duration.millis(100), kv1, kv2, kv3);
	  timelineBounce.getKeyFrames().add(kf1);
	  
	  // Event handler to call bouncing effect after the scroll down is finished.
	  EventHandler onFinished = new EventHandler() {
				@Override
				public void handle(Event event) {
					timelineBounce.play();
				}
	        };
	        
	        timelineDown = new Timeline();
	        timelineUp = new Timeline();
	        
	        // Animation for scroll down.
	  timelineDown.setCycleCount(1);
	  timelineDown.setAutoReverse(true);
	  final KeyValue kvDwn1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
	  final KeyValue kvDwn2 = new KeyValue(clipRect.translateYProperty(), 0);
	  final KeyValue kvDwn3 = new KeyValue(laytable.translateYProperty(), 0);
	  final KeyFrame kfDwn = new KeyFrame(Duration.millis(1000), onFinished, kvDwn1, kvDwn2, kvDwn3);
	  timelineDown.getKeyFrames().add(kfDwn);
	  
	  // Animation for scroll up.
	  timelineUp.setCycleCount(1); 
	  timelineUp.setAutoReverse(true);
	  final KeyValue kvUp1 = new KeyValue(clipRect.heightProperty(), 0);
	  final KeyValue kvUp2 = new KeyValue(clipRect.translateYProperty(), boxBounds.getHeight());
	  final KeyValue kvUp3 = new KeyValue(laytable.translateYProperty(), -boxBounds.getHeight());
	  final KeyFrame kfUp = new KeyFrame(Duration.millis(1000), kvUp1, kvUp2, kvUp3);
	  timelineUp.getKeyFrames().add(kfUp);
	  
	 }
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:51,代碼來源:Office_Entry.java

示例9: setAnimation

import javafx.animation.Timeline; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
private void setAnimation(){
  // Initially hiding the Top Pane
  clipRect = new Rectangle();
        clipRect.setWidth(boxBounds.getWidth());
  clipRect.setHeight(0);
  clipRect.translateYProperty().set(boxBounds.getWidth());
  layall.setClip(clipRect);
  layall.translateYProperty().set(-boxBounds.getWidth());
  
  layoffice.translateYProperty().set(-boxBounds.getWidth());
  
  // Animation for bouncing effect.
  final Timeline timelineBounce = new Timeline();
  timelineBounce.setCycleCount(2);
  timelineBounce.setAutoReverse(true);
  final KeyValue kv1 = new KeyValue(clipRect.heightProperty(), (boxBounds.getHeight()-15));
  final KeyValue kv2 = new KeyValue(clipRect.translateYProperty(), 15);
  final KeyValue kv3 = new KeyValue(layall.translateYProperty(), -15);
  final KeyFrame kf1 = new KeyFrame(Duration.millis(100), kv1, kv2, kv3);
  timelineBounce.getKeyFrames().add(kf1);
  
  // Event handler to call bouncing effect after the scroll down is finished.
  EventHandler onFinished = new EventHandler() {
			@Override
			public void handle(Event event) {
				timelineBounce.play();
			}
        };

        
        timelineDown = new Timeline();
        timelineUp = new Timeline();
        timelineoffice= new Timeline();
       
        // Animation for scroll down.
  timelineDown.setCycleCount(1);
  timelineDown.setAutoReverse(true);
  final KeyValue kvDwn1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
  final KeyValue kvDwn2 = new KeyValue(clipRect.translateYProperty(), 0);
  final KeyValue kvDwn3 = new KeyValue(layall.translateYProperty(), 0);
  final KeyValue kvDwn4 = new KeyValue(layoffice.translateYProperty(), -boxBounds.getHeight()-190);
  final KeyFrame kfDwn = new KeyFrame(Duration.millis(1000), onFinished, kvDwn1, kvDwn2, kvDwn3, kvDwn4);
  timelineDown.getKeyFrames().add(kfDwn);
  
  // Animation for scroll up.
  timelineUp.setCycleCount(1); 
  timelineUp.setAutoReverse(true);
  final KeyValue kvUp1 = new KeyValue(clipRect.heightProperty(), 0);
  final KeyValue kvUp2 = new KeyValue(clipRect.translateYProperty(), boxBounds.getHeight());
  final KeyValue kvUp3 = new KeyValue(layall.translateYProperty(), -boxBounds.getHeight()-190);
  final KeyValue kvUp4 = new KeyValue(layoffice.translateYProperty(), -boxBounds.getHeight()-190);
  final KeyFrame kfUp = new KeyFrame(Duration.millis(1000), kvUp1, kvUp2, kvUp3, kvUp4);
  timelineUp.getKeyFrames().add(kfUp);
  
  //Animation for the scrollside
  timelineoffice.setCycleCount(1);
  timelineoffice.setAutoReverse(true);
  final KeyValue kvside1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
  final KeyValue kvside2 = new KeyValue(clipRect.translateYProperty(), 0);
  final KeyValue kvside3 = new KeyValue(layoffice.translateYProperty(), 0);
  final KeyValue kvside4 = new KeyValue(layall.translateYProperty(), -boxBounds.getHeight());
  final KeyFrame kfside = new KeyFrame(Duration.millis(1000), kvside1, kvside2, kvside3, kvside4);
  timelineoffice.getKeyFrames().add(kfside);
  
 }
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:67,代碼來源:MainWindow.java

示例10: setAnimation

import javafx.animation.Timeline; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
private void setAnimation(){
	  // Initially hiding the Top Pane
	  clipRect = new Rectangle();
	        clipRect.setWidth(boxBounds.getWidth());
	  clipRect.setHeight(0);
	  clipRect.translateXProperty().set(boxBounds.getWidth());
	  topPane.setClip(clipRect);
	  topPane.translateXProperty().set(-boxBounds.getWidth());
	  
	  thirdpane.translateXProperty().set(-boxBounds.getWidth());
	  
	  fourthpane.translateXProperty().set(-boxBounds.getWidth());
	  
	  // Animation for bouncing effect.
	  final Timeline timelineBounce = new Timeline();
	  timelineBounce.setCycleCount(2);
	  timelineBounce.setAutoReverse(true);
	  final KeyValue kv1 = new KeyValue(clipRect.heightProperty(), (boxBounds.getHeight()-15));
	  final KeyValue kv2 = new KeyValue(clipRect.translateYProperty(), 15);
	  final KeyValue kv3 = new KeyValue(topPane.translateYProperty(), -15);
	  final KeyFrame kf1 = new KeyFrame(Duration.millis(100), kv1, kv2, kv3);
	  timelineBounce.getKeyFrames().add(kf1);
	  
	  // Event handler to call bouncing effect after the scroll down is finished.
	  EventHandler onFinished = new EventHandler() {
				@Override
				public void handle(Event event) {
					timelineBounce.play();
				}
	        };
	        
	        timelineDown = new Timeline();
	        timelineUp = new Timeline();
	        timelinethree= new Timeline();
	        timelinefour= new Timeline();
	        // Animation for scroll down.
	  timelineDown.setCycleCount(1);
	  timelineDown.setAutoReverse(true);
	  final KeyValue kvDwn1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
	  final KeyValue kvDwn2 = new KeyValue(clipRect.translateXProperty(), 0);
	  final KeyValue kvDwn3 = new KeyValue(topPane.translateXProperty(), 0);
	  final KeyValue kvDwn4 = new KeyValue(thirdpane.translateXProperty(), -boxBounds.getHeight());
	  final KeyValue kvDwn5 = new KeyValue(fourthpane.translateXProperty(), -boxBounds.getHeight());
	  final KeyFrame kfDwn = new KeyFrame(Duration.millis(1000), onFinished, kvDwn1, kvDwn2, kvDwn3, kvDwn4, kvDwn5);
	  timelineDown.getKeyFrames().add(kfDwn);
	  
	  // Animation for scroll up.
	  timelineUp.setCycleCount(1); 
	  timelineUp.setAutoReverse(true);
	  final KeyValue kvUp1 = new KeyValue(clipRect.heightProperty(), 0);
	  final KeyValue kvUp2 = new KeyValue(clipRect.translateXProperty(), boxBounds.getHeight());
	  final KeyValue kvUp3 = new KeyValue(topPane.translateXProperty(), -boxBounds.getHeight());
	  final KeyValue kvUp4 = new KeyValue(thirdpane.translateXProperty(), -boxBounds.getHeight());
	  final KeyValue kvUp5 = new KeyValue(fourthpane.translateXProperty(), -boxBounds.getHeight());
	  final KeyFrame kfUp = new KeyFrame(Duration.millis(1000), kvUp1, kvUp2, kvUp3, kvUp4, kvUp5);
	  timelineUp.getKeyFrames().add(kfUp);
	  
	  //Animation for the scrollside
	  timelinethree.setCycleCount(1);
	  timelinethree.setAutoReverse(true);
	  final KeyValue kvside1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
	  final KeyValue kvside2 = new KeyValue(clipRect.translateXProperty(), 0);
	  final KeyValue kvside3 = new KeyValue(thirdpane.translateXProperty(), 0);
	  final KeyValue kvside4 = new KeyValue(fourthpane.translateXProperty(), -boxBounds.getHeight());
	  final KeyFrame kfside = new KeyFrame(Duration.millis(1000), kvside1, kvside2, kvside3, kvside4);
	  timelinethree.getKeyFrames().add(kfside);
	  
	  timelinefour.setCycleCount(1);
	  timelinefour.setAutoReverse(true);
	  final KeyValue kvfourth1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
	  final KeyValue kvfourth2 = new KeyValue(clipRect.translateXProperty(), 0);
	  final KeyValue kvfourth3 = new KeyValue(fourthpane.translateXProperty(), 0);
	  final KeyFrame kffourth = new KeyFrame(Duration.millis(1000), kvfourth1, kvfourth2, kvfourth3);
	  timelinefour.getKeyFrames().add(kffourth);
	 }
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:77,代碼來源:Help.java


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