SlideShare uma empresa Scribd logo
1 de 38
Baixar para ler offline
Developing Rich Interfaces in
JavaFX for Ultrabooks
Felipe Pedroso
Community Manager – Intel Brazil
Bruno Borges
Principal Product Manager - Oracle LAD
2
Program Agenda
 The Future of PCs
 JavaFX and Touch Support
 Using JNI to Work with Sensors
3
Laptops are becoming
“SmartTops”
4
First GPS-enabled
Released on 2007
5
http://www.technologyreview.com/news/409999/laptops-as-earthquake-sensors/
6
http://www.frost.com/sublib/display-report.do?id=M8F0-01-00-00-00
7
http://news.cnet.com/8301-10805_3-57542720-75/microsoft-is-right-about-touch-screen-laptops/
8
Ultrabook™
Convertible &
Detachable
Ultrabook
™TabletSmartphone
Consumption Usages Creation/Productivity
Notebook
9
The Ultrabook™ Platform
Reshaping the PC Experience
9
Ambient
Light Sensor
Ambient
Light Sensor
GPS
GPS Compass
Compass
Near Field
Communicati
on
Near Field
Communicati
on
Gyroscope
Gyroscope
Ultrabook
™
Accelerometer
Accelerometer
Multi-Touch
Multi-Touch
Context Aware
Sensors
10
OK, they have all those
features…
… but how can we implement them
using Java?
11
To allow users to TOUCH my Java App...
• Should I use...
– AWT? Swing? SWT?
• Actually, you can use them but...
– They aren’t made for multi-touch (OK, there’s a way to do it)
– You must optimize your UI controls to be more ‘touch
friendly’
• So, how to do it in a simple and easy way?
12
13
MULTI TOUCH
SUPPORT
14
Actions supported
• Touch events: Down, Move and Up
– Tap (Down and Up) / Double tap
– Drag and Drop (Down, Move and Up)
– Hold
• Gestures
– Swipe: Up, Down, Left and Right
– Zoom: Pinch / Spread
– Rotate
15
• Your components must extend the Node class or any of its
subclasses (StackPane, ImageView, etc)
• Set the proper EventHandler to handle the action.
15
What do I need to do to manipulate
components?
16
• Apply a transform to the component (Translation,
Rotation and Scale):
• Let’s dive into some code!
What do I need to do to manipulate
components?
17
WHAT ABOUT
SENSORS?
#include JNI.h
18
Available sensors on Ultrabooks
• Accelerometer
– Proper acceleration in three axis (x, y, z)
• Gyrometer
– Device orientation
• Magnetometer
– Strenght and direction of magnetic fields
• GPS (Global Positioning System)
– Location and Time information
• NFC
– Near Field Communication
• Ambient Light Sensor
– Ambient Light Level
18
19
API Windows – Sensor Fusion
20
API Windows – Namespaces
• Windows.Sensors.* Common sensors
– Accelerometer
– Gyrometer
– Inclinometer
– OrientationSensor
– SimpleOrientationSensor
– Compass
– LightSensor
• Windows.Devices.Geolocation GPS
– Geolocator
• Windows.Networking.Proximity NFC
– ProximityDevice
21
Windows API – How to
• Get the default object of your sensor using the GetDefault method
• You can call the GetCurrentReading() to get the current value of the sensors or...
• ... work with the ReadingChanged event
– Set the attribute ReportInterval (please, respect the MinimumReportInterval to avoid
problems)
– Delegate a method to handle the event (something like setting a method as a listener)
– Handle the event!
• This procedure is valid only for sensors from Windows.Sensors namespace
22
How can I access that?
23
Using JNI to access the sensors from
Windows.Sensors
1. [Java] Create a native method to register the object that will
handle the events that come from the sensor
2. Generate the header file using javah
3. [C++] Create a DLL Project in Visual Studio with the DLLs and
namespaces of the Windows 8 APIS
4. [C++] Use a variable to keep a reference to the object and the ID
(GetMethodID) of the method that will handle the event
24
Using JNI to access the sensors from
Windows.Sensors
5. [C++] Initialize the sensor and delegate a C++ method to
handle the event
6. [C++] Redirect the delegate method call to the Java method
using the function CallVoidMethod with the following parameters:
the Java Object, the method ID and it’s parameters
7. [Java] Handle the event!
A lot of text? Please, show me the code!
25
JNI Callback from C++ to Java
public final class ShakenSensor {
static { System.loadLibrary("ShakenLib"); }
private ShakenListener listener;
public ShakenSensor (ShakenListener listener) {
this.listener = listener;
}
public native boolean registerObject();
public native boolean registerMethod();
private void shaken(long timestamp) {
listener.shaken(timestamp);
}
}
Load the
C++
Library
Define
native
methods
private method
to be called
from C++
26
JNI Callback from C++ to Java
// Shaken.h
JNIEXPORT jboolean JNICALL Java_sample_ShakenSensor_registerObject
(JNIEnv *, jobject obj);
JNIEXPORT jboolean JNICALL Java_sample_ShakenSensor_registerMethod
(JNIEnv * env, jobject obj);
The header file with mapped
native JNI methods
27
JNI Callback from C++ to Java
// Shaken.cpp
#include "Shaken.h"
#include "jni.h"
#include<iostream>
#using <Windows.winmd>
#using <Platform.winmd>
using namespace::Windows::Devices::Sensors;
JavaVM * currentJvm;
jobject shakenSensorJObject;
jmethodID shakenJMethod; // ShakenSensor.shaken(long)
cpp file including:
Windows Sensor Fusion API
Java Native Interface header
Shaken header
Keep references of
jobject, jmethodID,
currentJvm
28
JNI Callback from C++ to Java
// Shaken.cpp
…_ShakenSensor_registerObject (JNIEnv * env, jobject obj)
{
shakenSensorJObject = env->NewGlobalRef(obj);
jclass shakenSensorClass = env->GetObjectClass(shakenSensorJObject);
shakenJMethod = env->GetMethodID(shakenSensorClass, "shaken", "(J)V");
env->GetJavaVM(&currentJvm);
…
}
Get a reference to ShakenSensor object
from JNIEnv, then the jclass,
then the shaken Java method
29
JNI Callback from C++ to Java
// Shaken.cpp
void Shaken(Accelerometer^ sender, AccelerometerShakenEventArgs^ args){
invokeShakenOnJava(args->Timestamp.UniversalTime / 10000);
}
…_ShakenSensor_registerMethod (JNIEnv * env, jobject obj)
{
accelerometer->Shaken += ref new
Windows::Foundation::TypedEventHandler<Accelerometer^,AccelerometerShakenEventArgs^>(&Shaken);
…
}
registerMethod activates the Sensor and
register events to Shaken C++ method
Shaken method forwards
data to Java
30
JNI Callback from C++ to Java
// Shaken.cpp
void invokeShakenOnJava(jlong timest){
JNIEnv * jniEnvironment;
int envStt = currentJvm->GetEnv((void **)&jniEnvironment, JNI_VERSION_1_6);
// check the envStat == JNI_OK
//and call currentJvm->AttachCurrentThread if necessary
…
// call the Java method on the ShakenSensor Java Object
jniEnvironment->CallVoidMethod(shakenSensorJObject, shakenJMethod,timest);
// always detach current thread
currentJvm->DetachCurrentThread();
}
Make sure JVM is attached
to thread, then call the
method shakenJMethod
31
What about Linux?
Touch works fine, but there aren’t clear APIs to read
sensors. If you know how to do it, let’s work together!
32
Want to know more about Intel Software?
http://software.intel.com/en-us/
33
Windows Community
http://software.intel.com/en-us/windows
34
www.javafxcommunity.com
35
36
• The PC experience is being reshaped
• JavaFX + Touch = AWESOME
• Using JNI to access the sensors can be
LEGENDARY!
Take aways
37
Questions?
(if yes, the answer is 42)
38
Thanks a lot!
Bruno Borges
facebook.com/brunocborges
@brunoborges
Felipe Pedroso
facebook.com/felipe.a.pedroso
@felipeapedroso

