/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER 
 * Copyright  2008, 2010 Oracle and/or its affiliates.  All rights reserved. 
 * Use is subject to license terms.
 * 
 * This file is available and licensed under the following license:
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met: 
 * 
 *   * Redistributions of source code must retain the above copyright notice, 
 *     this list of conditions and the following disclaimer. 
 *
 *   * Redistributions in binary form must reproduce the above copyright notice,
 *     this list of conditions and the following disclaimer in the documentation
 *     and/or other materials provided with the distribution.
 *
 *   * Neither the name of Oracle Corporation nor the names of its contributors 
 *     may be used to endorse or promote products derived from this software 
 *     without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

/*
 * DialInterface.fx
 *
 * Created on Apr 24, 2009, 10:55:22 PM
 */

package fxaddressbook;

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.input.MouseEvent;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
import javafx.animation.Interpolator;
import javafx.scene.shape.Circle;

    //@author JavaFX Samples Team

    // Interface for Dialing Phone no.
public class DialInterface extends CustomNode {
    var circle1:Circle = null;
    var circle2:Circle = null;
    var circle3:Circle = null;
    var phoneNumber:String = null;
    var alertColor:Color = Color.WHITE;
    var message:String = "This is an interface only !";
    var grDialing:Group = Group {
        translateX: 50
        translateY: 70
        content: [
            //Dialing text with animation.
            Text {
                fill: Color.WHITE
                font:Font {
                    name: "Arial"
                    size: 15
                }
                x: 0
                y: 20
                content: "Dialing"
            }
            circle1 = Circle {
                visible: false
                centerX: 50,
                centerY: 15
                radius: 2
                fill: Color.WHITE
            }
            circle2 = Circle {
                visible: false
                centerX: 60,
                centerY: 15
                radius: 2
                fill: Color.WHITE
            }
            circle3 = Circle {
                visible: false
                centerX: 70,
                centerY: 15
                radius: 2
                fill: Color.WHITE
            }
            Text {
                fill: Color.WHITE
                font:Font {
                    name: "Arial"
                    size: 13
                }
                x: 0
                y: 40
                content: bind phoneNumber
            }
        ]
    }

    var grAlert:Group = Group{
        translateX: 50
        translateY: 200
        content: [
            Text {
                fill: bind alertColor
                font:Font {
                    size: 12
                    name: "Arial Bold"
                }
                textAlignment: TextAlignment.CENTER
                content: message
            }
        ]
    }

    public function showPhone(ph:String):Void{
        this.phoneNumber = ph;
    }

    public function startDialing():Void{
        Timeline {
            repeatCount: 1
            keyFrames: [
                KeyFrame {
                    time: 0s
                    action:function(){
                        dialTime.playFromStart();
                        grAlert.visible = false;
                    }
                },
                KeyFrame {
                    time: 5s
                    action:function(){
                        dialTime.stop();
                        grAlert.visible = true;
                        alertTime.playFromStart();
                    }
                }
            ]
        }.playFromStart();
        var dialTime = Timeline {
            repeatCount: 20
            keyFrames: [
                KeyFrame {
                    time: 300ms
                    values: [
                        circle1.visible => true tween Interpolator.LINEAR
                    ]
                },
                KeyFrame {
                    time: 600ms
                    values: [
                        circle2.visible => true tween Interpolator.LINEAR
                    ]
                },
                KeyFrame {
                    time: 900ms
                    values: [
                        circle3.visible => true tween Interpolator.LINEAR
                    ]
                },
                KeyFrame {
                    time: 1200ms
                    values: [
                        circle1.visible => false tween Interpolator.LINEAR,
                        circle2.visible => false tween Interpolator.LINEAR,
                        circle3.visible => false tween Interpolator.LINEAR
                    ]
                }
            ]
        };

        var alertTime = Timeline {
            repeatCount: 10
            keyFrames: [
                KeyFrame {
                    time: 250ms
                    action:function() {
                        alertColor = Color.GRAY
                    }
                },
                KeyFrame {
                    time: 500ms
                    action:function() {
                        alertColor = Color.WHITE
                    }
                }
            ]
        }
    }

    public override function create():Node {
        return Group {
            content: [
                Rectangle {
                    x: 0
                    y: 0
                    width: 240
                    height: 320
                    fill: Color.BLACK
                },
                grAlert,
                grDialing,
                 // Close button in title bar
                Rectangle {
                    blocksMouse: true
                    x: 215
                    y: 3
                    arcHeight: 4
                    arcWidth: 4
                    width: 20
                    height: 20
                    stroke: Color.GRAY
                    strokeWidth: 2
                    onMouseClicked:function(e:MouseEvent):Void {
                        this.visible = false;
                    }
                }
                // Close button 'x' in title bar
                Text {
                    fill: Color.WHITE
                    font:Font {
                        name: "Arial Bold"
                        size: 18
                    }
                    x: 220,
                    y: 19
                    content: "x"
                }
            ]
        };
    }
}
JavaFX Sample

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER 
 * Copyright  2008, 2010 Oracle and/or its affiliates.  All rights reserved. 
 * Use is subject to license terms.
 * 
 * This file is available and licensed under the following license:
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met: 
 * 
 *   * Redistributions of source code must retain the above copyright notice, 
 *     this list of conditions and the following disclaimer. 
 *
 *   * Redistributions in binary form must reproduce the above copyright notice,
 *     this list of conditions and the following disclaimer in the documentation
 *     and/or other materials provided with the distribution.
 *
 *   * Neither the name of Oracle Corporation nor the names of its contributors 
 *     may be used to endorse or promote products derived from this software 
 *     without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

