| 30 |
30 |
import android.os.Bundle;
|
| 31 |
31 |
import android.view.Gravity;
|
| 32 |
32 |
import android.view.View;
|
| 33 |
|
import android.widget.AdapterView;
|
| 34 |
|
import android.widget.ArrayAdapter;
|
| 35 |
33 |
import android.widget.Button;
|
| 36 |
34 |
import android.widget.LinearLayout;
|
| 37 |
35 |
import android.widget.NumberPicker;
|
| 38 |
36 |
import android.widget.NumberPicker.OnValueChangeListener;
|
| 39 |
|
import android.widget.Spinner;
|
| 40 |
37 |
import android.widget.TableRow;
|
| 41 |
38 |
|
| 42 |
39 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 43 |
40 |
|
| 44 |
|
public class CubesActivity extends Activity implements View.OnClickListener, AdapterView.OnItemSelectedListener
|
|
41 |
public class CubesActivity extends Activity implements View.OnClickListener
|
| 45 |
42 |
{
|
| 46 |
43 |
private static final int COLOR_OFF = 0xffffe81f;
|
| 47 |
44 |
private static final int COLOR_ON = 0xff0000ff;
|
| ... | ... | |
| 52 |
49 |
private LinearLayout mLay;
|
| 53 |
50 |
private boolean[] mShape;
|
| 54 |
51 |
private DistortedObject mObject;
|
| 55 |
|
private int mObjectType;
|
| 56 |
52 |
|
| 57 |
53 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 58 |
54 |
|
| ... | ... | |
| 61 |
57 |
{
|
| 62 |
58 |
super.onCreate(savedState);
|
| 63 |
59 |
|
| 64 |
|
setContentView(R.layout.objectpickerlayout);
|
|
60 |
setContentView(R.layout.cubespickerlayout);
|
| 65 |
61 |
|
| 66 |
|
mLay = (LinearLayout)findViewById(R.id.objectpicker_buttongrid);
|
|
62 |
mLay = (LinearLayout)findViewById(R.id.cubespicker_buttongrid);
|
| 67 |
63 |
|
| 68 |
|
mColsPicker = (NumberPicker)findViewById(R.id.objectpicker_cols);
|
| 69 |
|
mRowsPicker = (NumberPicker)findViewById(R.id.objectpicker_rows);
|
|
64 |
mColsPicker = (NumberPicker)findViewById(R.id.cubespicker_cols);
|
|
65 |
mRowsPicker = (NumberPicker)findViewById(R.id.cubespicker_rows);
|
| 70 |
66 |
|
| 71 |
67 |
mColsPicker.setMaxValue(10);
|
| 72 |
68 |
mColsPicker.setMinValue( 0);
|
| ... | ... | |
| 90 |
86 |
setGrid();
|
| 91 |
87 |
}
|
| 92 |
88 |
});
|
| 93 |
|
|
| 94 |
|
mObjectType = 0;
|
| 95 |
|
|
| 96 |
|
Spinner typeSpinner = (Spinner)findViewById(R.id.objectpicker_spinnerType);
|
| 97 |
|
typeSpinner.setOnItemSelectedListener(this);
|
| 98 |
|
|
| 99 |
|
String[] objectType = new String[] {"DistortedCubes", "DistortedBitmap"};
|
| 100 |
|
|
| 101 |
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, objectType);
|
| 102 |
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
| 103 |
|
typeSpinner.setAdapter(adapter);
|
| 104 |
89 |
}
|
| 105 |
90 |
|
| 106 |
91 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 150 |
135 |
}
|
| 151 |
136 |
}
|
| 152 |
137 |
|
| 153 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 154 |
|
|
| 155 |
|
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
|
| 156 |
|
{
|
| 157 |
|
switch(parent.getId())
|
| 158 |
|
{
|
| 159 |
|
case R.id.objectpicker_spinnerType: mObjectType = pos; break;
|
| 160 |
|
}
|
| 161 |
|
}
|
| 162 |
|
|
| 163 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 164 |
|
|
| 165 |
|
public void onNothingSelected(AdapterView<?> parent)
|
| 166 |
|
{
|
| 167 |
|
}
|
| 168 |
|
|
| 169 |
138 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 170 |
139 |
|
| 171 |
140 |
public void onClick(View view)
|
| ... | ... | |
| 224 |
193 |
|
| 225 |
194 |
public void Create(View v)
|
| 226 |
195 |
{
|
| 227 |
|
if( mObjectType==1 )
|
| 228 |
|
{
|
| 229 |
|
mObject = new DistortedBitmap(100,100,mNumCols);
|
| 230 |
|
}
|
| 231 |
|
else
|
| 232 |
|
{
|
| 233 |
|
String str = "";
|
|
196 |
String str = "";
|
| 234 |
197 |
|
| 235 |
|
for(int i=0; i<mNumRows*mNumCols; i++)
|
| 236 |
|
str += mShape[i] ? "1" : "0";
|
|
198 |
for(int i=0; i<mNumRows*mNumCols; i++)
|
|
199 |
str += mShape[i] ? "1" : "0";
|
| 237 |
200 |
|
| 238 |
|
mObject = new DistortedCubes(mNumCols, str, 10);
|
| 239 |
|
}
|
|
201 |
mObject = new DistortedCubes(mNumCols, str, 10);
|
| 240 |
202 |
|
| 241 |
203 |
setContentView(R.layout.cubeslayout);
|
| 242 |
204 |
}
|
Revert the Cubes App.