Project

General

Profile

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

examples / src / main / java / org / distorted / examples / dynamic / DynamicActivity.java @ f988589e

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 org.distorted.library.Distorted;
23
import org.distorted.library.type.Dynamic1D;
24
import org.distorted.examples.R;
25

    
26
import android.app.Activity;
27
import android.opengl.GLSurfaceView;
28
import android.os.Bundle;
29
import android.view.View;
30
import android.widget.SeekBar;
31
import android.widget.TextView;
32
import android.widget.SeekBar.OnSeekBarChangeListener;
33

    
34
///////////////////////////////////////////////////////////////////
35

    
36
public class DynamicActivity extends Activity implements OnSeekBarChangeListener
37
    {
38
    private SeekBar barD, barN;
39
    private TextView textD, textN;
40
   
41
///////////////////////////////////////////////////////////////////
42
    @Override
43
    protected void onCreate(Bundle savedInstanceState) 
44
      {
45
      super.onCreate(savedInstanceState);
46
      setContentView(R.layout.interpolatorlayout);
47
      
48
      barD = (SeekBar)findViewById(R.id.interpolatorSeekDuration);
49
      barD.setOnSeekBarChangeListener(this); 
50
      textD = (TextView)findViewById(R.id.interpolatorTextDuration);
51
      
52
      barN = (SeekBar)findViewById(R.id.interpolatorSeekNoise);
53
      barN.setOnSeekBarChangeListener(this); 
54
      textN = (TextView)findViewById(R.id.interpolatorTextNoise);
55
      
56
      barD.setProgress(50);
57
      textD.setText("Duration: 10 s");
58
      
59
      barN.setProgress(0);
60
      textN.setText("Noise: 0.0");
61
      }
62

    
63
///////////////////////////////////////////////////////////////////
64
    @Override
65
    protected void onResume() 
66
      {
67
      super.onResume();
68
      
69
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.interpolatorSurfaceView);
70
      mView.onResume();
71
      }
72

    
73
///////////////////////////////////////////////////////////////////
74
    @Override
75
    protected void onPause() 
76
      {
77
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.interpolatorSurfaceView);
78
      mView.onPause();
79
         
80
      super.onPause();
81
      }
82
    
83
///////////////////////////////////////////////////////////////////
84
    @Override
85
    public void onStop()
86
      {
87
      super.onStop();
88
      }
89

    
90
///////////////////////////////////////////////////////////////////
91
    @Override
92
    public void onDestroy()
93
      {  
94
      Distorted.onDestroy();
95
      super.onDestroy();
96
      }     
97
 
98
///////////////////////////////////////////////////////////////////
99
    
100
    public void Loop(View v)
101
      {
102
      DynamicSurfaceView.setMode(Dynamic1D.MODE_LOOP);
103
      }     
104
    
105
///////////////////////////////////////////////////////////////////
106

    
107
    public void Path(View v)
108
      {
109
      DynamicSurfaceView.setMode(Dynamic1D.MODE_PATH);
110
      }  
111

    
112
///////////////////////////////////////////////////////////////////
113

    
114
    public void Jump(View v)
115
      {
116
      DynamicSurfaceView.setMode(Dynamic1D.MODE_JUMP);
117
      }  
118
    
119
///////////////////////////////////////////////////////////////////
120

    
121
    public void Dim1D(View v)
122
      {
123
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_1D);
124
      }  
125

    
126
///////////////////////////////////////////////////////////////////
127

    
128
    public void Dim2D(View v)
129
      {
130
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_2D);
131
      }  
132
    
133
///////////////////////////////////////////////////////////////////
134

    
135
    public void Dim3DXY(View v)
136
      {
137
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_3DXY);
138
      }  
139

    
140
///////////////////////////////////////////////////////////////////
141

    
142
    public void Dim3DXZ(View v)
143
      {
144
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_3DXZ);
145
      }  
146
    
147
///////////////////////////////////////////////////////////////////
148
    
149
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
150
      {
151
      float v, t; 
152
      int i;
153
      
154
      switch (bar.getId()) 
155
        {
156
        case R.id.interpolatorSeekDuration: v = progress*200;
157
                                            i = (int)(v/100);
158
                                            t = i/10.0f;
159
                                            DynamicSurfaceView.setDuration((int)v);
160
                                            textD.setText("Duration: "+(int)t+" s");
161
                                            break;
162
        case R.id.interpolatorSeekNoise   : DynamicSurfaceView.setNoise(progress/100.0f);
163
                                            textN.setText("Noise: "+(progress/100.f));
164
                                            break;
165
        }
166
      }
167

    
168
///////////////////////////////////////////////////////////////////
169

    
170
    public void onStartTrackingTouch(SeekBar bar) { }
171
    
172
///////////////////////////////////////////////////////////////////
173

    
174
    public void onStopTrackingTouch(SeekBar bar)  { }
175
    
176
///////////////////////////////////////////////////////////////////
177
// end of file
178
}
(1-1/3)