Mais conteúdo relacionado

Semelhante a Developing Rich Interfaces in JavaFX for Ultrabooks

Jollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-levelJollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-levelJollen Chen
 
Using multitouch and sensors in Java
Using multitouch and sensors in JavaUsing multitouch and sensors in Java
Using multitouch and sensors in JavaIntel Software Brasil
 
Programming The Real World
Programming The Real WorldProgramming The Real World
Programming The Real Worldpauldeng
 
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...Paris Open Source Summit
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Paris Android User Group
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsLinaro
 
Hack the Real World with ANDROID THINGS
Hack the Real World with ANDROID THINGSHack the Real World with ANDROID THINGS
Hack the Real World with ANDROID THINGSDevFest DC
 
Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Daniel Luxemburg
 
Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013Opersys inc.
 
Node.js at Joyent: Engineering for Production
Node.js at Joyent: Engineering for ProductionNode.js at Joyent: Engineering for Production
Node.js at Joyent: Engineering for Productionjclulow
 
JDK Tools For Performance Diagnostics
JDK Tools For Performance DiagnosticsJDK Tools For Performance Diagnostics
JDK Tools For Performance DiagnosticsBaruch Sadogursky
 
a friend in need-a js indeed / Yonatan levin
a friend in need-a js indeed / Yonatan levina friend in need-a js indeed / Yonatan levin
a friend in need-a js indeed / Yonatan levingeektimecoil
 
