SlideShare a Scribd company logo
1 of 48
Download to read offline
1   Copyright © 2012, Oracle and/or its affiliates. All rights   Insert Informaion Protection Policy Classification from Slide 7
    reserved.
JavaFX 2.1 - следующее поколение
клиентской Java                    Presenting with

Александр Кузнецов                      LOGO
The following is intended to outline our general product
    direction. It is intended for information purposes only, and may
    not be incorporated into any contract. It is not a commitment to
    deliver any material, code, or functionality, and should not be
    relied upon in making purchasing decisions. The development,
    release, and timing of any features or functionality described
    for Oracle’s products remains at the sole discretion of Oracle.




3   Copyright © 2012, Oracle and/or its affiliates. All rights   Insert Informaion Protection Policy Classification from Slide 7
    reserved.
Интерфейс на Java




4   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
JavaFX




5   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Демонстрация




6   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Архитектура JavaFX
                                                                      UI Controls API




                                                                 Из чего состоит JavaFX?




7   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Архитектура JavaFX
                                                                 UI Controls API




Движок рендеринга
    ●       Высокопроизводительный
    ●       Аппаратно-ускоренный
    ●       Легковесный
    ●       Не использующий AWT или Swing

8   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Эффекты




9   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Эффекты

     ●       Пример использования
             node.setEffect(new BoxBlur(10, 10, 2));




10   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Трансформации




11   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Трансформации

     ●       Пример использования
             node.setRotate(node.getRotate() + 90);




12   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
3D-трансформации




13   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
3D-трансформации

             Пример использования
             Scene scene = new Scene(root, 500, 500, true);
             scene.setCamera(new PerspectiveCamera());
             ...
             node.setRotationAxis(Rotate.Y_AXIS);
             node.setRotate(node.getRotate() + 20);




14   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Граф сцены (Scene graph)
     ●       Направленный связный ацикличный граф
     ●       Задает структуру графических компонентов:
                ●         порядок отрисовки
                ●         порядок обработки событий
                ●         эффекты и трансформации

                                                                  Scene
                                                                      root

                                                                  Parent
                                                                     children




                                                                     снизу      сверху




15   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Анимация



                                                                              Animation



                                                                  Transition                  Timeline



                                                         FadeTransition, FillTransition,
                                                       ParallelTransition, PathTransition,
                                                      PauseTransition, RotateTransition,
                                                     ScaleTransition, SequentialTransition,
                                                      StrokeTransition, TranslateTransition




16   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Анимация: Transitions




17   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Анимация: Transitions

     ●       Пример использования:
             RotateTransitionBuilder.create()
                     .node(node)
                     .byAngle(90)
                     .build().play();




18   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Fluent API

     ●       Пример использования:
             RotateTransitionBuilder.create()
                     .node(node)
                     .byAngle(90)
                     .build().play();




            RotateTransition rotateTransition
                    = new RotateTransition();
            rotateTransition.setNode(node);
            rotateTransition.setByAngle(90);
            rotateTransition.play();




19   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Анимация: Transitions
     ●       ParallelTransition, SequentialTransition, PauseTransition

                 ParallelTransitionBuilder.create()
                     .cycleCount(Timeline.INDEFINITE)
                     .autoReverse(true)
                     .node(duke)
                     .children(
                         TranslateTransitionBuilder.create()
                             .byY(50)
                             .build(),
                         FadeTransitionBuilder.create()
                             .toValue(0)
                             .build()
                     )
                     .build().play();




20   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Анимация: Timeline
TimelineBuilder.create()
  .keyFrames(
    new KeyFrame(Duration.seconds(0), new KeyValue(x, 0), ...),
    new KeyFrame(Duration.seconds(5), new KeyValue(x, 100), ...),
   ...
).build();




                       Как значения изменяются во времени

                  Key value
                  x=0                                                            x = 100


                       0s                                  1s     2s   3s   4s    5s       6s
                          Keyframes


21   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Анимация: Interpolators




22   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Свойства (Properties)

     ●      Обычное свойство

                private int radius = DEFAULT_RADIUS;


                public int getRadius() {
                    return radius;
                }

                public void setRadius(int radius) {
                    this.radius = radius;
                }




23   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Свойства (Properties)

     ●      JavaFX свойство:

                private IntegerProperty radius
                        = new SimpleIntegerProperty(DEFAULT_RADIUS);

                public int getRadius() {
                    return radius.get();
                }

                public void setRadius(int radius) {
                    this.radius.set(radius);
                }

                public IntegerProperty radiusProperty() {
                    return radius;
                }



24   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Простое связывание (Binding)


     ●       В одну сторону:
                 IntegerProperty x = new SimpleIntegerProperty();
                 IntegerProperty y = new SimpleIntegerProperty();

                 x.bind(y.add(5));                                // x bind y + 5

     ●       В обе стороны:
                 IntegerProperty z = new SimpleIntegerProperty();

                 z.bindBidirectional(y);                          // z bind y with inverse




25   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Сложное связывание (Binding)

     ●      Сложное связывание:
         Label label = new Label();
         label.textProperty().bind(new ObjectBinding<String>() {
             {
                 bind(x, z);
             }

                        @Override
                        protected String computeValue() {
                            return x.get() == z.get() ? "Значения равны"
                                   : "x = " + x.get() + ", z = " + z.get();
                        }
         });

     ●      Полный контроль над связыванием
               ●         unbind(), addListener(), removeListener(), isBound()



26   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Демонстрация




27   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Архитектура JavaFX
                                                                  UI Controls API




               ●         Видео
               ●         Аудио




28   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Поддержка мультимедиа




     ●       H.264 в JavaFX 2.1
     ●       кодеки VP6, MP3
     ●       полноэкранное видео
     ●       канал прозрачности
     ●       полностью интегрировано в графическую систему
     ●       мгновенное воспроизведение звуков (low latency)


29   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Демонстрация




30   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Архитектура JavaFX
                                                                  UI Controls API




         ●         HTML 5.0
         ●         взаимодействие JavaScript и JavaFX
         ●         доступ к содержимому страницы



31   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Демонстрация




32   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Архитектура JavaFX
                                                                  UI Controls API




 Библиотека компонентов для построения
 графического пользовательского интерфейса
     ●       написаны на JavaFX
     ●       открытый исходный код
             http://openjdk.java.net/projects/openjfx/


33   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
UI Controls API


●      Анимированные диаграммы
●      Менеджеры расположения
       компонентов
●      Стилизация при помощи CSS




34   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Демонстрация




35   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Что ещё?

     ●       Java API
     ●       Средства разработки, отладки и тестирования
     ●       Взаимодействие с Swing и SWT
     ●       Развертывание (Deployment)
     ●       Что нового в версии JavaFX 2.1?




36   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API


 все возможности языка Java:
     ●       шаблоны
     ●       многопоточность
     ●       аннотации
     ●       доступен из любого JVM языка:
             Ruby, Scala, Groovy




37   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Средства

     ●       разработка:
                ●         любые Java IDE: NetBeans, Eclipse, IDEA
     ●       отладка:
                ●         любые средства для языка Java
     ●       тестирование:
                ●         Jemmy3 http://jemmy.java.net/




38   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Scene Builder




     ●       Подробнее в докладе Сергея Гринева



39   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
FXML
     example.fxml:
     ...
     <GridPane id="gridPane1" ...>
         <children>
             <Label id="label1" text="Имя" ... />
             <TextField id="textField1" ... />
     ...

     example.java:
     ...
                  Parent root = FXMLLoader.load(
                      getClass().getResource("example.fxml"));

                  stage.setScene(new Scene(root));
     ...




40   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
JavaFX в Swing и SWT приложениях


public class JFXPanel
       extends javax.swing.JComponent {
    …
    void setScene(Scene newScene) {...}
    …
}

public class FXCanvas
             extends org.eclipse.swt.widgets.Canvas {
    …
    void setScene(Scene newScene) {...}
    …
}




41   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Развертывание

     ➔       JAR-файл
     ➔       JNLP
     ➔       Апплет




