Project

General

Profile

Download (21.9 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / main / RubikSurfaceView.java @ 0b7e1b05

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.main;
21

    
22
import android.app.ActivityManager;
23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
25
import android.opengl.GLSurfaceView;
26
import android.util.AttributeSet;
27
import android.util.DisplayMetrics;
28
import android.view.MotionEvent;
29

    
30
import org.distorted.library.type.Static2D;
31
import org.distorted.library.type.Static3D;
32
import org.distorted.library.type.Static4D;
33
import org.distorted.objects.RubikObject;
34
import org.distorted.objects.RubikObjectMovement;
35
import org.distorted.solvers.SolverMain;
36
import org.distorted.states.RubikState;
37
import org.distorted.states.RubikStateSolver;
38
import org.distorted.states.RubikStateSolving;
39

    
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

    
42
public class RubikSurfaceView extends GLSurfaceView
43
{
44
    private static final int NUM_SPEED_PROBES = 10;
45

    
46
    public static final int MODE_ROTATE  = 0;
47
    public static final int MODE_DRAG    = 1;
48
    public static final int MODE_REPLACE = 2;
49

    
50
    // Moving the finger from the middle of the vertical screen to the right edge will rotate a
51
    // given face by SWIPING_SENSITIVITY/2 degrees.
52
    private final static int SWIPING_SENSITIVITY  = 240;
53
    // Moving the finger by 0.33 of an inch will start a Rotation.
54
    private final static float ROTATION_SENSITIVITY =  0.33f;
55
    // Every 0.33 of an inch the direction of cube drag will reset.
56
    private final static float DIRECTION_SENSITIVITY=  0.33f;
57

    
58
    // Where did we get this sqrt(3)/2 ? From the (default, i.e. 60 degrees - see InternalOutputSurface!)
59
    // FOV of the projection matrix of the Node onto the Screen.
60
    // Take a look how the CAMERA_POINT is used in onTouchEvent - (x,y) there are expressed in sort of
61
    // 'half-NDC' coordinates i.e. they range from +0.5 to -0.5; thus CAMERA_POINT also needs to be
62
    // in 'half-NDC'. Since in this coordinate system the height of the screen is equal to 1, then the
63
    // Z-distance from the center of the object to the camera is equal to (scrHeight/2)/tan(FOV/2) =
64
    // 0.5/tan(30) = sqrt(3)/2.
65
    // Why is the Z-distance between the camera and the object equal to (scrHeight/2)/tan(FOV/2)?
66
    // Because of the way the View part of the ModelView matrix is constructed in EffectQueueMatrix.send().
67
    private final Static4D CAMERA_POINT = new Static4D(0, 0, (float)Math.sqrt(3)*0.5f, 0);
68

    
69
    private RubikRenderer mRenderer;
70
    private RubikPreRender mPreRender;
71
    private RubikObjectMovement mMovement;
72
    private boolean mDragging, mBeginningRotation, mContinuingRotation;
73
    private int mScreenWidth, mScreenHeight, mScreenMin;
74

    
75
    private int mNumFingersDown;
76
    private float mX, mY;
77
    private float mStartRotX, mStartRotY;
78
    private float mAxisX, mAxisY;
79
    private float mRotationFactor;
80
    private int mLastCubitColor, mLastCubitFace, mLastCubit;
81
    private int mCurrentAxis, mCurrentRow;
82
    private float mCurrentAngle, mCurrRotSpeed;
83
    private float[] mLastX;
84
    private float[] mLastY;
85
    private long[] mLastT;
86
    private int mFirstIndex, mLastIndex;
87
    private int mDensity;
88

    
89
    private static Static4D mQuatCurrent    = new Static4D(0,0,0,1);
90
    private static Static4D mQuatAccumulated= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
91
    private static Static4D mTempCurrent    = new Static4D(0,0,0,1);
92
    private static Static4D mTempAccumulated= new Static4D(0,0,0,1);
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

    
96
    void setScreenSize(int width, int height)
97
      {
98
      mScreenWidth = width;
99
      mScreenHeight= height;
100

    
101
      mScreenMin = Math.min(width, height);
102
      }
103

    
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105

    
106
    boolean isVertical()
107
      {
108
      return mScreenHeight>mScreenWidth;
109
      }
110

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

    
113
    RubikRenderer getRenderer()
114
      {
115
      return mRenderer;
116
      }
117

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

    
120
    RubikPreRender getPreRender()
121
      {
122
      return mPreRender;
123
      }
124

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

    
127
    void setQuatAccumulated()
128
      {
129
      mQuatAccumulated.set(mTempAccumulated);
130
      }
131

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

    
134
    void setQuatCurrent()
135
      {
136
      mQuatCurrent.set(mTempCurrent);
137
      }
138

    
139
///////////////////////////////////////////////////////////////////////////////////////////////////
140

    
141
    Static4D getQuatAccumulated()
142
      {
143
      return mQuatAccumulated;
144
      }
145

    
146
///////////////////////////////////////////////////////////////////////////////////////////////////
147

    
148
    Static4D getQuatCurrent()
149
      {
150
      return mQuatCurrent;
151
      }
152

    
153
///////////////////////////////////////////////////////////////////////////////////////////////////
154

    
155
    void setMovement(RubikObjectMovement movement)
156
      {
157
      mMovement = movement;
158
      }
159

    
160
///////////////////////////////////////////////////////////////////////////////////////////////////
161

    
162
    private Static4D quatFromAngle(float angle)
163
      {
164
      float cosA = (float)Math.cos(angle);
165
      float sinA =-(float)Math.sin(angle);
166

    
167
      return new Static4D(0, 0, sinA, cosA);
168
      }
169

    
170
///////////////////////////////////////////////////////////////////////////////////////////////////
171

    
172
    private Static4D quatFromDrag(float dragX, float dragY)
173
      {
174
      float axisX = dragY;  // inverted X and Y - rotation axis is perpendicular to (dragX,dragY)
175
      float axisY = dragX;  // Why not (-dragY, dragX) ? because Y axis is also inverted!
176
      float axisZ = 0;
177
      float axisL = (float)Math.sqrt(axisX*axisX + axisY*axisY + axisZ*axisZ);
178

    
179
      if( axisL>0 )
180
        {
181
        axisX /= axisL;
182
        axisY /= axisL;
183
        axisZ /= axisL;
184

    
185
        float ratio = axisL;
186
        ratio = ratio - (int)ratio;     // the cos() is only valid in (0,Pi)
187

    
188
        float cosA = (float)Math.cos(Math.PI*ratio);
189
        float sinA = (float)Math.sqrt(1-cosA*cosA);
190

    
191
        return new Static4D(axisX*sinA, axisY*sinA, axisZ*sinA, cosA);
192
        }
193

    
194
      return new Static4D(0f, 0f, 0f, 1f);
195
      }
196

    
197
///////////////////////////////////////////////////////////////////////////////////////////////////
198
// cast the 3D axis we are currently rotating along to the 2D in-screen-surface axis
199

    
200
    private void computeCurrentAxis(Static3D axis)
201
      {
202
      Static4D axis4D = new Static4D(axis.get0(), axis.get1(), axis.get2(), 0);
203
      Static4D result = rotateVectorByQuat(axis4D, mQuatAccumulated);
204

    
205
      mAxisX =result.get0();
206
      mAxisY =result.get1();
207

    
208
      float len = (float)Math.sqrt(mAxisX*mAxisX + mAxisY*mAxisY);
209
      mAxisX /= len;
210
      mAxisY /= len;
211
      }
212

    
213
///////////////////////////////////////////////////////////////////////////////////////////////////
214
// return quat1*quat2
215

    
216
    public static Static4D quatMultiply( Static4D quat1, Static4D quat2 )
217
      {
218
      float qx = quat1.get0();
219
      float qy = quat1.get1();
220
      float qz = quat1.get2();
221
      float qw = quat1.get3();
222

    
223
      float rx = quat2.get0();
224
      float ry = quat2.get1();
225
      float rz = quat2.get2();
226
      float rw = quat2.get3();
227

    
228
      float tx = rw*qx - rz*qy + ry*qz + rx*qw;
229
      float ty = rw*qy + rz*qx + ry*qw - rx*qz;
230
      float tz = rw*qz + rz*qw - ry*qx + rx*qy;
231
      float tw = rw*qw - rz*qz - ry*qy - rx*qx;
232

    
233
      return new Static4D(tx,ty,tz,tw);
234
      }
235

    
236
///////////////////////////////////////////////////////////////////////////////////////////////////
237
// rotate 'vector' by quat  ( i.e. return quat*vector*(quat^-1) )
238

    
239
    public static Static4D rotateVectorByQuat(Static4D vector, Static4D quat)
240
      {
241
      float qx = quat.get0();
242
      float qy = quat.get1();
243
      float qz = quat.get2();
244
      float qw = quat.get3();
245

    
246
      Static4D quatInverted= new Static4D(-qx,-qy,-qz,qw);
247
      Static4D tmp = quatMultiply(quat,vector);
248

    
249
      return quatMultiply(tmp,quatInverted);
250
      }
251

    
252
///////////////////////////////////////////////////////////////////////////////////////////////////
253
// rotate 'vector' by quat^(-1)  ( i.e. return (quat^-1)*vector*quat )
254

    
255
    public static Static4D rotateVectorByInvertedQuat(Static4D vector, Static4D quat)
256
      {
257
      float qx = quat.get0();
258
      float qy = quat.get1();
259
      float qz = quat.get2();
260
      float qw = quat.get3();
261

    
262
      Static4D quatInverted= new Static4D(-qx,-qy,-qz,qw);
263
      Static4D tmp = quatMultiply(quatInverted,vector);
264

    
265
      return quatMultiply(tmp,quat);
266
      }
267

    
268
///////////////////////////////////////////////////////////////////////////////////////////////////
269

    
270
    private void addSpeedProbe(float x, float y)
271
      {
272
      long currTime = System.currentTimeMillis();
273
      boolean theSame = mLastIndex==mFirstIndex;
274

    
275
      mLastIndex++;
276
      if( mLastIndex>=NUM_SPEED_PROBES ) mLastIndex=0;
277

    
278
      mLastT[mLastIndex] = currTime;
279
      mLastX[mLastIndex] = x;
280
      mLastY[mLastIndex] = y;
281

    
282
      if( mLastIndex==mFirstIndex)
283
        {
284
        mFirstIndex++;
285
        if( mFirstIndex>=NUM_SPEED_PROBES ) mFirstIndex=0;
286
        }
287

    
288
      if( theSame )
289
        {
290
        mLastT[mFirstIndex] = currTime;
291
        mLastX[mFirstIndex] = x;
292
        mLastY[mFirstIndex] = y;
293
        }
294
      }
295

    
296
///////////////////////////////////////////////////////////////////////////////////////////////////
297

    
298
    private void computeCurrentSpeedInInchesPerSecond()
299
      {
300
      long firstTime = mLastT[mFirstIndex];
301
      long lastTime  = mLastT[mLastIndex];
302
      float fX = mLastX[mFirstIndex];
303
      float fY = mLastY[mFirstIndex];
304
      float lX = mLastX[mLastIndex];
305
      float lY = mLastY[mLastIndex];
306

    
307
      long timeDiff = lastTime-firstTime;
308

    
309
      mLastIndex = 0;
310
      mFirstIndex= 0;
311

    
312
      mCurrRotSpeed = timeDiff>0 ? 1000*retFingerDragDistanceInInches(fX,fY,lX,lY)/timeDiff : 0;
313
      }
314

    
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316

    
317
    private float retFingerDragDistanceInInches(float xFrom, float yFrom, float xTo, float yTo)
318
      {
319
      float xDist = mScreenWidth*(xFrom-xTo);
320
      float yDist = mScreenHeight*(yFrom-yTo);
321
      float distInPixels = (float)Math.sqrt(xDist*xDist + yDist*yDist);
322

    
323
      return distInPixels/mDensity;
324
      }
325

    
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327

    
328
    private void setUpDragOrRotate(boolean down, float x, float y)
329
      {
330
      int mode = RubikState.getMode();
331

    
332
      if( mode==MODE_DRAG )
333
        {
334
        mDragging           = true;
335
        mBeginningRotation  = false;
336
        mContinuingRotation = false;
337
        }
338
      else
339
        {
340
        Static4D touchPoint1 = new Static4D(x, y, 0, 0);
341
        Static4D rotatedTouchPoint1= rotateVectorByInvertedQuat(touchPoint1, mQuatAccumulated);
342
        Static4D rotatedCamera= rotateVectorByInvertedQuat(CAMERA_POINT, mQuatAccumulated);
343

    
344
        if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint1,rotatedCamera) )
345
          {
346
          mDragging           = false;
347
          mContinuingRotation = false;
348

    
349
          if( mode==MODE_ROTATE )
350
            {
351
            mBeginningRotation= mPreRender.canRotate();
352
            }
353
          else if( mode==MODE_REPLACE )
354
            {
355
            mBeginningRotation= false;
356

    
357
            if( down )
358
              {
359
              RubikStateSolver solver = (RubikStateSolver) RubikState.SVER.getStateClass();
360
              mLastCubitFace = mMovement.getTouchedFace();
361
              float[] point = mMovement.getTouchedPoint3D();
362
              int color = solver.getCurrentColor();
363
              RubikObject object = mPreRender.getObject();
364
              mLastCubit = object.getCubit(point);
365
              mPreRender.setTextureMap( mLastCubit, mLastCubitFace, color );
366
              mLastCubitColor = SolverMain.cubitIsLocked(object.getObjectList(), object.getSize(), mLastCubit);
367
              }
368
            }
369
          }
370
        else
371
          {
372
          mDragging           = true;
373
          mBeginningRotation  = false;
374
          mContinuingRotation = false;
375
          }
376
        }
377
      }
