Project

General

Profile

Download (23.9 KB) Statistics
| Branch: | Revision:

examples / src / main / java / org / distorted / examples / dynamic / DynamicSurfaceView.java @ d586fda6

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted 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
// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.examples.dynamic;
21

    
22
import android.app.ActivityManager;
23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
25
import android.graphics.Rect;
26
import android.opengl.GLSurfaceView;
27
import android.view.MotionEvent;
28
import android.util.AttributeSet;
29
import android.graphics.Canvas;
30
import android.graphics.Paint.Style;
31
import android.graphics.Paint;
32

    
33
import org.distorted.library.type.Dynamic;
34
import org.distorted.library.type.Dynamic1D;
35
import org.distorted.library.type.Dynamic2D;
36
import org.distorted.library.type.Dynamic3D;
37
import org.distorted.library.type.Dynamic4D;
38
import org.distorted.library.type.Static1D;
39
import org.distorted.library.type.Static2D;
40
import org.distorted.library.type.Static3D;
41
import org.distorted.library.type.Static4D;
42

    
43
import java.lang.ref.WeakReference;
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
public class DynamicSurfaceView extends GLSurfaceView
48
    {
49
    public static final int DIM_1D   = 0; 
50
    public static final int DIM_2D   = 1; 
51
    public static final int DIM_3DXY = 2; 
52
    public static final int DIM_3DXZ = 3; 
53
    public static final int DIM_4DXY = 4;
54
    public static final int DIM_4DZW = 5;
55

    
56
    private static final int MAX_DIM = 4;
57

    
58
    static final int NUM_POINTS = 250;
59
    private static final Object lock = new Object();
60

    
61
    private WeakReference<DynamicActivity> mAct;
62

    
63
    private static int halfScreenHeight=0;
64
    private static int halfScreenWidth =0;
65

    
66
    private Dynamic1D di1D;
67
    private Dynamic2D di2D;
68
    private Dynamic3D di3D;
69
    private Dynamic4D di4D;
70
    
71
    private Paint mPaint;
72
    private int mMoving;
73
    private int mDuration;
74
    private int mPosition;
75
    private long mDiffTime, mLastTime, mStartTime;
76
    private float[] mNoise = new float[MAX_DIM];
77
    private float mCount;
78

    
79
    private int mSize1, mSize2, mSizeT, mAvg;
80
    private float mFontHeight;
81

    
82
    private int currentDim= DIM_2D;
83
    
84
    private Static1D p1D;
85
    private Static2D p2D;
86
    private Static3D p3D;
87
    private Static4D p4D;
88

    
89
    private Static1D p1N;
90
    private Static2D p2N;
91
    private Static3D p3N;
92
    private Static4D p4N;
93

    
94
    private float[] mPoints = new float[MAX_DIM*NUM_POINTS];
95
    private boolean mRunning;
96

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98
    
99
    public DynamicSurfaceView(Context context, AttributeSet attrs)
100
      {
101
      super(context, attrs);
102

    
103
      DynamicActivity act = (DynamicActivity)context;
104
      mAct = new WeakReference<>(act);
105

    
106
      mPaint = new Paint();
107
      mPaint.setStyle(Style.FILL);
108
      mPaint.setAntiAlias(true);
109

    
110
      mDuration = 10000;
111
      mCount    = 0.0f;
112
      mPosition = 0;
113
      mDiffTime = -1;
114
      mLastTime = -1;
115
      mStartTime= -1;
116
      mMoving   = -1;
117
      mRunning  = false;
118

    
119
      for(int i=0; i<MAX_DIM; i++) mNoise[i] = 0.0f;
120

    
121
      clearPoints();
122

    
123
      di1D = new Dynamic1D(mDuration,mCount);
124
      p1N  = new Static1D(mNoise[0]);
125
      di2D = new Dynamic2D(mDuration,mCount);
126
      p2N  = new Static2D(mNoise[0],mNoise[1]);
127
      di3D = new Dynamic3D(mDuration,mCount);
128
      p3N  = new Static3D(mNoise[0],mNoise[1],mNoise[2]);
129
      di4D = new Dynamic4D(mDuration,mCount);
130
      p4N  = new Static4D(mNoise[0],mNoise[1],mNoise[2],mNoise[3]);
131

    
132
      di1D.setAccessType(Dynamic.ACCESS_TYPE_SEQUENTIAL);
133
      di2D.setAccessType(Dynamic.ACCESS_TYPE_SEQUENTIAL);
134
      di3D.setAccessType(Dynamic.ACCESS_TYPE_SEQUENTIAL);
135
      di4D.setAccessType(Dynamic.ACCESS_TYPE_SEQUENTIAL);
136

    
137
      if(!isInEditMode())
138
        {
139
        setFocusable(true);
140
        setFocusableInTouchMode(true);
141
        DynamicRenderer mRenderer = new DynamicRenderer(this);
142
        final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
143
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
144
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
145
        setRenderer(mRenderer);
146
        }
147
      }
148

    
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150

    
151
    public void onSurfaceChanged(int width,int height)
152
      {
153
      mAvg = (width+height)/2;
154

    
155
      mSize1 = mAvg/150;
156
      mSize2 = mAvg/50;
157
      mSizeT = mAvg/30;
158

    
159
      mPaint.setTextSize(mSizeT);
160
      mPaint.setTextAlign(Paint.Align.CENTER);
161

    
162
      final Rect textBounds = new Rect();
163
      String text = "1";
164
      mPaint.getTextBounds(text, 0, text.length(), textBounds);
165
      mFontHeight = textBounds.exactCenterY();
166

    
167
      clearPoints();
168
      }
169

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

    
172
    public static void setHalfWidth(int hw)
173
      {
174
      halfScreenWidth = hw;
175
      }
176

    
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178

    
179
    public static void setHalfHeight(int hh)
180
      {
181
      halfScreenHeight = hh;
182
      }
183

    
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185

    
186
    public void setMode(int mode)
187
      {
188
      di1D.setMode(mode);  
189
      di2D.setMode(mode);
190
      di3D.setMode(mode);
191
      di4D.setMode(mode);
192
      }
193

    
194
///////////////////////////////////////////////////////////////////////////////////////////////////
195

    
196
    public void setDuration(int duration)
197
      {
198
      mDuration = duration;
199
      
200
      di1D.setDuration(duration);
201
      di2D.setDuration(duration);
202
      di3D.setDuration(duration);
203
      di4D.setDuration(duration);
204
      }
205

    
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207

    
208
    public void setCount(float count)
209
      {
210
      mCount = count;
211

    
212
      di1D.setCount(count);
213
      di2D.setCount(count);
214
      di3D.setCount(count);
215
      di4D.setCount(count);
216
      }
217

    
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219

    
220
    public void setConvexity(float convexity)
221
      {
222
      di1D.setConvexity(convexity);
223
      di2D.setConvexity(convexity);
224
      di3D.setConvexity(convexity);
225
      di4D.setConvexity(convexity);
226
      }
227

    
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229

    
230
    public void setNoise(float noise0, float noise1, float noise2, float noise3)
231
      {
232
      mNoise[0] = noise0;
233
      mNoise[1] = noise1;
234
      mNoise[2] = noise2;
235
      mNoise[3] = noise3;
236

    
237
      p1N.set(mNoise[0]);
238
      p2N.set(mNoise[0],mNoise[1]);
239
      p3N.set(mNoise[0],mNoise[1],mNoise[2]);
240
      p4N.set(mNoise[0],mNoise[1],mNoise[2], mNoise[3]);
241

    
242
      di1D.setNoise(p1N);
243
      di2D.setNoise(p2N);
244
      di3D.setNoise(p3N);
245
      di4D.setNoise(p4N);
246
      }
247
    
248
///////////////////////////////////////////////////////////////////////////////////////////////////
249

    
250
    public void setDimension(int dim)
251
      {
252
      if( currentDim != dim )
253
        {
254
        if( !(currentDim==DIM_3DXY && dim==DIM_3DXZ) && !(currentDim==DIM_3DXZ && dim==DIM_3DXY) &&
255
            !(currentDim==DIM_4DXY && dim==DIM_4DZW) && !(currentDim==DIM_4DZW && dim==DIM_4DXY)  )
256
          {
257
          resetPoints();
258
          }
259

    
260
        currentDim = dim;
261
        }
262
      }
263
    
264
///////////////////////////////////////////////////////////////////////////////////////////////////
265
    
266
    public void drawCurve(Canvas c, long time)
267
      {
268
      if( mLastTime<0 )
269
        {
270
        mLastTime = time;
271
        }
272
      else
273
        {
274
        mDiffTime = time - mLastTime;
275
        }
276

    
277
      synchronized(lock)
278
        {
279
        switch(currentDim)
280
          {
281
          case DIM_1D  : drawHorizontalAxis(c,"x");
282
                         drawPath(c,di1D,0,1,time);
283
                         drawRedPoints1D(c);
284
                         break;
285
          case DIM_2D  : drawHorizontalAxis(c,"x");
286
                         drawVerticalAxis  (c,"y");
287
                         drawPath(c,di2D,0,1,time);
288
                         drawRedPoints2D(c);
289
                         break;
290
          case DIM_3DXY: drawHorizontalAxis(c,"x");
291
                         drawVerticalAxis  (c,"y");
292
                         drawPath(c,di3D,0,1,time);
293
                         drawRedPoints3D(c);
294
                         break;
295
          case DIM_3DXZ: drawHorizontalAxis(c,"x");
296
                         drawVerticalAxis  (c,"z");
297
                         drawPath(c,di3D,0,2,time);
298
                         drawRedPoints3D(c);
299
                         break;
300
          case DIM_4DXY: drawHorizontalAxis(c,"x");
301
                         drawVerticalAxis  (c,"y");
302
                         drawPath(c,di4D,0,1,time);
303
                         drawRedPoints4D(c);
304
                         break;
305
          case DIM_4DZW: drawHorizontalAxis(c,"z");
306
                         drawVerticalAxis  (c,"w");
307
                         drawPath(c,di4D,2,3,time);
308
                         drawRedPoints4D(c);
309
                         break;
310
          }
311
        }
312

    
313
      mLastTime = time;
314
      }
315

    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317

    
318
    private void clearPoints()
319
      {
320
      for(int i=0; i<MAX_DIM*NUM_POINTS; i++)
321
         {
322
         mPoints[i] = -100000.0f;
323
         }
324
      }
325

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

    
328
    public void resetPoints()
329
      {
330
      synchronized(lock)
331
        {
332
        clearPoints();
333

    
334
        switch(currentDim)
335
          {
336
          case DIM_1D  : di1D.removeAll(); break;
337
          case DIM_2D  : di2D.removeAll(); break;
338
          case DIM_3DXY:
339
          case DIM_3DXZ: di3D.removeAll(); break;
340
          case DIM_4DXY:
341
          case DIM_4DZW: di4D.removeAll(); break;
342
          }
343

    
344
        DynamicActivity act = mAct.get();
345
        act.setNumRedPoints(0);
346
        act.clearPoints();
347
        }
348
      }
349

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351

    
352
    public void startDynamic()
353
      {
354
      mRunning = true;
355
      mLastTime= -1;
356
      mStartTime = System.currentTimeMillis();
357

    
358
      clearPoints();
359
      di1D.resetToBeginning();
360
      di2D.resetToBeginning();
361
      di3D.resetToBeginning();
362
      di4D.resetToBeginning();
363
      }
364

    
365
///////////////////////////////////////////////////////////////////////////////////////////////////
366

    
367
    public void stopDynamic()
368
      {
369
      mRunning = false;
370
      }
371

    
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373

    
374
    private void drawHorizontalAxis(Canvas c, String label)
375
      {
376
      mPaint.setColor(0xff000000);
377

    
378
      c.drawLine(0, halfScreenHeight, halfScreenWidth*2, halfScreenHeight, mPaint);
379
      c.drawText( label, 0.95f*halfScreenWidth*2, halfScreenHeight + mSizeT , mPaint);
380
      }
381

    
382

    
383
///////////////////////////////////////////////////////////////////////////////////////////////////
384

    
385
    private void drawVerticalAxis(Canvas c, String label)
386
      {
387
      mPaint.setColor(0xff000000);
388

    
389
      c.drawLine(halfScreenWidth, 0, halfScreenWidth, halfScreenHeight*2, mPaint);
390
      c.drawText(label, halfScreenWidth + mSizeT,                mSizeT , mPaint);
391
      }
392

    
393
///////////////////////////////////////////////////////////////////////////////////////////////////
394

    
395
    private void drawPath(Canvas c, Dynamic dyn, int indexH, int indexW, long time)
396
      {
397
      int len = dyn.getNumPoints();
398

    
399
      if( len>=2 )
400
        {
401
        if( mRunning )
402
          {
403
          if ( ++mPosition >= NUM_POINTS ) mPosition=0;
404

    
405
          if( dyn.getDimension()==1 )
406
            {
407
            mPoints[MAX_DIM*mPosition+indexW] = halfScreenHeight;
408
            }
409

    
410
          if( dyn.get(mPoints,MAX_DIM*mPosition, time-mStartTime, mDiffTime) )
411
            {
412
            stopDynamic();
413
            }
414

    
415
          addNewSpeedPoint(time);
416
          }
417

    
418
        for(int i=0; i<NUM_POINTS; i++)
419
          {
420
          int color = i<=mPosition ? 0xff - (mPosition           -i)*0xff/(NUM_POINTS-1)
421
                                   : 0xff - (mPosition+NUM_POINTS-i)*0xff/(NUM_POINTS-1);
422

    
423
          mPaint.setColor( 0xffffff + ((color&0xff)<<24) );
424
          c.drawCircle(mPoints[MAX_DIM*i+indexH], mPoints[MAX_DIM*i+indexW] , mSize1, mPaint );
425
          }
426
        }
427
      }
428

    
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430

    
431
    private void drawRedPoints1D(Canvas c)
432
      {
433
      int len = di1D.getNumPoints();
434

    
435
      for(int curr=0; curr<len; curr++)
436
        {
437
        p1D = di1D.getPoint(curr);
438
        drawRedPoint(c,curr+"", p1D.get1(), halfScreenHeight);
439
        }
440
      }
441

    
442
///////////////////////////////////////////////////////////////////////////////////////////////////
443

    
444
    private void drawRedPoints2D(Canvas c)
445
      {
446
      int len = di2D.getNumPoints();
447

    
448
      for(int curr=0; curr<len; curr++)
449
        {
450
        p2D = di2D.getPoint(curr);
451
        drawRedPoint(c,curr+"", p2D.get1(), p2D.get2());
452
        }
453
      }
454

    
455
///////////////////////////////////////////////////////////////////////////////////////////////////
456

    
457
    private void drawRedPoints3D(Canvas c)
458
      {
459
      int len = di3D.getNumPoints();
460

    
461
      for(int curr=0; curr<len; curr++)
462
        {
463
        p3D = di3D.getPoint(curr);
464
        drawRedPoint(c,curr+"", p3D.get1(), currentDim==DIM_3DXY ? p3D.get2():p3D.get3());
465
        }
466
      }
467

    
468
///////////////////////////////////////////////////////////////////////////////////////////////////
469

    
470
    private void drawRedPoints4D(Canvas c)
471
      {
472
      int len = di4D.getNumPoints();
473

    
474
      for(int curr=0; curr<len; curr++)
475
        {
476
        p4D = di4D.getPoint(curr);
477

    
478
        if( currentDim==DIM_4DXY ) drawRedPoint(c,curr+"", p4D.get1(), p4D.get2());
479
        else                       drawRedPoint(c,curr+"", p4D.get3(), p4D.get4());
480
        }
481
      }
482

    
483
///////////////////////////////////////////////////////////////////////////////////////////////////
484

    
485
    private void drawRedPoint(Canvas c, String label, float width, float height)
486
      {
487
      mPaint.setColor(0xffff0000);
488
      c.drawCircle( width, height, mSize2, mPaint);
489
      mPaint.setColor(0xffffffff);
490
      c.drawText(label, width,height-mFontHeight, mPaint);
491
      }
492

    
493
///////////////////////////////////////////////////////////////////////////////////////////////////
494

    
495
    private void addNewPoint(int x, int y)
496
      {
497
      float gx,gy,gz,gw;
498
      int len;
499
      int minDist = (mAvg*mAvg)/100;
500

    
501
      switch(currentDim)
502
        {
503
        case DIM_1D : len = di1D.getNumPoints();
504

    
505
                      for(int g=0; g<len; g++)
506
                        {
507
                        p1D = di1D.getPoint(g);
508
                        gx = p1D.get1();
509
                                    
510
                        if( (x-gx)*(x-gx) < minDist )
511
                          {
512
                          mMoving = g;
513
                          break;
514
                          }
515
                        }
516
                      if( mMoving <0 )
517
                        {
518
                        synchronized(lock)
519
                          {
520
                          di1D.add(new Static1D(x));
521
                          mAct.get().setNumRedPoints(len+1);
522
                          }
523
                        }
524
                      break;
525
        case DIM_2D : len = di2D.getNumPoints();
526
                                 
527
                      for(int g=0; g<len; g++)
528
                        {
529
                        p2D = di2D.getPoint(g);
530
                        gx = p2D.get1();
531
                        gy = p2D.get2();
532
                                    
533
                        if( (x-gx)*(x-gx) + (y-gy)*(y-gy) < minDist )
534
                          {
535
                          mMoving = g;
536
                          break;
537
                          }
538
                        }
539
                      if( mMoving <0 )
540
                        {
541
                        synchronized(lock)
542
                          {
543
                          di2D.add(new Static2D(x,y));
544
                          mAct.get().setNumRedPoints(len+1);
545
                          }
546
                        }
547
                      break;
548
        case DIM_3DXY:
549
        case DIM_3DXZ:len = di3D.getNumPoints();
550
                                 
551
                      for(int g=0; g<len; g++)
552
                        {
553
                        p3D = di3D.getPoint(g);
554
                        gx = p3D.get1();
555
                        gy = p3D.get2();
556
                        gz = p3D.get3();
557
                               
558
                        if( currentDim==DIM_3DXY )
559
                          {
560
                          if( (x-gx)*(x-gx) + (y-gy)*(y-gy) < minDist )
561
                            {
562
                            mMoving = g;
563
                            break;
564
                            }
565
                          }
566
                        if( currentDim==DIM_3DXZ )
567
                          {
568
                          if( (x-gx)*(x-gx) + (y-gz)*(y-gz) < minDist )
569
                            {
570
                            mMoving = g;
571
                            break;
572
                            }
573
                          }
574
                        }
575

    
576
                      if( mMoving <0 )
577
                        {
578
                        synchronized(lock)
579
                          {
580
                          if( currentDim==DIM_3DXY ) di3D.add(new Static3D(x,y, halfScreenHeight));
581
                          if( currentDim==DIM_3DXZ ) di3D.add(new Static3D(x, halfScreenHeight,y));
582
                          mAct.get().setNumRedPoints(len+1);
583
                          }
584
                        }
585
                      break;
586
        case DIM_4DXY:
587
        case DIM_4DZW:len = di4D.getNumPoints();
588

    
589
                      for(int g=0; g<len; g++)
590
                        {
591
                        p4D = di4D.getPoint(g);
592
                        gx = p4D.get1();
593
                        gy = p4D.get2();
594
                        gz = p4D.get3();
595
                        gw = p4D.get4();
596

    
597
                        if( currentDim==DIM_4DXY )
598
                          {
599
                          if( (x-gx)*(x-gx) + (y-gy)*(y-gy) < minDist )
600
                            {
601
                            mMoving = g;
602
                            break;
603
                            }
604
                          }
605
                        if( currentDim==DIM_4DZW )
606
                          {
607
                          if( (x-gz)*(x-gz) + (y-gw)*(y-gw) < minDist )
608
                            {
609
                            mMoving = g;
610
                            break;
611
                            }
612
                          }
613
                        }
614

    
615
                      if( mMoving <0 )
616
                        {
617
                        synchronized(lock)
618
                          {
619
                          if( currentDim==DIM_4DXY ) di4D.add(new Static4D(x,y, halfScreenWidth, halfScreenHeight));
620
                          if( currentDim==DIM_4DZW ) di4D.add(new Static4D( halfScreenWidth, halfScreenHeight,x,y));
621
                          mAct.get().setNumRedPoints(len+1);
622
                          }
623
                        }
624
                      break;
625
        }
626
      }
627
    
628
///////////////////////////////////////////////////////////////////////////////////////////////////
629

    
630
    private void addNewSpeedPoint(long time)
631
      {
632
      int prev = mPosition-1;
633
      if( prev<0 ) prev = NUM_POINTS-1;
634

    
635
      float xdiff = mPoints[MAX_DIM*prev  ]-mPoints[MAX_DIM*mPosition  ];
636
      float ydiff = mPoints[MAX_DIM*prev+1]-mPoints[MAX_DIM*mPosition+1];
637
      float zdiff = mPoints[MAX_DIM*prev+2]-mPoints[MAX_DIM*mPosition+2];
638
      float wdiff = mPoints[MAX_DIM*prev+3]-mPoints[MAX_DIM*mPosition+3];
639

    
640
      float dist = (float)Math.sqrt( xdiff*xdiff + ydiff*ydiff + zdiff*zdiff + wdiff*wdiff);
641
      float speed= mDiffTime<=0 ? 0: dist / mDiffTime;
642
      float timepoint = ((float)(time-mStartTime))/mDuration;
643

    
644
      if( dist<1000.0f )   // otherwise this is a very first call; do not send it!
645
        {
646
        mAct.get().addPoint( timepoint - (int)timepoint, speed );
647
        }
648
      }
649

    
650
///////////////////////////////////////////////////////////////////////////////////////////////////
651

    
652
    @Override
653
    public boolean onTouchEvent(MotionEvent event)
654
      {
655
      int action = event.getAction();
656
      int xDown, yDown;
657

    
658
      switch(action)
659
        {
660
        case MotionEvent.ACTION_DOWN: xDown = (int)event.getX();
661
                                      yDown = (int)event.getY();
662
                                      
663
                                      addNewPoint(xDown,yDown);
664
                                    
665
                                      break;
666
        case MotionEvent.ACTION_MOVE: if( mMoving >=0 )
667
                                        {
668
                                        xDown = (int)event.getX();
669
                                        yDown = (int)event.getY();
670
                                        
671
                                        switch(currentDim)
672
                                          {
673
                                          case DIM_1D  : di1D.setPoint(mMoving, xDown);
674
                                                         break;
675
                                          case DIM_2D  : di2D.setPoint(mMoving, xDown, yDown);
676
                                                         break;
677
                                          case DIM_3DXY: di3D.setPoint(mMoving, xDown, yDown, (int)di3D.getPoint(mMoving).get3());
678
                                                         break;
679
                                          case DIM_3DXZ: di3D.setPoint(mMoving, xDown, (int)di3D.getPoint(mMoving).get2(), yDown);
680
                                                         break;
681
                                          case DIM_4DXY: di4D.setPoint(mMoving, xDown, yDown, (int)di4D.getPoint(mMoving).get3(), (int)di4D.getPoint(mMoving).get4());
682
                                                         break;
683
                                          case DIM_4DZW: di4D.setPoint(mMoving, (int)di4D.getPoint(mMoving).get1(), (int)di4D.getPoint(mMoving).get2(), xDown, yDown);
684
                                                         break;
685
                                          }
686
                                        }                           
687
                                      break;
688
        case MotionEvent.ACTION_UP  : mMoving = -1;
689
                                      break;
690
        }
691
            
692
      return true;
693
      }
694
  }
(4-4/4)