520 likes | 771 Views
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
E N D
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 • Example app: ZenGuitar3D Multi-touch considerations for JavaFX
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
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
Handling the Swipe Gesture (SwipeEvent) Note: Lambda expressions from JDK 8 are used here to simplify event handling
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
The Rotate Gesture • User typically drags two fingers around each other • Rotate events are continuously generated, containing angle-related info
The Zoom Gesture • User typically drags two fingers apart or closer together • Zoom events are continuously generated, containing zoom factor-related info
Touch Event and Touch Points Thomas Laenner - http://thomas.laenner.dk/
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
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/
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
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
Making UI Controls Larger for Touching Specify an -fx-font-size property in the #root selector
“JavaFX 3D gives you the ability to use 3D geometry, cameras, and lights in JavaFX.” Jasper Potts JavaFX Engineer, Oracle Corporation
Mesh Geometry (3D Shapes) • Predefined shapes • Box • Cylinder • Sphere • User-defined shapes • Using TriangleMesh/ MeshView 26
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
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
3D Lights • Lights are nodes in the scene graph • PointLight • AmbientLight • Default light provided if no active lights 34
Switching Modes (TouchPoint#belongsTo) GuitarString3D instance 40
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
Visit Here: http://fxexperience.com Tip: This site is authored by Oracle JavaFX Engineers 49