/*
 * DialInterface.fx
 *
 * Created on Apr 24, 2009, 10:55:22 PM
 */

package fxaddressbook;

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.input.MouseEvent;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
import javafx.animation.Interpolator;
import javafx.scene.shape.Circle;

    //@author JavaFX Samples Team

    // Interface for Dialing Phone no.
public class DialInterface extends CustomNode {
    var circle1:Circle = null;
    var circle2:Circle = null;
    var circle3:Circle = null;
    var phoneNumber:String = null;
    var alertColor:Color = Color.WHITE;
    var message:String = "This is an interface only !";
    var grDialing:Group = Group {
        translateX: 50
        translateY: 70
        content: [
            //Dialing text with animation.
            Text {
                fill: Color.WHITE
                font:Font {
                    name: "Arial"
                    size: 15
                }
                x: 0
                y: 20
                content: "Dialing"
            }
            circle1 = Circle {
                visible: false
                centerX: 50,
                centerY: 15
                radius: 2
                fill: Color.WHITE
            }
            circle2 = Circle {
                visible: false
                centerX: 60,
                centerY: 15
                radius: 2
                fill: Color.WHITE
            }
            circle3 = Circle {
                visible: false
                centerX: 70,
                centerY: 15
                radius: 2
                fill: Color.WHITE
            }
            Text {
                fill: Color.WHITE
                font:Font {
                    name: "Arial"
                    size: 13
                }
                x: 0
                y: 40
                content: bind phoneNumber
            }
        ]
    }

    var grAlert:Group = Group{
        translateX: 50
        translateY: 200
        content: [
            Text {
                fill: bind alertColor
                font:Font {
                    size: 12
                    name: "Arial Bold"
                }
                textAlignment: TextAlignment.CENTER
                content: message
            }
        ]
    }

    public function showPhone(ph:String):Void{
        this.phoneNumber = ph;
    }

    public function startDialing():Void{
        Timeline {
            repeatCount: 1
            keyFrames: [
                KeyFrame {
                    time: 0s
                    action:function(){
                        dialTime.playFromStart();
                        grAlert.visible = false;
                    }
                },
                KeyFrame {
                    time: 5s
                    action:function(){
                        dialTime.stop();
                        grAlert.visible = true;
                        alertTime.playFromStart();
                    }
                }
            ]
        }.playFromStart();
        var dialTime = Timeline {
            repeatCount: 20
            keyFrames: [
                KeyFrame {
                    time: 300ms
                    values: [
                        circle1.visible => true tween Interpolator.LINEAR
                    ]
                },
                KeyFrame {
                    time: 600ms
                    values: [
                        circle2.visible => true tween Interpolator.LINEAR
                    ]
                },
                KeyFrame {
                    time: 900ms
                    values: [
                        circle3.visible => true tween Interpolator.LINEAR
                    ]
                },
                KeyFrame {
                    time: 1200ms
                    values: [
                        circle1.visible => false tween Interpolator.LINEAR,
                        circle2.visible => false tween Interpolator.LINEAR,
                        circle3.visible => false tween Interpolator.LINEAR
                    ]
                }
            ]
        };

        var alertTime = Timeline {
            repeatCount: 10
            keyFrames: [
                KeyFrame {
                    time: 250ms
                    action:function() {
                        alertColor = Color.GRAY
                    }
                },
                KeyFrame {
                    time: 500ms
                    action:function() {
                        alertColor = Color.WHITE
                    }
                }
            ]
        }
    }

    public override function create():Node {
        return Group {
            content: [
                Rectangle {
                    x: 0
                    y: 0
                    width: 240
                    height: 320
                    fill: Color.BLACK
                },
                grAlert,
                grDialing,
                 // Close button in title bar
                Rectangle {
                    blocksMouse: true
                    x: 215
                    y: 3
                    arcHeight: 4
                    arcWidth: 4
                    width: 20
                    height: 20
                    stroke: Color.GRAY
                    strokeWidth: 2
                    onMouseClicked:function(e:MouseEvent):Void {
                        this.visible = false;
                    }
                }
                // Close button 'x' in title bar
                Text {
                    fill: Color.WHITE
                    font:Font {
                        name: "Arial Bold"
                        size: 18
                    }
                    x: 220,
                    y: 19
                    content: "x"
                }
            ]
        };
    }
}
JavaFX Sample

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER 
 * Copyright  2008, 2010 Oracle and/or its affiliates.  All rights reserved. 
 * Use is subject to license terms.
 * 
 * This file is available and licensed under the following license:
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met: 
 * 
 *   * Redistributions of source code must retain the above copyright notice, 
 *     this list of conditions and the following disclaimer. 
 *
 *   * Redistributions in binary form must reproduce the above copyright notice,
 *     this list of conditions and the following disclaimer in the documentation
 *     and/or other materials provided with the distribution.
 *
 *   * Neither the name of Oracle Corporation nor the names of its contributors 
 *     may be used to endorse or promote products derived from this software 
 *     without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

