Changeset 14168
- Timestamp:
- 12/14/12 11:53:50 (12 years ago)
- Location:
- issm/trunk-jpl/src/android/ISSM
- Files:
-
- 7 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/android/ISSM/project.properties
r14109 r14168 12 12 13 13 # Project target. 14 target=android-1 514 target=android-17 -
issm/trunk-jpl/src/android/ISSM/res/layout/activity_mapselection.xml
r14110 r14168 2 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 3 android:layout_width="fill_parent" 4 android:layout_height="fill_parent" > 4 android:layout_height="fill_parent" 5 android:background="@drawable/issmlogo" > 5 6 6 <Button7 <ImageButton 7 8 android:id="@+id/button1" 8 9 style="@layout/activity_mapselection" … … 11 12 android:layout_alignParentBottom="true" 12 13 android:layout_alignParentLeft="true" 13 android:layout_marginBottom=" 33dp"14 android:layout_marginLeft=" 32dp"15 android: text="Greenland" />14 android:layout_marginBottom="21dp" 15 android:layout_marginLeft="46dp" 16 android:src="@drawable/greenland" /> 16 17 17 < Button18 <ImageButton 18 19 android:id="@+id/button2" 19 20 android:layout_width="wrap_content" 20 21 android:layout_height="wrap_content" 21 android:layout_alignBaseline="@+id/button1"22 22 android:layout_alignBottom="@+id/button1" 23 android:layout_ marginLeft="24dp"24 android:layout_ toRightOf="@+id/button1"25 android: text="Antarctica" />23 android:layout_alignParentRight="true" 24 android:layout_marginRight="34dp" 25 android:src="@drawable/antarctica" /> 26 26 27 </RelativeLayout>27 </RelativeLayout> -
issm/trunk-jpl/src/android/ISSM/src/com/example/issm/ISSM.java
r14109 r14168 1 1 package com.example.issm; 2 2 3 import java.io.IOException;4 import java.io.InputStream;5 3 import java.nio.ByteBuffer; 6 4 import java.nio.ByteOrder; 7 5 import java.nio.DoubleBuffer; 8 import java.text.DecimalFormat;9 6 10 7 import android.opengl.GLSurfaceView; 11 8 import android.os.Bundle; 12 9 import android.app.Activity; 13 import android.content.res.AssetManager;14 import android.text.TextUtils;15 10 import android.view.Menu; 11 import android.view.MenuInflater; 12 import android.view.MenuItem; 16 13 import android.view.View; 17 14 import android.view.View.OnClickListener; … … 21 18 import android.widget.SeekBar; 22 19 import android.widget.TextView; 20 import android.widget.Toast; 23 21 24 22 … … 36 34 private SeekBar bar; 37 35 private TextView /*txtStatus,*/ txtValue; 36 private ColorMap colorMap; 38 37 39 38 … … 54 53 this.txtValue = (TextView) super.findViewById(R.id.value); 55 54 Button button = (Button) super.findViewById(R.id.button1); 55 frame = (FrameLayout)findViewById(R.id.frame); 56 56 button.setOnClickListener(this); 57 57 … … 60 60 issmNative = new IssmJni(); 61 61 this.createModel(); 62 this.colorMap = new ColorMap(); 62 63 buff = ByteBuffer.allocateDirect(size*12*8).order(ByteOrder.nativeOrder()).asDoubleBuffer(); 63 64 65 64 } 66 65 //------------------------------------------------------------------------------------------------ … … 82 81 issmNative.solveISSMModel(5,buff); 83 82 } 84 //------------------------------------------------------------------------------------------------ 83 //------------------------------------------------------------------------------------------------ 84 public boolean onCreateOptionsMenu(Menu menu) 85 { 86 MenuInflater menuInflater = getMenuInflater(); 87 menuInflater.inflate(R.menu.issm_menu,menu); 88 89 return true; 90 } 91 //------------------------------------------------------------------------------------------------ 92 public boolean onOptionsItemSelected(MenuItem item) 93 { 94 switch (item.getItemId()) 95 { 96 case R.id.menu_about: 97 Toast.makeText(ISSM.this, "ISSM Application", Toast.LENGTH_SHORT).show(); 98 return true; 99 100 case R.id.cl_autumn: 101 colorMap.setAutumn(); 102 drawFigure(); 103 return true; 104 105 case R.id.cl_bone: 106 colorMap.setBone(); 107 drawFigure(); 108 return true; 109 110 case R.id.cl_cool: 111 colorMap.setCool(); 112 drawFigure(); 113 return true; 114 115 case R.id.cl_copper: 116 colorMap.setCopper(); 117 drawFigure(); 118 return true; 119 120 case R.id.cl_gray: 121 colorMap.setGray(); 122 drawFigure(); 123 return true; 124 125 case R.id.cl_hot: 126 colorMap.setGray(); 127 drawFigure(); 128 return true; 129 130 case R.id.cl_hsv: 131 colorMap.setDefault(); 132 drawFigure(); 133 return true; 134 135 case R.id.cl_jet: 136 colorMap.setJet(); 137 drawFigure(); 138 return true; 139 140 case R.id.cl_pink: 141 colorMap.setPink(); 142 drawFigure(); 143 return true; 144 145 case R.id.cl_spring: 146 colorMap.setSpring(); 147 drawFigure(); 148 return true; 149 150 case R.id.cl_summer: 151 colorMap.setSummer(); 152 drawFigure(); 153 return true; 154 155 case R.id.cl_winter: 156 colorMap.setWinter(); 157 drawFigure(); 158 return true; 159 default: 160 return super.onOptionsItemSelected(item); 161 } 162 163 } 164 //--------------------------------------------------------------------------------- 85 165 public void onClick(View view) 86 166 { 87 //factorial method88 /*String input = this.input.getText().toString();89 if(TextUtils.isEmpty(input))90 {91 return;92 }*/93 //example of how to fill buffer Native94 167 this.fillBuffer(); 95 96 mGLView = new MyGLSurfaceView(this, buff, size); 97 frame = (FrameLayout)findViewById(R.id.frame); 98 frame.addView(mGLView); 168 drawFigure(); 99 169 } 170 //---------------------------------------------------------------------------------- 171 public void drawFigure() 172 { 173 frame.removeView(mGLView); 174 mGLView = new MyGLSurfaceView(this, buff, size, colorMap); 175 frame.addView(mGLView); 176 } 177 //----------------------------------------------------------------------------------- 100 178 } -
issm/trunk-jpl/src/android/ISSM/src/com/example/issm/MapSelection.java
r14046 r14168 15 15 import android.view.View; 16 16 import android.widget.Button; 17 import android.widget.ImageButton; 17 18 import android.widget.Toast; 18 19 import android.content.Intent; … … 25 26 private static final String PREFERENCE_FIRST_RUN = null; 26 27 private String extStorageDirectory; 27 private String issmFolder; 28 private String issmFolder; 28 29 //------------------------------------------------------------------------ 29 30 public void onCreate(Bundle icicle) … … 49 50 50 51 //this button represents greenland and pass signal to issm 51 Button gl = (Button) findViewById(R.id.button1);52 ImageButton gl = (ImageButton) findViewById(R.id.button1); 52 53 gl.setOnClickListener(new View.OnClickListener() 53 54 { … … 62 63 63 64 //this button represents artarctica and pass signal to issm 64 Button art = (Button) findViewById(R.id.button2);65 ImageButton art = (ImageButton) findViewById(R.id.button2); 65 66 art.setOnClickListener(new View.OnClickListener() 66 67 { -
issm/trunk-jpl/src/android/ISSM/src/com/example/issm/MyGLSurfaceView.java
r14109 r14168 11 11 { 12 12 private MyGLRenderer mRend; 13 private int iter = 0; 14 DoubleBuffer db; 15 int size; 13 private DoubleBuffer db; 14 private int size; 16 15 double vmax = 0, vmin=0; 17 final int rowNumber = 64; 18 double[][] colorMap = { 19 { 1.0000, 0, 0 }, 20 { 1.0000, 0.0938 , 0 }, 21 { 1.0000, 0.1875 , 0}, 22 { 1.0000, 0.2812 , 0}, 23 { 1.0000, 0.3750 , 0}, 24 { 1.0000, 0.4688 , 0}, 25 { 1.0000, 0.5625 , 0}, 26 { 1.0000, 0.6562 , 0}, 27 { 1.0000, 0.7500 , 0}, 28 { 1.0000, 0.8438 , 0}, 29 { 1.0000, 0.9375 , 0}, 30 { 0.9688, 1.0000 , 0}, 31 { 0.8750, 1.0000 , 0}, 32 { 0.7812, 1.0000 , 0}, 33 { 0.6875, 1.0000 , 0}, 34 { 0.5938, 1.0000 , 0}, 35 { 0.5000, 1.0000 , 0}, 36 { 0.4062, 1.0000 , 0}, 37 { 0.3125, 1.0000 , 0}, 38 { 0.2188, 1.0000 , 0}, 39 { 0.1250, 1.0000 , 0}, 40 { 0.0312, 1.0000, 0}, 41 { 0, 1.0000, 0.0625}, 42 { 0, 1.0000, 0.1562}, 43 { 0, 1.0000, 0.2500}, 44 { 0, 1.0000, 0.3438}, 45 { 0, 1.0000, 0.4375}, 46 { 0, 1.0000, 0.5312}, 47 { 0, 1.0000, 0.6250}, 48 { 0, 1.0000, 0.7188}, 49 { 0, 1.0000, 0.8125}, 50 { 0, 1.0000, 0.9062}, 51 { 0, 1.0000, 1.0000}, 52 { 0, 0.9062, 1.0000}, 53 { 0, 0.8125, 1.0000}, 54 { 0, 0.7188, 1.0000}, 55 { 0, 0.6250, 1.0000}, 56 { 0, 0.5312, 1.0000}, 57 { 0, 0.4375, 1.0000}, 58 { 0, 0.3438, 1.0000}, 59 { 0, 0.2500, 1.0000}, 60 { 0, 0.1562, 1.0000}, 61 { 0, 0.0625, 1.0000}, 62 { 0.0312, 0, 1.0000}, 63 { 0.1250, 0, 1.0000}, 64 { 0.2188, 0, 1.0000}, 65 { 0.3125, 0, 1.0000}, 66 { 0.4062, 0, 1.0000}, 67 { 0.5000, 0, 1.0000}, 68 { 0.5938, 0, 1.0000}, 69 { 0.6875, 0, 1.0000}, 70 { 0.7812, 0, 1.0000}, 71 { 0.8750, 0, 1.0000}, 72 { 0.9688, 0, 1.0000}, 73 { 1.0000, 0, 0.9375}, 74 { 1.0000, 0, 0.8438}, 75 { 1.0000, 0, 0.7500}, 76 { 1.0000, 0, 0.6562}, 77 { 1.0000, 0, 0.5625}, 78 { 1.0000, 0, 0.4688}, 79 { 1.0000, 0, 0.3750}, 80 { 1.0000, 0, 0.2812}, 81 { 1.0000, 0, 0.1875}, 82 { 1.0000, 0, 0.0938}}; 83 float[][] colorMapInFloat; 84 public MyGLSurfaceView(Context context, DoubleBuffer db, int size) 16 final int rowNumber = 64, firstVelocity = 9; 17 ColorMap colorMap; 18 public MyGLSurfaceView(Context context, DoubleBuffer db, int size, ColorMap colorMap) 85 19 { 86 20 super(context); 87 88 21 // Create an OpenGL ES 2.0 context. 89 22 setEGLContextClientVersion(2); 90 23 this.db = db; 91 24 this.size = size; 92 colorMapInFloat = new float[64][3]; 93 94 for (int i = 0 ; i < 64; i++) 95 { 96 for (int j = 0 ; j < 3; j++) 97 { 98 colorMapInFloat[i][j] = (float) colorMap[i][j]; 99 } 100 } 101 vmin = db.get(9); 102 findMinMaxVelocity(); 103 System.out.println("max" +vmax +" "+ "min"+vmin ); 25 this.colorMap = colorMap; 26 vmin = db.get(firstVelocity); 27 findMinMaxVelocity(); 104 28 intialize(); 105 29 } 106 30 private void intialize() 107 31 { 108 final int NMAX_TRIANGLES = 2000;109 32 final int MAX_VERTICES = 21; 110 33 float f[][] = new float[size][MAX_VERTICES]; 111 int n, random; 34 //indexes prefer to velocity at each vertices of triangles. 35 int index1, index2, index3; 112 36 final int SCALE_FACTOR = 700000; 37 RGB rgb = new RGB(); 113 38 for (int i = 0; i < size; i++) 114 39 { … … 127 52 f[i][20] = 1.0f; 128 53 129 in t index1 = getRowColor(db.get(12*i+9));130 in t index2 = getRowColor(db.get(12*i+10));131 in t index3 = getRowColor(db.get(12*i+11));54 index1 = getRowColor(db.get(12*i+9)); 55 index2 = getRowColor(db.get(12*i+10)); 56 index3 = getRowColor(db.get(12*i+11)); 132 57 133 float r1 = colorMapInFloat[index1][0]; 134 float g1 = colorMapInFloat[index1][1]; 135 float b1 = colorMapInFloat[index1][2]; 58 colorMap.getRGB(index1, rgb); 59 float r1 = rgb.getR(); 60 float g1 = rgb.getG(); 61 float b1 = rgb.getB(); 136 62 137 float r2 = colorMapInFloat[index2][0]; 138 float g2 = colorMapInFloat[index2][1]; 139 float b2 = colorMapInFloat[index2][2]; 63 colorMap.getRGB(index2, rgb); 64 float r2 = rgb.getR(); 65 float g2 = rgb.getG(); 66 float b2 = rgb.getB(); 140 67 141 float r3 = colorMapInFloat[index3][0]; 142 float g3 = colorMapInFloat[index3][1]; 143 float b3 = colorMapInFloat[index3][2]; 68 colorMap.getRGB(index3, rgb); 69 float r3 = rgb.getR(); 70 float g3 = rgb.getG(); 71 float b3 = rgb.getB(); 144 72 145 73 … … 176 104 } 177 105 178 } 179 private float getData() 180 { 181 float result = (float) db.get(iter)/1000000; 182 //System.out.println("result" + result); 183 if(iter < size*12) iter++; 184 else iter = 0; 185 return result; 186 } 187 106 } 188 107 private int getRowColor(double velocity) 189 108 { 190 //velocity = 0;191 109 double alpha=(vmax-velocity)/(vmax-vmin) ; 192 110 int row = (int) (alpha * (rowNumber-1));
Note:
See TracChangeset
for help on using the changeset viewer.