Project

General

Profile

« Previous | Next » 

Revision 5690134d

Added by Leszek Koltunski over 3 years ago

Dynamic App: add support for the new SpeedMode inside Dynamics. (so far only first two SpeedModes - smooth and segment_constant - are supported )

View differences:

src/main/java/org/distorted/examples/dynamic/DynamicActivity.java
43 43
    {
44 44
    private TextView textDuration, textCount, textNoise, textConvexity;
45 45
    private int mNoise0,mNoise1,mNoise2,mNoise3;
46
    private int mDim, mMode;
46
    private int mDim, mMode, mSpeed;
47 47

  
48 48
///////////////////////////////////////////////////////////////////////////////////////////////////
49 49

  
......
60 60
      textNoise    = findViewById(R.id.dynamicTextNoise);
61 61

  
62 62
      mNoise0=mNoise1=mNoise2=mNoise3=0;
63
      mDim = DynamicSurfaceView.DIM_2D;
64
      mMode= Dynamic1D.MODE_LOOP;
63
      mDim  = DynamicSurfaceView.DIM_2D;
64
      mMode = Dynamic.MODE_LOOP;
65
      mSpeed= Dynamic.SPEED_MODE_SMOOTH;
65 66

  
66 67
      SeekBar barD = findViewById(R.id.dynamicSeekDuration);
67 68
      barD.setOnSeekBarChangeListener(this);
......
78 79

  
79 80
      Spinner dimensionSpinner  = findViewById(R.id.dynamicSpinnerDimension);
80 81
      dimensionSpinner.setOnItemSelectedListener(this);
81
      String[] dimensions = { "Dimension 1" , "Dimension 2" , "Dimension 3 (XY)" , "Dimension 3 (XZ)" , "Dimension 4 (XY)" , "Dimension 4 (ZW)" , "Quaternion XY" , "Quaternion ZW" };
82
      String[] dimensions = { "Dim 1" , "Dim 2" , "Dim 3 (XY)" , "Dim 3 (XZ)" , "Dim 4 (XY)" , "Dim 4 (ZW)" , "Quat XY" , "Quat ZW" };
82 83

  
83 84
      ArrayAdapter<String> adapterDim = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, dimensions );
84 85
      adapterDim.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
......
87 88

  
88 89
      Spinner modeSpinner  = findViewById(R.id.dynamicSpinnerMode);
89 90
      modeSpinner.setOnItemSelectedListener(this);
90
      String[] modes = { "MODE_LOOP" , "MODE_PATH" , "MODE_JUMP" };
91
      String[] modes = { "LOOP" , "PATH" , "JUMP" };
91 92

  
92 93
      ArrayAdapter<String> adapterMode = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, modes );
93 94
      adapterMode.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
94 95
      modeSpinner.setAdapter(adapterMode);
95 96
      modeSpinner.setSelection(0);
96 97

  
98
      Spinner speedSpinner  = findViewById(R.id.dynamicSpinnerSpeedMode);
99
      speedSpinner.setOnItemSelectedListener(this);
100
      String[] speeds = { "SMOOTH" , "SEGM_CONST" , "GLOB_CONST" };
101

  
102
      ArrayAdapter<String> adapterSpeed = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, speeds );
103
      adapterSpeed.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
104
      speedSpinner.setAdapter(adapterSpeed);
105
      speedSpinner.setSelection(0);
106

  
97 107
      if( savedState==null )
98 108
        {
99 109
        barD.setProgress(50);
......
199 209
      mMode = mode;
200 210
      }
201 211

  
212
///////////////////////////////////////////////////////////////////////////////////////////////////
213

  
214
    public void setSpeedMode(int mode)
215
      {
216
      DynamicSurfaceView view = findViewById(R.id.dynamicSurfaceView);
217
      view.setSpeedMode(mode);
218
      mSpeed = mode;
219
      }
220

  
202 221
///////////////////////////////////////////////////////////////////////////////////////////////////
203 222

  
204 223
    public void Start(View v)
......
247 266
          case 2: setMode(Dynamic.MODE_JUMP); break;
248 267
          }
249 268
        }
269
      else if( spinnerID == R.id.dynamicSpinnerSpeedMode )
270
        {
271
        switch(pos)
272
          {
273
          case 0: setSpeedMode(Dynamic.SPEED_MODE_SMOOTH           ); break;
274
          case 1: setSpeedMode(Dynamic.SPEED_MODE_SEGMENT_CONSTANT ); break;
275
          case 2: setSpeedMode(Dynamic.SPEED_MODE_GLOBALLY_CONSTANT); break;
276
          }
277
        }
250 278
      }
251 279

  
252 280
///////////////////////////////////////////////////////////////////////////////////////////////////
......
256 284
      {
257 285
      super.onSaveInstanceState(savedInstanceState);
258 286

  
259
      savedInstanceState.putInt("dim" , mDim );
260
      savedInstanceState.putInt("mode", mMode);
287
      savedInstanceState.putInt("dim"  , mDim  );
288
      savedInstanceState.putInt("mode" , mMode );
289
      savedInstanceState.putInt("speed", mSpeed);
261 290
      }
262 291

  
263 292
///////////////////////////////////////////////////////////////////////////////////////////////////
......
267 296
      {
268 297
      super.onRestoreInstanceState(savedInstanceState);
269 298

  
270
      mDim = savedInstanceState.getInt("dim");
271
      mMode= savedInstanceState.getInt("mode");
299
      mDim  = savedInstanceState.getInt("dim");
300
      mMode = savedInstanceState.getInt("mode");
301
      mSpeed= savedInstanceState.getInt("speed");
272 302

  
273 303
      setDim(mDim);
274 304
      setMode(mMode);
305
      setSpeedMode(mSpeed);
275 306
      }
276 307

  
277 308
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/dynamic/DynamicSurfaceView.java
196 196
      diQu.setMode(mode);
197 197
      }
198 198

  
199
///////////////////////////////////////////////////////////////////////////////////////////////////
200

  
201
    public void setSpeedMode(int mode)
202
      {
203
      di1D.setSpeedMode(mode);
204
      di2D.setSpeedMode(mode);
205
      di3D.setSpeedMode(mode);
206
      di4D.setSpeedMode(mode);
207
      diQu.setSpeedMode(mode); // not implemented yet!
208
      }
209

  
199 210
///////////////////////////////////////////////////////////////////////////////////////////////////
200 211

  
201 212
    public void setDuration(int duration)
src/main/res/layout/dynamicslayout.xml
23 23
            android:layout_weight="0.5"
24 24
            android:id="@+id/dynamicSpinnerMode"/>
25 25

  
26
        <Spinner
27
            android:layout_width="0dp"
28
            android:layout_height="50dp"
29
            android:layout_weight="0.5"
30
            android:id="@+id/dynamicSpinnerSpeedMode"/>
31

  
26 32
    </LinearLayout>
27 33

  
28 34
    <LinearLayout

Also available in: Unified diff