本文整理汇总了Java中javafx.animation.TranslateTransition.setCycleCount方法的典型用法代码示例。如果您正苦于以下问题:Java TranslateTransition.setCycleCount方法的具体用法?Java TranslateTransition.setCycleCount怎么用?Java TranslateTransition.setCycleCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.animation.TranslateTransition
的用法示例。
在下文中一共展示了TranslateTransition.setCycleCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TranslateTransitionSample
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
public TranslateTransitionSample() {
super(400,40);
Circle circle = new Circle(20, Color.CRIMSON);
circle.setTranslateX(20);
circle.setTranslateY(20);
getChildren().add(circle);
translateTransition = new TranslateTransition(Duration.seconds(4),circle);
translateTransition.setFromX(20);
translateTransition.setToX(380);
translateTransition.setCycleCount(Timeline.INDEFINITE);
translateTransition.setAutoReverse(true);
translateTransition = TranslateTransitionBuilder.create()
.duration(Duration.seconds(4))
.node(circle)
.fromX(20)
.toX(380)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
}
示例2: initialize
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
@FXML
public void initialize(){
Main.checkFullScreen();
Main.getAlertWindow().setOnCloseRequest(e -> spriteImage.setImage(new Image(Gang.getCarSpriteURL())));
// updating labels
distanceLabel.setText("To go: "+ Gang.getDistance() +"Mi");
conditionsLabel.setText("Condition: "+ Gang.getHealthConditions());
daysLabel.setText("Days: "+ Gang.getDays());
statusLabel.setText("Status: Resting");
// setting up how the animation will work
drivingTransition = new TranslateTransition();
drivingTransition.setDuration(Duration.seconds(animationDuration));
drivingTransition.setToX(Main.getMainWindow().getWidth() - 850);
drivingTransition.setNode(sprite);
drivingTransition.setCycleCount(Animation.INDEFINITE);
// fixes the bug with thread not ending when stage was closed
Main.getMainWindow().setOnCloseRequest(e -> Gang.setMoving(false));
}
示例3: updateGUI
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
@FXML
private void updateGUI(){
spriteImage.setImage(new Image(Gang.getCarSpriteURL()));
// updating drivingTransition
drivingTransition = new TranslateTransition();
drivingTransition.setDuration(Duration.seconds(animationDuration));
drivingTransition.setToX((Main.getMainWindow().getWidth() / -1) - 400);
drivingTransition.setNode(sprite);
drivingTransition.setCycleCount(Animation.INDEFINITE);
// updating labels
distanceLabel.setText("To go: "+ Gang.getDistance() +"Mi");
conditionsLabel.setText("Condition: "+ Gang.getHealthConditions());
daysLabel.setText("Days: "+ Gang.getDays());
statusLabel.setText("Status: Resting");
}
示例4: 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();
}
示例5: TransitionForAll
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private void TransitionForAll(Rectangle rectangle, double layoutXFrom, double layoutXTo, double layoutYFrom, double layoutYTo) {
mainPane.getChildren().add(rectangle);
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(800), rectangle);
translateTransition.setFromX(layoutXFrom);
translateTransition.setToX(layoutXTo);
translateTransition.setFromY(layoutYFrom);
translateTransition.setToY(layoutYTo);
translateTransition.setCycleCount(1);
translateTransition.setAutoReverse(true);
FadeTransition fadeTransition = new FadeTransition(Duration.millis(800), rectangle);
fadeTransition.setFromValue(1.0f);
fadeTransition.setToValue(0f);
fadeTransition.setCycleCount(1);
fadeTransition.setAutoReverse(true);
translateTransition.play();
fadeTransition.play();
rectangle.setDisable(true);
Rectangle newRectangle = new Rectangle(10, 10);
eventExit(rectangle, newRectangle);
}
示例6: autoFocusPolygonAnimated
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private void autoFocusPolygonAnimated(final LocationPolygon polygon) {
final double xScale = (foregroundPane.getBoundingBox().getWidth() / polygon.prefWidth(0))
* Constants.ZOOM_FIT_PERCENTAGE_WIDTH;
final double yScale = (foregroundPane.getBoundingBox().getHeight() / polygon.prefHeight(0))
* Constants.ZOOM_FIT_PERCENTAGE_HEIGHT;
final double scale = (xScale < yScale) ? xScale : yScale;
final ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(500));
scaleTransition.setToX(scale);
scaleTransition.setToY(scale);
scaleTransition.setCycleCount(1);
scaleTransition.setAutoReverse(true);
final Point2D transition = calculateTransition(scale, polygon);
final TranslateTransition translateTransition = new TranslateTransition(Duration.millis(500));
translateTransition.setToX(transition.getX());
translateTransition.setToY(transition.getY());
translateTransition.setCycleCount(1);
translateTransition.setAutoReverse(true);
final ParallelTransition parallelTransition
= new ParallelTransition(this, scaleTransition, translateTransition);
parallelTransition.play();
}
示例7: createMiddleContent
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private Node createMiddleContent() {
String title = "MKX Menu App";
HBox letters = new HBox(0);
letters.setAlignment(Pos.CENTER);
for (int i = 0; i < title.length(); i++) {
Text letter = new Text(title.charAt(i) + "");
letter.setFont(FONT);
letter.setFill(Color.WHITE);
letters.getChildren().add(letter);
TranslateTransition tt = new TranslateTransition(Duration.seconds(2), letter);
tt.setDelay(Duration.millis(i * 50));
tt.setToY(-25);
tt.setAutoReverse(true);
tt.setCycleCount(TranslateTransition.INDEFINITE);
tt.play();
}
return letters;
}
示例8: panelShake
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
/**
* Shake a panel in the event of an error.
*
* @param pane the pane to shake
*/
public static void panelShake(Pane pane) {
int duration = 100;
int count = 2;
TranslateTransition transition1 = new TranslateTransition(Duration.millis(duration), pane);
transition1.setFromX(0);
transition1.setToX(-5);
transition1.setInterpolator(Interpolator.LINEAR);
TranslateTransition transition2 = new TranslateTransition(Duration.millis(duration), pane);
transition2.setFromX(-5);
transition2.setToX(5);
transition2.setDelay(Duration.millis(duration));
transition2.setInterpolator(Interpolator.LINEAR);
transition2.setCycleCount(count);
TranslateTransition transition3 = new TranslateTransition(Duration.millis(duration), pane);
transition3.setToX(0);
transition3.setDelay(Duration.millis((count + 1) * duration));
transition3.setInterpolator(Interpolator.LINEAR);
transition1.play();
transition2.play();
transition3.play();
}
示例9: 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());
}
});
}
示例10: 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();
}
示例11: selectedStateChanged
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private void selectedStateChanged() {
TranslateTransition transition = new TranslateTransition(Duration.millis(100), thumb);
double thumbAreaWidth = snapSize(thumbArea.prefWidth(-1));
double thumbWidth = snapSize(thumb.prefWidth(-1));
if (!getSkinnable().isSelected())
transition.setByX(-(thumbAreaWidth - thumbWidth));
else {
transition.setByX(thumbAreaWidth - thumbWidth);
}
transition.setCycleCount(1);
transition.play();
}
示例12: initialize
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
log(CMPDL.title());
log("Java version " + System.getProperty("java.version"));
destinationPath.setText(System.getProperty("user.home") + File.separator + "modpack");
if (System.getProperty("os.name").toLowerCase().contains("win")) {
TranslateTransition transition = new TranslateTransition(Duration.seconds(1), title);
transition.setFromY(-10);
transition.setToY(10);
transition.setCycleCount(Animation.INDEFINITE);
transition.setAutoReverse(true);
transition.play();
}
}
示例13: Shaker
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
public Shaker(Node node) {
tt = new TranslateTransition(Duration.millis(100), node);
tt.setFromX(0f);
tt.setByX(6f);
tt.setCycleCount(4);
tt.setAutoReverse(true);
}
示例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);
}
示例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);
}