Simple Animation

/*
* Main.fx
*
* Created on 2010-jul-26, 14:20:23
*/
package fallingtext;

/**
 * @author Henrik "Berra" Samuelsson
 */
public class Main {

    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    def __layoutInfo_button: javafx.scene.layout.LayoutInfo = javafx.scene.layout.LayoutInfo {
        width: 75.0
    }
    public-read def button: javafx.scene.control.Button = javafx.scene.control.Button {
        visible: true
        layoutX: 200.0
        layoutY: 150.0
        layoutInfo: __layoutInfo_button
        text: "Drop it"
        action: buttonActionAtStart
    }
    
    def __layoutInfo_button2: javafx.scene.layout.LayoutInfo = javafx.scene.layout.LayoutInfo {
        width: 75.0
    }
    public-read def button2: javafx.scene.control.Button = javafx.scene.control.Button {
        visible: true
        layoutX: 200.0
        layoutY: 150.0
        layoutInfo: __layoutInfo_button2
        text: "Lift it"
        action: button2ActionAtEnd
    }
    
    public-read def kableFont: javafx.scene.text.Font = javafx.scene.text.Font {
        name: "Kabel Ult BT"
        size: 100.0
        oblique: true
        embolden: true
    }
    
    public-read def redStrokeColor: javafx.scene.paint.Color = javafx.scene.paint.Color {
        red: 0.6
        green: 0.2
    }
    
    public-read def pointLight: javafx.scene.effect.light.PointLight = javafx.scene.effect.light.PointLight {
        x: 100.0
        y: 30.0
        z: 120.0
    }
    
    public-read def lightingEffect: javafx.scene.effect.Lighting = javafx.scene.effect.Lighting {
        light: pointLight
        diffuseConstant: 0.8
        specularConstant: 0.8
        specularExponent: 14.8
        surfaceScale: 1.5
    }
    
    public-read def textBerra: javafx.scene.text.Text = javafx.scene.text.Text {
        layoutX: 105.0
        layoutY: 0.0
        effect: lightingEffect
        fill: javafx.scene.paint.Color.WHITE
        stroke: redStrokeColor
        strokeWidth: 5.0
        font: kableFont
        content: "Berra"
    }
    
    public-read def scene: javafx.scene.Scene = javafx.scene.Scene {
        width: 480.0
        height: 320.0
        content: getDesignRootNodes ()
    }
    
    public-read def currentState: org.netbeans.javafx.design.DesignState = org.netbeans.javafx.design.DesignState {
        names: [ "Start", "End", ]
        actual: 0
        timelines: [
            javafx.animation.Timeline {
                keyFrames: [
                    javafx.animation.KeyFrame {
                        time: 0ms
                        values: [
                            button.layoutX => button.layoutX tween javafx.animation.Interpolator.DISCRETE,
                            button.layoutY => button.layoutY tween javafx.animation.Interpolator.DISCRETE,
                            __layoutInfo_button.width => __layoutInfo_button.width tween javafx.animation.Interpolator.DISCRETE,
                            button2.layoutX => button2.layoutX tween javafx.animation.Interpolator.DISCRETE,
                            button2.layoutY => button2.layoutY tween javafx.animation.Interpolator.DISCRETE,
                            textBerra.layoutX => textBerra.layoutX tween javafx.animation.Interpolator.DISCRETE,
                            textBerra.layoutY => textBerra.layoutY tween javafx.animation.Interpolator.DISCRETE,
                        ]
                    }
                    javafx.animation.KeyFrame {
                        time: 2000ms
                        values: [
                            button.layoutX => 200.0 tween javafx.animation.Interpolator.LINEAR,
                            button.layoutY => 150.0 tween javafx.animation.Interpolator.LINEAR,
                            __layoutInfo_button.width => 75.0 tween javafx.animation.Interpolator.LINEAR,
                            button2.layoutX => 200.0 tween javafx.animation.Interpolator.LINEAR,
                            button2.layoutY => 150.0 tween javafx.animation.Interpolator.LINEAR,
                            textBerra.layoutX => 105.0 tween javafx.animation.Interpolator.LINEAR,
                            textBerra.layoutY => 80.0 tween javafx.animation.Interpolator.LINEAR,
                        ]
                        action: function() {
                            button.visible = true;
                            button.text = "Drop it";
                            button2.visible = false;
                        }
                    }
                ]
            }
            javafx.animation.Timeline {
                keyFrames: [
                    javafx.animation.KeyFrame {
                        time: 0ms
                        values: [
                            button.layoutX => button.layoutX tween javafx.animation.Interpolator.DISCRETE,
                            button.layoutY => button.layoutY tween javafx.animation.Interpolator.DISCRETE,
                            __layoutInfo_button.width => __layoutInfo_button.width tween javafx.animation.Interpolator.DISCRETE,
                            button2.layoutX => button2.layoutX tween javafx.animation.Interpolator.DISCRETE,
                            button2.layoutY => button2.layoutY tween javafx.animation.Interpolator.DISCRETE,
                            textBerra.layoutX => textBerra.layoutX tween javafx.animation.Interpolator.DISCRETE,
                            textBerra.layoutY => textBerra.layoutY tween javafx.animation.Interpolator.DISCRETE,
                        ]
                    }
                    javafx.animation.KeyFrame {
                        time: 400ms
                        values: [
                            button.layoutX => 200.0 tween javafx.animation.Interpolator.EASEIN,
                            button.layoutY => 150.0 tween javafx.animation.Interpolator.EASEIN,
                            __layoutInfo_button.width => 75.0 tween javafx.animation.Interpolator.EASEIN,
                            button2.layoutX => 200.0 tween javafx.animation.Interpolator.EASEIN,
                            button2.layoutY => 150.0 tween javafx.animation.Interpolator.EASEIN,
                            textBerra.layoutX => 105.0 tween javafx.animation.Interpolator.EASEIN,
                            textBerra.layoutY => 300.0 tween javafx.animation.Interpolator.EASEIN,
                        ]
                        action: function() {
                            button.visible = false;
                            button.text = "Lift it";
                            button2.visible = true;
                        }
                    }
                ]
            }
        ]
    }
    
    public function getDesignRootNodes (): javafx.scene.Node[] {
        [ button, button2, textBerra, ]
    }
    
    public function getDesignScene (): javafx.scene.Scene {
        scene
    }
    // </editor-fold>

    function button2ActionAtEnd(): Void {
        currentState.actual = currentState.findIndex("Start");
         }

   

    function buttonActionAtStart(): Void {
        currentState.actual = currentState.findIndex("End");
         }

}

function run (): Void {
    var design = Main {};

    javafx.stage.Stage {
        title: "Main"
        scene: design.getDesignScene ()
    }
}


Comments