Permalink
Browse files

Multitouch Controller updated

  • Loading branch information...
1 parent 30a08a3 commit 9652ac44813fa6a1d5dd19961851baa7bc22d4b8 @dbyrne committed Mar 15, 2011
@@ -30,7 +30,10 @@
import android.content.Context;
import android.content.res.Configuration;
import android.util.AttributeSet;
-import byrne.fractal.MultiTouchController.*;
+
+import org.metalev.multitouch.controller.MultiTouchController;
+import org.metalev.multitouch.controller.MultiTouchController.*;
+
public class FractalView extends View implements MultiTouchObjectCanvas<FractalView.Img> {
@@ -41,7 +44,7 @@
private ComplexEquation equation;
private MultiTouchController<FractalView.Img> multiTouchController;
private Resources res;
- private boolean setFull = false, zoom = true, greenLight = true, relative=false;
+ private boolean setFull = false, zoom = true, relative=false;
private ColorSet colorSet = ColorSet.RAINBOW;
private FractalType fractalType = FractalType.MANDELBROT;
int maxIterations = 40;
@@ -55,7 +58,7 @@
public FractalView(Context context, AttributeSet attrs) {
super(context, attrs);
res = context.getResources();
- multiTouchController = new MultiTouchController<FractalView.Img>(this, res);
+ multiTouchController = new MultiTouchController<FractalView.Img>(this);
this.setEquation(ComplexEquation.SECOND_ORDER);
}
@@ -312,11 +315,6 @@ public void stopFractalTask() {
mGenerateFractalTask.cancel(true);
}
- while(!greenLight) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {}
- }
}
public void startFractalTask(boolean reset) {
@@ -334,14 +332,13 @@ public void startFractalTask(boolean reset) {
mFractoid.setCalibrateButtonEnabled(false,relative);
calculateColors(1021);
- greenLight = false;
+
mGenerateFractalTask = new GenerateFractalTask(this,relative);
+ System.out.println("Starting new fractal");
mGenerateFractalTask.execute();
}
- public void greenLight() {
- greenLight = true;
- }
+
public void setRelative(boolean r) {
relative = r;
@@ -454,11 +451,7 @@ protected void resetCoords() {
return true;
} else {
if (fractalBitmap != null) {
- if (greenLight){
- return multiTouchController.onTouchEvent(event);
- } else {
- stopFractalTask();
- }
+ return multiTouchController.onTouchEvent(event);
}
}
return true;
@@ -501,6 +494,7 @@ public Img getDraggableObjectAtPoint(PointInfo pt) {
*/
public void selectObject(Img img, PointInfo touchPoint) {
if (img == null) {
+ System.out.println("fractalBitmap="+fractalBitmap.toString());
backgroundBitmap = fractalBitmap;
recalculate();
}
@@ -509,7 +503,8 @@ public void selectObject(Img img, PointInfo touchPoint) {
/** Get the current position and scale of the selected image. Called whenever a drag starts or is reset. */
public void getPositionAndScale(Img img, PositionAndScale objPosAndScaleOut) {
- objPosAndScaleOut.set(img.getCenterX(), img.getCenterY(), img.getScale());
+ objPosAndScaleOut.set(img.getCenterX(), img.getCenterY(),true, img.getScale(),
+ false, 0.0f, 0.0f, false, 0.0f);
}
/** Set the position and scale of the dragged/stretched image. */
@@ -41,10 +41,8 @@
import android.content.ContentValues;
import android.widget.Button;
import android.widget.EditText;
-import byrne.fractal.MultiTouchController;
-import byrne.fractal.MultiTouchController.MultiTouchObjectCanvas;
-import byrne.fractal.MultiTouchController.PointInfo;
-import byrne.fractal.MultiTouchController.PositionAndScale;
+
+import org.metalev.multitouch.controller.MultiTouchController.*;
//import android.os.Debug;
@@ -74,7 +74,6 @@ private Bitmap createBitmap() {
updateCount++;
if (isCancelled()) {
- fractalView.greenLight();
return b;
}
@@ -131,7 +130,6 @@ private Bitmap createBitmap() {
fractalView.clearBackground();
fractalView.setTime(System.currentTimeMillis()-startTime);
fractalView.turnCalibrateButtonOn();
- fractalView.greenLight();
fractalView.invalidate();
}
}
Oops, something went wrong.

0 comments on commit 9652ac4

Please sign in to comment.