42   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Что будет в JavaFX 2.1

     ●       поддержка Mac OS
     ●       beta-поддержка Linux
     ●       JavaScript -> Java вызовы
     ●       а также:
                ●         улучшения в FXML, в рендеринге шрифтов, в SplitPane, в классах
                          Task и Service, в поддержке меню приложения
                ●         новые диаграммы, новый компонент ComboBox
                ●         поддержка форматов AAC, H.264/MPEG




43   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Возможности JavaFX

     ●       Богатая графика и анимация
     ●       Мультимедиа
     ●       HTML 5.0
     ●       UI-элементы
     ●       FXML и CSS
     ●       Апплет/JNLP/JAR
     ●       Интеграция со Swing и SWT




44   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Демонстрация




45   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Ссылки

     ●       JavaFX http://javafx.com
     ●       Примеры:
             http://www.oracle.com/technetwork/java/javafx/samples/index.html

     ●       JavaFX и Scala http://code.google.com/p/scalafx/
     ●       JavaFX и Groovy http://groovyfx.org/




46   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
47   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
JavaFX 2.1 - следующее поколение клиентской Java

More Related Content

Similar to JavaFX 2.1 - следующее поколение клиентской Java

OSI_MySQL_Performance Schema
OSI_MySQL_Performance SchemaOSI_MySQL_Performance Schema
OSI_MySQL_Performance SchemaMayank Prasad
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...jaxLondonConference
 
Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Arun Gupta
 
Introduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiIntroduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiBruno Borges
 
Java EE7
Java EE7Java EE7
Java EE7Jay Lee
 
Graal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them AllGraal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them AllThomas Wuerthinger
 
"Quantum" Performance Effects
"Quantum" Performance Effects"Quantum" Performance Effects
"Quantum" Performance EffectsSergey Kuksenko
 
Spring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFuSpring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFuVMware Tanzu
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java PlatformSivakumar Thyagarajan
 
A Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado EmbeddedA Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado EmbeddedBruno Borges
 
Como criar o jogo 2048 em Java 8 e JavaFX
Como criar o jogo 2048 em Java 8 e JavaFXComo criar o jogo 2048 em Java 8 e JavaFX
Como criar o jogo 2048 em Java 8 e JavaFXBruno Borges
 
As novidades do Java EE 7: do HTML5 ao JMS 2.0
As novidades do Java EE 7: do HTML5 ao JMS 2.0As novidades do Java EE 7: do HTML5 ao JMS 2.0
As novidades do Java EE 7: do HTML5 ao JMS 2.0Bruno Borges
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesArun Gupta
 
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX LondonJAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX LondonArun Gupta
 
Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)Logico
 
Clean code bites
Clean code bitesClean code bites
Clean code bitesRoy Nitert
 
20200402 oracle cloud infrastructure data science
20200402 oracle cloud infrastructure data science20200402 oracle cloud infrastructure data science
20200402 oracle cloud infrastructure data scienceKenichi Sonoda
 
GlassFish BOF
GlassFish BOFGlassFish BOF
GlassFish BOFglassfish
 

Similar to JavaFX 2.1 - следующее поколение клиентской Java (20)

OSI_MySQL_Performance Schema
OSI_MySQL_Performance SchemaOSI_MySQL_Performance Schema
OSI_MySQL_Performance Schema
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
 
Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5
 
Introduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiIntroduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry Pi
 
Java EE7
Java EE7Java EE7
Java EE7
 
Graal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them AllGraal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them All
 
Java ee7 1hour
Java ee7 1hourJava ee7 1hour
Java ee7 1hour
 
"Quantum" Performance Effects
"Quantum" Performance Effects"Quantum" Performance Effects
"Quantum" Performance Effects
 
Spring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFuSpring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFu
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java Platform
 
A Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado EmbeddedA Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado Embedded
 
Como criar o jogo 2048 em Java 8 e JavaFX
Como criar o jogo 2048 em Java 8 e JavaFXComo criar o jogo 2048 em Java 8 e JavaFX
Como criar o jogo 2048 em Java 8 e JavaFX
 
