Java Code Examples for javafx.animation.Timeline#playFromStart()
The following examples show how to use
javafx.animation.Timeline#playFromStart() .
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: PinDecoration.java From BlockMap with MIT License | 5 votes |
private void updateVisible() { byGroup.forEach(PinGroup::remove); byGroup.clear(); int i = 0; Timeline t = new Timeline(); for (PinRegion r : byRegion.values()) t.getKeyFrames().add(new KeyFrame(Duration.millis(1 * i++), e -> r.updateVisible())); t.playFromStart(); }
Example 2
Source File: Toast.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
private void doShow() { LOGGER.info("show toast: {}", this); if (window != null) { if (autoCenter) { connectAutoCenterHandler(); } if (Double.isNaN(screenX) || Double.isNaN(screenY)) { super.show(window); } else { super.show(window, screenX, screenY); } } else { // anchor if (autoCenter) { Scene scene = anchor.getScene(); if (scene != null) { window = scene.getWindow(); } if (window == null) { throw new IllegalStateException("anchor node is not attached to a window"); } connectAutoCenterHandler(); } super.show(anchor, Double.isNaN(screenX) ? 0.0 : screenX, Double.isNaN(screenY) ? 0.0 : screenY); } if (isAutoHide() && !duration.isIndefinite()) { hideTimer = new Timeline(new KeyFrame(duration)); hideTimer.setOnFinished((ActionEvent event) -> { hideTimer = null; Toast.this.hide(); }); hideTimer.playFromStart(); } FadeTransition transition = new FadeTransition(fadeInDuration, content); transition.setFromValue(0.0); transition.setToValue(contentOpacity); transition.play(); }
Example 3
Source File: WaitMessageDialog.java From marathonv5 with Apache License 2.0 | 5 votes |
public void _show() { timeSeconds.set(STARTTIME); timeline = new Timeline(); KeyValue keyValue = new KeyValue(timeSeconds, Integer.MAX_VALUE); timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(Integer.MAX_VALUE), keyValue)); timeline.playFromStart(); show(); }
Example 4
Source File: DashboardController.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public void createTimer() { // Bind the timerLabel text property to the timeSeconds property timerLabel = new Label(); timerLabel.textProperty().bind(timeSeconds.asString()); timerLabel.setTextFill(Color.WHITE); //timerLabel.setStyle("-fx-font-size: 4em;"); timeSeconds.set(STARTTIME); timeline = new Timeline(); timeline.getKeyFrames().add( new KeyFrame(Duration.seconds(STARTTIME+1), new KeyValue(timeSeconds, 0))); timeline.playFromStart(); btnRefresh = new JFXButton(); btnRefresh.setText("Refresh"); btnRefresh.setOnAction(e -> handleRefresh()); // btnRefresh.setOnAction(new EventHandler<ActionEvent>() { // // public void handle(ActionEvent event) { // if (timeline != null) { // timeline.stop(); // } // timeSeconds.set(STARTTIME); // timeline = new Timeline(); // timeline.getKeyFrames().add( // new KeyFrame(Duration.seconds(STARTTIME+1), // new KeyValue(timeSeconds, 0))); // timeline.playFromStart(); // } // }); }
Example 5
Source File: CameraTransformer.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public void transitionCameraTo(double milliseconds, double tx, double ty, double tz, double rx, double ry, double rz) { final Timeline timeline = new Timeline(); timeline.getKeyFrames().addAll(new KeyFrame[]{ new KeyFrame(Duration.millis(milliseconds), new KeyValue[]{// Frame End new KeyValue(xRotateProperty(), rx, Interpolator.EASE_BOTH), new KeyValue(yRotateProperty(), ry, Interpolator.EASE_BOTH), new KeyValue(zRotateProperty(), rz, Interpolator.EASE_BOTH), new KeyValue(xTranslateProperty(), tx, Interpolator.EASE_BOTH), new KeyValue(yTranslateProperty(), ty, Interpolator.EASE_BOTH), new KeyValue(zTranslateProperty(), tz, Interpolator.EASE_BOTH) }) }); timeline.playFromStart(); }
Example 6
Source File: Rubik.java From RubikFX with GNU General Public License v3.0 | 4 votes |
private void rotateFace(final String btRot, boolean bPreview, boolean bCancel){ if(onRotation.get()){ return; } onRotation.set(true); System.out.println((bPreview?(bCancel?"Cancelling: ":"Simulating: "):"Rotating: ")+btRot); boolean bFaceArrow= !(btRot.startsWith("X")||btRot.startsWith("Y")||btRot.startsWith("Z")); if(bPreview || onScrambling.get() || onReplaying.get() || secondRotation){ // rotate cube indexes rot.turn(btRot); // get new indexes in terms of blocks numbers from original order reorder=rot.getCube(); // select cubies to rotate: those in reorder different from order. if(!bFaceArrow){ layer=reorder.stream().collect(Collectors.toList()); }else { AtomicInteger index = new AtomicInteger(); layer=order.stream() .filter(o->!Objects.equals(o, reorder.get(index.getAndIncrement()))) .collect(Collectors.toList()); // add central cubie layer.add(0,reorder.get(Utils.getCenter(btRot))); } // set rotation axis axis=Utils.getAxis(btRot); } // define rotation double angIni=(bPreview || onScrambling.get() || onReplaying.get() || secondRotation?0d:5d)*(btRot.endsWith("i")?1d:-1d); double angEnd=(bPreview?5d:90d)*(btRot.endsWith("i")?1d:-1d); rotation.set(angIni); rotation.addListener(rotMap); // create animation Timeline timeline=new Timeline(); timeline.getKeyFrames().add( new KeyFrame(Duration.millis(onScrambling.get() || onReplaying.get()?200:(bPreview?100:600)), e->{ rotation.removeListener(rotMap); secondRotation=false; if(bPreview){ if(bCancel){ previewFace.set(""); onPreview.set(false); } else if(mouse.get()==MOUSE_RELEASED){ // early released, rotate back mouse.set(MOUSE_OUT); onRotation.set(false); updateArrow(btRot,false); } else { previewFace.set(btRot); } } else if(!(onScrambling.get() || onReplaying.get())){ // complete rotation mouse.set(MOUSE_OUT); previewFace.set("V"); if(!hoveredOnClick.get()){ // lost hover event, trigger it to clean up updateArrow(btRot,false); } else { // at the end of rotation, still hovered, if it's clicked again, it's a second rotation secondRotation=true; } hoveredOnClick.set(false); } onRotation.set(false); }, new KeyValue(rotation,angEnd))); timeline.playFromStart(); if(bPreview || onScrambling.get() || onReplaying.get() || secondRotation){ // update order with last list, to start all over again in the next rotation order=reorder.stream().collect(Collectors.toList()); } // count only face rotations not cube rotations if(!bPreview && !onScrambling.get() && bFaceArrow){ count.set(count.get()+1); // check if solved solved.set(Utils.checkSolution(order)); } }