Changeset 14710


Ignore:
Timestamp:
04/22/13 21:34:06 (12 years ago)
Author:
ltnguyen
Message:

ADD: color bar

Location:
issm/trunk-jpl/src/mobile/android/ISSM_APP
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/mobile/android/ISSM_APP/bin/AndroidManifest.xml

    r14547 r14710  
    55    android:installLocation="preferExternal" >
    66    <uses-sdk
    7         android:minSdkVersion="10"
     7        android:minSdkVersion="11"
    88        android:targetSdkVersion="15" />
    99        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  • issm/trunk-jpl/src/mobile/android/ISSM_APP/res/layout/issmcore.xml

    r14694 r14710  
    3636        android:background="@drawable/back_button"/> -->
    3737   
     38    <gov.nasa.jpl.issm.ColorBar
     39        android:id="@+id/colorbar"
     40        android:layout_width="wrap_content"
     41        android:layout_height="wrap_content"
     42        android:layout_alignTop="@+id/spinner" />
    3843    <Spinner
    3944        android:id="@+id/spinner"
    4045        android:layout_width="wrap_content"
    4146        android:layout_height="wrap_content"
    42         android:layout_alignBottom="@+id/back"
    4347        android:layout_marginBottom="5dp"
    4448        android:layout_toRightOf="@+id/play"
  • issm/trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ColorBar.java

    r14472 r14710  
    11package gov.nasa.jpl.issm;
     2
     3import java.text.DecimalFormat;
    24
    35import android.content.Context;
     
    57import android.graphics.Color;
    68import android.graphics.Paint;
     9import android.util.AttributeSet;
    710import android.view.MotionEvent;
    811import android.view.View;
     
    1518    private int width = 30;
    1619        private int start_x = 10;
    17         private int start_y = 30;
     20        private int start_y = 10;
    1821        private int end_y = 0;
    1922        boolean touch;
    2023        final int MAX_SCALING =255;
    2124        double [][] colorBuffer;
    22     public ColorBar(Context context)
     25        private String vmax;
     26        private String vmin;
     27        private String vmid;
     28        private boolean drawInformation = false;
     29    public ColorBar(Context context, AttributeSet attrs)
    2330    {
    24         super(context);
     31        super(context,attrs);
    2532        setWillNotDraw(false);
    2633        paint.setStrokeWidth(5);
     
    2936        touch = false;
    3037    }
    31 //----------------------------------------------------------------   
     38//----------------------------------------------------------------
     39    //change the color map
     40    public void setVelocity(double vmax, double vmin)
     41    {
     42        this.vmin = vmin+"";
     43        String max = vmax+"";
     44        String mid = ((vmax+vmin)/2) + "";
     45        this.vmax = max.substring(0,3) + max.substring(max.length()-3, max.length());
     46        this.vmid = mid.substring(0,3) + mid.substring(mid.length()-3, mid.length());
     47        drawInformation = true;
     48    }
     49//-----------------------------------------------------------------   
    3250    //change the color map
    3351    public void setColorMap(ColorMap colorMap)
     
    4159        int r,g,b;
    4260        int y = start_y;
    43         for(int i = 0; i < 64; i++ )
     61        for(int i = 63; i >= 0; i-- )
    4462        {       
    4563                r =  Math.round((float)colorBuffer[i][0]*MAX_SCALING);
     
    4765                b =  Math.round((float)colorBuffer[i][2]*MAX_SCALING);
    4866                paint.setColor(Color.argb(MAX_SCALING, r, g, b));
    49                 canvas.drawLine(start_x, y, start_x+width, y, paint);
     67                canvas.drawLine(y, start_x,y, start_x+width, paint);
    5068               
    51                 if(i == 60)  canvas.drawText("_0.0", start_x+width, y, textpaint);
    52                 if(i == 48) canvas.drawText("_0.2", start_x+width, y, textpaint);
    53                 if(i == 36) canvas.drawText("_0.4", start_x+width, y, textpaint);
    54                 if(i == 24) canvas.drawText("_0.6", start_x+width, y, textpaint);
    55                 if(i == 12) canvas.drawText("_0.8", start_x+width, y, textpaint);
    56                 if(i == 0) canvas.drawText("_1.0", start_x+width, y, textpaint);
    57                
    58                 y+=5;
     69                if(drawInformation)
     70                {
     71                        if(i == 63)  canvas.drawText(vmin,y, start_x+width+20, textpaint);
     72                        if(i == 38) canvas.drawText(vmid,y, start_x+width+20, textpaint);
     73                        if(i == 8)      canvas.drawText(vmax,y, start_x+width+20, textpaint);
     74                        if(i == 0) canvas.drawText("V(m/yr)",y+10, start_x+width, textpaint);
     75                }
     76                y+=3;
    5977        }
    60        
    6178        end_y = y;
    6279    }
    63 //----------------------------------------------------------------       
    64     //allow user to move color bar around
     80//----------------------------------------------------------------   
     81    /*allow user to move color bar around
    6582    @Override
    6683    public boolean onTouchEvent (MotionEvent event)
     
    89106              }
    90107              return true;
    91     }
     108    }*/
    92109//----------------------------------------------------------------       
    93110}
    94111////////////////////////////////////////////////////////////////////////////
     112class Velocity
     113{
     114        private double vmax;
     115        private double vmin;
     116        public void setVmax(double vmax) {this.vmax = vmax;}
     117        public void setVmin(double vmin) {this.vmin = vmin;}
     118        public double getVmax() {return vmax;}
     119        public double getVmin() {return vmin;}
     120}
  • issm/trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ISSM.java

    r14703 r14710  
    5151        private ProgressDialog dialog;
    5252        private ColorBar colorBar;
     53        private Velocity velocity;
    5354        private SliderMenu sliders;
    5455        private ImageView defaultMap;
     
    9293                defaultMap = (ImageView) findViewById(R.id.defaultMap);
    9394                dialog = new ProgressDialog(this);
    94 
     95                colorBar = (ColorBar) findViewById(R.id.colorbar);
    9596        //load up the ISSM library and create double buffer in java
    9697        //which later on will be pass for native for allocation.
    9798        issmNative = new IssmJni();
     99        velocity = new Velocity();
    98100       
    99101        //set default color map to be HSV
    100102        this.colorMap = new ColorMap();
    101103        //create colorBar
    102         colorBar = new ColorBar(this);
    103104        colorBar.setColorMap(colorMap);
    104105        spinner.setOnItemSelectedListener(new OnItemSelectedListener()
     
    112113                                        String color = (String) spinner.getItemAtPosition(item);
    113114                                        colorMap.setColor(color);
     115                                        colorBar.setColorMap(colorMap);
     116                                        colorBar.invalidate();
    114117                                        drawFigure();
    115118                                }
     
    242245    {
    243246        frame.removeView(mGLView);
    244         mGLView = new MyGLSurfaceView(this, buff, size, colorMap);
     247        mGLView = new MyGLSurfaceView(this, buff, size, colorMap, velocity);
     248        colorBar.setVelocity(velocity.getVmax(), velocity.getVmin());
     249        colorBar.invalidate();
    245250        frame.addView(mGLView);
    246251    }
  • issm/trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/MyGLSurfaceView.java

    r14693 r14710  
    88
    99
    10 class MyGLSurfaceView extends GLSurfaceView
     10public class MyGLSurfaceView extends GLSurfaceView
    1111{
    1212        private MyGLRenderer mRend;
     
    1616        final int firstVelocity = 9;
    1717        ColorMap colorMap;
    18        
     18        Velocity velocity;
    1919        // pinch to zoom
    2020        float oldDist = 100.0f;
     
    2222       
    2323        int mode = 0;
    24     public MyGLSurfaceView(Context context, DoubleBuffer db, int size, ColorMap colorMap)
     24    public MyGLSurfaceView(Context context, DoubleBuffer db, int size, ColorMap colorMap, Velocity velocity)
    2525    {
    2626        super(context);
     
    3030        this.size = size;
    3131        this.colorMap = colorMap;
     32        this.velocity = velocity;
    3233        vmin = db.get(firstVelocity);
    3334        findMinMaxVelocity();
    3435        intialize();
     36        this.velocity.setVmin(vmin);
     37        this.velocity.setVmax(vmax);
    3538    }
    3639    private void intialize()
Note: See TracChangeset for help on using the changeset viewer.