A friend in need - A JS indeed
A friend in need - A JS indeedA friend in need - A JS indeed
A friend in need - A JS indeedYonatan Levin
 
Extending Android with New Devices
Extending Android with New DevicesExtending Android with New Devices
Extending Android with New DevicesShree Kumar
 
The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84Mahmoud Samir Fayed
 
FusionInventory at LSM/RMLL 2012
FusionInventory at LSM/RMLL 2012FusionInventory at LSM/RMLL 2012
FusionInventory at LSM/RMLL 2012Nouh Walid
 
2012 java one-con3648
2012 java one-con36482012 java one-con3648
2012 java one-con3648Eing Ong
 

Semelhante a Developing Rich Interfaces in JavaFX for Ultrabooks (20)

Jollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-levelJollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-level
 
Using multitouch and sensors in Java
Using multitouch and sensors in JavaUsing multitouch and sensors in Java
Using multitouch and sensors in Java
 
Programming The Real World
Programming The Real WorldProgramming The Real World
Programming The Real World
 
IoT on Raspberry Pi
IoT on Raspberry PiIoT on Raspberry Pi
IoT on Raspberry Pi
 
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Hack the Real World with ANDROID THINGS
Hack the Real World with ANDROID THINGSHack the Real World with ANDROID THINGS
Hack the Real World with ANDROID THINGS
 
Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)
 
Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013
 
Node.js at Joyent: Engineering for Production
Node.js at Joyent: Engineering for ProductionNode.js at Joyent: Engineering for Production
Node.js at Joyent: Engineering for Production
 
JDK Tools For Performance Diagnostics
JDK Tools For Performance DiagnosticsJDK Tools For Performance Diagnostics
JDK Tools For Performance Diagnostics
 
a friend in need-a js indeed / Yonatan levin
a friend in need-a js indeed / Yonatan levina friend in need-a js indeed / Yonatan levin
a friend in need-a js indeed / Yonatan levin
 
A friend in need - A JS indeed
A friend in need - A JS indeedA friend in need - A JS indeed
A friend in need - A JS indeed
 
Extending Android with New Devices
Extending Android with New DevicesExtending Android with New Devices
Extending Android with New Devices
 
Opencv
OpencvOpencv
Opencv
 
The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84
 
FusionInventory at LSM/RMLL 2012
FusionInventory at LSM/RMLL 2012FusionInventory at LSM/RMLL 2012
FusionInventory at LSM/RMLL 2012
 
2012 java one-con3648
2012 java one-con36482012 java one-con3648
2012 java one-con3648
 

Mais de Bruno Borges

Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesBruno Borges
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on KubernetesBruno Borges
 
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsFrom GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsBruno Borges
 
Making Sense of Serverless Computing
Making Sense of Serverless ComputingMaking Sense of Serverless Computing
Making Sense of Serverless ComputingBruno Borges
 
Visual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring DevelopersVisual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring DevelopersBruno Borges
 
Taking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudTaking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudBruno Borges
 
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...Bruno Borges
 
Melhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemMelhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemBruno Borges
 
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemTecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemBruno Borges
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudBruno Borges
 
Migrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXMigrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXBruno Borges
 
Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?Bruno Borges
 
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Bruno Borges
 
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Bruno Borges
 
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]Bruno Borges
 
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Bruno Borges
 
Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]Bruno Borges
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the CloudBruno Borges
 
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXTweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXBruno Borges
 
Integrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSocketsIntegrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSocketsBruno Borges
 

Mais de Bruno Borges (20)

Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on Kubernetes
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes
 
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsFrom GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
 
Making Sense of Serverless Computing
Making Sense of Serverless ComputingMaking Sense of Serverless Computing
Making Sense of Serverless Computing
 
Visual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring DevelopersVisual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring Developers
 
Taking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudTaking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure Cloud
 
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
 
Melhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemMelhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na Nuvem
 
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemTecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The Cloud
 
Migrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXMigrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFX
 
Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?
 
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
 
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
 
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
 
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
 
Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the Cloud
 
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXTweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
 
Integrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSocketsIntegrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSockets
 

Último

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Último (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Developing Rich Interfaces in JavaFX for Ultrabooks

  • 1. Developing Rich Interfaces in JavaFX for Ultrabooks Felipe Pedroso Community Manager – Intel Brazil Bruno Borges Principal Product Manager - Oracle LAD
  • 2. 2 Program Agenda  The Future of PCs  JavaFX and Touch Support  Using JNI to Work with Sensors
  • 9. 9 The Ultrabook™ Platform Reshaping the PC Experience 9 Ambient Light Sensor Ambient Light Sensor GPS GPS Compass Compass Near Field Communicati on Near Field Communicati on Gyroscope Gyroscope Ultrabook ™ Accelerometer Accelerometer Multi-Touch Multi-Touch Context Aware Sensors
  • 10. 10 OK, they have all those features… … but how can we implement them using Java?
  • 11. 11 To allow users to TOUCH my Java App... • Should I use... – AWT? Swing? SWT? • Actually, you can use them but... – They aren’t made for multi-touch (OK, there’s a way to do it) – You must optimize your UI controls to be more ‘touch friendly’ • So, how to do it in a simple and easy way?
  • 12. 12
  • 14. 14 Actions supported • Touch events: Down, Move and Up – Tap (Down and Up) / Double tap – Drag and Drop (Down, Move and Up) – Hold • Gestures – Swipe: Up, Down, Left and Right – Zoom: Pinch / Spread – Rotate
  • 15. 15 • Your components must extend the Node class or any of its subclasses (StackPane, ImageView, etc) • Set the proper EventHandler to handle the action. 15 What do I need to do to manipulate components?
  • 16. 16 • Apply a transform to the component (Translation, Rotation and Scale): • Let’s dive into some code! What do I need to do to manipulate components?
  • 18. 18 Available sensors on Ultrabooks • Accelerometer – Proper acceleration in three axis (x, y, z) • Gyrometer – Device orientation • Magnetometer – Strenght and direction of magnetic fields • GPS (Global Positioning System) – Location and Time information • NFC – Near Field Communication • Ambient Light Sensor – Ambient Light Level 18
  • 19. 19 API Windows – Sensor Fusion
  • 20. 20 API Windows – Namespaces • Windows.Sensors.* Common sensors – Accelerometer – Gyrometer – Inclinometer – OrientationSensor – SimpleOrientationSensor – Compass – LightSensor • Windows.Devices.Geolocation GPS – Geolocator • Windows.Networking.Proximity NFC – ProximityDevice
  • 21. 21 Windows API – How to • Get the default object of your sensor using the GetDefault method • You can call the GetCurrentReading() to get the current value of the sensors or... • ... work with the ReadingChanged event – Set the attribute ReportInterval (please, respect the MinimumReportInterval to avoid problems) – Delegate a method to handle the event (something like setting a method as a listener) – Handle the event! • This procedure is valid only for sensors from Windows.Sensors namespace
  • 22. 22 How can I access that?
  • 23. 23 Using JNI to access the sensors from Windows.Sensors 1. [Java] Create a native method to register the object that will handle the events that come from the sensor 2. Generate the header file using javah 3. [C++] Create a DLL Project in Visual Studio with the DLLs and namespaces of the Windows 8 APIS 4. [C++] Use a variable to keep a reference to the object and the ID (GetMethodID) of the method that will handle the event
  • 24. 24 Using JNI to access the sensors from Windows.Sensors 5. [C++] Initialize the sensor and delegate a C++ method to handle the event 6. [C++] Redirect the delegate method call to the Java method using the function CallVoidMethod with the following parameters: the Java Object, the method ID and it’s parameters 7. [Java] Handle the event! A lot of text? Please, show me the code!
  • 25. 25 JNI Callback from C++ to Java public final class ShakenSensor { static { System.loadLibrary("ShakenLib"); } private ShakenListener listener; public ShakenSensor (ShakenListener listener) { this.listener = listener; } public native boolean registerObject(); public native boolean registerMethod(); private void shaken(long timestamp) { listener.shaken(timestamp); } } Load the C++ Library Define native methods private method to be called from C++
  • 26. 26 JNI Callback from C++ to Java // Shaken.h JNIEXPORT jboolean JNICALL Java_sample_ShakenSensor_registerObject (JNIEnv *, jobject obj); JNIEXPORT jboolean JNICALL Java_sample_ShakenSensor_registerMethod (JNIEnv * env, jobject obj); The header file with mapped native JNI methods
  • 27. 27 JNI Callback from C++ to Java // Shaken.cpp #include "Shaken.h" #include "jni.h" #include<iostream> #using <Windows.winmd> #using <Platform.winmd> using namespace::Windows::Devices::Sensors; JavaVM * currentJvm; jobject shakenSensorJObject; jmethodID shakenJMethod; // ShakenSensor.shaken(long) cpp file including: Windows Sensor Fusion API Java Native Interface header Shaken header Keep references of jobject, jmethodID, currentJvm
  • 28. 28 JNI Callback from C++ to Java // Shaken.cpp …_ShakenSensor_registerObject (JNIEnv * env, jobject obj) { shakenSensorJObject = env->NewGlobalRef(obj); jclass shakenSensorClass = env->GetObjectClass(shakenSensorJObject); shakenJMethod = env->GetMethodID(shakenSensorClass, "shaken", "(J)V"); env->GetJavaVM(&currentJvm); … } Get a reference to ShakenSensor object from JNIEnv, then the jclass, then the shaken Java method
  • 29. 29 JNI Callback from C++ to Java // Shaken.cpp void Shaken(Accelerometer^ sender, AccelerometerShakenEventArgs^ args){ invokeShakenOnJava(args->Timestamp.UniversalTime / 10000); } …_ShakenSensor_registerMethod (JNIEnv * env, jobject obj) { accelerometer->Shaken += ref new Windows::Foundation::TypedEventHandler<Accelerometer^,AccelerometerShakenEventArgs^>(&Shaken); … } registerMethod activates the Sensor and register events to Shaken C++ method Shaken method forwards data to Java
  • 30. 30 JNI Callback from C++ to Java // Shaken.cpp void invokeShakenOnJava(jlong timest){ JNIEnv * jniEnvironment; int envStt = currentJvm->GetEnv((void **)&jniEnvironment, JNI_VERSION_1_6); // check the envStat == JNI_OK //and call currentJvm->AttachCurrentThread if necessary … // call the Java method on the ShakenSensor Java Object jniEnvironment->CallVoidMethod(shakenSensorJObject, shakenJMethod,timest); // always detach current thread currentJvm->DetachCurrentThread(); } Make sure JVM is attached to thread, then call the method shakenJMethod
  • 31. 31 What about Linux? Touch works fine, but there aren’t clear APIs to read sensors. If you know how to do it, let’s work together!
  • 32. 32 Want to know more about Intel Software? http://software.intel.com/en-us/
  • 35. 35
  • 36. 36 • The PC experience is being reshaped • JavaFX + Touch = AWESOME • Using JNI to access the sensors can be LEGENDARY! Take aways
  • 37. 37 Questions? (if yes, the answer is 42)
  • 38. 38 Thanks a lot! Bruno Borges facebook.com/brunocborges @brunoborges Felipe Pedroso facebook.com/felipe.a.pedroso @felipeapedroso