1 /*
   2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  */
   5 package test.scenegraph.lcd.animation;
   6 
   7 import javafx.animation.Interpolator;
   8 import javafx.animation.KeyFrame;
   9 import javafx.animation.KeyValue;
  10 import javafx.animation.Timeline;
  11 import javafx.application.Application;
  12 import javafx.collections.FXCollections;
  13 import javafx.event.EventHandler;
  14 import javafx.scene.Scene;
  15 import javafx.scene.control.ChoiceBox;

  16 import javafx.scene.control.TextArea;

  17 import javafx.scene.input.MouseEvent;
  18 import javafx.scene.layout.Pane;
  19 import javafx.scene.layout.VBox;

  20 import javafx.scene.paint.Color;
  21 import javafx.scene.shape.Circle;

  22 import javafx.scene.text.FontSmoothingType;
  23 import javafx.scene.text.Text;

  24 import javafx.stage.Stage;
  25 import javafx.util.Duration;
  26 import test.javaclient.shared.Utils;
  27 
  28 /**
  29  *
  30  * @author Alexander Petrov
  31  */
  32 public class AnimationLCDTextTestApp extends Application {
  33 
  34     /**
  35      * @param args the command line arguments
  36      */
  37     public static void main(String[] args) {
  38         //launch(args);
  39         Utils.launch(AnimationLCDTextTestApp.class, args);
  40     }
  41 
  42     @Override
  43     public void start(Stage primaryStage) {
  44 
  45 
  46         final TextArea testText = new TextArea("Test");
  47         testText.setPrefHeight(50);
  48         testText.setPrefWidth(500);


  49 
  50         final ChoiceBox<Interpolator> interpolatorChoiceBox = new ChoiceBox<Interpolator>();
  51         interpolatorChoiceBox.getItems().addAll(FXCollections.observableArrayList(
  52                     Interpolator.LINEAR,
  53                     Interpolator.DISCRETE,
  54                     Interpolator.EASE_BOTH,
  55                     Interpolator.EASE_IN,
  56                     Interpolator.EASE_OUT
  57                     ));
  58         interpolatorChoiceBox.setPrefHeight(25);
  59         interpolatorChoiceBox.setPrefWidth(500);
  60 
  61         interpolatorChoiceBox.getSelectionModel().selectFirst();
  62 
  63 
  64         final Text lcdText = new Text();
  65         lcdText.setX(100);
  66         lcdText.setY(100);
  67         lcdText.setFontSmoothingType(FontSmoothingType.LCD);


  68         lcdText.textProperty().bind(testText.textProperty());
  69 
  70         final Circle point = new Circle(100, 100, 2, Color.RED);















  71 
  72         Pane temp = new Pane(lcdText, point);
  73         temp.setMinWidth(500);
  74         temp.setMinHeight(500);
  75         temp.setOnMouseClicked(new EventHandler<MouseEvent>() {
  76             @Override
  77             public void handle(MouseEvent event) {
  78                 point.setCenterX(event.getX());
  79                 point.setCenterY(event.getY());
  80 
  81                 new Timeline(

  82                     new KeyFrame(Duration.seconds(5),
  83                         new KeyValue(lcdText.xProperty(), event.getX(),
  84                             interpolatorChoiceBox.getSelectionModel().getSelectedItem())),
  85                     new KeyFrame(Duration.seconds(5),
  86                         new KeyValue(lcdText.yProperty(), event.getY(),
  87                             interpolatorChoiceBox.getSelectionModel().getSelectedItem()))
  88                 ).play();


  89             }
  90         });
  91         Pane root = new VBox(temp, testText, interpolatorChoiceBox);






  92         Scene scene = new Scene(root, 500, 575);
  93 
  94         primaryStage.setTitle("Test Animnation LCD Text");
  95         primaryStage.setResizable(false);
  96         primaryStage.setScene(scene);
  97         primaryStage.show();
  98     }
  99 }
 100 
 101 
 102 
--- EOF ---