/**
* Program for Photo Flip in javafx 2.0
*/
package flip;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
import javafx.util.Duration;
/**
* @author sakura
*
*/
public class ImageDisplay extends Application
{
private Timeline anim;
public ImageDisplay()
{
anim = new Timeline();
}
public ImageView create()
{
ImageView view = new ImageView(new Image("C:\\Users\\sakura\\Desktop\\player1.png",false));
view.setTranslateX(50);
view.setTranslateY(90);
KeyFrame frame = new KeyFrame(Duration.millis(1), new KeyValue(view.scaleXProperty(), -1, Interpolator.LINEAR));
anim.getKeyFrames().addAll(frame);//,frame1);
anim.setRate(1);
anim.play();
return view;
}
public Group root()
{
Group root = new Group();
root.getChildren().add(create());
return root;
}
@Override
public void start(Stage stage)
{
Scene scene = new Scene(root(),800,600);
stage.setScene(scene);
//stage.setFullScreen(true);
stage.show();
}
public static void main(String []args)
{
launch(args);
}
}