Created
September 19, 2011 14:27
-
-
Save DrDaleks/1226619 to your computer and use it in GitHub Desktop.
Icy multi-touch sample code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package plugins.adufour.tests; | |
import javax.vecmath.Vector2f; | |
import plugins.adufour.ezplug.EzLabel; | |
import plugins.adufour.ezplug.EzPlug; | |
import plugins.adufour.ezplug.EzStoppable; | |
import plugins.adufour.multitouch.MultiTouchProvider; | |
import plugins.adufour.multitouch.TwoFingersListener; | |
public class TestMT extends EzPlug implements EzStoppable | |
{ | |
EzLabel label = new EzLabel(" "); | |
@Override | |
protected void initialize() | |
{ | |
addEzComponent(label); | |
} | |
MultiTouchProvider mtp; | |
TwoFingersListener tfl; | |
boolean stop; | |
@Override | |
protected void execute() | |
{ | |
stop = false; | |
mtp = new MultiTouchProvider(); | |
tfl = new TwoFingersListener() | |
{ | |
@Override | |
public void rotate(MultiTouchProvider source, float angle) | |
{ | |
label.setText("Rotation: " + angle); | |
} | |
@Override | |
public void pinch(MultiTouchProvider source, float delta) | |
{ | |
label.setText("Pinch: " + delta); | |
} | |
@Override | |
public void drag(MultiTouchProvider source, Vector2f direction, float delta) | |
{ | |
label.setText("Drag [" + direction.x + "," + direction.y + "]: " + delta); | |
} | |
}; | |
mtp.addTwoFingersListener(tfl); | |
System.out.println("started listening multitouch events..."); | |
while (!stop) | |
Thread.yield(); | |
} | |
@Override | |
public void clean() | |
{ | |
} | |
@Override | |
public void stopExecution() | |
{ | |
stop = true; | |
mtp.removeTwoFingersListener(tfl); | |
mtp = null; | |
System.out.println("stopped listening multitouch events !"); | |
System.gc(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment