Pro JavaFX Platform Chap1. Ex1.

2009년 8월 6일 목요일

HelloEarthRise

image

package projavafx.helloearthrise.ui;

import javafx.animation.transition.TranslateTransition;
import javafx.animation.*;
import javafx.stage.Stage;
import javafx.scene.*;
import javafx.scene.image.*;
import javafx.scene.media.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.*;

var textRef:Text;

// Provides the animated scrolling behavior for the text
var transTransition = TranslateTransition {
duration: 75s
node: bind textRef
toY: -820
interpolator: Interpolator.LINEAR
repeatCount: Timeline.INDEFINITE
}

Stage {
title: "Hello Earthrise"
scene: Scene {
content: [
ImageView {
image: Image {
url: "
http://projavafx.com/images/earthrise.jpg"
}
},

Group {
layoutX: 50
layoutY: 180
content: [
textRef = Text {
layoutY: 100
textOrigin: TextOrigin.TOP
textAlignment: TextAlignment.JUSTIFY
wrappingWidth: 380
// Note that this syntax creates one long string of text
content:
"Earthrise at Christmas: "
"[Forty] years ago this Christmas, a turbulent world "
"looked to the heavens for a unique view of our home "
"planet. This photo of Earthrise over the lunar horizon "
"was taken by the Apollo 8 crew in December 1968, showing "
"Earth for the first time as it appears from deep space. "
"Astronauts Frank Borman, Jim Lovell and William Anders "
"had become the first humans to leave Earth orbit, "
"entering lunar orbit on Christmas Eve. In a historic live "
"broadcast that night, the crew took turns reading from "
"the Book of Genesis, closing with a holiday wish from "
"Commander Borman: \"We close with good night, good luck, "
"a Merry Christmas, and God bless all of you -- all of "
"you on the good Earth.\""
//The approximate color used in the scrolling Star Wars intro
fill: Color.rgb(187, 195, 107)
font: Font.font("SansSerif", FontWeight.BOLD, 24);
}
]
clip:
Rectangle {
width: 430
height: 85
}
}
]
}
}
// Start playing an audio clip
MediaPlayer {
autoPlay: true
repeatCount: MediaPlayer.REPEAT_FOREVER
media: Media {
source: "
http://projavafx.com/audio/zarathustra.mid"
}
}
// Start the text animation
transTransition.play();

0 개의 댓글: