Changeset 14168


Ignore:
Timestamp:
12/14/12 11:53:50 (12 years ago)
Author:
ltnguyen
Message:

Added: new look to ISSM android app, and color menu.

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  
    1212
    1313# Project target.
    14 target=android-15
     14target=android-17
  • issm/trunk-jpl/src/android/ISSM/res/layout/activity_mapselection.xml

    r14110 r14168  
    22    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    33        android:layout_width="fill_parent"
    4         android:layout_height="fill_parent" >
     4        android:layout_height="fill_parent"
     5        android:background="@drawable/issmlogo" >
    56
    6         <Button
     7        <ImageButton
    78            android:id="@+id/button1"
    89            style="@layout/activity_mapselection"
     
    1112            android:layout_alignParentBottom="true"
    1213            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" />
    1617
    17         <Button
     18        <ImageButton
    1819            android:id="@+id/button2"
    1920            android:layout_width="wrap_content"
    2021            android:layout_height="wrap_content"
    21             android:layout_alignBaseline="@+id/button1"
    2222            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" />
    2626
    27     </RelativeLayout>
     27           </RelativeLayout>
  • issm/trunk-jpl/src/android/ISSM/src/com/example/issm/ISSM.java

    r14109 r14168  
    11package com.example.issm;
    22
    3 import java.io.IOException;
    4 import java.io.InputStream;
    53import java.nio.ByteBuffer;
    64import java.nio.ByteOrder;
    75import java.nio.DoubleBuffer;
    8 import java.text.DecimalFormat;
    96
    107import android.opengl.GLSurfaceView;
    118import android.os.Bundle;
    129import android.app.Activity;
    13 import android.content.res.AssetManager;
    14 import android.text.TextUtils;
    1510import android.view.Menu;
     11import android.view.MenuInflater;
     12import android.view.MenuItem;
    1613import android.view.View;
    1714import android.view.View.OnClickListener;
     
    2118import android.widget.SeekBar;
    2219import android.widget.TextView;
     20import android.widget.Toast;
    2321
    2422
     
    3634        private SeekBar bar;
    3735    private TextView /*txtStatus,*/ txtValue;
     36    private ColorMap colorMap;
    3837   
    3938
     
    5453        this.txtValue  = (TextView) super.findViewById(R.id.value);
    5554        Button button = (Button) super.findViewById(R.id.button1);
     55            frame = (FrameLayout)findViewById(R.id.frame);
    5656        button.setOnClickListener(this);
    5757       
     
    6060        issmNative = new IssmJni();
    6161        this.createModel();
     62        this.colorMap = new ColorMap();
    6263        buff = ByteBuffer.allocateDirect(size*12*8).order(ByteOrder.nativeOrder()).asDoubleBuffer();
    63        
    64 
    6564    }
    6665//------------------------------------------------------------------------------------------------   
     
    8281        issmNative.solveISSMModel(5,buff);
    8382    }
    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//---------------------------------------------------------------------------------   
    85165    public void onClick(View view)
    86166        {
    87                 //factorial method
    88                 /*String input = this.input.getText().toString();
    89                 if(TextUtils.isEmpty(input))
    90                 {
    91                         return;
    92                 }*/             
    93                 //example of how to fill buffer Native
    94167                this.fillBuffer();
    95                
    96                 mGLView = new MyGLSurfaceView(this, buff, size);
    97             frame = (FrameLayout)findViewById(R.id.frame);
    98             frame.addView(mGLView);
     168                drawFigure();
    99169        }
     170//----------------------------------------------------------------------------------
     171    public void drawFigure()
     172    {
     173        frame.removeView(mGLView);
     174        mGLView = new MyGLSurfaceView(this, buff, size, colorMap);
     175        frame.addView(mGLView);
     176    }
     177//-----------------------------------------------------------------------------------   
    100178}
  • issm/trunk-jpl/src/android/ISSM/src/com/example/issm/MapSelection.java

    r14046 r14168  
    1515import android.view.View;
    1616import android.widget.Button;
     17import android.widget.ImageButton;
    1718import android.widget.Toast;
    1819import android.content.Intent;
     
    2526        private static final String PREFERENCE_FIRST_RUN = null;
    2627        private String extStorageDirectory;
    27         private String issmFolder;
     28        private String issmFolder; 
    2829//------------------------------------------------------------------------     
    2930        public void onCreate(Bundle icicle)
     
    4950       
    5051                //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);             
    5253                gl.setOnClickListener(new View.OnClickListener()
    5354                {
     
    6263               
    6364                //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);
    6566                art.setOnClickListener(new View.OnClickListener()
    6667                {
  • issm/trunk-jpl/src/android/ISSM/src/com/example/issm/MyGLSurfaceView.java

    r14109 r14168  
    1111{
    1212        private MyGLRenderer mRend;
    13         private int iter = 0;
    14         DoubleBuffer db;
    15         int size;
     13        private DoubleBuffer db;
     14        private int size;
    1615        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)
    8519    {
    8620        super(context);
    87 
    8821        // Create an OpenGL ES 2.0 context.
    8922        setEGLContextClientVersion(2);
    9023        this.db = db;
    9124        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();
    10428        intialize();
    10529    }
    10630    private void intialize()
    10731    {
    108         final int NMAX_TRIANGLES = 2000;
    10932        final int MAX_VERTICES = 21;
    11033        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;
    11236        final int SCALE_FACTOR = 700000;
     37        RGB rgb = new RGB();
    11338                for (int i = 0; i < size; i++)
    11439                {
     
    12752                                f[i][20] = 1.0f;
    12853                               
    129                                 int index1 = getRowColor(db.get(12*i+9));
    130                                 int index2 = getRowColor(db.get(12*i+10));
    131                                 int 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));
    13257                               
    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();
    13662                               
    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();
    14067                               
    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();
    14472                               
    14573                               
     
    176104        }
    177105       
    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    } 
    188107    private int getRowColor(double velocity)
    189108    {
    190         //velocity = 0;
    191109        double alpha=(vmax-velocity)/(vmax-vmin) ;
    192110        int row = (int) (alpha * (rowNumber-1));
Note: See TracChangeset for help on using the changeset viewer.