Search in sources :

Example 16 with Duration

use of javafx.util.Duration in project latexdraw by arnobl.

the class Canvas method setZoom.

@Override
public void setZoom(final double x, final double y, final double z) {
    if (z <= getMaxZoom() && z >= getMinZoom() && !MathUtils.INST.equalsDouble(z, zoom.getValue())) {
        zoom.setValue(z);
        final Duration duration = Duration.millis(250);
        final ParallelTransition parallelTransition = new ParallelTransition();
        parallelTransition.getChildren().addAll(new Timeline(new KeyFrame(duration, new KeyValue(scaleYProperty(), z))), new Timeline(new KeyFrame(duration, new KeyValue(scaleXProperty(), z))));
        parallelTransition.play();
        setModified(true);
    }
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) Duration(javafx.util.Duration) ParallelTransition(javafx.animation.ParallelTransition)

Example 17 with Duration

use of javafx.util.Duration in project org.csstudio.display.builder by kasemir.

the class TooltipSupport method hack_behavior.

private static void hack_behavior(final Object behavior, final String aspect, final int ms) throws Exception {
    final Field field = behavior.getClass().getDeclaredField(aspect);
    field.setAccessible(true);
    final Timeline timer = (Timeline) field.get(behavior);
    timer.getKeyFrames().clear();
    timer.getKeyFrames().add(new KeyFrame(new Duration(ms)));
    logger.log(Level.FINE, "Set Tooltip " + aspect + " to " + ms + " ms");
}
Also used : Field(java.lang.reflect.Field) Timeline(javafx.animation.Timeline) KeyFrame(javafx.animation.KeyFrame) Duration(javafx.util.Duration)

Example 18 with Duration

use of javafx.util.Duration in project contentment by GeePawHill.

the class VideoPlayerExperiment method start.

@Override
public void start(Stage stage) throws Exception {
    Media media = new Media(new File("../core/src/main/resources/blackHandbraked.mp4").toURI().toString());
    MediaPlayer player = new MediaPlayer(media);
    player.pause();
    player.setCycleCount(Integer.MAX_VALUE);
    MediaView mediaView = new MediaView(player);
    mediaView.setFitWidth(1280d);
    BorderPane pane = new BorderPane();
    pane.setCenter(mediaView);
    ToolBar tools = new ToolBar();
    Text total = new Text("TOTAL");
    total.setStroke(Color.WHITE);
    total.setFill(Color.BLUE);
    total.setFont(new Font("Buxton Sketch", 60d));
    tools.getItems().add(total);
    Text time = new Text("HI MOM!");
    time.setStroke(Color.WHITE);
    time.setFill(Color.BLUE);
    time.setFont(new Font("Buxton Sketch", 60d));
    tools.getItems().add(time);
    pane.setTop(tools);
    player.currentTimeProperty().addListener(new ChangeListener<Duration>() {

        @Override
        public void changed(ObservableValue<? extends Duration> observable, Duration oldValue, Duration newValue) {
            double elapsed = ((double) player.getCurrentCount()) * player.getCycleDuration().toMillis() + newValue.toMillis();
            time.setText("" + elapsed);
            total.setText(player.getCycleDuration().toString());
        }
    });
    player.setOnEndOfMedia(() -> System.out.println("End"));
    stage.setScene(new Scene(pane));
    stage.show();
    player.play();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) Media(javafx.scene.media.Media) Text(javafx.scene.text.Text) Duration(javafx.util.Duration) Scene(javafx.scene.Scene) MediaView(javafx.scene.media.MediaView) Font(javafx.scene.text.Font) ToolBar(javafx.scene.control.ToolBar) File(java.io.File) MediaPlayer(javafx.scene.media.MediaPlayer)

Example 19 with Duration

use of javafx.util.Duration in project Board-Instrumentation-Framework by intel.

the class DynamicTransition method ReadTransitionInformation.

