Anticipating the day when multi-touch interfaces become more pervasive, are there libraries in Java that can be used for developing touch applications? I'm looking for interfaces similar to MouseListener / MouseMotionListener / MouseWheelListener.
The MT4j project has everything you need to develop multitouch applications in java. All the well known multitouch gestures are already built in and can be accessed as simple as listening to mouse events (for example: component.addGestureListener(..)). It also features a hardware accelerated scene graph, similar to JavaFX. You can even simulate multitouch input by connecting one ore more mice to your machine. Check it out at http://www.mt4j.org
Sparsh is still in my bookmarks from the last time I was investigating multitouch java solutions.
While not as straight forward as the typical mouse listener or click listener, it still provides a reasonable interface.
You need your listening class to implement sparshui.client.Client
, which requires the processEvent
method definition.
public void processEvent(int groupID, Event event) {
if(event instanceof TouchEvent) {
TouchEvent e = (TouchEvent)event;
if(e.getState() == TouchState.BIRTH) {
//do initial touch stuff
} else if(e.getState() == TouchState.MOVE) {
//do dragging stuff
}
}
else if(event instanceof DragEvent) {
DragEvent e = (DragEvent)event;
//do DragEvent specific stuff
} else if(event instanceof RotateEvent) {
RotateEvent e = (RotateEvent)event;
//do RotateEvent specific stuff
} else if(event instanceof ZoomEvent) {
ZoomEvent e = (ZoomEvent)event;
//do ZoomEvent specific stuff
}
//several other gesture types....
}
After that, you need to start up the gesture recognition server, passing in your component
new ServerConnection("localhost", objectImplementingClientInterface);
Looking at the code examples on the site should give you a pretty good idea of the framework.
How about this: http://kenai.com/projects/macmultitouch
I am primarily working in Processing and designing my UI from the ground up. I've been looking for a solution which doesn't prescribe a UI framework which both MT4J and JavaFX appear to do. Furthermore, MT4J appears to be abandoned.
This looks like a promising solution at least for Windows but I'm unsure if it's actually released yet: http://wiki.gestureworks.com/index.php/GestureWorksCore:Gestureworks_Core_Tutorials
This is specifically for Processing, cross-platform, open-source and active: https://github.com/vialab/SMT
MT4J doesn't work with Windows 8.
If the applicatin is only for one user, you can use JavaFX. There are different listener for touch events. But it is not possible to process two gestures at the same time, because all touch points will merge to one gesture. For big multi touch screens it is a disadvange. For normal screens, where is only one user its ok.
But there is also GestureWorks. There you can define new gesture or use the predefined gesture. The gestures are defined in a XML File (called GML). Any object can handle there own gestures. But you have to implement the hitTest and the point assignment manually. But there is a greate tutorial.
Another library, which i don't tested, ist the Multi Touch SDK by PQ Lab.
© 2022 - 2024 — McMap. All rights reserved.