Please note: You must be signed in to download files.
Capturing mouse points and drawing on the screen in Java can be burdensome. The Java Virtual Machines that run on embedded devices do their best to handle native windows messages as fast as possible, but it often does not translate to the type of speed and performance one can gain from doing this in a native application. When implementing signature capture purely within Java, I've noticed that the mouse points captured are choppy and rigid, and that the drawing of the actual signature on the screen is slow.
Therefore, we're going to show you how to offload this task completely to the native side with a JNI example.
The project attached was built with eMbedded Visual Tools 4.0, but the project can easily be converted to either Visual Studio 2005 or Visual Studio 2008. The JNI DLL was compiled with SUN's JDK version 1.4.2 (19), along with the Java demo.
The way we do it here is to subclass (intercept the window handle of) a Java Frame object, which means that we would then handle all the windows messages destined for the Java window. Within that Java Frame object we define a Java Canvas object which we will officially designate as the signature capture window.
When you subclass a windows procedure, you handle ALL messages to the window, but the trick here is to only pay attention to windows messages that occur within the signature control window. Thus, any mouse movements outside this rectangle should be ignored and passed back to the original windows procedure that handles the Java Frame object. In addition, you should only pay attention to WM_PAINT messages that affect the signature capture area only.
From the native code, you will see that when we are ready to draw to the signature capture area, we only invalidate that region (rectangle) of the window, and we evaluate the WM_PAINT message to ensure that this area of the window is the only one that is being affected.
We also expose a method for users to offload the actual creation of the .BMP file of the signature capture region to native code.
We've included a Java demo that exercises these native functions. It creates a simple Frame that includes a Canvas (signature capture) and a button for creating a .BMP file of the current signature in the Canvas.
A prebuilt .CAB is included in the .zip of the project that contains all of the necessary files (Java test .jar, native DLL and .lnk file) to see the sample work.
NOTE: This was tested against NSIcom's Cr-EME JVM (version 4.12 - resolution aware) on a Windows Mobile 6.1 Professional device. The sample would need to be modified slightly to run against QVGA screens, because the sample hard codes its window boundaries based on VGA type screen resolutions.
I've been trying to use this demo on Windows mobile 6.1 professional but using a different JVM (esmertec jbed) and not having much luck. I've changed the java code to use the correct screen resolutions (using a 240x320) screen. The canvas will display okay but nothing appears when I try and write on it. Pressing the capture button will save the image but without a signature. Does the dll depend on any specific features of that particular Cr-EME JVM?