// 3 variations to zoom with two finger gestures
// TODO Do study on usability for different interaction approaches.
// 1. pos of last finger
Location centerLocation = map.getLocation(transCenter.x, transCenter.y);
zoomMapEvent.setTransformationCenterLocation(centerLocation);
// 2. object center: pinch gesture w/o fixed finger-location connection
// float[] objectCenterXY =
// map.mapDisplay.getScreenFromObjectPosition(map.mapDisplay.getWidth()/2,
// map.mapDisplay.getHeight()/2);
// PVector objectCenter = new PVector(objectCenterXY[0], objectCenterXY[1]);
// map.mapDisplay.setInnerTransformationCenter(objectCenter);
// 3. middle pos between both fingers
float newDist = getDistance(tuioCursor1, tuioCursor2);
float scaleDelta = newDist / oldDist;
oldDist = newDist;
zoomMapEvent.setZoomDelta(scaleDelta);
eventDispatcher.fireMapEvent(zoomMapEvent);
}
if (rotate) {
// TODO Use events (instead of direct map manipulation)
// rotate center
map.mapDisplay.setTransformationCenter(transCenter);
float newAngle = getAngleBetween(tuioCursor1, tuioCursor2);
float angle = newAngle - oldAngle;
oldAngle = newAngle;
map.rotate(angle);
}
} else if (tuioCursor1 != null) {
// One finger: pan
if (tuioCursor1.getCursorID() == tcur.getCursorID()) {
TuioPoint oldTuioPoint = tcur.getPath().get(tcur.getPath().size() - 2);
Location fromLocation = map.mapDisplay.getLocation(oldTuioPoint.getScreenX(p.width),
oldTuioPoint.getScreenY(p.height));
Location toLocation = map.mapDisplay.getLocation(tuioCursor1.getScreenX(p.width),
tuioCursor1.getScreenY(p.height));
PanMapEvent panMapEvent = new PanMapEvent(this, map.getId(), PanMapEvent.PAN_BY);
panMapEvent.setFromLocation(fromLocation);
panMapEvent.setToLocation(toLocation);