/*
 * DialInterface.fx
 *
 * Created on Apr 24, 2009, 10:55:22 PM
 */

package fxaddressbook;

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.input.MouseEvent;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
import javafx.animation.Interpolator;
import javafx.scene.shape.Circle;

    //@author JavaFX Samples Team

    // Interface for Dialing Phone no.
public class DialInterface extends CustomNode {
    var circle1:Circle = null;
    var circle2:Circle = null;
    var circle3:Circle = null;
    var phoneNumber:String = null;
    var alertColor:Color = Color.WHITE;
    var message:String = "This is an interface only !";
    var grDialing:Group = Group {
        translateX: 50
        translateY: 70
        content: [
            //Dialing text with animation.
            Text {
                fill: Color.WHITE
                font:Font {
                    name: "Arial"
                    size: 15
                }
                x: 0
                y: 20
                content: "Dialing"
            }
            circle1 = Circle {
                visible: false
                centerX: 50,
                centerY: 15
                radius: 2
                fill: Color.WHITE
            }
            circle2 = Circle {
                visible: false
                centerX: 60,
                centerY: 15
                radius: 2
                fill: Color.WHITE
            }
            circle3 = Circle {
                visible: false
                centerX: 70,
                centerY: 15
                radius: 2
                fill: Color.WHITE
            }
            Text {
                fill: Color.WHITE
                font:Font {
                    name: "Arial"
                    size: 13
                }
                x: 0
                y: 40
                content: bind phoneNumber
            }
        ]
    }

    var grAlert:Group = Group{
        translateX: 50
        translateY: 200
        content: [
            Text {
                fill: bind alertColor
                font:Font {
                    size: 12
                    name: "Arial Bold"
                }
                textAlignment: TextAlignment.CENTER
                content: message
            }
        ]
    }

    public function showPhone(ph:String):Void{
        this.phoneNumber = ph;
    }

    public function startDialing():Void{
        Timeline {
            repeatCount: 1
            keyFrames: [
                KeyFrame {
                    time: 0s
                    action:function(){
                        dialTime.playFromStart();
                        grAlert.visible = false;
                    }
                },
                KeyFrame {
                    time: 5s
                    action:function(){
                        dialTime.stop();
                        grAlert.visible = true;
                        alertTime.playFromStart();
                    }
                }
            ]
        }.playFromStart();
        var dialTime = Timeline {
            repeatCount: 20
            keyFrames: [
                KeyFrame {
                    time: 300ms
                    values: [
                        circle1.visible => true tween Interpolator.LINEAR
                    ]
                },
                KeyFrame {
                    time: 600ms
                    values: [
                        circle2.visible => true tween Interpolator.LINEAR
                    ]
                },
                KeyFrame {
                    time: 900ms
                    values: [
                        circle3.visible => true tween Interpolator.LINEAR
                    ]
                },
                KeyFrame {
                    time: 1200ms
                    values: [
                        circle1.visible => false tween Interpolator.LINEAR,
                        circle2.visible => false tween Interpolator.LINEAR,
                        circle3.visible => false tween Interpolator.LINEAR
                    ]
                }
            ]
        };

        var alertTime = Timeline {
            repeatCount: 10
            keyFrames: [
                KeyFrame {
                    time: 250ms
                    action:function() {
                        alertColor = Color.GRAY
                    }
                },
                KeyFrame {
                    time: 500ms
                    action:function() {
                        alertColor = Color.WHITE
                    }
                }
            ]
        }
    }

    public override function create():Node {
        return Group {
            content: [
                Rectangle {
                    x: 0
                    y: 0
                    width: 240
                    height: 320
                    fill: Color.BLACK
                },
                grAlert,
                grDialing,
                 // Close button in title bar
                Rectangle {
                    blocksMouse: true
                    x: 215
                    y: 3
                    arcHeight: 4
                    arcWidth: 4
                    width: 20
                    height: 20
                    stroke: Color.GRAY
                    strokeWidth: 2
                    onMouseClicked:function(e:MouseEvent):Void {
                        this.visible = false;
                    }
                }
                // Close button 'x' in title bar
                Text {
                    fill: Color.WHITE
                    font:Font {
                        name: "Arial Bold"
                        size: 18
                    }
                    x: 220,
                    y: 19
                    content: "x"
                }
            ]
        };
    }
}