29
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 1 Developing JavaFX Apps for Tablets (JavaFX Multi-touch Features) Jim Weaver Java Technology Ambassador Oracle Corporation @JavaFXpert [email protected]

Developing JavaFX Apps for Tablets

  • Upload
    ngomien

  • View
    223

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 131

Developing JavaFX Apps for Tablets(JavaFX Multi-touch Features)

Jim Weaver

Java Technology Ambassador

Oracle Corporation

@JavaFXpert

[email protected]

Page 2: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 132 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16

JavaFXMulti-touch Features

Touch Gestures

– Swipe, Scroll, Rotate, Zoom

Touch Event and Touch Points

The Pagination Control

Accommodating Fingers

Page 3: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 133 3

Please note

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.

Page 4: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 134

Touch Gestures

Page 5: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 135

The Swipe Gesture

Commonly a finger drag in one direction

A single event is produced for the gesture

May be left, right, up, or down

Page 6: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 136

Handling the Swipe Gesture (SwipeEvent)

Note: Lambda expressions from JDK 8 are used here to simplify event handling

Page 7: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 137

Handling the Swipe Gesture (SwipeEvent)

Page 8: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 138

The Scroll Gesture

User turns mouse wheel, drags finger on

touch screen, etc.

Scroll events are continuously generated,

containing x/y position-related info

Events are pixel-based or character/line-

based

If inertia is supported, scroll events may

be generated after user quits scrolling

Page 9: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 139

Handling the Scroll Gesture (ScrollEvent)

Page 10: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1310

The Rotate Gesture

User typically drags two fingers around

each other

Rotate events are continuously generated,

containing angle-related info

Page 11: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1311

Handling the Rotate Gesture (RotateEvent)

Page 12: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1312

The Zoom Gesture

User typically drags two fingers apart or

closer together

Zoom events are continuously generated,

containing zoom factor-related info

Page 13: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1313

Handling the Zoom Gesture (ZoomEvent)

Page 14: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1314

Touch Event and Touch Points

Thomas Laenner - http://thomas.laenner.dk/

Page 15: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1315

Handling Touch (TouchEvent/TouchPoint)

A TouchEvent contains information about

a touch, including:

– Event type: Pressed, released, moved, or

stationary

– Touch points: The TouchPoint instances

that represent each of the points that were

touched

Each TouchEvent has a unique ID to identify the

events and touch points in a multi-touch action

Page 16: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1316

Responding to Touch Events

Page 17: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1317

A Touch Demo from the JavaFX Community

Touchyfxy app by Danno Ferrin http://speling.shemnon.com/

Touchfxy is an open source JavaFX

application developed by Danno Ferrin to

demonstrate gestures and touch events

To obtain Touchfxy, see Danno’s blog at

http://speling.shenmon.com

Page 18: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1318

The Pagination Control

Page 19: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1319

Using the Pagination Control

The Pagination control is used for

navigation between pages

Each page is a Node subclass

Numeric page indicators, or bullet-style

indicators, may be set with the style class STYLE_CLASS_BULLET

Page 20: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1320

Using the Pagination Control

Page 21: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1321

Accommodating Fingers

Page 22: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1322

Making UI Controls Larger for Touching

The default sizes for

JavaFX UI controls are

conducive to using a

mouse as a pointing device

An easy way to modify the

default sizes is to use CSS

Page 23: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1323

Making UI Controls Larger for Touching

Specify an -fx-font-size

property in the #root selector

Page 24: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1324 24

Start Here: http://javafxcommunity.com

Page 25: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1325 25

Download JDK 8 Early Access Release

Page 26: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1326 26

Visit Here: http://fxexperience.com

Tip: This site is authored by Oracle JavaFXEngineers

Page 27: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1327

Questions?

Page 28: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1328

Developing JavaFX Apps for Tablets(JavaFX Multi-touch Features)

Jim Weaver

Java Technology Ambassador

Oracle Corporation

@JavaFXpert

[email protected]

Page 29: Developing JavaFX Apps for Tablets

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1329