378

    
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380

    
381
    private void drag(float x, float y)
382
      {
383
      if( retFingerDragDistanceInInches(mX,mY,x,y) > DIRECTION_SENSITIVITY )
384
        {
385
        mX = x;
386
        mY = y;
387
        mTempAccumulated.set(quatMultiply(mQuatCurrent, mQuatAccumulated));
388
        mTempCurrent.set(0f, 0f, 0f, 1f);
389
        mPreRender.setQuatCurrentOnNextRender();
390
        mPreRender.setQuatAccumulatedOnNextRender();
391
        }
392

    
393
      mTempCurrent.set(quatFromDrag(mX-x,y-mY));
394
      mPreRender.setQuatCurrentOnNextRender();
395
      }
396

    
397
///////////////////////////////////////////////////////////////////////////////////////////////////
398

    
399
    private void finishRotation()
400
      {
401
      computeCurrentSpeedInInchesPerSecond();
402
      int angle = mPreRender.getObject().computeNearestAngle(mCurrentAngle, mCurrRotSpeed);
403
      mPreRender.finishRotation(angle);
404

    
405
      if( RubikState.getCurrentState()==RubikState.SOLV && angle!=0 )
406
        {
407
        RubikStateSolving solving = (RubikStateSolving)RubikState.SOLV.getStateClass();
408
        solving.addMove(mCurrentAxis, mCurrentRow, angle);
409
        }
410

    
411
      mContinuingRotation = false;
412
      mBeginningRotation  = false;
413
      mDragging           = true;
414
      }
