javafx 2.0 への誘い

24
への誘い

Upload: yuichi-sakuraba

Post on 22-May-2015

3.840 views

Category:

Technology


3 download

DESCRIPTION

JJUG CCC 2011 Falll 発表資料「JavaFX 2.0への誘い」Introducting JavaFX 2.0

TRANSCRIPT

Page 1: JavaFX 2.0 への誘い

への誘い

Page 2: JavaFX 2.0 への誘い

Agenda

JavaFX 2.0

General Purpose

Java の UI の歴史

UI

Conclusion

Page 3: JavaFX 2.0 への誘い

History

Page 4: JavaFX 2.0 への誘い

JDK/JRE

Java

Non-Java

AWT SwingJava 2D

SwingX

JAI/ImageIO

Java 3DJOGL

LG3D

SWTGWTF3 JavaFX

JavaFX2.0

JavaFX3.0

Page 5: JavaFX 2.0 への誘い

JavaFX 2.0

第3の Java の GUI ライブラリ

高性能レンダリングエンジン

アニメーション /エフェクト

JVMで動作する言語から利用可

Page 6: JavaFX 2.0 への誘い

JavaFX

UI GeneralPurpose

SceneGraph

Page 7: JavaFX 2.0 への誘い

Stage

StageScene

Scene

VBox

VBox

HBox

HBox

TableView

TableView

Label

TextBox

Button

Page 8: JavaFX 2.0 への誘い

Node

Control Pane Shape

Page 9: JavaFX 2.0 への誘い

Node

Control Pane Shape

Web

Media

Chart

Page 10: JavaFX 2.0 への誘い

WebWebView view = new WebView();

WebEngine engine = view.getEngine();engine.load("http://google.com/");

Page 11: JavaFX 2.0 への誘い

Media

Media media = new Media(url);MediaPlayer player = new MediaPlayer(media);MediaView view = new MediaView(player);

player.play();

Page 12: JavaFX 2.0 への誘い

SceneGraph の構築

public class Hello extends Application { @Override public void start(Stage stage) { // コンテナ Group container = new Group(); // シーングラフのルート要素を生成し、コンテナを貼る Scene scene = new Scene(container, 100, 20); stage.setScene(scene);

// ラベルを生成しコンテナに貼る Label label = new Label("Hello, World!"); container.getChildren().add(label); stage.show(); } public static void main(String[] args) { Application.launch(Hello.class, null); }}

public class Hello extends Application { @Override public void start(Stage stage) { // コンテナ Group container = new Group(); // シーングラフのルート要素を生成し、コンテナを貼る Scene scene = new Scene(container, 100, 20); stage.setScene(scene);

// ラベルを生成しコンテナに貼る Label label = new Label("Hello, World!"); container.getChildren().add(label); stage.show(); } public static void main(String[] args) { Application.launch(Hello.class, null); }}

public class Hello extends Application { @Override public void start(Stage stage) { // コンテナ Group container = new Group(); // シーングラフのルート要素を生成し、コンテナを貼る Scene scene = new Scene(container, 100, 20); stage.setScene(scene);

// ラベルを生成しコンテナに貼る Label label = new Label("Hello, World!"); container.getChildren().add(label); stage.show(); } public static void main(String[] args) { Application.launch(Hello.class, null); }}

public class Hello extends Application { @Override public void start(Stage stage) { // コンテナ Group container = new Group(); // シーングラフのルート要素を生成し、コンテナを貼る Scene scene = new Scene(container, 100, 20); stage.setScene(scene);

// ラベルを生成しコンテナに貼る Label label = new Label("Hello, World!"); container.getChildren().add(label); stage.show(); } public static void main(String[] args) { Application.launch(Hello.class, null); }}

SceneGraph の構築

Page 13: JavaFX 2.0 への誘い

SceneGraph の構築

<?import javafx.scene.control.*?><?import javafx.scene.layout.*?>

<FlowPane xmlns:fx="http://javafx.com/fxml"> <children> <Label text="Label" /> <TextBox fx:id="textBox" text="TextBox" /> <Button fx:id="button" text="Button" /> </children></FlowPane>

FXML

Page 14: JavaFX 2.0 への誘い

JavaFX

SceneGraph

UI GeneralPurpose

Node

Control Region Shape

Web Media Chart

FXMLAnimation

Effect

CSS

Page 15: JavaFX 2.0 への誘い

Animation

自動補完

Page 16: JavaFX 2.0 への誘い

Animation

Page 17: JavaFX 2.0 への誘い

Effect

Node image = ...;GaussianBlur blur = new GaussianBlur();blur.setRadius(10.0);image.setEffect(blur);

Node image = ...;DropShadow shdw= new DropShadow();shdw.setOffsetX(5); shdw.setOffsetY(5);image.setEffect(shdw);

Node image = ...;image.setEffect(new Reflection());

Node image = ...;image.setEffect(new SepiaTone());

Page 18: JavaFX 2.0 への誘い

CSS

Scene scene = new Scene(container, 400, 100);// スタイルシートの設定scene.getStylesheets().add("/style.css");

.button { -fx-font: 24pt "SansSerif"; -fx-text-fill: #006666; -fx-background-color: orange; -fx-border-radius: 20; -fx-background-radius: 20; -fx-padding: 5;}

.button { -fx-font: 16pt "SansSerif"; -fx-text-fill: #00FF33; -fx-background-color: #0066FF; -fx-border-radius: 0; -fx-background-radius: 0; -fx-padding: 20;}

Page 19: JavaFX 2.0 への誘い

CSS

Scene scene = new Scene(container, 400, 100);// スタイルシートの設定scene.getStylesheets().add("/style.css");

.button { -fx-font: 24pt "SansSerif"; -fx-text-fill: #006666; -fx-background-color: orange; -fx-border-radius: 20; -fx-background-radius: 20; -fx-padding: 5;}

.button { -fx-font: 16pt "SansSerif"; -fx-text-fill: #00FF33; -fx-background-color: #0066FF; -fx-border-radius: 0; -fx-background-radius: 0; -fx-padding: 20;}

Page 20: JavaFX 2.0 への誘い

JavaFX

SceneGraph

UI GeneralPurpose

Node

Control Region Shape

Web Media Chart

FXMLAnimation

Effect

CSS

Property Async

Bind Collection

Page 21: JavaFX 2.0 への誘い

MVC

Model

View

ControllerEvent

Observer Pattern

Page 22: JavaFX 2.0 への誘い

MVC

Model

View

Controller

Bind

// モデルDoubleProperty xProperty = new DoubleProperty();

Slider slider = new Slider(50, 300, 0);// モデルにスライダの値をバインドさせるxProperty.bind(slider.valueProperty());

Rectangle rect = new Rectangle(50, 10, 50, 30); // 四角の x座標にモデルをバインドさせるrect.xProperty().bind(xProperty);

Page 23: JavaFX 2.0 への誘い

JavaFX

SceneGraph

UI GeneralPurpose

Node

Control Region Shape

Web Media Chart

FXMLAnimation

Effect

CSS

Property Async

Bind Collection

JavaSE8 OpenJDK

Tool

NetBeans 7.1 Scene Builder

デザイナ向けツールが ...

Page 24: JavaFX 2.0 への誘い

への誘い