package org.pollux3d.state;
import org.pollux3d.tuio.TuioInput;
import org.pollux3d.tuio.TuioInputListener;
import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.scene.Node;
public class TuioStatsState extends AbstractAppState implements TuioInputListener {
private TuioInput tuioInput;
private Node tuioStatsNode = new Node("TUIO Stats Node");
protected BitmapText tuioStatsText;
protected BitmapText tuioStatsText2;
public Node getTuioStatsNode() {
return tuioStatsNode;
}
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
tuioInput = TuioInput.get();
tuioInput.addListener(this);
BitmapFont guiFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt");
BitmapText tuioStatsLabel = new BitmapText(guiFont, false);
tuioStatsLabel.setLocalTranslation(0, tuioStatsLabel.getLineHeight()*3, 0);
tuioStatsLabel.setText("Tuio Input:");
tuioStatsNode.attachChild(tuioStatsLabel);
tuioStatsText = new BitmapText(guiFont, false);
tuioStatsText.setLocalTranslation(80, tuioStatsText.getLineHeight()*3, 0);
tuioStatsText.setText("");
tuioStatsNode.attachChild(tuioStatsText);
tuioStatsText2 = new BitmapText(guiFont, false);
tuioStatsText2.setLocalTranslation(80, tuioStatsText2.getLineHeight()*2, 0);
tuioStatsText2.setText("");
tuioStatsNode.attachChild(tuioStatsText2);
}
public void onMove(int cursorId, int delta, int delta2, int newX, int newY) {
if (cursorId == 0) {
tuioStatsText.setText("X: "+newX+" Y:"+newY);
} else if(cursorId == 1) {
tuioStatsText2.setText("X: "+newX+" Y:"+newY);
}
}
public void onNew(int cursorId, int x, int y) {
}
public void onRelease(int cursorId) {
if (cursorId == 0) {
tuioStatsText.setText("");
} else if(cursorId == 1) {
tuioStatsText2.setText("");
}
}
}