415

    
416
///////////////////////////////////////////////////////////////////////////////////////////////////
417

    
418
    private void continueRotation(float x, float y)
419
      {
420
      float dx = x-mStartRotX;
421
      float dy = y-mStartRotY;
422
      float alpha = dx*mAxisX + dy*mAxisY;
423
      float x2 = dx - alpha*mAxisX;
424
      float y2 = dy - alpha*mAxisY;
425

    
426
      float len = (float)Math.sqrt(x2*x2 + y2*y2);
427

    
428
      // we have the length of 1D vector 'angle', now the direction:
429
      float tmp = mAxisY==0 ? -mAxisX*y2 : mAxisY*x2;
430

    
431
      float angle = (tmp>0 ? 1:-1)*len*mRotationFactor;
432
      mCurrentAngle = SWIPING_SENSITIVITY*angle;
433
      mPreRender.getObject().continueRotation(mCurrentAngle);
434

    
435
      addSpeedProbe(x2,y2);
436
      }
437

    
438
///////////////////////////////////////////////////////////////////////////////////////////////////
439

    
440
    private void beginRotation(float x, float y)
441
      {
442
      mStartRotX = x;
443
      mStartRotY = y;
444

    
445
      Static4D touchPoint2 = new Static4D(x, y, 0, 0);
446
      Static4D rotatedTouchPoint2= rotateVectorByInvertedQuat(touchPoint2, mQuatAccumulated);
447

    
448
      Static2D res = mMovement.newRotation(rotatedTouchPoint2);
449
      RubikObject object = mPreRender.getObject();
450

    
451
      mCurrentAxis = (int)res.get0();
452
      float offset = res.get1();
453
      mCurrentRow = (int)(object.returnMultiplier()*offset);
454
      computeCurrentAxis( object.getRotationAxis()[mCurrentAxis] );
455
      mRotationFactor = object.returnRotationFactor(offset);
456

    
457
      object.beginNewRotation( mCurrentAxis, mCurrentRow );
458

    
459
      if( RubikState.getCurrentState()==RubikState.READ )
460
        {
461
        RubikStateSolving solving = (RubikStateSolving)RubikState.SOLV.getStateClass();
462
        solving.resetElapsed();
463

    
464
        final RubikActivity act = (RubikActivity)getContext();
465

    
466
        act.runOnUiThread(new Runnable()
467
          {
468
          @Override
469
          public void run()
470
            {
471
            RubikState.switchState( act, RubikState.SOLV);
472
            }
473
          });
474
        }
475

    
476
      addSpeedProbe(x,y);
477

    
478
      mBeginningRotation = false;
479
      mContinuingRotation= true;
480
      }