public static DynamicTransition ReadTransitionInformation(FrameworkNode baseNode) {
    DynamicTransition.Transition _TransitionType = DynamicTransition.Transition.NONE;
    int _Transition_xGridCount = 10;
    int _Transition_yGridCount = 10;
    int _Transition_Delay = 100;
    Color _Transition_Snapshot_Color_bg = Color.TRANSPARENT;
    Duration _Transition_Duration = Duration.millis(1500);
    for (FrameworkNode node : baseNode.getChildNodes()) {
        if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#Comment")) {
            continue;
        }
        if (node.getNodeName().equalsIgnoreCase("Transition")) {
            String strTransition = node.getTextContent();
            _TransitionType = DynamicTransition.VerifyTransitionType(strTransition);
            if (_TransitionType == DynamicTransition.Transition.INVALID) {
                LOGGER.severe("Invalid Transition [" + strTransition + "] specified.  Valid values are: " + DynamicTransition.names());
                return null;
            }
            if (node.hasAttribute("xGrids")) {
                _Transition_xGridCount = node.getIntegerAttribute("xGrids", 0);
                if (_Transition_xGridCount <= 0) {
                    LOGGER.severe("Invlid xGrids value for Transition: " + node.getAttribute("xGrids"));
                    return null;
                }
            }
            if (node.hasAttribute("yGrids")) {
                _Transition_yGridCount = node.getIntegerAttribute("yGrids", 0);
                if (_Transition_yGridCount <= 0) {
                    LOGGER.severe("Invlid yGrids value for Transition: " + node.getAttribute("yGrids"));
                    return null;
                }
            }
            if (node.hasAttribute("Duration")) {
                int Transition_Duration = node.getIntegerAttribute("Duration", 0);
                if (Transition_Duration <= 0) {
                    LOGGER.severe("Invlid Duration value for Transition: " + node.getAttribute("Duration"));
                    return null;
                }
                _Transition_Duration = Duration.millis(Transition_Duration);
            }
            if (node.hasAttribute("Delay")) {
                _Transition_Delay = node.getIntegerAttribute("Delay", 0);
                if (_Transition_Delay <= 0) {
                    LOGGER.severe("Invlid Delay value for Transition: " + node.getAttribute("Delay"));
                    return null;
                }
            }
        // nuking this, s not really needed anymore
        // if (node.hasAttribute("Background"))
        // {
        // String strColor = node.getAttribute("Background");
        // try
        // {
        // _Transition_Snapshot_Color_bg = Color.web(strColor);
        // }
        // catch (Exception e)
        // {
        // LOGGER.severe("Invalid Background value for getTransition: " + strColor);
        // return false;
        // }
        // }
        }
    }
    DynamicTransition objTransition = new DynamicTransition(_TransitionType);
    objTransition.setDelay(_Transition_Delay);
    objTransition.setDuration(_Transition_Duration);
    objTransition.setNoOfTilesX(_Transition_xGridCount);
    objTransition.setNoOfTilesY(_Transition_yGridCount);
    objTransition.setSnapshotColor(_Transition_Snapshot_Color_bg);
    // _objTransition = objTransition;
    return objTransition;
}
Also used : Color(javafx.scene.paint.Color) Duration(javafx.util.Duration) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 20 with Duration

use of javafx.util.Duration in project lttng-scope by lttng.

the class LoadingOverlay method fadeOut.

public synchronized void fadeOut() {
    if (fCurrentFadeOut != null) {
        /* We're already fading out, let it continue. */
        return;
    }
    if (fCurrentFadeIn != null) {
        fCurrentFadeIn.pause();
        fCurrentFadeIn = null;
    }
    double fullOpacity = fOpts.loadingOverlayFullOpacity.get();
    double transparentOpacity = fOpts.loadingOverlayTransparentOpacity.get();
    double fullFadeOutDuration = fOpts.loadingOverlayFadeOutDuration.get();
    double startOpacity = getOpacity();
    /* Do a rule-of-three to determine the duration of fade-in we need. */
    double neededDuration = (startOpacity / fullOpacity) * fullFadeOutDuration;
    FadeTransition fadeOut = new FadeTransition(new Duration(neededDuration), this);
    fadeOut.setFromValue(startOpacity);
    fadeOut.setToValue(transparentOpacity);
    fadeOut.play();
    fCurrentFadeOut = fadeOut;
}
Also used : FadeTransition(javafx.animation.FadeTransition) Duration(javafx.util.Duration)

Aggregations

Duration (javafx.util.Duration)26 KeyFrame (javafx.animation.KeyFrame)11 Timeline (javafx.animation.Timeline)11 Node (javafx.scene.Node)8 KeyValue (javafx.animation.KeyValue)6 Color (javafx.scene.paint.Color)6 List (java.util.List)5 InvalidationListener (javafx.beans.InvalidationListener)5 EventHandler (javafx.event.EventHandler)5 ArrayList (java.util.ArrayList)4 ActionEvent (javafx.event.ActionEvent)4 Image (javafx.scene.image.Image)4 ImageView (javafx.scene.image.ImageView)4 Region (javafx.scene.layout.Region)4 UnmodifiableListSet (com.sun.javafx.collections.UnmodifiableListSet)3 Direction (com.sun.javafx.scene.traversal.Direction)3 FadeTransition (javafx.animation.FadeTransition)3 Button (javafx.scene.control.Button)3 StackPane (javafx.scene.layout.StackPane)3 MediaFile (com.negativevr.media_library.files.MediaFile)2