As novidades do Java EE 7: do HTML5 ao JMS 2.0
As novidades do Java EE 7: do HTML5 ao JMS 2.0As novidades do Java EE 7: do HTML5 ao JMS 2.0
As novidades do Java EE 7: do HTML5 ao JMS 2.0
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
 
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX LondonJAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
 
Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)
 
Clean code bites
Clean code bitesClean code bites
Clean code bites
 
Completable future
Completable futureCompletable future
Completable future
 
20200402 oracle cloud infrastructure data science
20200402 oracle cloud infrastructure data science20200402 oracle cloud infrastructure data science
20200402 oracle cloud infrastructure data science
 
GlassFish BOF
GlassFish BOFGlassFish BOF
GlassFish BOF
 

JavaFX 2.1 - следующее поколение клиентской Java

  • 1. 1 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7 reserved.
  • 2. JavaFX 2.1 - следующее поколение клиентской Java Presenting with Александр Кузнецов LOGO
  • 3. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3 Copyright © 2012, Oracle and/or its affiliates. All rights Insert Informaion Protection Policy Classification from Slide 7 reserved.
  • 4. Интерфейс на Java 4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 5. JavaFX 5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 6. Демонстрация 6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 7. Архитектура JavaFX UI Controls API Из чего состоит JavaFX? 7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 8. Архитектура JavaFX UI Controls API Движок рендеринга ● Высокопроизводительный ● Аппаратно-ускоренный ● Легковесный ● Не использующий AWT или Swing 8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 9. Эффекты 9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 10. Эффекты ● Пример использования node.setEffect(new BoxBlur(10, 10, 2)); 10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 11. Трансформации 11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 12. Трансформации ● Пример использования node.setRotate(node.getRotate() + 90); 12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 13. 3D-трансформации 13 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 14. 3D-трансформации Пример использования Scene scene = new Scene(root, 500, 500, true); scene.setCamera(new PerspectiveCamera()); ... node.setRotationAxis(Rotate.Y_AXIS); node.setRotate(node.getRotate() + 20); 14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 15. Граф сцены (Scene graph) ● Направленный связный ацикличный граф ● Задает структуру графических компонентов: ● порядок отрисовки ● порядок обработки событий ● эффекты и трансформации Scene root Parent children снизу сверху 15 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 16. Анимация Animation Transition Timeline FadeTransition, FillTransition, ParallelTransition, PathTransition, PauseTransition, RotateTransition, ScaleTransition, SequentialTransition, StrokeTransition, TranslateTransition 16 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 17. Анимация: Transitions 17 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 18. Анимация: Transitions ● Пример использования: RotateTransitionBuilder.create() .node(node) .byAngle(90) .build().play(); 18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 19. Fluent API ● Пример использования: RotateTransitionBuilder.create() .node(node) .byAngle(90) .build().play(); RotateTransition rotateTransition = new RotateTransition(); rotateTransition.setNode(node); rotateTransition.setByAngle(90); rotateTransition.play(); 19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 20. Анимация: Transitions ● ParallelTransition, SequentialTransition, PauseTransition ParallelTransitionBuilder.create() .cycleCount(Timeline.INDEFINITE) .autoReverse(true) .node(duke) .children( TranslateTransitionBuilder.create() .byY(50) .build(), FadeTransitionBuilder.create() .toValue(0) .build() ) .build().play(); 20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 21. Анимация: Timeline TimelineBuilder.create() .keyFrames( new KeyFrame(Duration.seconds(0), new KeyValue(x, 0), ...), new KeyFrame(Duration.seconds(5), new KeyValue(x, 100), ...), ... ).build(); Как значения изменяются во времени Key value x=0 x = 100 0s 1s 2s 3s 4s 5s 6s Keyframes 21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 22. Анимация: Interpolators 22 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 23. Свойства (Properties) ● Обычное свойство private int radius = DEFAULT_RADIUS; public int getRadius() { return radius; } public void setRadius(int radius) { this.radius = radius; } 23 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 24. Свойства (Properties) ● JavaFX свойство: private IntegerProperty radius = new SimpleIntegerProperty(DEFAULT_RADIUS); public int getRadius() { return radius.get(); } public void setRadius(int radius) { this.radius.set(radius); } public IntegerProperty radiusProperty() { return radius; } 24 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 25. Простое связывание (Binding) ● В одну сторону: IntegerProperty x = new SimpleIntegerProperty(); IntegerProperty y = new SimpleIntegerProperty(); x.bind(y.add(5)); // x bind y + 5 ● В обе стороны: IntegerProperty z = new SimpleIntegerProperty(); z.bindBidirectional(y); // z bind y with inverse 25 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 26. Сложное связывание (Binding) ● Сложное связывание: Label label = new Label(); label.textProperty().bind(new ObjectBinding<String>() { { bind(x, z); } @Override protected String computeValue() { return x.get() == z.get() ? "Значения равны" : "x = " + x.get() + ", z = " + z.get(); } }); ● Полный контроль над связыванием ● unbind(), addListener(), removeListener(), isBound() 26 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 27. Демонстрация 27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 28. Архитектура JavaFX UI Controls API ● Видео ● Аудио 28 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 29. Поддержка мультимедиа ● H.264 в JavaFX 2.1 ● кодеки VP6, MP3 ● полноэкранное видео ● канал прозрачности ● полностью интегрировано в графическую систему ● мгновенное воспроизведение звуков (low latency) 29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 30. Демонстрация 30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 31. Архитектура JavaFX UI Controls API ● HTML 5.0 ● взаимодействие JavaScript и JavaFX ● доступ к содержимому страницы 31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 32. Демонстрация 32 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 33. Архитектура JavaFX UI Controls API Библиотека компонентов для построения графического пользовательского интерфейса ● написаны на JavaFX ● открытый исходный код http://openjdk.java.net/projects/openjfx/ 33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 34. UI Controls API ● Анимированные диаграммы ● Менеджеры расположения компонентов ● Стилизация при помощи CSS 34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 35. Демонстрация 35 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 36. Что ещё? ● Java API ● Средства разработки, отладки и тестирования ● Взаимодействие с Swing и SWT ● Развертывание (Deployment) ● Что нового в версии JavaFX 2.1? 36 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 37. Java API все возможности языка Java: ● шаблоны ● многопоточность ● аннотации ● доступен из любого JVM языка: Ruby, Scala, Groovy 37 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 38. Средства ● разработка: ● любые Java IDE: NetBeans, Eclipse, IDEA ● отладка: ● любые средства для языка Java ● тестирование: ● Jemmy3 http://jemmy.java.net/ 38 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 39. Scene Builder ● Подробнее в докладе Сергея Гринева 39 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 40. FXML example.fxml: ... <GridPane id="gridPane1" ...> <children> <Label id="label1" text="Имя" ... /> <TextField id="textField1" ... /> ... example.java: ... Parent root = FXMLLoader.load( getClass().getResource("example.fxml")); stage.setScene(new Scene(root)); ... 40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 41. JavaFX в Swing и SWT приложениях public class JFXPanel extends javax.swing.JComponent { … void setScene(Scene newScene) {...} … } public class FXCanvas extends org.eclipse.swt.widgets.Canvas { … void setScene(Scene newScene) {...} … } 41 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 42. Развертывание ➔ JAR-файл ➔ JNLP ➔ Апплет 42 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 43. Что будет в JavaFX 2.1 ● поддержка Mac OS ● beta-поддержка Linux ● JavaScript -> Java вызовы ● а также: ● улучшения в FXML, в рендеринге шрифтов, в SplitPane, в классах Task и Service, в поддержке меню приложения ● новые диаграммы, новый компонент ComboBox ● поддержка форматов AAC, H.264/MPEG 43 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 44. Возможности JavaFX ● Богатая графика и анимация ● Мультимедиа ● HTML 5.0 ● UI-элементы ● FXML и CSS ● Апплет/JNLP/JAR ● Интеграция со Swing и SWT 44 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 45. Демонстрация 45 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 46. Ссылки ● JavaFX http://javafx.com ● Примеры: http://www.oracle.com/technetwork/java/javafx/samples/index.html ● JavaFX и Scala http://code.google.com/p/scalafx/ ● JavaFX и Groovy http://groovyfx.org/ 46 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 47. 47 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.