481

    
482
///////////////////////////////////////////////////////////////////////////////////////////////////
483

    
484
    private void actionMove(MotionEvent event)
485
      {
486
      float x = (event.getX() - mScreenWidth*0.5f)/mScreenMin;
487
      float y = (mScreenHeight*0.5f -event.getY())/mScreenMin;
488

    
489

    
490
      //android.util.Log.e("view", "num fingers: "+mNumFingersDown+" x="+event.getX()+" y="+event.getY());
491

    
492

    
493
      if( mBeginningRotation )
494
        {
495
        if( retFingerDragDistanceInInches(mX,mY,x,y) > ROTATION_SENSITIVITY )
496
          {
497
          beginRotation(x,y);
498
          }
499
        }
500
      else if( mContinuingRotation )
501
        {
502
        continueRotation(x,y);
503
        }
504
      else if( mDragging )
505
        {
506
        drag(x,y);
507
        }
508
      else
509
        {
510
        setUpDragOrRotate(false,x,y);
511
        }
512
      }
513

    
514
///////////////////////////////////////////////////////////////////////////////////////////////////
515

    
516
    private void actionDown(MotionEvent event)
517
      {
518
      mNumFingersDown++;
519

    
520
      //android.util.Log.e("view", "down1 num fingers: "+mNumFingersDown+" x="+event.getX()+" y="+event.getY());
521

    
522
      mX = (event.getX() - mScreenWidth*0.5f)/mScreenMin;
523
      mY = (mScreenHeight*0.5f -event.getY())/mScreenMin;
524

    
525
      setUpDragOrRotate(true,mX,mY);
526
      }
