1 / 52

Scratching the Surface with JavaFX

Scratching the Surface with JavaFX. Jim Weaver Java Technology Ambassador Oracle Corporation @ JavaFXpert james.weaver@oracle.com. Touch Gestures Swipe, Scroll, Rotate, Zoom Touch Event and Touch Points The Pagination Control Accommodating Fingers Introduction to JavaFX 3D

toril
Download Presentation

Scratching the Surface with JavaFX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Scratching the Surface with JavaFX Jim Weaver Java Technology Ambassador Oracle Corporation @JavaFXpert james.weaver@oracle.com

  2. Touch Gestures • Swipe, Scroll, Rotate, Zoom • Touch Event and Touch Points • The Pagination Control • Accommodating Fingers • Introduction to JavaFX 3D • Example app: ZenGuitar3D Multi-touch considerations for JavaFX

  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. 3

  4. Touch Gestures

  5. 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

  6. Handling the Swipe Gesture (SwipeEvent) Note: Lambda expressions from JDK 8 are used here to simplify event handling

  7. Handling the Swipe Gesture (SwipeEvent)

  8. 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

  9. Handling the Scroll Gesture (ScrollEvent)

  10. The Rotate Gesture • User typically drags two fingers around each other • Rotate events are continuously generated, containing angle-related info

  11. Handling the Rotate Gesture (RotateEvent)

  12. The Zoom Gesture • User typically drags two fingers apart or closer together • Zoom events are continuously generated, containing zoom factor-related info

  13. Handling the Zoom Gesture (ZoomEvent)

  14. Touch Event and Touch Points Thomas Laenner - http://thomas.laenner.dk/

  15. Handling Touch (TouchEvent/TouchPoint) • A TouchEventcontains 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

  16. Responding to Touch Events

  17. A Touch Demo from the JavaFX Community • Touchfxyis an open source JavaFX application developed by DannoFerrin to demonstrate gestures and touch events • To obtain Touchfxy, see Danno’s blog at http://speling.shenmon.com Touchyfxy app by DannoFerrin http://speling.shemnon.com/

  18. The Pagination Control

  19. 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

  20. Using the Pagination Control

  21. Accommodating Fingers

  22. Making UI Controls Larger for Touching • The default sizes for JavaFXUI controls are conducive to using a mouse as a pointing device • An easy way to modify the default sizes is to use CSS

  23. Making UI Controls Larger for Touching Specify an -fx-font-size property in the #root selector

  24. Introduction to JavaFX 3D

  25. “JavaFX 3D gives you the ability to use 3D geometry, cameras, and lights in JavaFX.” Jasper Potts JavaFX Engineer, Oracle Corporation

  26. Mesh Geometry (3D Shapes) • Predefined shapes • Box • Cylinder • Sphere • User-defined shapes • Using TriangleMesh/ MeshView 26

  27. Creating Primitive Shapes and Materials 27

  28. 3D Materials and Textures https://wikis.oracle.com/display/OpenJDK/3D+Features • PhongMaterial has these properties • Ambient color • Diffuse color, diffuse map • Specular color, specular map • Specular power • Bump map • Self-illumination map 28

  29. Duke’s nose has a Diffuse Map texture 29

  30. This planet has a Bump Map texture 30

  31. UV Mapping Textures to Shapes Tip: A texture is a 2D image to be mapped on a 3D surface Source: http://en.wikipedia.org/wiki/File:UVMapping.png 31

  32. Placing a Texture on a Sphere 32

  33. Placing a Texture on a Sphere 33

  34. 3D Lights • Lights are nodes in the scene graph • PointLight • AmbientLight • Default light provided if no active lights 34

  35. Lights, Camera, Action! 35

  36. Example multi-touch app: ZenGuitar3D

  37. Showing the Picker (TouchEvent) 37

  38. Rotating Instrument Picker with Scroll Gesture 38

  39. Playing Strings (TouchEvent / TouchPoint) 39

  40. Switching Modes (TouchPoint#belongsTo) GuitarString3D instance 40

  41. Setting up to Rotate on Three Axes 41

  42. Using Scroll Gesture for X/Y Rotate 42

  43. Using Rotate Gesture for Z Rotate 43

  44. Using Zoom Gesture for Scaling 44

  45. Using Timeline to Transform to Home Position 45

  46. ZenGuitar3D Uses the JFugue5 Library • An open-source Java API for programming music without the complexities of MIDI • Developed by David Koelle • Available at http://JFugue.org 46

  47. Start Here: http://javafxcommunity.com 47

  48. Download JDK 8 Early Access Release 48

  49. Visit Here: http://fxexperience.com Tip: This site is authored by Oracle JavaFX Engineers 49

  50. Questions?

More Related