/*----------------------setPositionAndScale--------------------------------------------------------------------*/ public boolean setPositionAndScale(KiwiGLSurfaceView obj, PositionAndScale pos, PointInfo info) { Log.d(TAG, "setPositionAndScale"); if (this.mLastTouchInfo == null) { this.mLastTouchInfo = new PointInfo(); this.mLastTouchInfo.set(info); return true; } this.mCurrentTouchInfo.set(info); boolean isMulti = mLastTouchInfo.isMultiTouch(); float dx = mCurrentTouchInfo.getX() - mLastTouchInfo.getX(); float dy = mCurrentTouchInfo.getY() - mLastTouchInfo.getY(); float x1 = mCurrentTouchInfo.getX(); float y1 = mCurrentTouchInfo.getY(); float x0 = x1 - dx; float y0 = y1 + dy; float scale = 1.0f; float angle = 0.0f; if (isMulti && mLastTouchInfo.getMultiTouchDiameter() != 0.0f) { scale = mCurrentTouchInfo.getMultiTouchDiameter() / mLastTouchInfo.getMultiTouchDiameter(); } if (isMulti) { angle = mCurrentTouchInfo.getMultiTouchAngle() - mLastTouchInfo.getMultiTouchAngle(); } MyRunnable myrun = new MyRunnable(); myrun.dx = dx; myrun.dy = dy; myrun.x0 = x0; myrun.y0 = y0; myrun.x1 = x1; myrun.y1 = y1; myrun.scale = scale; myrun.angle = angle; myrun.isMulti = isMulti; this.queueEvent(myrun); mLastTouchInfo.set(mCurrentTouchInfo); return true; }
public void testJoin() throws Exception { ExecutorService es = Executors.newFixedThreadPool(10); List<MyRunnable> runnables = new ArrayList<MyRunnable>(); for (int i = 0; i < 6; i++) { runnables.add(new MyRunnable(service.getEPRuntime())); } for (Runnable toRun : runnables) { es.submit(toRun); } es.shutdown(); es.awaitTermination(20, TimeUnit.SECONDS); for (MyRunnable runnable : runnables) { assertNull(runnable.getException()); } }