527

    
528
///////////////////////////////////////////////////////////////////////////////////////////////////
529

    
530
    private void actionUp(MotionEvent event)
531
      {
532
      mNumFingersDown--;
533

    
534
      //android.util.Log.e("view", "up1 num fingers: "+mNumFingersDown+" x="+event.getX()+" y="+event.getY());
535

    
536
      if( mDragging )
537
        {
538
        mTempAccumulated.set(quatMultiply(mQuatCurrent, mQuatAccumulated));
539
        mTempCurrent.set(0f, 0f, 0f, 1f);
540
        mPreRender.setQuatCurrentOnNextRender();
541
        mPreRender.setQuatAccumulatedOnNextRender();
542
        }
543

    
544
      if( mContinuingRotation )
545
        {
546
        finishRotation();
547
        }
548

    
549
      if( mLastCubitColor>=0 )
550
        {
551
        mPreRender.setTextureMap( mLastCubit, mLastCubitFace, mLastCubitColor );
552
        }
553
      }
554

    
555
///////////////////////////////////////////////////////////////////////////////////////////////////
556

    
557
    private void actionDown2(MotionEvent event)
558
      {
559
      mNumFingersDown++;
560

    
561
      if( mBeginningRotation )
562
        {
563
        mContinuingRotation = false;
564
        mBeginningRotation  = false;
565
        mDragging           = true;
566
        }
567
      else if( mContinuingRotation )
568
        {
569
        finishRotation();
570
        }
571

    
572
      //android.util.Log.e("view", "down2 num fingers: "+mNumFingersDown+" x="+event.getX()+" y="+event.getY());
573
      }
574

    
575
///////////////////////////////////////////////////////////////////////////////////////////////////
576

    
577
    private void actionUp2(MotionEvent event)
578
      {
579
      mNumFingersDown--;
580

    
581
      //android.util.Log.e("view", "up2 num fingers: "+mNumFingersDown+" x="+event.getX()+" y="+event.getY());
582
      }
583

    
584
///////////////////////////////////////////////////////////////////////////////////////////////////
585
// PUBLIC API
586
///////////////////////////////////////////////////////////////////////////////////////////////////
587

    
588
    public RubikSurfaceView(Context context, AttributeSet attrs)
589
      {
590
      super(context,attrs);
591

    
592
      if(!isInEditMode())
593
        {
594
        mLastCubitColor = -1;
595
        mCurrRotSpeed   = 0.0f;
596

    
597
        mLastX = new float[NUM_SPEED_PROBES];
598
        mLastY = new float[NUM_SPEED_PROBES];
599
        mLastT = new long[NUM_SPEED_PROBES];
600
        mFirstIndex =0;
601
        mLastIndex  =0;
602

    
603
        mNumFingersDown = 0;
604

    
605
        mRenderer  = new RubikRenderer(this);
606
        mPreRender = new RubikPreRender(this);
607

    
608
        RubikActivity act = (RubikActivity)context;
609
        DisplayMetrics dm = new DisplayMetrics();
610
        act.getWindowManager().getDefaultDisplay().getMetrics(dm);
611

    
612
        mDensity = dm.densityDpi;
613

    
614
        final ActivityManager activityManager= (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
615

    
616
        if( activityManager!=null )
617
          {
618
          final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
619
          setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
620
          setRenderer(mRenderer);
621
          }
622
        }
623
      }
624

    
625
///////////////////////////////////////////////////////////////////////////////////////////////////
626

    
627
    @Override
628
    public boolean onTouchEvent(MotionEvent event)
629
      {
630
      int action = event.getActionMasked();
631

    
632
      switch(action)
633
         {
634
         case MotionEvent.ACTION_DOWN        : actionDown(event) ; break;
635
         case MotionEvent.ACTION_MOVE        : actionMove(event) ; break;
636
         case MotionEvent.ACTION_UP          : actionUp(event)   ; break;
637
         case MotionEvent.ACTION_POINTER_DOWN: actionDown2(event); break;
638
         case MotionEvent.ACTION_POINTER_UP  : actionUp2(event)  ; break;
639
         }
640

    
641
      return true;
642
      }
643
}
644

    
(4-4/4)