Changeset 17423


Ignore:
Timestamp:
03/12/14 12:39:14 (11 years ago)
Author:
toanqngu
Message:

CHG: Moved images to assets for better performance. Online web mode is on. Offline mode is not active for now. Native is the old build

Location:
issm/mobile/android
Files:
44 added
18 deleted
42 edited

Legend:

Unmodified
Added
Removed
  • issm/mobile/android/ISSM/.classpath

    r14046 r17423  
    22<classpath>
    33        <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    4         <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
     4        <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    55        <classpathentry kind="src" path="src"/>
    66        <classpathentry kind="src" path="gen"/>
     7        <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
    78        <classpathentry kind="output" path="bin/classes"/>
    89</classpath>
  • issm/mobile/android/ISSM/project.properties

    r14524 r17423  
    1212
    1313# Project target.
    14 target=android-17
     14target=android-18
  • issm/mobile/android/ISSM_APP/.classpath

    r14472 r17423  
    22<classpath>
    33        <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    4         <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
     4        <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
     5        <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
    56        <classpathentry kind="src" path="src"/>
    67        <classpathentry kind="src" path="gen"/>
  • issm/mobile/android/ISSM_APP/AndroidManifest.xml

    r14844 r17423  
     1<?xml version="1.0" encoding="utf-8"?>
    12<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    23    package="gov.nasa.jpl.issm"
     4    android:installLocation="preferExternal"
    35    android:versionCode="1"
    4     android:versionName="1.0"
    5     android:installLocation="preferExternal" >
     6    android:versionName="1.0" >
     7
    68    <uses-sdk
    7         android:minSdkVersion="10"
    8         android:targetSdkVersion="15" />
    9         <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    10         <uses-permission android:name="android.permission.INTERNET" />
    11         <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    12            
     9        android:minSdkVersion="11"
     10        android:targetSdkVersion="18" />
     11
     12    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     13    <uses-permission android:name="android.permission.INTERNET" />
     14    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     15
    1316    <application
    1417        android:icon="@drawable/ic_launcher"
    1518        android:label="@string/app_name"
    1619        android:theme="@style/AppTheme" >
    17         <activity android:name="gov.nasa.jpl.issm.ISSMAPP"
    18                   android:screenOrientation="portrait"
    19                   android:label="@string/title_activity_issm"
    20                   android:noHistory="true" >
     20        <activity
     21            android:name="gov.nasa.jpl.issm.ISSMAPP"
     22            android:label="@string/title_activity_issm"
     23            android:noHistory="true"
     24            android:screenOrientation="portrait" >
    2125            <intent-filter>
    2226                <action android:name="android.intent.action.MAIN" />
    23                                 <category android:name="android.intent.category.LAUNCHER" />
     27
     28                <category android:name="android.intent.category.LAUNCHER" />
    2429            </intent-filter>
    25             </activity>
    26             <activity
     30        </activity>
     31        <activity
    2732            android:name="gov.nasa.jpl.issm.MenuPage"
    28             android:screenOrientation="portrait"
    29             android:label="@string/title_activity_issm" >
     33            android:label="@string/title_activity_issm"
     34            android:screenOrientation="portrait" >
    3035        </activity>
    3136        <activity
    3237            android:name="gov.nasa.jpl.issm.VideoActivity"
    33             android:screenOrientation="portrait"
    34             android:label="@string/title_video_issm" >
     38            android:label="@string/title_video_issm"
     39            android:screenOrientation="landscape" >
    3540        </activity>
    3641        <activity
    3742            android:name="gov.nasa.jpl.issm.ZoomImageViewActivity"
    38             android:screenOrientation="portrait"
    39             android:label="@string/title_activity_issm" >
     43            android:label="@string/title_activity_issm"
     44            android:screenOrientation="portrait" >
    4045        </activity>
    4146        <activity
    4247            android:name="gov.nasa.jpl.issm.AboutActivity"
    43             android:screenOrientation="portrait"
    44             android:label="@string/title_activity_issm" >
     48            android:label="@string/title_activity_issm"
     49            android:screenOrientation="portrait" >
    4550        </activity>
    46          <activity
     51        <activity
    4752            android:name="gov.nasa.jpl.issm.TeamActivity"
    48             android:screenOrientation="portrait"
    49             android:label="@string/title_activity_issm" >
     53            android:label="@string/title_activity_issm"
     54            android:screenOrientation="portrait" >
    5055        </activity>
    5156        <activity
    5257            android:name="gov.nasa.jpl.issm.ISSM"
    53             android:screenOrientation="portrait"
    54             android:label="@string/title_activity_issm" >
     58            android:label="@string/title_activity_issm"
     59            android:screenOrientation="portrait" >
    5560        </activity>
    5661        <activity
    5762            android:name="gov.nasa.jpl.issm.GalleryImage"
    58             android:screenOrientation="portrait"
    59             android:label="@string/title_activity_issm" >
     63            android:label="@string/title_activity_issm"
     64            android:screenOrientation="portrait" >
    6065        </activity>
    61        
     66        <activity
     67            android:name="gov.nasa.jpl.issm.ISSMWebActivity"
     68            android:label="@string/title_activity_issmweb_online" android:configChanges="orientation|screenSize">
     69        </activity>
    6270    </application>
    6371
  • issm/mobile/android/ISSM_APP/assets/about.html

    r14547 r17423  
    11<html>
    2 
    3 <h1>About Ice Sheet System Software</h1>
    4 ISSM is the result of a collaboration between the <b>Jet Propulsion Laboratory</b> and <b>University of California at Irvine</b>.<br><br>
    5 Its purpose is to tackle the challenge of modeling the evolution of the polar ice caps in Greenland and Antarctica. <br>
    6 ISSM is funded by the NASA Cryosphere and MAP (Modeling Analysis and Prediction) programs, JPL R&amp;TD(Research, Technology and Development) and the National Science Foundation.<br><br>
    7 Our main collaborators are:MSSMat Laboratory of ƒcole Centrale Paris, Argonne National Laboratory and the Department of Geology of University of Buffalo, NY.<br>
    8 As synthesized in the last <b>Intergovernmental Panel on Climate Change</b> (IPCC) Assessment Report AR4,future changes in the Greenland and Antarctic ice sheet mass, particularly due to changes in ice flow,are a major source of uncertainty that could increase sea level rise projections.<br>
    9 To remedy this problem, large scale ice flow models are necessary that can accurately model the evolution of Greenland and Antarctica in a warming climate. <br>
    10 In order to achieve this goal,and improve projections of future sea level rise, ISSM relies on state of the art technologies,developed in synergy with the Research and Technology Development (R&amp;TD) at JPL.
     2        <body>
     3                <h1 >About Ice Sheet System Software</h1>
     4                ISSM is the result of a collaboration between the <b>Jet Propulsion Laboratory</b> and <b>University of California at Irvine</b>.<br><br>
     5                Its purpose is to tackle the challenge of modeling the evolution of the polar ice caps in Greenland and Antarctica. <br>
     6                ISSM is funded by the NASA Cryosphere and MAP (Modeling Analysis and Prediction) programs, JPL R&amp;TD(Research, Technology and Development) and the National Science Foundation.<br><br>
     7                Our main collaborators are:MSSMat Laboratory of <i>f</i>cole Centrale Paris, Argonne National Laboratory and the Department of Geology of University of Buffalo, NY.<br>
     8                As synthesized in the last <b>Intergovernmental Panel on Climate Change</b> (IPCC) Assessment Report AR4,future changes in the Greenland and Antarctic ice sheet mass, particularly due to changes in ice flow,are a major source of uncertainty that could increase sea level rise projections.<br>
     9                To remedy this problem, large scale ice flow models are necessary that can accurately model the evolution of Greenland and Antarctica in a warming climate. <br>
     10                In order to achieve this goal,and improve projections of future sea level rise, ISSM relies on state of the art technologies,developed in synergy with the Research and Technology Development (R&amp;TD) at JPL.
     11        </body>
    1112</html>
  • issm/mobile/android/ISSM_APP/bin/AndroidManifest.xml

    r14844 r17423  
     1<?xml version="1.0" encoding="utf-8"?>
    12<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    23    package="gov.nasa.jpl.issm"
     4    android:installLocation="preferExternal"
    35    android:versionCode="1"
    4     android:versionName="1.0"
    5     android:installLocation="preferExternal" >
     6    android:versionName="1.0" >
     7
    68    <uses-sdk
    7         android:minSdkVersion="10"
    8         android:targetSdkVersion="15" />
    9         <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    10         <uses-permission android:name="android.permission.INTERNET" />
    11         <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    12            
     9        android:minSdkVersion="11"
     10        android:targetSdkVersion="18" />
     11
     12    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     13    <uses-permission android:name="android.permission.INTERNET" />
     14    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     15
    1316    <application
    1417        android:icon="@drawable/ic_launcher"
    1518        android:label="@string/app_name"
    1619        android:theme="@style/AppTheme" >
    17         <activity android:name="gov.nasa.jpl.issm.ISSMAPP"
    18                   android:screenOrientation="portrait"
    19                   android:label="@string/title_activity_issm"
    20                   android:noHistory="true" >
     20        <activity
     21            android:name="gov.nasa.jpl.issm.ISSMAPP"
     22            android:label="@string/title_activity_issm"
     23            android:noHistory="true"
     24            android:screenOrientation="portrait" >
    2125            <intent-filter>
    2226                <action android:name="android.intent.action.MAIN" />
    23                                 <category android:name="android.intent.category.LAUNCHER" />
     27
     28                <category android:name="android.intent.category.LAUNCHER" />
    2429            </intent-filter>
    25             </activity>
    26             <activity
     30        </activity>
     31        <activity
    2732            android:name="gov.nasa.jpl.issm.MenuPage"
    28             android:screenOrientation="portrait"
    29             android:label="@string/title_activity_issm" >
     33            android:label="@string/title_activity_issm"
     34            android:screenOrientation="portrait" >
    3035        </activity>
    3136        <activity
    3237            android:name="gov.nasa.jpl.issm.VideoActivity"
    33             android:screenOrientation="portrait"
    34             android:label="@string/title_video_issm" >
     38            android:label="@string/title_video_issm"
     39            android:screenOrientation="landscape" >
    3540        </activity>
    3641        <activity
    3742            android:name="gov.nasa.jpl.issm.ZoomImageViewActivity"
    38             android:screenOrientation="portrait"
    39             android:label="@string/title_activity_issm" >
     43            android:label="@string/title_activity_issm"
     44            android:screenOrientation="portrait" >
    4045        </activity>
    4146        <activity
    4247            android:name="gov.nasa.jpl.issm.AboutActivity"
    43             android:screenOrientation="portrait"
    44             android:label="@string/title_activity_issm" >
     48            android:label="@string/title_activity_issm"
     49            android:screenOrientation="portrait" >
    4550        </activity>
    46          <activity
     51        <activity
    4752            android:name="gov.nasa.jpl.issm.TeamActivity"
    48             android:screenOrientation="portrait"
    49             android:label="@string/title_activity_issm" >
     53            android:label="@string/title_activity_issm"
     54            android:screenOrientation="portrait" >
    5055        </activity>
    5156        <activity
    5257            android:name="gov.nasa.jpl.issm.ISSM"
    53             android:screenOrientation="portrait"
    54             android:label="@string/title_activity_issm" >
     58            android:label="@string/title_activity_issm"
     59            android:screenOrientation="portrait" >
    5560        </activity>
    5661        <activity
    5762            android:name="gov.nasa.jpl.issm.GalleryImage"
    58             android:screenOrientation="portrait"
    59             android:label="@string/title_activity_issm" >
     63            android:label="@string/title_activity_issm"
     64            android:screenOrientation="portrait" >
    6065        </activity>
    61        
     66        <activity
     67            android:name="gov.nasa.jpl.issm.ISSMWebActivity"
     68            android:label="@string/title_activity_issmweb_online" android:configChanges="orientation|screenSize">
     69        </activity>
    6270    </application>
    6371
  • issm/mobile/android/ISSM_APP/project.properties

    r14547 r17423  
    1212
    1313# Project target.
    14 target=android-15
     14target=android-18
  • issm/mobile/android/ISSM_APP/res/anim/left_out.xml

    r14472 r17423  
    99    android:fromYDelta="0%"
    1010    android:toYDelta="0%"
    11     android:duration="1500"
     11    android:duration="300"
    1212    android:zAdjustment="top" />
    1313 
  • issm/mobile/android/ISSM_APP/res/anim/right_in.xml

    r14472 r17423  
    99    android:fromYDelta="0%"
    1010    android:toYDelta="0%"
    11     android:duration="2000"
     11    android:duration="300"
    1212    android:zAdjustment="top" />
    1313 
  • issm/mobile/android/ISSM_APP/res/layout/aboutpage.xml

    r14547 r17423  
    33    android:layout_width="match_parent"
    44    android:layout_height="match_parent"
     5    android:background="@drawable/mainbackground"
    56    android:orientation="vertical" >
    67
  • issm/mobile/android/ISSM_APP/res/layout/gallery.xml

    r14711 r17423  
    33    android:layout_width="match_parent"
    44    android:layout_height="match_parent"
    5     android:background="@layout/roundcorner"
    6     android:orientation="vertical" >
     5    android:orientation="vertical"
     6    android:background="@drawable/mainbackground" >
     7<!--         android:background="@layout/roundcorner" -->
    78   
    89    <FrameLayout
  • issm/mobile/android/ISSM_APP/res/layout/menupage.xml

    r14516 r17423  
    11<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    2         android:layout_width="fill_parent"
    3         android:layout_height="fill_parent"
    4         android:background="@drawable/mainbackground" >
    5        
    6          <Button
    7             android:id="@+id/intro"
    8             android:layout_width="wrap_content"
    9             android:layout_height="wrap_content"
    10             android:layout_marginTop="60dp"
    11             android:layout_marginLeft="15dp"
    12             android:background="@drawable/snow_button"
    13             android:text="About" />
     2    android:layout_width="fill_parent"
     3    android:layout_height="fill_parent"
     4    android:background="@drawable/mainbackground" >
    145
    15         <Button
    16             android:id="@+id/video"
    17             android:layout_width="wrap_content"
    18             android:layout_height="wrap_content"
    19             android:layout_alignTop="@+id/intro"
    20             android:layout_alignParentRight="true"
    21             android:layout_marginRight="19dp"
    22             android:background="@drawable/snow_button"
    23             android:text="Video" />
     6    <TextView
     7        android:layout_width="200sp"
     8        android:layout_height="wrap_content"
     9        android:layout_alignParentTop="true"
     10        android:layout_centerHorizontal="true"
     11        android:layout_marginTop="95sp"
     12        android:gravity="center"
     13        android:text="Welcome to"
     14        android:textSize="40sp" />
    2415
    25         <Button
    26             android:id="@+id/start"
    27             android:layout_width="wrap_content"
    28             android:layout_height="wrap_content"
    29             android:layout_alignParentBottom="true"
    30             android:layout_alignRight="@+id/intro"
    31             android:layout_marginBottom="73dp"
    32                 android:background="@drawable/snow_button"
    33             android:text="Play" />
     16    <!-- <Button -->
     17    <!-- android:id="@+id/intro" -->
     18    <!-- android:layout_width="wrap_content" -->
     19    <!-- android:layout_height="wrap_content" -->
     20    <!-- android:layout_marginLeft="15dp" -->
     21    <!-- android:layout_marginTop="60dp" -->
     22    <!-- android:background="@drawable/snow_button" -->
     23    <!-- android:text="About" /> -->
    3424
    35         <Button
    36             android:id="@+id/visitus"
    37             android:layout_width="wrap_content"
    38             android:layout_height="wrap_content"
    39             android:layout_alignParentTop="true"
    40             android:layout_centerHorizontal="true"
    41             android:layout_marginTop="15dp"
    42             android:background="@drawable/snow_button"
    43             android:text="Team" />
    44        
    45         <Button
    46             android:id="@+id/galleryimage"
    47             android:layout_width="wrap_content"
    48             android:layout_height="wrap_content"
    49             android:layout_alignTop="@+id/start"
    50             android:layout_alignParentRight="true"
    51             android:layout_marginRight="19dp"
    52             android:background="@drawable/snow_button"
    53             android:text="Gallery" />
    5425
    55     </RelativeLayout>
     26    <!-- <Button -->
     27    <!-- android:id="@+id/video" -->
     28    <!-- android:layout_width="wrap_content" -->
     29    <!-- android:layout_height="wrap_content" -->
     30    <!-- android:layout_alignParentRight="true" -->
     31    <!-- android:layout_alignTop="@+id/intro" -->
     32    <!-- android:layout_marginRight="19dp" -->
     33    <!-- android:background="@drawable/snow_button" -->
     34    <!-- android:text="Video" /> -->
     35
     36    <Button
     37        android:id="@+id/start"
     38        android:layout_width="wrap_content"
     39        android:layout_height="wrap_content"
     40        android:layout_alignParentBottom="true"
     41        android:layout_centerHorizontal="true"
     42        android:layout_marginBottom="70sp"
     43        android:background="@drawable/snow_button"
     44        android:gravity="center"
     45        android:shadowColor="#ffffff"
     46        android:shadowDx="0"
     47        android:shadowDy="0"
     48        android:shadowRadius="8"
     49        android:text="Start"
     50        android:textAlignment="center"
     51        android:textColor="#ffffff"
     52        android:textSize="18sp" />
     53
     54    <!-- <Button -->
     55    <!-- android:id="@+id/visitus" -->
     56    <!-- android:layout_width="wrap_content" -->
     57    <!-- android:layout_height="wrap_content" -->
     58    <!-- android:layout_alignParentTop="true" -->
     59    <!-- android:layout_centerHorizontal="true" -->
     60    <!-- android:layout_marginTop="15dp" -->
     61    <!-- android:background="@drawable/snow_button" -->
     62    <!-- android:text="Team" /> -->
     63
     64
     65    <!-- <Button -->
     66    <!-- android:id="@+id/galleryimage" -->
     67    <!-- android:layout_width="wrap_content" -->
     68    <!-- android:layout_height="wrap_content" -->
     69    <!-- android:layout_alignParentRight="true" -->
     70    <!-- android:layout_alignTop="@+id/start" -->
     71    <!-- android:layout_marginRight="19dp" -->
     72    <!-- android:background="@drawable/snow_button" -->
     73    <!-- android:text="Gallery" /> -->
     74
     75</RelativeLayout>
  • issm/mobile/android/ISSM_APP/res/layout/teampage.xml

    r14547 r17423  
    11<?xml version="1.0" encoding="utf-8"?>
    2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     2<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    33    android:layout_width="match_parent"
    44    android:layout_height="match_parent"
    55    android:orientation="vertical" >
    6    
    7     <WebView android:id="@+id/teampage"
    8             android:layout_height="fill_parent"
    9             android:layout_width="fill_parent" />
    106
    11 </LinearLayout>
     7    <WebView
     8        android:id="@+id/teampage"
     9        android:layout_width="fill_parent"
     10        android:layout_height="fill_parent" />
     11
     12</RelativeLayout>
  • issm/mobile/android/ISSM_APP/res/layout/videopage.xml

    r14528 r17423  
    99   
    1010
    11         <VideoView
    12             android:id="@+id/videoview"
    13             android:layout_width="wrap_content"
    14             android:layout_height="wrap_content"
    15             android:layout_centerInParent="true"
    16              />
     11<!--         <VideoView -->
     12<!--             android:id="@+id/videoview" -->
     13<!--             android:layout_height="match_parent" -->
     14<!--             android:layout_width="match_parent" -->
     15<!--             android:layout_centerInParent="true" -->
     16<!--              /> -->
     17        <com.google.android.youtube.player.YouTubePlayerView
     18        android:id="@+id/youtubeplayer"
     19        android:layout_width="fill_parent"
     20        android:layout_height="fill_parent">
     21    </com.google.android.youtube.player.YouTubePlayerView>
     22       
     23       
    1724
    1825</RelativeLayout>
  • issm/mobile/android/ISSM_APP/res/values/dimens.xml

    r14472 r17423  
     1<?xml version="1.0" encoding="utf-8"?>
    12<resources>
    23
     
    45    <dimen name="padding_medium">8dp</dimen>
    56    <dimen name="padding_large">16dp</dimen>
     7    <dimen name="activity_horizontal_margin">16dp</dimen>
     8    <dimen name="activity_vertical_margin">16dp</dimen>
    69
    710</resources>
  • issm/mobile/android/ISSM_APP/res/values/strings.xml

    r14694 r17423  
     1<?xml version="1.0" encoding="utf-8"?>
    12<resources>
    23
     
    89    <string name="title_activity_issm">ISSM</string>
    910    <string name="color_prompt">Pick a Color Map</string>
    10  
     11
    1112    <string-array name="colormap_array">
    1213        <item>HSV</item>
     
    2324        <item>Summer</item>
    2425    </string-array>
    25         <string name="Greenland">Run Greenland Model</string>
    26         <string name="Antarctica">Run Antarctica Model</string>
     26
     27    <string name="Greenland">Run Greenland Model</string>
     28    <string name="Antarctica">Run Antarctica Model</string>
     29    <string name="title_activity_issmweb_online">ISSMWebOnlineActivity</string>
     30    <string name="action_settings">Settings</string>
    2731
    2832</resources>
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/AboutActivity.java

    r14547 r17423  
    11package gov.nasa.jpl.issm;
    22
     3import java.io.File;
     4import java.io.FileNotFoundException;
     5import java.io.FileOutputStream;
     6import java.io.IOException;
     7import java.io.InputStream;
     8
     9import android.app.ActionBar;
    310import android.app.Activity;
     11import android.content.Intent;
    412import android.os.Bundle;
     13import android.util.Log;
     14import android.view.View;
    515import android.webkit.WebView;
     16import android.widget.Button;
    617import gov.nasa.jpl.issm.MyWebViewClient;
    718
     19public class AboutActivity extends BaseActivity {
    820
    9 public class AboutActivity extends Activity {
    10        
    1121        private WebView myWebView;
    12         String SrcPath = "file:///android_asset/about.html";
    13        
    14          /** Called when the activity is first created. */
    15            @Override
    16            public void onCreate(Bundle savedInstanceState) {
    17                //super.onCreate(savedInstanceState);
    18                //setContentView(R.layout.aboutpage);
    19                    super.onCreate(savedInstanceState);
    20                         setContentView(R.layout.aboutpage);
    21                        
    22                        
    23          
    24                         myWebView = (WebView) findViewById(R.id.aboutpage);
    25                         myWebView.setWebViewClient(new MyWebViewClient());
    26                         //myWebView.getSettings().setJavaScriptEnabled(true);
    27                         myWebView.loadUrl(SrcPath);
    28            }
     22        String SrcPath = "file:///android_asset/";
     23        String html = "";
     24
     25        /** Called when the activity is first created. */
     26        @Override
     27        public void onCreate(Bundle savedInstanceState) {
     28                // super.onCreate(savedInstanceState);
     29                // setContentView(R.layout.aboutpage);
     30                super.onCreate(savedInstanceState);
     31                setContentView(R.layout.aboutpage);
     32                transition();
     33                loadAboutFile();
     34                // Go back to the main menu
     35                Button homeTab = (Button) findViewById(R.id.play_tab);
     36                homeTab.setOnClickListener(new View.OnClickListener() {
     37                        public void onClick(View v) {
     38                                Intent i = new Intent(AboutActivity.this, MenuPage.class);
     39                                startActivity(i);
     40                                finish();
     41                        }
     42                });
     43                // navigate to youtube video
     44                Button video = (Button) findViewById(R.id.video_tab);
     45                video.setOnClickListener(new View.OnClickListener() {
     46                        public void onClick(View v) {
     47                                // String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
     48                                // Intent i = new Intent(Intent.ACTION_VIEW);
     49                                // i.setData(Uri.parse(url));
     50                                Intent i = new Intent(AboutActivity.this, VideoActivity.class);
     51                                startActivity(i);
     52                                finish();
     53                        }
     54                });
     55                // pop up a text box that contains information about ISSM
     56                // final Button intro = (Button) findViewById(R.id.about_tab);
     57                // intro.setOnClickListener(new View.OnClickListener() {
     58                // public void onClick(View v) {
     59                // // LayoutInflater layoutInflater =
     60                // //
     61                // (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
     62                // // View popupView = layoutInflater.inflate(R.layout.popuptext,
     63                // // null);
     64                // // final PopupWindow popupWindow = new PopupWindow( popupView,
     65                // // 400,600, true);
     66                // // popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
     67                // // Button dismiss =
     68                // // (Button)popupView.findViewById(R.id.dismiss);
     69                // // dismiss.setOnClickListener(new Button.OnClickListener()
     70                // // {
     71                // // public void onClick(View v)
     72                // // {
     73                // // popupWindow.dismiss();
     74                // // }
     75                // // });
     76                // Intent i = new Intent(AboutActivity.this, AboutActivity.class);
     77                // startActivity(i);
     78                // }
     79                // });
     80                // Show Team Website
     81                Button visitus = (Button) findViewById(R.id.team_tab);
     82                visitus.setOnClickListener(new View.OnClickListener() {
     83                        public void onClick(View v) {
     84                                // String url = "http://issm.jpl.nasa.gov/";
     85                                // Intent i = new Intent(Intent.ACTION_VIEW);
     86                                // i.setData(Uri.parse(url));
     87                                // startActivity(i);
     88
     89                                Intent i = new Intent(AboutActivity.this, TeamActivity.class);
     90                                startActivity(i);
     91                                finish();
     92                        }
     93                });
     94                // start gallery image
     95                Button galleryImage = (Button) findViewById(R.id.gallery_tab);
     96                galleryImage.setOnClickListener(new View.OnClickListener() {
     97                        public void onClick(View v) {
     98                                Intent i = new Intent(AboutActivity.this, GalleryImage.class);
     99                                startActivity(i);
     100                                finish();
     101                        }
     102                });
     103
     104                myWebView = (WebView) findViewById(R.id.aboutpage);
     105                myWebView.setWebViewClient(new MyWebViewClient());
     106                // myWebView.getSettings().setJavaScriptEnabled(true);
     107                // myWebView.loadUrl(SrcPath + "about.html");
     108                myWebView
     109                                .loadDataWithBaseURL(SrcPath, html, "text/html", "utf-8", null);
     110        }
     111
     112        @Override
     113        public void onBackPressed() {
     114                Intent i = new Intent(AboutActivity.this, MenuPage.class);
     115                startActivity(i);
     116                finish();
     117        }
     118
     119        private void loadAboutFile() {
     120                InputStream is;
     121                byte[] buffer = null;
     122                try {
     123                        is = getResources().getAssets().open("about.html");
     124                        int size = is.available();
     125                        buffer = new byte[size];
     126                        is.read(buffer);
     127                        is.close();
     128                } catch (IOException e1) {
     129                        // TODO Auto-generated catch block
     130                        e1.printStackTrace();
     131                }
     132                html = new String(buffer);
     133                html = html.replace("old string", "new string");
     134        }
    29135
    30136}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ColorBar.java

    r15013 r17423  
    77import android.util.AttributeSet;
    88import android.view.View;
     9
    910/////////////////////////////////////////////////////////////
    10 public class ColorBar extends View
    11 {
     11public class ColorBar extends View {
    1212        Paint paint = new Paint();
    1313        Paint textpaint = new Paint();
    14         //coordinate of the colorbar
    15     private int width = 30;
     14        // coordinate of the colorbar
     15        private int width = 30;
    1616        private int start_x = 10;
    1717        private int start_y = 10;
    18         //private int end_y = 0;
     18        // private int end_y = 0;
    1919        boolean touch;
    20         final int MAX_SCALING =255;
    21         double [][] colorBuffer;
     20        final int MAX_SCALING = 255;
     21        double[][] colorBuffer;
    2222        private String vmax;
    2323        private String vmin;
    2424        private String vmid;
    2525        private boolean drawInformation = false;
    26     public ColorBar(Context context, AttributeSet attrs)
    27     {
    28         super(context,attrs);
    29         setWillNotDraw(false);
    30         paint.setStrokeWidth(5);
     26
     27        public ColorBar(Context context, AttributeSet attrs) {
     28                super(context, attrs);
     29                setWillNotDraw(false);
     30                paint.setStrokeWidth(5);
    3131                textpaint.setColor(Color.WHITE);
    32         textpaint.setTextSize(20);
    33         touch = false;
    34     }
    35 //----------------------------------------------------------------
    36     //change the color map
    37     public void setVelocity(double vmax, double vmin)
    38     {
    39         this.vmin = vmin+"";
    40         String max = vmax+"";
    41         String mid = ((vmax+vmin)/2) + "";
    42         this.vmax = max.substring(0,3) + max.substring(max.length()-3, max.length());
    43         this.vmid = mid.substring(0,3) + mid.substring(mid.length()-3, mid.length());
    44         drawInformation = true;
    45     }
    46 //-----------------------------------------------------------------   
    47     //change the color map
    48     public void setColorMap(ColorMap colorMap)
    49     {
    50         this.colorBuffer = colorMap.getColorBuffer();
    51     }
    52 //----------------------------------------------------------------       
    53     @Override
    54     public void onDraw(Canvas canvas)
    55     {
    56         int r,g,b;
    57         int y = start_y;
    58         for(int i = 63; i >= 0; i-- )
    59         {       
    60                 r =  Math.round((float)colorBuffer[i][0]*MAX_SCALING);
    61                 g =  Math.round((float)colorBuffer[i][1]*MAX_SCALING);
    62                 b =  Math.round((float)colorBuffer[i][2]*MAX_SCALING);
    63                 paint.setColor(Color.argb(MAX_SCALING, r, g, b));
    64                 canvas.drawLine(y, start_x,y, start_x+width, paint);
    65                
    66                 if(drawInformation)
    67                 {
    68                         if(i == 63)  canvas.drawText(vmin,y, start_x+width+20, textpaint);
    69                         if(i == 38) canvas.drawText(vmid,y, start_x+width+20, textpaint);
    70                         if(i == 8)      canvas.drawText(vmax,y, start_x+width+20, textpaint);
    71                         if(i == 0) canvas.drawText("V(m/yr)",y+10, start_x+width, textpaint);
    72                 }
    73                 y+=3;
    74         }
    75         //end_y = y;
    76     }
    77 //----------------------------------------------------------------   
    78     /*allow user to move color bar around
    79     @Override
    80     public boolean onTouchEvent (MotionEvent event)
    81     {
     32                textpaint.setTextSize(20);
     33                touch = false;
     34        }
    8235
    83               if (event.getAction() == MotionEvent.ACTION_DOWN)
    84               {   
    85                   int x = (int) event.getX();
    86                   int y = (int) event.getY();
    87                   if(x >= start_x && x <= start_x+width && y >= start_y && y <= end_y)
    88                           touch = true;
    89               }
    90               else if (event.getAction() == MotionEvent.ACTION_MOVE)
    91               {
    92                  if(touch)
    93                  {
    94                          start_x = (int) event.getX();
    95                          start_y = (int) event.getY();
    96                  }
    97                  invalidate();
    98        
    99               }
    100               else if (event.getAction() == MotionEvent.ACTION_UP)
    101               {
    102                   touch = false;
    103               }
    104               return true;
    105     }*/
    106 //----------------------------------------------------------------       
     36        // ----------------------------------------------------------------
     37        // change the color map
     38        public void setVelocity(double vmax, double vmin) {
     39                this.vmin = vmin + "";
     40                String max = vmax + "";
     41                String mid = ((vmax + vmin) / 2) + "";
     42                this.vmax = max.substring(0, 3)
     43                                + max.substring(max.length() - 3, max.length());
     44                this.vmid = mid.substring(0, 3)
     45                                + mid.substring(mid.length() - 3, mid.length());
     46                drawInformation = true;
     47        }
     48
     49        // -----------------------------------------------------------------
     50        // change the color map
     51        public void setColorMap(ColorMap colorMap) {
     52                this.colorBuffer = colorMap.getColorBuffer();
     53        }
     54
     55        // ----------------------------------------------------------------
     56        @Override
     57        public void onDraw(Canvas canvas) {
     58                int r, g, b;
     59                int y = start_y;
     60                for (int i = 63; i >= 0; i--) {
     61                        r = Math.round((float) colorBuffer[i][0] * MAX_SCALING);
     62                        g = Math.round((float) colorBuffer[i][1] * MAX_SCALING);
     63                        b = Math.round((float) colorBuffer[i][2] * MAX_SCALING);
     64                        paint.setColor(Color.argb(MAX_SCALING, r, g, b));
     65                        canvas.drawLine(y, start_x, y, start_x + width, paint);
     66
     67                        if (drawInformation) {
     68                                if (i == 63)
     69                                        canvas.drawText(vmin, y, start_x + width + 20, textpaint);
     70                                if (i == 38)
     71                                        canvas.drawText(vmid, y, start_x + width + 20, textpaint);
     72                                if (i == 8)
     73                                        canvas.drawText(vmax, y, start_x + width + 20, textpaint);
     74                                if (i == 0)
     75                                        canvas.drawText("V(m/yr)", y + 10, start_x + width,
     76                                                        textpaint);
     77                        }
     78                        y += 3;
     79                }
     80                // end_y = y;
     81        }
     82        // ----------------------------------------------------------------
     83        /*
     84         * allow user to move color bar around
     85         *
     86         * @Override public boolean onTouchEvent (MotionEvent event) {
     87         *
     88         * if (event.getAction() == MotionEvent.ACTION_DOWN) { int x = (int)
     89         * event.getX(); int y = (int) event.getY(); if(x >= start_x && x <=
     90         * start_x+width && y >= start_y && y <= end_y) touch = true; } else if
     91         * (event.getAction() == MotionEvent.ACTION_MOVE) { if(touch) { start_x =
     92         * (int) event.getX(); start_y = (int) event.getY(); } invalidate();
     93         *
     94         * } else if (event.getAction() == MotionEvent.ACTION_UP) { touch = false; }
     95         * return true; }
     96         */
     97        // ----------------------------------------------------------------
    10798}
    108 ////////////////////////////////////////////////////////////////////////////
    109 class Velocity
    110 {
     99
     100// //////////////////////////////////////////////////////////////////////////
     101class Velocity {
    111102        private double vmax;
    112103        private double vmin;
    113         public void setVmax(double vmax) {this.vmax = vmax;}
    114         public void setVmin(double vmin) {this.vmin = vmin;}
    115         public double getVmax() {return vmax;}
    116         public double getVmin() {return vmin;}
     104
     105        public void setVmax(double vmax) {
     106                this.vmax = vmax;
     107        }
     108
     109        public void setVmin(double vmin) {
     110                this.vmin = vmin;
     111        }
     112
     113        public double getVmax() {
     114                return vmax;
     115        }
     116
     117        public double getVmin() {
     118                return vmin;
     119        }
    117120}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ColorMap.java

    r14516 r17423  
    22
    33/////////////////////////////////////////////////////////
    4 class ColorMap
    5 {
     4class ColorMap {
    65        private double[][] d;
    76        final int rowNumber = 64;
    8 //-------------------------------------------------------
    9         public ColorMap()
    10         {
     7
     8        // -------------------------------------------------------
     9        public ColorMap() {
    1110                setDefault();
    1211        }
    13 //-------------------------------------------------------
    14         public double[][] getColorBuffer()
    15         {
     12
     13        // -------------------------------------------------------
     14        public double[][] getColorBuffer() {
    1615                return d;
    1716        }
    18 //--------------------------------------------------------
    19         public void setColor(String color)
    20         {
     17
     18        // --------------------------------------------------------
     19        public void setColor(String color) {
    2120                String cl = color.toLowerCase().trim();
    22                 if (cl.equals("hsv")) setDefault();
    23                 if (cl.equals("autumn")) setAutumn();
    24                 if (cl.equals("bone")) setBone();
    25                 if (cl.equals("cool")) setCool();
    26                 if (cl.equals("copper")) setCopper();
    27                 if (cl.equals("gray")) setGray();
    28                 if (cl.equals("hot")) setHot();
    29                 if (cl.equals("jet")) setJet();
    30                 if (cl.equals("pink")) setPink();
    31                 if (cl.equals("spring")) setSpring();
    32                 if (cl.equals("winter")) setWinter();
    33                 if (cl.equals("summer")) setSummer();
    34         }
    35 //--------------------------------------------------------     
    36         //set default color map => hsv {{{
    37         public void setDefault()
    38         {
    39                 d = new double[][]{     
    40                                 {1.0,   0.0,    0.0 },
    41                                 { 1.0,  0.0938,         0.0 },
    42                                 { 1.0,  0.1875,         0.0 },
    43                                 { 1.0,  0.2813,         0.0 },
    44                                 { 1.0,  0.375,  0.0 },
    45                                 { 1.0,  0.4688,         0.0 },
    46                                 { 1.0,  0.5625,         0.0 },
    47                                 { 1.0,  0.6563,         0.0 },
    48                                 { 1.0,  0.75,   0.0 },
    49                                 { 1.0,  0.8438,         0.0 },
    50                                 { 1.0,  0.9375,         0.0 },
    51                                 { 0.9688,       1.0,    0.0 },
    52                                 { 0.875,        1.0,    0.0 },
    53                                 { 0.7813,       1.0,    0.0 },
    54                                 { 0.6875,       1.0,    0.0 },
    55                                 { 0.5938,       1.0,    0.0 },
    56                                 { 0.5,  1.0,    0.0 },
    57                                 { 0.4063,       1.0,    0.0 },
    58                                 { 0.3125,       1.0,    0.0 },
    59                                 { 0.2188,       1.0,    0.0 },
    60                                 { 0.125,        1.0,    0.0 },
    61                                 { 0.0313,       1.0,    0.0 },
    62                                 { 0.0,  1.0,    0.0625 },
    63                                 { 0.0,  1.0,    0.1563 },
    64                                 { 0.0,  1.0,    0.25 },
    65                                 { 0.0,  1.0,    0.3438 },
    66                                 { 0.0,  1.0,    0.4375 },
    67                                 { 0.0,  1.0,    0.5313 },
    68                                 { 0.0,  1.0,    0.625 },
    69                                 { 0.0,  1.0,    0.7188 },
    70                                 { 0.0,  1.0,    0.8125 },
    71                                 { 0.0,  1.0,    0.9063 },
    72                                 { 0.0,  1.0,    1.0 },
    73                                 { 0.0,  0.9063,         1.0 },
    74                                 { 0.0,  0.8125,         1.0 },
    75                                 { 0.0,  0.7188,         1.0 },
    76                                 { 0.0,  0.625,  1.0 },
    77                                 { 0.0,  0.5313,         1.0 },
    78                                 { 0.0,  0.4375,         1.0 },
    79                                 { 0.0,  0.3438,         1.0 },
    80                                 { 0.0,  0.25,   1.0 },
    81                                 { 0.0,  0.1563,         1.0 },
    82                                 { 0.0,  0.0625,         1.0 },
    83                                 { 0.0313,       0.0,    1.0 },
    84                                 { 0.125,        0.0,    1.0 },
    85                                 { 0.2188,       0.0,    1.0 },
    86                                 { 0.3125,       0.0,    1.0 },
    87                                 { 0.4063,       0.0,    1.0 },
    88                                 { 0.5,  0.0,    1.0 },
    89                                 { 0.5938,       0.0,    1.0 },
    90                                 { 0.6875,       0.0,    1.0 },
    91                                 { 0.7813,       0.0,    1.0 },
    92                                 { 0.875,        0.0,    1.0 },
    93                                 { 0.9688,       0.0,    1.0 },
    94                                 { 1.0,  0.0,    0.9375 },
    95                                 { 1.0,  0.0,    0.8438 },
    96                                 { 1.0,  0.0,    0.75 },
    97                                 { 1.0,  0.0,    0.6563 },
    98                                 { 1.0,  0.0,    0.5625 },
    99                                 { 1.0,  0.0,    0.4688 },
    100                                 { 1.0,  0.0,    0.375 },
    101                                 { 1.0,  0.0,    0.2813 },
    102                                 { 1.0,  0.0,    0.1875 },
    103                                 { 1.0,  0.0,    0.0938 }
    104                         };
    105         }
    106         //}}}
    107 //-------------------------------------------------------
    108         public void setAutumn()
    109         {
    110                 d = new double[][]{
    111                                 { 1.0,  0.0,    0.0 },
    112                                 { 1.0,  0.0159,         0.0 },
    113                                 { 1.0,  0.0317,         0.0 },
    114                                 { 1.0,  0.0476,         0.0 },
    115                                 { 1.0,  0.0635,         0.0 },
    116                                 { 1.0,  0.0794,         0.0 },
    117                                 { 1.0,  0.0952,         0.0 },
    118                                 { 1.0,  0.1111,         0.0 },
    119                                 { 1.0,  0.127,  0.0 },
    120                                 { 1.0,  0.1429,         0.0 },
    121                                 { 1.0,  0.1587,         0.0 },
    122                                 { 1.0,  0.1746,         0.0 },
    123                                 { 1.0,  0.1905,         0.0 },
    124                                 { 1.0,  0.2063,         0.0 },
    125                                 { 1.0,  0.2222,         0.0 },
    126                                 { 1.0,  0.2381,         0.0 },
    127                                 { 1.0,  0.254,  0.0 },
    128                                 { 1.0,  0.2698,         0.0 },
    129                                 { 1.0,  0.2857,         0.0 },
    130                                 { 1.0,  0.3016,         0.0 },
    131                                 { 1.0,  0.3175,         0.0 },
    132                                 { 1.0,  0.3333,         0.0 },
    133                                 { 1.0,  0.3492,         0.0 },
    134                                 { 1.0,  0.3651,         0.0 },
    135                                 { 1.0,  0.381,  0.0 },
    136                                 { 1.0,  0.3968,         0.0 },
    137                                 { 1.0,  0.4127,         0.0 },
    138                                 { 1.0,  0.4286,         0.0 },
    139                                 { 1.0,  0.4444,         0.0 },
    140                                 { 1.0,  0.4603,         0.0 },
    141                                 { 1.0,  0.4762,         0.0 },
    142                                 { 1.0,  0.4921,         0.0 },
    143                                 { 1.0,  0.5079,         0.0 },
    144                                 { 1.0,  0.5238,         0.0 },
    145                                 { 1.0,  0.5397,         0.0 },
    146                                 { 1.0,  0.5556,         0.0 },
    147                                 { 1.0,  0.5714,         0.0 },
    148                                 { 1.0,  0.5873,         0.0 },
    149                                 { 1.0,  0.6032,         0.0 },
    150                                 { 1.0,  0.619,  0.0 },
    151                                 { 1.0,  0.6349,         0.0 },
    152                                 { 1.0,  0.6508,         0.0 },
    153                                 { 1.0,  0.6667,         0.0 },
    154                                 { 1.0,  0.6825,         0.0 },
    155                                 { 1.0,  0.6984,         0.0 },
    156                                 { 1.0,  0.7143,         0.0 },
    157                                 { 1.0,  0.7302,         0.0 },
    158                                 { 1.0,  0.746,  0.0 },
    159                                 { 1.0,  0.7619,         0.0 },
    160                                 { 1.0,  0.7778,         0.0 },
    161                                 { 1.0,  0.7937,         0.0 },
    162                                 { 1.0,  0.8095,         0.0 },
    163                                 { 1.0,  0.8254,         0.0 },
    164                                 { 1.0,  0.8413,         0.0 },
    165                                 { 1.0,  0.8571,         0.0 },
    166                                 { 1.0,  0.873,  0.0 },
    167                                 { 1.0,  0.8889,         0.0 },
    168                                 { 1.0,  0.9048,         0.0 },
    169                                 { 1.0,  0.9206,         0.0 },
    170                                 { 1.0,  0.9365,         0.0 },
    171                                 { 1.0,  0.9524,         0.0 },
    172                                 { 1.0,  0.9683,         0.0 },
    173                                 { 1.0,  0.9841,         0.0 },
    174                                 { 1.0,  1.0,    0.0 }
    175                         };
    176         }
    177 //-------------------------------------------------------
    178         public void setBone()
    179         {
    180                 d = new double[][]{
    181                                 { 0.0,  0.0,    0.0052 },
    182                                 { 0.0139,       0.0139,         0.0243 },
    183                                 { 0.0278,       0.0278,         0.0434 },
    184                                 { 0.0417,       0.0417,         0.0625 },
    185                                 { 0.0556,       0.0556,         0.0816 },
    186                                 { 0.0694,       0.0694,         0.1007 },
    187                                 { 0.0833,       0.0833,         0.1198 },
    188                                 { 0.0972,       0.0972,         0.1389 },
    189                                 { 0.1111,       0.1111,         0.158 },
    190                                 { 0.125,        0.125,  0.1771 },
    191                                 { 0.1389,       0.1389,         0.1962 },
    192                                 { 0.1528,       0.1528,         0.2153 },
    193                                 { 0.1667,       0.1667,         0.2344 },
    194                                 { 0.1806,       0.1806,         0.2535 },
    195                                 { 0.1944,       0.1944,         0.2726 },
    196                                 { 0.2083,       0.2083,         0.2917 },
    197                                 { 0.2222,       0.2222,         0.3108 },
    198                                 { 0.2361,       0.2361,         0.3299 },
    199                                 { 0.25,         0.25,   0.349 },
    200                                 { 0.2639,       0.2639,         0.3681 },
    201                                 { 0.2778,       0.2778,         0.3872 },
    202                                 { 0.2917,       0.2917,         0.4062 },
    203                                 { 0.3056,       0.3056,         0.4253 },
    204                                 { 0.3194,       0.3194,         0.4444 },
    205                                 { 0.3333,       0.3385,         0.4583 },
    206                                 { 0.3472,       0.3576,         0.4722 },
    207                                 { 0.3611,       0.3767,         0.4861 },
    208                                 { 0.375,        0.3958,         0.5 },
    209                                 { 0.3889,       0.4149,         0.5139 },
    210                                 { 0.4028,       0.434,  0.5278 },
    211                                 { 0.4167,       0.4531,         0.5417 },
    212                                 { 0.4306,       0.4722,         0.5556 },
    213                                 { 0.4444,       0.4913,         0.5694 },
    214                                 { 0.4583,       0.5104,         0.5833 },
    215                                 { 0.4722,       0.5295,         0.5972 },
    216                                 { 0.4861,       0.5486,         0.6111 },
    217                                 { 0.5,  0.5677,         0.625 },
    218                                 { 0.5139,       0.5868,         0.6389 },
    219                                 { 0.5278,       0.6059,         0.6528 },
    220                                 { 0.5417,       0.625,  0.6667 },
    221                                 { 0.5556,       0.6441,         0.6806 },
    222                                 { 0.5694,       0.6632,         0.6944 },
    223                                 { 0.5833,       0.6823,         0.7083 },
    224                                 { 0.5972,       0.7014,         0.7222 },
    225                                 { 0.6111,       0.7205,         0.7361 },
    226                                 { 0.625,        0.7396,         0.75 },
    227                                 { 0.6389,       0.7587,         0.7639 },
    228                                 { 0.6528,       0.7778,         0.7778 },
    229                                 { 0.6745,       0.7917,         0.7917 },
    230                                 { 0.6962,       0.8056,         0.8056 },
    231                                 { 0.7179,       0.8194,         0.8194 },
    232                                 { 0.7396,       0.8333,         0.8333 },
    233                                 { 0.7613,       0.8472,         0.8472 },
    234                                 { 0.783,        0.8611,         0.8611 },
    235                                 { 0.8047,       0.875,  0.875 },
    236                                 { 0.8264,       0.8889,         0.8889 },
    237                                 { 0.8481,       0.9028,         0.9028 },
    238                                 { 0.8698,       0.9167,         0.9167 },
    239                                 { 0.8915,       0.9306,         0.9306 },
    240                                 { 0.9132,       0.9444,         0.9444 },
    241                                 { 0.9349,       0.9583,         0.9583 },
    242                                 { 0.9566,       0.9722,         0.9722 },
    243                                 { 0.9783,       0.9861,         0.9861 },
    244                                 { 1.0,  1.0,    1.0 }
    245                         };
    246         }               
    247 //-------------------------------------------------------
    248         public void setCool()
    249         {
    250                 d = new double[][]{
    251                                 { 0.0,  1.0,    1.0 },
    252                                 { 0.0159,       0.9841,         1.0 },
    253                                 { 0.0317,       0.9683,         1.0 },
    254                                 { 0.0476,       0.9524,         1.0 },
    255                                 { 0.0635,       0.9365,         1.0 },
    256                                 { 0.0794,       0.9206,         1.0 },
    257                                 { 0.0952,       0.9048,         1.0 },
    258                                 { 0.1111,       0.8889,         1.0 },
    259                                 { 0.127,        0.873,  1.0 },
    260                                 { 0.1429,       0.8571,         1.0 },
    261                                 { 0.1587,       0.8413,         1.0 },
    262                                 { 0.1746,       0.8254,         1.0 },
    263                                 { 0.1905,       0.8095,         1.0 },
    264                                 { 0.2063,       0.7937,         1.0 },
    265                                 { 0.2222,       0.7778,         1.0 },
    266                                 { 0.2381,       0.7619,         1.0 },
    267                                 { 0.254,        0.746,  1.0 },
    268                                 { 0.2698,       0.7302,         1.0 },
    269                                 { 0.2857,       0.7143,         1.0 },
    270                                 { 0.3016,       0.6984,         1.0 },
    271                                 { 0.3175,       0.6825,         1.0 },
    272                                 { 0.3333,       0.6667,         1.0 },
    273                                 { 0.3492,       0.6508,         1.0 },
    274                                 { 0.3651,       0.6349,         1.0 },
    275                                 { 0.381,        0.619,  1.0 },
    276                                 { 0.3968,       0.6032,         1.0 },
    277                                 { 0.4127,       0.5873,         1.0 },
    278                                 { 0.4286,       0.5714,         1.0 },
    279                                 { 0.4444,       0.5556,         1.0 },
    280                                 { 0.4603,       0.5397,         1.0 },
    281                                 { 0.4762,       0.5238,         1.0 },
    282                                 { 0.4921,       0.5079,         1.0 },
    283                                 { 0.5079,       0.4921,         1.0 },
    284                                 { 0.5238,       0.4762,         1.0 },
    285                                 { 0.5397,       0.4603,         1.0 },
    286                                 { 0.5556,       0.4444,         1.0 },
    287                                 { 0.5714,       0.4286,         1.0 },
    288                                 { 0.5873,       0.4127,         1.0 },
    289                                 { 0.6032,       0.3968,         1.0 },
    290                                 { 0.619,        0.381,  1.0 },
    291                                 { 0.6349,       0.3651,         1.0 },
    292                                 { 0.6508,       0.3492,         1.0 },
    293                                 { 0.6667,       0.3333,         1.0 },
    294                                 { 0.6825,       0.3175,         1.0 },
    295                                 { 0.6984,       0.3016,         1.0 },
    296                                 { 0.7143,       0.2857,         1.0 },
    297                                 { 0.7302,       0.2698,         1.0 },
    298                                 { 0.746,        0.254,  1.0 },
    299                                 { 0.7619,       0.2381,         1.0 },
    300                                 { 0.7778,       0.2222,         1.0 },
    301                                 { 0.7937,       0.2063,         1.0 },
    302                                 { 0.8095,       0.1905,         1.0 },
    303                                 { 0.8254,       0.1746,         1.0 },
    304                                 { 0.8413,       0.1587,         1.0 },
    305                                 { 0.8571,       0.1429,         1.0 },
    306                                 { 0.873,        0.127,  1.0 },
    307                                 { 0.8889,       0.1111,         1.0 },
    308                                 { 0.9048,       0.0952,         1.0 },
    309                                 { 0.9206,       0.0794,         1.0 },
    310                                 { 0.9365,       0.0635,         1.0 },
    311                                 { 0.9524,       0.0476,         1.0 },
    312                                 { 0.9683,       0.0317,         1.0 },
    313                                 { 0.9841,       0.0159,         1.0 },
    314                                 { 1.0,  0.0,    1.0 }
    315                         };
    316         }
    317 //-------------------------------------------------------
    318         public void setCopper()
    319         {
    320                 d = new double[][]{
    321                                 { 0.0,  0.0,    0.0 },
    322                                 { 0.0198,       0.0124,         0.0079 },
    323                                 { 0.0397,       0.0248,         0.0158 },
    324                                 { 0.0595,       0.0372,         0.0237 },
    325                                 { 0.0794,       0.0496,         0.0316 },
    326                                 { 0.0992,       0.062,  0.0395 },
    327                                 { 0.119,        0.0744,         0.0474 },
    328                                 { 0.1389,       0.0868,         0.0553 },
    329                                 { 0.1587,       0.0992,         0.0632 },
    330                                 { 0.1786,       0.1116,         0.0711 },
    331                                 { 0.1984,       0.124,  0.079 },
    332                                 { 0.2183,       0.1364,         0.0869 },
    333                                 { 0.2381,       0.1488,         0.0948 },
    334                                 { 0.2579,       0.1612,         0.1027 },
    335                                 { 0.2778,       0.1736,         0.1106 },
    336                                 { 0.2976,       0.186,  0.1185 },
    337                                 { 0.3175,       0.1984,         0.1263 },
    338                                 { 0.3373,       0.2108,         0.1342 },
    339                                 { 0.3571,       0.2232,         0.1421 },
    340                                 { 0.377,        0.2356,         0.15 },
    341                                 { 0.3968,       0.248,  0.1579 },
    342                                 { 0.4167,       0.2604,         0.1658 },
    343                                 { 0.4365,       0.2728,         0.1737 },
    344                                 { 0.4563,       0.2852,         0.1816 },
    345                                 { 0.4762,       0.2976,         0.1895 },
    346                                 { 0.496,        0.31,   0.1974 },
    347                                 { 0.5159,       0.3224,         0.2053 },
    348                                 { 0.5357,       0.3348,         0.2132 },
    349                                 { 0.5556,       0.3472,         0.2211 },
    350                                 { 0.5754,       0.3596,         0.229 },
    351                                 { 0.5952,       0.372,  0.2369 },
    352                                 { 0.6151,       0.3844,         0.2448 },
    353                                 { 0.6349,       0.3968,         0.2527 },
    354                                 { 0.6548,       0.4092,         0.2606 },
    355                                 { 0.6746,       0.4216,         0.2685 },
    356                                 { 0.6944,       0.434,  0.2764 },
    357                                 { 0.7143,       0.4464,         0.2843 },
    358                                 { 0.7341,       0.4588,         0.2922 },
    359                                 { 0.754,        0.4712,         0.3001 },
    360                                 { 0.7738,       0.4836,         0.308 },
    361                                 { 0.7937,       0.496,  0.3159 },
    362                                 { 0.8135,       0.5084,         0.3238 },
    363                                 { 0.8333,       0.5208,         0.3317 },
    364                                 { 0.8532,       0.5332,         0.3396 },
    365                                 { 0.873,        0.5456,         0.3475 },
    366                                 { 0.8929,       0.558,  0.3554 },
    367                                 { 0.9127,       0.5704,         0.3633 },
    368                                 { 0.9325,       0.5828,         0.3712 },
    369                                 { 0.9524,       0.5952,         0.379 },
    370                                 { 0.9722,       0.6076,         0.3869 },
    371                                 { 0.9921,       0.62,   0.3948 },
    372                                 { 1.0,  0.6324,         0.4027 },
    373                                 { 1.0,  0.6448,         0.4106 },
    374                                 { 1.0,  0.6572,         0.4185 },
    375                                 { 1.0,  0.6696,         0.4264 },
    376                                 { 1.0,  0.682,  0.4343 },
    377                                 { 1.0,  0.6944,         0.4422 },
    378                                 { 1.0,  0.7068,         0.4501 },
    379                                 { 1.0,  0.7192,         0.458 },
    380                                 { 1.0,  0.7316,         0.4659 },
    381                                 { 1.0,  0.744,  0.4738 },
    382                                 { 1.0,  0.7564,         0.4817 },
    383                                 { 1.0,  0.7688,         0.4896 },
    384                                 { 1.0,  0.7812,         0.4975 },
    385                         };
    386         }
    387 //-------------------------------------------------------
    388         public void setGray()
    389         {
    390                 d = new double[][]{
    391                                 { 0.0,  0.0,    0.0 },
    392                                 { 0.0159,       0.0159,         0.0159 },
    393                                 { 0.0317,       0.0317,         0.0317 },
    394                                 { 0.0476,       0.0476,         0.0476 },
    395                                 { 0.0635,       0.0635,         0.0635 },
    396                                 { 0.0794,       0.0794,         0.0794 },
    397                                 { 0.0952,       0.0952,         0.0952 },
    398                                 { 0.1111,       0.1111,         0.1111 },
    399                                 { 0.127,        0.127,  0.127 },
    400                                 { 0.1429,       0.1429,         0.1429 },
    401                                 { 0.1587,       0.1587,         0.1587 },
    402                                 { 0.1746,       0.1746,         0.1746 },
    403                                 { 0.1905,       0.1905,         0.1905 },
    404                                 { 0.2063,       0.2063,         0.2063 },
    405                                 { 0.2222,       0.2222,         0.2222 },
    406                                 { 0.2381,       0.2381,         0.2381 },
    407                                 { 0.254,        0.254,  0.254 },
    408                                 { 0.2698,       0.2698,         0.2698 },
    409                                 { 0.2857,       0.2857,         0.2857 },
    410                                 { 0.3016,       0.3016,         0.3016 },
    411                                 { 0.3175,       0.3175,         0.3175 },
    412                                 { 0.3333,       0.3333,         0.3333 },
    413                                 { 0.3492,       0.3492,         0.3492 },
    414                                 { 0.3651,       0.3651,         0.3651 },
    415                                 { 0.381,        0.381,  0.381 },
    416                                 { 0.3968,       0.3968,         0.3968 },
    417                                 { 0.4127,       0.4127,         0.4127 },
    418                                 { 0.4286,       0.4286,         0.4286 },
    419                                 { 0.4444,       0.4444,         0.4444 },
    420                                 { 0.4603,       0.4603,         0.4603 },
    421                                 { 0.4762,       0.4762,         0.4762 },
    422                                 { 0.4921,       0.4921,         0.4921 },
    423                                 { 0.5079,       0.5079,         0.5079 },
    424                                 { 0.5238,       0.5238,         0.5238 },
    425                                 { 0.5397,       0.5397,         0.5397 },
    426                                 { 0.5556,       0.5556,         0.5556 },
    427                                 { 0.5714,       0.5714,         0.5714 },
    428                                 { 0.5873,       0.5873,         0.5873 },
    429                                 { 0.6032,       0.6032,         0.6032 },
    430                                 { 0.619,        0.619,  0.619 },
    431                                 { 0.6349,       0.6349,         0.6349 },
    432                                 { 0.6508,       0.6508,         0.6508 },
    433                                 { 0.6667,       0.6667,         0.6667 },
    434                                 { 0.6825,       0.6825,         0.6825 },
    435                                 { 0.6984,       0.6984,         0.6984 },
    436                                 { 0.7143,       0.7143,         0.7143 },
    437                                 { 0.7302,       0.7302,         0.7302 },
    438                                 { 0.746,        0.746,  0.746 },
    439                                 { 0.7619,       0.7619,         0.7619 },
    440                                 { 0.7778,       0.7778,         0.7778 },
    441                                 { 0.7937,       0.7937,         0.7937 },
    442                                 { 0.8095,       0.8095,         0.8095 },
    443                                 { 0.8254,       0.8254,         0.8254 },
    444                                 { 0.8413,       0.8413,         0.8413 },
    445                                 { 0.8571,       0.8571,         0.8571 },
    446                                 { 0.873,        0.873,  0.873 },
    447                                 { 0.8889,       0.8889,         0.8889 },
    448                                 { 0.9048,       0.9048,         0.9048 },
    449                                 { 0.9206,       0.9206,         0.9206 },
    450                                 { 0.9365,       0.9365,         0.9365 },
    451                                 { 0.9524,       0.9524,         0.9524 },
    452                                 { 0.9683,       0.9683,         0.9683 },
    453                                 { 0.9841,       0.9841,         0.9841 },
    454                                 { 1.0,  1.0,    1.0 }
    455                         };
    456         }
    457 //-------------------------------------------------------
    458         public void setHot()
    459         {
    460                 d = new double[][]{
    461                                 { 0.0417,       0.0,    0.0 },
    462                                 { 0.0833,       0.0,    0.0 },
    463                                 { 0.125,        0.0,    0.0 },
    464                                 { 0.1667,       0.0,    0.0 },
    465                                 { 0.2083,       0.0,    0.0 },
    466                                 { 0.25,         0.0,    0.0 },
    467                                 { 0.2917,       0.0,    0.0 },
    468                                 { 0.3333,       0.0,    0.0 },
    469                                 { 0.375,        0.0,    0.0 },
    470                                 { 0.4167,       0.0,    0.0 },
    471                                 { 0.4583,       0.0,    0.0 },
    472                                 { 0.5,  0.0,    0.0 },
    473                                 { 0.5417,       0.0,    0.0 },
    474                                 { 0.5833,       0.0,    0.0 },
    475                                 { 0.625,        0.0,    0.0 },
    476                                 { 0.6667,       0.0,    0.0 },
    477                                 { 0.7083,       0.0,    0.0 },
    478                                 { 0.75,         0.0,    0.0 },
    479                                 { 0.7917,       0.0,    0.0 },
    480                                 { 0.8333,       0.0,    0.0 },
    481                                 { 0.875,        0.0,    0.0 },
    482                                 { 0.9167,       0.0,    0.0 },
    483                                 { 0.9583,       0.0,    0.0 },
    484                                 { 1.0,  0.0,    0.0 },
    485                                 { 1.0,  0.0417,         0.0 },
    486                                 { 1.0,  0.0833,         0.0 },
    487                                 { 1.0,  0.125,  0.0 },
    488                                 { 1.0,  0.1667,         0.0 },
    489                                 { 1.0,  0.2083,         0.0 },
    490                                 { 1.0,  0.25,   0.0 },
    491                                 { 1.0,  0.2917,         0.0 },
    492                                 { 1.0,  0.3333,         0.0 },
    493                                 { 1.0,  0.375,  0.0 },
    494                                 { 1.0,  0.4167,         0.0 },
    495                                 { 1.0,  0.4583,         0.0 },
    496                                 { 1.0,  0.5,    0.0 },
    497                                 { 1.0,  0.5417,         0.0 },
    498                                 { 1.0,  0.5833,         0.0 },
    499                                 { 1.0,  0.625,  0.0 },
    500                                 { 1.0,  0.6667,         0.0 },
    501                                 { 1.0,  0.7083,         0.0 },
    502                                 { 1.0,  0.75,   0.0 },
    503                                 { 1.0,  0.7917,         0.0 },
    504                                 { 1.0,  0.8333,         0.0 },
    505                                 { 1.0,  0.875,  0.0 },
    506                                 { 1.0,  0.9167,         0.0 },
    507                                 { 1.0,  0.9583,         0.0 },
    508                                 { 1.0,  1.0,    0.0 },
    509                                 { 1.0,  1.0,    0.0625 },
    510                                 { 1.0,  1.0,    0.125 },
    511                                 { 1.0,  1.0,    0.1875 },
    512                                 { 1.0,  1.0,    0.25 },
    513                                 { 1.0,  1.0,    0.3125 },
    514                                 { 1.0,  1.0,    0.375 },
    515                                 { 1.0,  1.0,    0.4375 },
    516                                 { 1.0,  1.0,    0.5 },
    517                                 { 1.0,  1.0,    0.5625 },
    518                                 { 1.0,  1.0,    0.625 },
    519                                 { 1.0,  1.0,    0.6875 },
    520                                 { 1.0,  1.0,    0.75 },
    521                                 { 1.0,  1.0,    0.8125 },
    522                                 { 1.0,  1.0,    0.875 },
    523                                 { 1.0,  1.0,    0.9375 },
    524                                 { 1.0,  1.0,    1.0 },
    525                         };
    526         }
    527 //-------------------------------------------------------
    528         public void setJet()
    529         {
    530                 d = new double[][]{
    531                                 { 0.0,  0.0,    0.5625 },
    532                                 { 0.0,  0.0,    0.625 },
    533                                 { 0.0,  0.0,    0.6875 },
    534                                 { 0.0,  0.0,    0.75 },
    535                                 { 0.0,  0.0,    0.8125 },
    536                                 { 0.0,  0.0,    0.875 },
    537                                 { 0.0,  0.0,    0.9375 },
    538                                 { 0.0,  0.0,    1.0 },
    539                                 { 0.0,  0.0625,         1.0 },
    540                                 { 0.0,  0.125,  1.0 },
    541                                 { 0.0,  0.1875,         1.0 },
    542                                 { 0.0,  0.25,   1.0 },
    543                                 { 0.0,  0.3125,         1.0 },
    544                                 { 0.0,  0.375,  1.0 },
    545                                 { 0.0,  0.4375,         1.0 },
    546                                 { 0.0,  0.5,    1.0 },
    547                                 { 0.0,  0.5625,         1.0 },
    548                                 { 0.0,  0.625,  1.0 },
    549                                 { 0.0,  0.6875,         1.0 },
    550                                 { 0.0,  0.75,   1.0 },
    551                                 { 0.0,  0.8125,         1.0 },
    552                                 { 0.0,  0.875,  1.0 },
    553                                 { 0.0,  0.9375,         1.0 },
    554                                 { 0.0,  1.0,    1.0 },
    555                                 { 0.0625,       1.0,    0.9375 },
    556                                 { 0.125,        1.0,    0.875 },
    557                                 { 0.1875,       1.0,    0.8125 },
    558                                 { 0.25,         1.0,    0.75 },
    559                                 { 0.3125,       1.0,    0.6875 },
    560                                 { 0.375,        1.0,    0.625 },
    561                                 { 0.4375,       1.0,    0.5625 },
    562                                 { 0.5,  1.0,    0.5 },
    563                                 { 0.5625,       1.0,    0.4375 },
    564                                 { 0.625,        1.0,    0.375 },
    565                                 { 0.6875,       1.0,    0.3125 },
    566                                 { 0.75,         1.0,    0.25 },
    567                                 { 0.8125,       1.0,    0.1875 },
    568                                 { 0.875,        1.0,    0.125 },
    569                                 { 0.9375,       1.0,    0.0625 },
    570                                 { 1.0,  1.0,    0.0 },
    571                                 { 1.0,  0.9375,         0.0 },
    572                                 { 1.0,  0.875,  0.0 },
    573                                 { 1.0,  0.8125,         0.0 },
    574                                 { 1.0,  0.75,   0.0 },
    575                                 { 1.0,  0.6875,         0.0 },
    576                                 { 1.0,  0.625,  0.0 },
    577                                 { 1.0,  0.5625,         0.0 },
    578                                 { 1.0,  0.5,    0.0 },
    579                                 { 1.0,  0.4375,         0.0 },
    580                                 { 1.0,  0.375,  0.0 },
    581                                 { 1.0,  0.3125,         0.0 },
    582                                 { 1.0,  0.25,   0.0 },
    583                                 { 1.0,  0.1875,         0.0 },
    584                                 { 1.0,  0.125,  0.0 },
    585                                 { 1.0,  0.0625,         0.0 },
    586                                 { 1.0,  0.0,    0.0 },
    587                                 { 0.9375,       0.0,    0.0 },
    588                                 { 0.875,        0.0,    0.0 },
    589                                 { 0.8125,       0.0,    0.0 },
    590                                 { 0.75,         0.0,    0.0 },
    591                                 { 0.6875,       0.0,    0.0 },
    592                                 { 0.625,        0.0,    0.0 },
    593                                 { 0.5625,       0.0,    0.0 },
    594                                 { 0.5,  0.0,    0.0 }
    595                         };
    596         }
    597 //-------------------------------------------------------
    598         public void setPink()
    599         {
    600                 d = new double[][]{
    601                                 { 0.1179,       0.0,    0.0 },
    602                                 { 0.1959,       0.1029,         0.1029 },
    603                                 { 0.2507,       0.1455,         0.1455 },
    604                                 { 0.2955,       0.1782,         0.1782 },
    605                                 { 0.3343,       0.2057,         0.2057 },
    606                                 { 0.3691,       0.23,   0.23 },
    607                                 { 0.4009,       0.252,  0.252 },
    608                                 { 0.4303,       0.2722,         0.2722 },
    609                                 { 0.4579,       0.291,  0.291 },
    610                                 { 0.4839,       0.3086,         0.3086 },
    611                                 { 0.5085,       0.3253,         0.3253 },
    612                                 { 0.532,        0.3412,         0.3412 },
    613                                 { 0.5546,       0.3563,         0.3563 },
    614                                 { 0.5762,       0.3709,         0.3709 },
    615                                 { 0.5971,       0.3849,         0.3849 },
    616                                 { 0.6172,       0.3984,         0.3984 },
    617                                 { 0.6367,       0.4115,         0.4115 },
    618                                 { 0.6557,       0.4241,         0.4241 },
    619                                 { 0.6741,       0.4364,         0.4364 },
    620                                 { 0.692,        0.4484,         0.4484 },
    621                                 { 0.7094,       0.46,   0.46 },
    622                                 { 0.7265,       0.4714,         0.4714 },
    623                                 { 0.7431,       0.4825,         0.4825 },
    624                                 { 0.7594,       0.4933,         0.4933 },
    625                                 { 0.7664,       0.5175,         0.504 },
    626                                 { 0.7732,       0.5407,         0.5143 },
    627                                 { 0.78,         0.5628,         0.5245 },
    628                                 { 0.7868,       0.5842,         0.5345 },
    629                                 { 0.7935,       0.6048,         0.5443 },
    630                                 { 0.8001,       0.6247,         0.554 },
    631                                 { 0.8067,       0.644,  0.5634 },
    632                                 { 0.8133,       0.6627,         0.5727 },
    633                                 { 0.8197,       0.6809,         0.5819 },
    634                                 { 0.8262,       0.6986,         0.5909 },
    635                                 { 0.8325,       0.7159,         0.5998 },
    636                                 { 0.8389,       0.7328,         0.6086 },
    637                                 { 0.8452,       0.7493,         0.6172 },
    638                                 { 0.8514,       0.7655,         0.6257 },
    639                                 { 0.8576,       0.7813,         0.6341 },
    640                                 { 0.8637,       0.7968,         0.6424 },
    641                                 { 0.8698,       0.812,  0.6506 },
    642                                 { 0.8759,       0.827,  0.6587 },
    643                                 { 0.8819,       0.8416,         0.6667 },
    644                                 { 0.8879,       0.856,  0.6746 },
    645                                 { 0.8938,       0.8702,         0.6824 },
    646                                 { 0.8997,       0.8842,         0.6901 },
    647                                 { 0.9056,       0.8979,         0.6977 },
    648                                 { 0.9114,       0.9114,         0.7052 },
    649                                 { 0.9172,       0.9172,         0.7272 },
    650                                 { 0.923,        0.923,  0.7485 },
    651                                 { 0.9287,       0.9287,         0.7692 },
    652                                 { 0.9344,       0.9344,         0.7893 },
    653                                 { 0.94,         0.94,   0.809 },
    654                                 { 0.9456,       0.9456,         0.8282 },
    655                                 { 0.9512,       0.9512,         0.8469 },
    656                                 { 0.9567,       0.9567,         0.8653 },
    657                                 { 0.9623,       0.9623,         0.8832 },
    658                                 { 0.9677,       0.9677,         0.9008 },
    659                                 { 0.9732,       0.9732,         0.9181 },
    660                                 { 0.9786,       0.9786,         0.9351 },
    661                                 { 0.984,        0.984,  0.9517 },
    662                                 { 0.9894,       0.9894,         0.9681 },
    663                                 { 0.9947,       0.9947,         0.9842 },
    664                                 { 1.0,  1.0,    1.0 }
    665                         };
    666         }
    667 //-------------------------------------------------------
    668         public void setSpring()
    669         {
    670                 d = new double[][]{
    671                                 { 1.0,  0.0,    1.0 },
    672                                 { 1.0,  0.0159,         0.9841 },
    673                                 { 1.0,  0.0317,         0.9683 },
    674                                 { 1.0,  0.0476,         0.9524 },
    675                                 { 1.0,  0.0635,         0.9365 },
    676                                 { 1.0,  0.0794,         0.9206 },
    677                                 { 1.0,  0.0952,         0.9048 },
    678                                 { 1.0,  0.1111,         0.8889 },
    679                                 { 1.0,  0.127,  0.873 },
    680                                 { 1.0,  0.1429,         0.8571 },
    681                                 { 1.0,  0.1587,         0.8413 },
    682                                 { 1.0,  0.1746,         0.8254 },
    683                                 { 1.0,  0.1905,         0.8095 },
    684                                 { 1.0,  0.2063,         0.7937 },
    685                                 { 1.0,  0.2222,         0.7778 },
    686                                 { 1.0,  0.2381,         0.7619 },
    687                                 { 1.0,  0.254,  0.746 },
    688                                 { 1.0,  0.2698,         0.7302 },
    689                                 { 1.0,  0.2857,         0.7143 },
    690                                 { 1.0,  0.3016,         0.6984 },
    691                                 { 1.0,  0.3175,         0.6825 },
    692                                 { 1.0,  0.3333,         0.6667 },
    693                                 { 1.0,  0.3492,         0.6508 },
    694                                 { 1.0,  0.3651,         0.6349 },
    695                                 { 1.0,  0.381,  0.619 },
    696                                 { 1.0,  0.3968,         0.6032 },
    697                                 { 1.0,  0.4127,         0.5873 },
    698                                 { 1.0,  0.4286,         0.5714 },
    699                                 { 1.0,  0.4444,         0.5556 },
    700                                 { 1.0,  0.4603,         0.5397 },
    701                                 { 1.0,  0.4762,         0.5238 },
    702                                 { 1.0,  0.4921,         0.5079 },
    703                                 { 1.0,  0.5079,         0.4921 },
    704                                 { 1.0,  0.5238,         0.4762 },
    705                                 { 1.0,  0.5397,         0.4603 },
    706                                 { 1.0,  0.5556,         0.4444 },
    707                                 { 1.0,  0.5714,         0.4286 },
    708                                 { 1.0,  0.5873,         0.4127 },
    709                                 { 1.0,  0.6032,         0.3968 },
    710                                 { 1.0,  0.619,  0.381 },
    711                                 { 1.0,  0.6349,         0.3651 },
    712                                 { 1.0,  0.6508,         0.3492 },
    713                                 { 1.0,  0.6667,         0.3333 },
    714                                 { 1.0,  0.6825,         0.3175 },
    715                                 { 1.0,  0.6984,         0.3016 },
    716                                 { 1.0,  0.7143,         0.2857 },
    717                                 { 1.0,  0.7302,         0.2698 },
    718                                 { 1.0,  0.746,  0.254 },
    719                                 { 1.0,  0.7619,         0.2381 },
    720                                 { 1.0,  0.7778,         0.2222 },
    721                                 { 1.0,  0.7937,         0.2063 },
    722                                 { 1.0,  0.8095,         0.1905 },
    723                                 { 1.0,  0.8254,         0.1746 },
    724                                 { 1.0,  0.8413,         0.1587 },
    725                                 { 1.0,  0.8571,         0.1429 },
    726                                 { 1.0,  0.873,  0.127 },
    727                                 { 1.0,  0.8889,         0.1111 },
    728                                 { 1.0,  0.9048,         0.0952 },
    729                                 { 1.0,  0.9206,         0.0794 },
    730                                 { 1.0,  0.9365,         0.0635 },
    731                                 { 1.0,  0.9524,         0.0476 },
    732                                 { 1.0,  0.9683,         0.0317 },
    733                                 { 1.0,  0.9841,         0.0159 },
    734                                 { 1.0,  1.0,    0.0 }
    735                         };
    736         }
    737 //-------------------------------------------------------
    738         public void setSummer()
    739         {
    740                 d = new double[][]{
    741                                 { 0.0,  0.5,    0.4 },
    742                                 { 0.0159,       0.5079,         0.4 },
    743                                 { 0.0317,       0.5159,         0.4 },
    744                                 { 0.0476,       0.5238,         0.4 },
    745                                 { 0.0635,       0.5317,         0.4 },
    746                                 { 0.0794,       0.5397,         0.4 },
    747                                 { 0.0952,       0.5476,         0.4 },
    748                                 { 0.1111,       0.5556,         0.4 },
    749                                 { 0.127,        0.5635,         0.4 },
    750                                 { 0.1429,       0.5714,         0.4 },
    751                                 { 0.1587,       0.5794,         0.4 },
    752                                 { 0.1746,       0.5873,         0.4 },
    753                                 { 0.1905,       0.5952,         0.4 },
    754                                 { 0.2063,       0.6032,         0.4 },
    755                                 { 0.2222,       0.6111,         0.4 },
    756                                 { 0.2381,       0.619,  0.4 },
    757                                 { 0.254,        0.627,  0.4 },
    758                                 { 0.2698,       0.6349,         0.4 },
    759                                 { 0.2857,       0.6429,         0.4 },
    760                                 { 0.3016,       0.6508,         0.4 },
    761                                 { 0.3175,       0.6587,         0.4 },
    762                                 { 0.3333,       0.6667,         0.4 },
    763                                 { 0.3492,       0.6746,         0.4 },
    764                                 { 0.3651,       0.6825,         0.4 },
    765                                 { 0.381,        0.6905,         0.4 },
    766                                 { 0.3968,       0.6984,         0.4 },
    767                                 { 0.4127,       0.7063,         0.4 },
    768                                 { 0.4286,       0.7143,         0.4 },
    769                                 { 0.4444,       0.7222,         0.4 },
    770                                 { 0.4603,       0.7302,         0.4 },
    771                                 { 0.4762,       0.7381,         0.4 },
    772                                 { 0.4921,       0.746,  0.4 },
    773                                 { 0.5079,       0.754,  0.4 },
    774                                 { 0.5238,       0.7619,         0.4 },
    775                                 { 0.5397,       0.7698,         0.4 },
    776                                 { 0.5556,       0.7778,         0.4 },
    777                                 { 0.5714,       0.7857,         0.4 },
    778                                 { 0.5873,       0.7937,         0.4 },
    779                                 { 0.6032,       0.8016,         0.4 },
    780                                 { 0.619,        0.8095,         0.4 },
    781                                 { 0.6349,       0.8175,         0.4 },
    782                                 { 0.6508,       0.8254,         0.4 },
    783                                 { 0.6667,       0.8333,         0.4 },
    784                                 { 0.6825,       0.8413,         0.4 },
    785                                 { 0.6984,       0.8492,         0.4 },
    786                                 { 0.7143,       0.8571,         0.4 },
    787                                 { 0.7302,       0.8651,         0.4 },
    788                                 { 0.746,        0.873,  0.4 },
    789                                 { 0.7619,       0.881,  0.4 },
    790                                 { 0.7778,       0.8889,         0.4 },
    791                                 { 0.7937,       0.8968,         0.4 },
    792                                 { 0.8095,       0.9048,         0.4 },
    793                                 { 0.8254,       0.9127,         0.4 },
    794                                 { 0.8413,       0.9206,         0.4 },
    795                                 { 0.8571,       0.9286,         0.4 },
    796                                 { 0.873,        0.9365,         0.4 },
    797                                 { 0.8889,       0.9444,         0.4 },
    798                                 { 0.9048,       0.9524,         0.4 },
    799                                 { 0.9206,       0.9603,         0.4 },
    800                                 { 0.9365,       0.9683,         0.4 },
    801                                 { 0.9524,       0.9762,         0.4 },
    802                                 { 0.9683,       0.9841,         0.4 },
    803                                 { 0.9841,       0.9921,         0.4 },
    804                                 { 1.0,  1.0,    0.4 }
    805                         };
    806         }
    807 //-------------------------------------------------------
    808         public void setWinter()
    809         {
    810                 d = new double[][]{
    811                                 { 0.0,  0.0,    1.0 },
    812                                 { 0.0,  0.0159,         0.9921 },
    813                                 { 0.0,  0.0317,         0.9841 },
    814                                 { 0.0,  0.0476,         0.9762 },
    815                                 { 0.0,  0.0635,         0.9683 },
    816                                 { 0.0,  0.0794,         0.9603 },
    817                                 { 0.0,  0.0952,         0.9524 },
    818                                 { 0.0,  0.1111,         0.9444 },
    819                                 { 0.0,  0.127,  0.9365 },
    820                                 { 0.0,  0.1429,         0.9286 },
    821                                 { 0.0,  0.1587,         0.9206 },
    822                                 { 0.0,  0.1746,         0.9127 },
    823                                 { 0.0,  0.1905,         0.9048 },
    824                                 { 0.0,  0.2063,         0.8968 },
    825                                 { 0.0,  0.2222,         0.8889 },
    826                                 { 0.0,  0.2381,         0.881 },
    827                                 { 0.0,  0.254,  0.873 },
    828                                 { 0.0,  0.2698,         0.8651 },
    829                                 { 0.0,  0.2857,         0.8571 },
    830                                 { 0.0,  0.3016,         0.8492 },
    831                                 { 0.0,  0.3175,         0.8413 },
    832                                 { 0.0,  0.3333,         0.8333 },
    833                                 { 0.0,  0.3492,         0.8254 },
    834                                 { 0.0,  0.3651,         0.8175 },
    835                                 { 0.0,  0.381,  0.8095 },
    836                                 { 0.0,  0.3968,         0.8016 },
    837                                 { 0.0,  0.4127,         0.7937 },
    838                                 { 0.0,  0.4286,         0.7857 },
    839                                 { 0.0,  0.4444,         0.7778 },
    840                                 { 0.0,  0.4603,         0.7698 },
    841                                 { 0.0,  0.4762,         0.7619 },
    842                                 { 0.0,  0.4921,         0.754 },
    843                                 { 0.0,  0.5079,         0.746 },
    844                                 { 0.0,  0.5238,         0.7381 },
    845                                 { 0.0,  0.5397,         0.7302 },
    846                                 { 0.0,  0.5556,         0.7222 },
    847                                 { 0.0,  0.5714,         0.7143 },
    848                                 { 0.0,  0.5873,         0.7063 },
    849                                 { 0.0,  0.6032,         0.6984 },
    850                                 { 0.0,  0.619,  0.6905 },
    851                                 { 0.0,  0.6349,         0.6825 },
    852                                 { 0.0,  0.6508,         0.6746 },
    853                                 { 0.0,  0.6667,         0.6667 },
    854                                 { 0.0,  0.6825,         0.6587 },
    855                                 { 0.0,  0.6984,         0.6508 },
    856                                 { 0.0,  0.7143,         0.6429 },
    857                                 { 0.0,  0.7302,         0.6349 },
    858                                 { 0.0,  0.746,  0.627 },
    859                                 { 0.0,  0.7619,         0.619 },
    860                                 { 0.0,  0.7778,         0.6111 },
    861                                 { 0.0,  0.7937,         0.6032 },
    862                                 { 0.0,  0.8095,         0.5952 },
    863                                 { 0.0,  0.8254,         0.5873 },
    864                                 { 0.0,  0.8413,         0.5794 },
    865                                 { 0.0,  0.8571,         0.5714 },
    866                                 { 0.0,  0.873,  0.5635 },
    867                                 { 0.0,  0.8889,         0.5556 },
    868                                 { 0.0,  0.9048,         0.5476 },
    869                                 { 0.0,  0.9206,         0.5397 },
    870                                 { 0.0,  0.9365,         0.5317 },
    871                                 { 0.0,  0.9524,         0.5238 },
    872                                 { 0.0,  0.9683,         0.5159 },
    873                                 { 0.0,  0.9841,         0.5079 },
    874                                 { 0.0,  1.0,    0.5 }
    875                         };
    876         }       
    877 //-------------------------------------------------------
    878         public void getRGB(double alpha, RGB rgb)
    879         {
    880 
    881                 double d1,d2,d3;
    882                 double d1a,d2a,d3a;
    883                 double d1b,d2b,d3b;
    884                 int    index1,index2;
    885 
    886                 if (alpha==0){
    887                         d1=d[0][0];
    888                         d2=d[0][1];
    889                         d3=d[0][2];
     21                if (cl.equals("hsv"))
     22                        setDefault();
     23                if (cl.equals("autumn"))
     24                        setAutumn();
     25                if (cl.equals("bone"))
     26                        setBone();
     27                if (cl.equals("cool"))
     28                        setCool();
     29                if (cl.equals("copper"))
     30                        setCopper();
     31                if (cl.equals("gray"))
     32                        setGray();
     33                if (cl.equals("hot"))
     34                        setHot();
     35                if (cl.equals("jet"))
     36                        setJet();
     37                if (cl.equals("pink"))
     38                        setPink();
     39                if (cl.equals("spring"))
     40                        setSpring();
     41                if (cl.equals("winter"))
     42                        setWinter();
     43                if (cl.equals("summer"))
     44                        setSummer();
     45        }
     46
     47        // --------------------------------------------------------
     48        // set default color map => hsv {{{
     49        public void setDefault() {
     50                d = new double[][] { { 1.0, 0.0, 0.0 }, { 1.0, 0.0938, 0.0 },
     51                                { 1.0, 0.1875, 0.0 }, { 1.0, 0.2813, 0.0 },
     52                                { 1.0, 0.375, 0.0 }, { 1.0, 0.4688, 0.0 },
     53                                { 1.0, 0.5625, 0.0 }, { 1.0, 0.6563, 0.0 }, { 1.0, 0.75, 0.0 },
     54                                { 1.0, 0.8438, 0.0 }, { 1.0, 0.9375, 0.0 },
     55                                { 0.9688, 1.0, 0.0 }, { 0.875, 1.0, 0.0 },
     56                                { 0.7813, 1.0, 0.0 }, { 0.6875, 1.0, 0.0 },
     57                                { 0.5938, 1.0, 0.0 }, { 0.5, 1.0, 0.0 }, { 0.4063, 1.0, 0.0 },
     58                                { 0.3125, 1.0, 0.0 }, { 0.2188, 1.0, 0.0 },
     59                                { 0.125, 1.0, 0.0 }, { 0.0313, 1.0, 0.0 },
     60                                { 0.0, 1.0, 0.0625 }, { 0.0, 1.0, 0.1563 }, { 0.0, 1.0, 0.25 },
     61                                { 0.0, 1.0, 0.3438 }, { 0.0, 1.0, 0.4375 },
     62                                { 0.0, 1.0, 0.5313 }, { 0.0, 1.0, 0.625 },
     63                                { 0.0, 1.0, 0.7188 }, { 0.0, 1.0, 0.8125 },
     64                                { 0.0, 1.0, 0.9063 }, { 0.0, 1.0, 1.0 }, { 0.0, 0.9063, 1.0 },
     65                                { 0.0, 0.8125, 1.0 }, { 0.0, 0.7188, 1.0 },
     66                                { 0.0, 0.625, 1.0 }, { 0.0, 0.5313, 1.0 },
     67                                { 0.0, 0.4375, 1.0 }, { 0.0, 0.3438, 1.0 }, { 0.0, 0.25, 1.0 },
     68                                { 0.0, 0.1563, 1.0 }, { 0.0, 0.0625, 1.0 },
     69                                { 0.0313, 0.0, 1.0 }, { 0.125, 0.0, 1.0 },
     70                                { 0.2188, 0.0, 1.0 }, { 0.3125, 0.0, 1.0 },
     71                                { 0.4063, 0.0, 1.0 }, { 0.5, 0.0, 1.0 }, { 0.5938, 0.0, 1.0 },
     72                                { 0.6875, 0.0, 1.0 }, { 0.7813, 0.0, 1.0 },
     73                                { 0.875, 0.0, 1.0 }, { 0.9688, 0.0, 1.0 },
     74                                { 1.0, 0.0, 0.9375 }, { 1.0, 0.0, 0.8438 }, { 1.0, 0.0, 0.75 },
     75                                { 1.0, 0.0, 0.6563 }, { 1.0, 0.0, 0.5625 },
     76                                { 1.0, 0.0, 0.4688 }, { 1.0, 0.0, 0.375 },
     77                                { 1.0, 0.0, 0.2813 }, { 1.0, 0.0, 0.1875 },
     78                                { 1.0, 0.0, 0.0938 } };
     79        }
     80
     81        // }}}
     82        // -------------------------------------------------------
     83        public void setAutumn() {
     84                d = new double[][] { { 1.0, 0.0, 0.0 }, { 1.0, 0.0159, 0.0 },
     85                                { 1.0, 0.0317, 0.0 }, { 1.0, 0.0476, 0.0 },
     86                                { 1.0, 0.0635, 0.0 }, { 1.0, 0.0794, 0.0 },
     87                                { 1.0, 0.0952, 0.0 }, { 1.0, 0.1111, 0.0 },
     88                                { 1.0, 0.127, 0.0 }, { 1.0, 0.1429, 0.0 },
     89                                { 1.0, 0.1587, 0.0 }, { 1.0, 0.1746, 0.0 },
     90                                { 1.0, 0.1905, 0.0 }, { 1.0, 0.2063, 0.0 },
     91                                { 1.0, 0.2222, 0.0 }, { 1.0, 0.2381, 0.0 },
     92                                { 1.0, 0.254, 0.0 }, { 1.0, 0.2698, 0.0 },
     93                                { 1.0, 0.2857, 0.0 }, { 1.0, 0.3016, 0.0 },
     94                                { 1.0, 0.3175, 0.0 }, { 1.0, 0.3333, 0.0 },
     95                                { 1.0, 0.3492, 0.0 }, { 1.0, 0.3651, 0.0 },
     96                                { 1.0, 0.381, 0.0 }, { 1.0, 0.3968, 0.0 },
     97                                { 1.0, 0.4127, 0.0 }, { 1.0, 0.4286, 0.0 },
     98                                { 1.0, 0.4444, 0.0 }, { 1.0, 0.4603, 0.0 },
     99                                { 1.0, 0.4762, 0.0 }, { 1.0, 0.4921, 0.0 },
     100                                { 1.0, 0.5079, 0.0 }, { 1.0, 0.5238, 0.0 },
     101                                { 1.0, 0.5397, 0.0 }, { 1.0, 0.5556, 0.0 },
     102                                { 1.0, 0.5714, 0.0 }, { 1.0, 0.5873, 0.0 },
     103                                { 1.0, 0.6032, 0.0 }, { 1.0, 0.619, 0.0 },
     104                                { 1.0, 0.6349, 0.0 }, { 1.0, 0.6508, 0.0 },
     105                                { 1.0, 0.6667, 0.0 }, { 1.0, 0.6825, 0.0 },
     106                                { 1.0, 0.6984, 0.0 }, { 1.0, 0.7143, 0.0 },
     107                                { 1.0, 0.7302, 0.0 }, { 1.0, 0.746, 0.0 },
     108                                { 1.0, 0.7619, 0.0 }, { 1.0, 0.7778, 0.0 },
     109                                { 1.0, 0.7937, 0.0 }, { 1.0, 0.8095, 0.0 },
     110                                { 1.0, 0.8254, 0.0 }, { 1.0, 0.8413, 0.0 },
     111                                { 1.0, 0.8571, 0.0 }, { 1.0, 0.873, 0.0 },
     112                                { 1.0, 0.8889, 0.0 }, { 1.0, 0.9048, 0.0 },
     113                                { 1.0, 0.9206, 0.0 }, { 1.0, 0.9365, 0.0 },
     114                                { 1.0, 0.9524, 0.0 }, { 1.0, 0.9683, 0.0 },
     115                                { 1.0, 0.9841, 0.0 }, { 1.0, 1.0, 0.0 } };
     116        }
     117
     118        // -------------------------------------------------------
     119        public void setBone() {
     120                d = new double[][] { { 0.0, 0.0, 0.0052 }, { 0.0139, 0.0139, 0.0243 },
     121                                { 0.0278, 0.0278, 0.0434 }, { 0.0417, 0.0417, 0.0625 },
     122                                { 0.0556, 0.0556, 0.0816 }, { 0.0694, 0.0694, 0.1007 },
     123                                { 0.0833, 0.0833, 0.1198 }, { 0.0972, 0.0972, 0.1389 },
     124                                { 0.1111, 0.1111, 0.158 }, { 0.125, 0.125, 0.1771 },
     125                                { 0.1389, 0.1389, 0.1962 }, { 0.1528, 0.1528, 0.2153 },
     126                                { 0.1667, 0.1667, 0.2344 }, { 0.1806, 0.1806, 0.2535 },
     127                                { 0.1944, 0.1944, 0.2726 }, { 0.2083, 0.2083, 0.2917 },
     128                                { 0.2222, 0.2222, 0.3108 }, { 0.2361, 0.2361, 0.3299 },
     129                                { 0.25, 0.25, 0.349 }, { 0.2639, 0.2639, 0.3681 },
     130                                { 0.2778, 0.2778, 0.3872 }, { 0.2917, 0.2917, 0.4062 },
     131                                { 0.3056, 0.3056, 0.4253 }, { 0.3194, 0.3194, 0.4444 },
     132                                { 0.3333, 0.3385, 0.4583 }, { 0.3472, 0.3576, 0.4722 },
     133                                { 0.3611, 0.3767, 0.4861 }, { 0.375, 0.3958, 0.5 },
     134                                { 0.3889, 0.4149, 0.5139 }, { 0.4028, 0.434, 0.5278 },
     135                                { 0.4167, 0.4531, 0.5417 }, { 0.4306, 0.4722, 0.5556 },
     136                                { 0.4444, 0.4913, 0.5694 }, { 0.4583, 0.5104, 0.5833 },
     137                                { 0.4722, 0.5295, 0.5972 }, { 0.4861, 0.5486, 0.6111 },
     138                                { 0.5, 0.5677, 0.625 }, { 0.5139, 0.5868, 0.6389 },
     139                                { 0.5278, 0.6059, 0.6528 }, { 0.5417, 0.625, 0.6667 },
     140                                { 0.5556, 0.6441, 0.6806 }, { 0.5694, 0.6632, 0.6944 },
     141                                { 0.5833, 0.6823, 0.7083 }, { 0.5972, 0.7014, 0.7222 },
     142                                { 0.6111, 0.7205, 0.7361 }, { 0.625, 0.7396, 0.75 },
     143                                { 0.6389, 0.7587, 0.7639 }, { 0.6528, 0.7778, 0.7778 },
     144                                { 0.6745, 0.7917, 0.7917 }, { 0.6962, 0.8056, 0.8056 },
     145                                { 0.7179, 0.8194, 0.8194 }, { 0.7396, 0.8333, 0.8333 },
     146                                { 0.7613, 0.8472, 0.8472 }, { 0.783, 0.8611, 0.8611 },
     147                                { 0.8047, 0.875, 0.875 }, { 0.8264, 0.8889, 0.8889 },
     148                                { 0.8481, 0.9028, 0.9028 }, { 0.8698, 0.9167, 0.9167 },
     149                                { 0.8915, 0.9306, 0.9306 }, { 0.9132, 0.9444, 0.9444 },
     150                                { 0.9349, 0.9583, 0.9583 }, { 0.9566, 0.9722, 0.9722 },
     151                                { 0.9783, 0.9861, 0.9861 }, { 1.0, 1.0, 1.0 } };
     152        }
     153
     154        // -------------------------------------------------------
     155        public void setCool() {
     156                d = new double[][] { { 0.0, 1.0, 1.0 }, { 0.0159, 0.9841, 1.0 },
     157                                { 0.0317, 0.9683, 1.0 }, { 0.0476, 0.9524, 1.0 },
     158                                { 0.0635, 0.9365, 1.0 }, { 0.0794, 0.9206, 1.0 },
     159                                { 0.0952, 0.9048, 1.0 }, { 0.1111, 0.8889, 1.0 },
     160                                { 0.127, 0.873, 1.0 }, { 0.1429, 0.8571, 1.0 },
     161                                { 0.1587, 0.8413, 1.0 }, { 0.1746, 0.8254, 1.0 },
     162                                { 0.1905, 0.8095, 1.0 }, { 0.2063, 0.7937, 1.0 },
     163                                { 0.2222, 0.7778, 1.0 }, { 0.2381, 0.7619, 1.0 },
     164                                { 0.254, 0.746, 1.0 }, { 0.2698, 0.7302, 1.0 },
     165                                { 0.2857, 0.7143, 1.0 }, { 0.3016, 0.6984, 1.0 },
     166                                { 0.3175, 0.6825, 1.0 }, { 0.3333, 0.6667, 1.0 },
     167                                { 0.3492, 0.6508, 1.0 }, { 0.3651, 0.6349, 1.0 },
     168                                { 0.381, 0.619, 1.0 }, { 0.3968, 0.6032, 1.0 },
     169                                { 0.4127, 0.5873, 1.0 }, { 0.4286, 0.5714, 1.0 },
     170                                { 0.4444, 0.5556, 1.0 }, { 0.4603, 0.5397, 1.0 },
     171                                { 0.4762, 0.5238, 1.0 }, { 0.4921, 0.5079, 1.0 },
     172                                { 0.5079, 0.4921, 1.0 }, { 0.5238, 0.4762, 1.0 },
     173                                { 0.5397, 0.4603, 1.0 }, { 0.5556, 0.4444, 1.0 },
     174                                { 0.5714, 0.4286, 1.0 }, { 0.5873, 0.4127, 1.0 },
     175                                { 0.6032, 0.3968, 1.0 }, { 0.619, 0.381, 1.0 },
     176                                { 0.6349, 0.3651, 1.0 }, { 0.6508, 0.3492, 1.0 },
     177                                { 0.6667, 0.3333, 1.0 }, { 0.6825, 0.3175, 1.0 },
     178                                { 0.6984, 0.3016, 1.0 }, { 0.7143, 0.2857, 1.0 },
     179                                { 0.7302, 0.2698, 1.0 }, { 0.746, 0.254, 1.0 },
     180                                { 0.7619, 0.2381, 1.0 }, { 0.7778, 0.2222, 1.0 },
     181                                { 0.7937, 0.2063, 1.0 }, { 0.8095, 0.1905, 1.0 },
     182                                { 0.8254, 0.1746, 1.0 }, { 0.8413, 0.1587, 1.0 },
     183                                { 0.8571, 0.1429, 1.0 }, { 0.873, 0.127, 1.0 },
     184                                { 0.8889, 0.1111, 1.0 }, { 0.9048, 0.0952, 1.0 },
     185                                { 0.9206, 0.0794, 1.0 }, { 0.9365, 0.0635, 1.0 },
     186                                { 0.9524, 0.0476, 1.0 }, { 0.9683, 0.0317, 1.0 },
     187                                { 0.9841, 0.0159, 1.0 }, { 1.0, 0.0, 1.0 } };
     188        }
     189
     190        // -------------------------------------------------------
     191        public void setCopper() {
     192                d = new double[][] { { 0.0, 0.0, 0.0 }, { 0.0198, 0.0124, 0.0079 },
     193                                { 0.0397, 0.0248, 0.0158 }, { 0.0595, 0.0372, 0.0237 },
     194                                { 0.0794, 0.0496, 0.0316 }, { 0.0992, 0.062, 0.0395 },
     195                                { 0.119, 0.0744, 0.0474 }, { 0.1389, 0.0868, 0.0553 },
     196                                { 0.1587, 0.0992, 0.0632 }, { 0.1786, 0.1116, 0.0711 },
     197                                { 0.1984, 0.124, 0.079 }, { 0.2183, 0.1364, 0.0869 },
     198                                { 0.2381, 0.1488, 0.0948 }, { 0.2579, 0.1612, 0.1027 },
     199                                { 0.2778, 0.1736, 0.1106 }, { 0.2976, 0.186, 0.1185 },
     200                                { 0.3175, 0.1984, 0.1263 }, { 0.3373, 0.2108, 0.1342 },
     201                                { 0.3571, 0.2232, 0.1421 }, { 0.377, 0.2356, 0.15 },
     202                                { 0.3968, 0.248, 0.1579 }, { 0.4167, 0.2604, 0.1658 },
     203                                { 0.4365, 0.2728, 0.1737 }, { 0.4563, 0.2852, 0.1816 },
     204                                { 0.4762, 0.2976, 0.1895 }, { 0.496, 0.31, 0.1974 },
     205                                { 0.5159, 0.3224, 0.2053 }, { 0.5357, 0.3348, 0.2132 },
     206                                { 0.5556, 0.3472, 0.2211 }, { 0.5754, 0.3596, 0.229 },
     207                                { 0.5952, 0.372, 0.2369 }, { 0.6151, 0.3844, 0.2448 },
     208                                { 0.6349, 0.3968, 0.2527 }, { 0.6548, 0.4092, 0.2606 },
     209                                { 0.6746, 0.4216, 0.2685 }, { 0.6944, 0.434, 0.2764 },
     210                                { 0.7143, 0.4464, 0.2843 }, { 0.7341, 0.4588, 0.2922 },
     211                                { 0.754, 0.4712, 0.3001 }, { 0.7738, 0.4836, 0.308 },
     212                                { 0.7937, 0.496, 0.3159 }, { 0.8135, 0.5084, 0.3238 },
     213                                { 0.8333, 0.5208, 0.3317 }, { 0.8532, 0.5332, 0.3396 },
     214                                { 0.873, 0.5456, 0.3475 }, { 0.8929, 0.558, 0.3554 },
     215                                { 0.9127, 0.5704, 0.3633 }, { 0.9325, 0.5828, 0.3712 },
     216                                { 0.9524, 0.5952, 0.379 }, { 0.9722, 0.6076, 0.3869 },
     217                                { 0.9921, 0.62, 0.3948 }, { 1.0, 0.6324, 0.4027 },
     218                                { 1.0, 0.6448, 0.4106 }, { 1.0, 0.6572, 0.4185 },
     219                                { 1.0, 0.6696, 0.4264 }, { 1.0, 0.682, 0.4343 },
     220                                { 1.0, 0.6944, 0.4422 }, { 1.0, 0.7068, 0.4501 },
     221                                { 1.0, 0.7192, 0.458 }, { 1.0, 0.7316, 0.4659 },
     222                                { 1.0, 0.744, 0.4738 }, { 1.0, 0.7564, 0.4817 },
     223                                { 1.0, 0.7688, 0.4896 }, { 1.0, 0.7812, 0.4975 }, };
     224        }
     225
     226        // -------------------------------------------------------
     227        public void setGray() {
     228                d = new double[][] { { 0.0, 0.0, 0.0 }, { 0.0159, 0.0159, 0.0159 },
     229                                { 0.0317, 0.0317, 0.0317 }, { 0.0476, 0.0476, 0.0476 },
     230                                { 0.0635, 0.0635, 0.0635 }, { 0.0794, 0.0794, 0.0794 },
     231                                { 0.0952, 0.0952, 0.0952 }, { 0.1111, 0.1111, 0.1111 },
     232                                { 0.127, 0.127, 0.127 }, { 0.1429, 0.1429, 0.1429 },
     233                                { 0.1587, 0.1587, 0.1587 }, { 0.1746, 0.1746, 0.1746 },
     234                                { 0.1905, 0.1905, 0.1905 }, { 0.2063, 0.2063, 0.2063 },
     235                                { 0.2222, 0.2222, 0.2222 }, { 0.2381, 0.2381, 0.2381 },
     236                                { 0.254, 0.254, 0.254 }, { 0.2698, 0.2698, 0.2698 },
     237                                { 0.2857, 0.2857, 0.2857 }, { 0.3016, 0.3016, 0.3016 },
     238                                { 0.3175, 0.3175, 0.3175 }, { 0.3333, 0.3333, 0.3333 },
     239                                { 0.3492, 0.3492, 0.3492 }, { 0.3651, 0.3651, 0.3651 },
     240                                { 0.381, 0.381, 0.381 }, { 0.3968, 0.3968, 0.3968 },
     241                                { 0.4127, 0.4127, 0.4127 }, { 0.4286, 0.4286, 0.4286 },
     242                                { 0.4444, 0.4444, 0.4444 }, { 0.4603, 0.4603, 0.4603 },
     243                                { 0.4762, 0.4762, 0.4762 }, { 0.4921, 0.4921, 0.4921 },
     244                                { 0.5079, 0.5079, 0.5079 }, { 0.5238, 0.5238, 0.5238 },
     245                                { 0.5397, 0.5397, 0.5397 }, { 0.5556, 0.5556, 0.5556 },
     246                                { 0.5714, 0.5714, 0.5714 }, { 0.5873, 0.5873, 0.5873 },
     247                                { 0.6032, 0.6032, 0.6032 }, { 0.619, 0.619, 0.619 },
     248                                { 0.6349, 0.6349, 0.6349 }, { 0.6508, 0.6508, 0.6508 },
     249                                { 0.6667, 0.6667, 0.6667 }, { 0.6825, 0.6825, 0.6825 },
     250                                { 0.6984, 0.6984, 0.6984 }, { 0.7143, 0.7143, 0.7143 },
     251                                { 0.7302, 0.7302, 0.7302 }, { 0.746, 0.746, 0.746 },
     252                                { 0.7619, 0.7619, 0.7619 }, { 0.7778, 0.7778, 0.7778 },
     253                                { 0.7937, 0.7937, 0.7937 }, { 0.8095, 0.8095, 0.8095 },
     254                                { 0.8254, 0.8254, 0.8254 }, { 0.8413, 0.8413, 0.8413 },
     255                                { 0.8571, 0.8571, 0.8571 }, { 0.873, 0.873, 0.873 },
     256                                { 0.8889, 0.8889, 0.8889 }, { 0.9048, 0.9048, 0.9048 },
     257                                { 0.9206, 0.9206, 0.9206 }, { 0.9365, 0.9365, 0.9365 },
     258                                { 0.9524, 0.9524, 0.9524 }, { 0.9683, 0.9683, 0.9683 },
     259                                { 0.9841, 0.9841, 0.9841 }, { 1.0, 1.0, 1.0 } };
     260        }
     261
     262        // -------------------------------------------------------
     263        public void setHot() {
     264                d = new double[][] { { 0.0417, 0.0, 0.0 }, { 0.0833, 0.0, 0.0 },
     265                                { 0.125, 0.0, 0.0 }, { 0.1667, 0.0, 0.0 },
     266                                { 0.2083, 0.0, 0.0 }, { 0.25, 0.0, 0.0 }, { 0.2917, 0.0, 0.0 },
     267                                { 0.3333, 0.0, 0.0 }, { 0.375, 0.0, 0.0 },
     268                                { 0.4167, 0.0, 0.0 }, { 0.4583, 0.0, 0.0 }, { 0.5, 0.0, 0.0 },
     269                                { 0.5417, 0.0, 0.0 }, { 0.5833, 0.0, 0.0 },
     270                                { 0.625, 0.0, 0.0 }, { 0.6667, 0.0, 0.0 },
     271                                { 0.7083, 0.0, 0.0 }, { 0.75, 0.0, 0.0 }, { 0.7917, 0.0, 0.0 },
     272                                { 0.8333, 0.0, 0.0 }, { 0.875, 0.0, 0.0 },
     273                                { 0.9167, 0.0, 0.0 }, { 0.9583, 0.0, 0.0 }, { 1.0, 0.0, 0.0 },
     274                                { 1.0, 0.0417, 0.0 }, { 1.0, 0.0833, 0.0 },
     275                                { 1.0, 0.125, 0.0 }, { 1.0, 0.1667, 0.0 },
     276                                { 1.0, 0.2083, 0.0 }, { 1.0, 0.25, 0.0 }, { 1.0, 0.2917, 0.0 },
     277                                { 1.0, 0.3333, 0.0 }, { 1.0, 0.375, 0.0 },
     278                                { 1.0, 0.4167, 0.0 }, { 1.0, 0.4583, 0.0 }, { 1.0, 0.5, 0.0 },
     279                                { 1.0, 0.5417, 0.0 }, { 1.0, 0.5833, 0.0 },
     280                                { 1.0, 0.625, 0.0 }, { 1.0, 0.6667, 0.0 },
     281                                { 1.0, 0.7083, 0.0 }, { 1.0, 0.75, 0.0 }, { 1.0, 0.7917, 0.0 },
     282                                { 1.0, 0.8333, 0.0 }, { 1.0, 0.875, 0.0 },
     283                                { 1.0, 0.9167, 0.0 }, { 1.0, 0.9583, 0.0 }, { 1.0, 1.0, 0.0 },
     284                                { 1.0, 1.0, 0.0625 }, { 1.0, 1.0, 0.125 },
     285                                { 1.0, 1.0, 0.1875 }, { 1.0, 1.0, 0.25 }, { 1.0, 1.0, 0.3125 },
     286                                { 1.0, 1.0, 0.375 }, { 1.0, 1.0, 0.4375 }, { 1.0, 1.0, 0.5 },
     287                                { 1.0, 1.0, 0.5625 }, { 1.0, 1.0, 0.625 },
     288                                { 1.0, 1.0, 0.6875 }, { 1.0, 1.0, 0.75 }, { 1.0, 1.0, 0.8125 },
     289                                { 1.0, 1.0, 0.875 }, { 1.0, 1.0, 0.9375 }, { 1.0, 1.0, 1.0 }, };
     290        }
     291
     292        // -------------------------------------------------------
     293        public void setJet() {
     294                d = new double[][] { { 0.0, 0.0, 0.5625 }, { 0.0, 0.0, 0.625 },
     295                                { 0.0, 0.0, 0.6875 }, { 0.0, 0.0, 0.75 }, { 0.0, 0.0, 0.8125 },
     296                                { 0.0, 0.0, 0.875 }, { 0.0, 0.0, 0.9375 }, { 0.0, 0.0, 1.0 },
     297                                { 0.0, 0.0625, 1.0 }, { 0.0, 0.125, 1.0 },
     298                                { 0.0, 0.1875, 1.0 }, { 0.0, 0.25, 1.0 }, { 0.0, 0.3125, 1.0 },
     299                                { 0.0, 0.375, 1.0 }, { 0.0, 0.4375, 1.0 }, { 0.0, 0.5, 1.0 },
     300                                { 0.0, 0.5625, 1.0 }, { 0.0, 0.625, 1.0 },
     301                                { 0.0, 0.6875, 1.0 }, { 0.0, 0.75, 1.0 }, { 0.0, 0.8125, 1.0 },
     302                                { 0.0, 0.875, 1.0 }, { 0.0, 0.9375, 1.0 }, { 0.0, 1.0, 1.0 },
     303                                { 0.0625, 1.0, 0.9375 }, { 0.125, 1.0, 0.875 },
     304                                { 0.1875, 1.0, 0.8125 }, { 0.25, 1.0, 0.75 },
     305                                { 0.3125, 1.0, 0.6875 }, { 0.375, 1.0, 0.625 },
     306                                { 0.4375, 1.0, 0.5625 }, { 0.5, 1.0, 0.5 },
     307                                { 0.5625, 1.0, 0.4375 }, { 0.625, 1.0, 0.375 },
     308                                { 0.6875, 1.0, 0.3125 }, { 0.75, 1.0, 0.25 },
     309                                { 0.8125, 1.0, 0.1875 }, { 0.875, 1.0, 0.125 },
     310                                { 0.9375, 1.0, 0.0625 }, { 1.0, 1.0, 0.0 },
     311                                { 1.0, 0.9375, 0.0 }, { 1.0, 0.875, 0.0 },
     312                                { 1.0, 0.8125, 0.0 }, { 1.0, 0.75, 0.0 }, { 1.0, 0.6875, 0.0 },
     313                                { 1.0, 0.625, 0.0 }, { 1.0, 0.5625, 0.0 }, { 1.0, 0.5, 0.0 },
     314                                { 1.0, 0.4375, 0.0 }, { 1.0, 0.375, 0.0 },
     315                                { 1.0, 0.3125, 0.0 }, { 1.0, 0.25, 0.0 }, { 1.0, 0.1875, 0.0 },
     316                                { 1.0, 0.125, 0.0 }, { 1.0, 0.0625, 0.0 }, { 1.0, 0.0, 0.0 },
     317                                { 0.9375, 0.0, 0.0 }, { 0.875, 0.0, 0.0 },
     318                                { 0.8125, 0.0, 0.0 }, { 0.75, 0.0, 0.0 }, { 0.6875, 0.0, 0.0 },
     319                                { 0.625, 0.0, 0.0 }, { 0.5625, 0.0, 0.0 }, { 0.5, 0.0, 0.0 } };
     320        }
     321
     322        // -------------------------------------------------------
     323        public void setPink() {
     324                d = new double[][] { { 0.1179, 0.0, 0.0 }, { 0.1959, 0.1029, 0.1029 },
     325                                { 0.2507, 0.1455, 0.1455 }, { 0.2955, 0.1782, 0.1782 },
     326                                { 0.3343, 0.2057, 0.2057 }, { 0.3691, 0.23, 0.23 },
     327                                { 0.4009, 0.252, 0.252 }, { 0.4303, 0.2722, 0.2722 },
     328                                { 0.4579, 0.291, 0.291 }, { 0.4839, 0.3086, 0.3086 },
     329                                { 0.5085, 0.3253, 0.3253 }, { 0.532, 0.3412, 0.3412 },
     330                                { 0.5546, 0.3563, 0.3563 }, { 0.5762, 0.3709, 0.3709 },
     331                                { 0.5971, 0.3849, 0.3849 }, { 0.6172, 0.3984, 0.3984 },
     332                                { 0.6367, 0.4115, 0.4115 }, { 0.6557, 0.4241, 0.4241 },
     333                                { 0.6741, 0.4364, 0.4364 }, { 0.692, 0.4484, 0.4484 },
     334                                { 0.7094, 0.46, 0.46 }, { 0.7265, 0.4714, 0.4714 },
     335                                { 0.7431, 0.4825, 0.4825 }, { 0.7594, 0.4933, 0.4933 },
     336                                { 0.7664, 0.5175, 0.504 }, { 0.7732, 0.5407, 0.5143 },
     337                                { 0.78, 0.5628, 0.5245 }, { 0.7868, 0.5842, 0.5345 },
     338                                { 0.7935, 0.6048, 0.5443 }, { 0.8001, 0.6247, 0.554 },
     339                                { 0.8067, 0.644, 0.5634 }, { 0.8133, 0.6627, 0.5727 },
     340                                { 0.8197, 0.6809, 0.5819 }, { 0.8262, 0.6986, 0.5909 },
     341                                { 0.8325, 0.7159, 0.5998 }, { 0.8389, 0.7328, 0.6086 },
     342                                { 0.8452, 0.7493, 0.6172 }, { 0.8514, 0.7655, 0.6257 },
     343                                { 0.8576, 0.7813, 0.6341 }, { 0.8637, 0.7968, 0.6424 },
     344                                { 0.8698, 0.812, 0.6506 }, { 0.8759, 0.827, 0.6587 },
     345                                { 0.8819, 0.8416, 0.6667 }, { 0.8879, 0.856, 0.6746 },
     346                                { 0.8938, 0.8702, 0.6824 }, { 0.8997, 0.8842, 0.6901 },
     347                                { 0.9056, 0.8979, 0.6977 }, { 0.9114, 0.9114, 0.7052 },
     348                                { 0.9172, 0.9172, 0.7272 }, { 0.923, 0.923, 0.7485 },
     349                                { 0.9287, 0.9287, 0.7692 }, { 0.9344, 0.9344, 0.7893 },
     350                                { 0.94, 0.94, 0.809 }, { 0.9456, 0.9456, 0.8282 },
     351                                { 0.9512, 0.9512, 0.8469 }, { 0.9567, 0.9567, 0.8653 },
     352                                { 0.9623, 0.9623, 0.8832 }, { 0.9677, 0.9677, 0.9008 },
     353                                { 0.9732, 0.9732, 0.9181 }, { 0.9786, 0.9786, 0.9351 },
     354                                { 0.984, 0.984, 0.9517 }, { 0.9894, 0.9894, 0.9681 },
     355                                { 0.9947, 0.9947, 0.9842 }, { 1.0, 1.0, 1.0 } };
     356        }
     357
     358        // -------------------------------------------------------
     359        public void setSpring() {
     360                d = new double[][] { { 1.0, 0.0, 1.0 }, { 1.0, 0.0159, 0.9841 },
     361                                { 1.0, 0.0317, 0.9683 }, { 1.0, 0.0476, 0.9524 },
     362                                { 1.0, 0.0635, 0.9365 }, { 1.0, 0.0794, 0.9206 },
     363                                { 1.0, 0.0952, 0.9048 }, { 1.0, 0.1111, 0.8889 },
     364                                { 1.0, 0.127, 0.873 }, { 1.0, 0.1429, 0.8571 },
     365                                { 1.0, 0.1587, 0.8413 }, { 1.0, 0.1746, 0.8254 },
     366                                { 1.0, 0.1905, 0.8095 }, { 1.0, 0.2063, 0.7937 },
     367                                { 1.0, 0.2222, 0.7778 }, { 1.0, 0.2381, 0.7619 },
     368                                { 1.0, 0.254, 0.746 }, { 1.0, 0.2698, 0.7302 },
     369                                { 1.0, 0.2857, 0.7143 }, { 1.0, 0.3016, 0.6984 },
     370                                { 1.0, 0.3175, 0.6825 }, { 1.0, 0.3333, 0.6667 },
     371                                { 1.0, 0.3492, 0.6508 }, { 1.0, 0.3651, 0.6349 },
     372                                { 1.0, 0.381, 0.619 }, { 1.0, 0.3968, 0.6032 },
     373                                { 1.0, 0.4127, 0.5873 }, { 1.0, 0.4286, 0.5714 },
     374                                { 1.0, 0.4444, 0.5556 }, { 1.0, 0.4603, 0.5397 },
     375                                { 1.0, 0.4762, 0.5238 }, { 1.0, 0.4921, 0.5079 },
     376                                { 1.0, 0.5079, 0.4921 }, { 1.0, 0.5238, 0.4762 },
     377                                { 1.0, 0.5397, 0.4603 }, { 1.0, 0.5556, 0.4444 },
     378                                { 1.0, 0.5714, 0.4286 }, { 1.0, 0.5873, 0.4127 },
     379                                { 1.0, 0.6032, 0.3968 }, { 1.0, 0.619, 0.381 },
     380                                { 1.0, 0.6349, 0.3651 }, { 1.0, 0.6508, 0.3492 },
     381                                { 1.0, 0.6667, 0.3333 }, { 1.0, 0.6825, 0.3175 },
     382                                { 1.0, 0.6984, 0.3016 }, { 1.0, 0.7143, 0.2857 },
     383                                { 1.0, 0.7302, 0.2698 }, { 1.0, 0.746, 0.254 },
     384                                { 1.0, 0.7619, 0.2381 }, { 1.0, 0.7778, 0.2222 },
     385                                { 1.0, 0.7937, 0.2063 }, { 1.0, 0.8095, 0.1905 },
     386                                { 1.0, 0.8254, 0.1746 }, { 1.0, 0.8413, 0.1587 },
     387                                { 1.0, 0.8571, 0.1429 }, { 1.0, 0.873, 0.127 },
     388                                { 1.0, 0.8889, 0.1111 }, { 1.0, 0.9048, 0.0952 },
     389                                { 1.0, 0.9206, 0.0794 }, { 1.0, 0.9365, 0.0635 },
     390                                { 1.0, 0.9524, 0.0476 }, { 1.0, 0.9683, 0.0317 },
     391                                { 1.0, 0.9841, 0.0159 }, { 1.0, 1.0, 0.0 } };
     392        }
     393
     394        // -------------------------------------------------------
     395        public void setSummer() {
     396                d = new double[][] { { 0.0, 0.5, 0.4 }, { 0.0159, 0.5079, 0.4 },
     397                                { 0.0317, 0.5159, 0.4 }, { 0.0476, 0.5238, 0.4 },
     398                                { 0.0635, 0.5317, 0.4 }, { 0.0794, 0.5397, 0.4 },
     399                                { 0.0952, 0.5476, 0.4 }, { 0.1111, 0.5556, 0.4 },
     400                                { 0.127, 0.5635, 0.4 }, { 0.1429, 0.5714, 0.4 },
     401                                { 0.1587, 0.5794, 0.4 }, { 0.1746, 0.5873, 0.4 },
     402                                { 0.1905, 0.5952, 0.4 }, { 0.2063, 0.6032, 0.4 },
     403                                { 0.2222, 0.6111, 0.4 }, { 0.2381, 0.619, 0.4 },
     404                                { 0.254, 0.627, 0.4 }, { 0.2698, 0.6349, 0.4 },
     405                                { 0.2857, 0.6429, 0.4 }, { 0.3016, 0.6508, 0.4 },
     406                                { 0.3175, 0.6587, 0.4 }, { 0.3333, 0.6667, 0.4 },
     407                                { 0.3492, 0.6746, 0.4 }, { 0.3651, 0.6825, 0.4 },
     408                                { 0.381, 0.6905, 0.4 }, { 0.3968, 0.6984, 0.4 },
     409                                { 0.4127, 0.7063, 0.4 }, { 0.4286, 0.7143, 0.4 },
     410                                { 0.4444, 0.7222, 0.4 }, { 0.4603, 0.7302, 0.4 },
     411                                { 0.4762, 0.7381, 0.4 }, { 0.4921, 0.746, 0.4 },
     412                                { 0.5079, 0.754, 0.4 }, { 0.5238, 0.7619, 0.4 },
     413                                { 0.5397, 0.7698, 0.4 }, { 0.5556, 0.7778, 0.4 },
     414                                { 0.5714, 0.7857, 0.4 }, { 0.5873, 0.7937, 0.4 },
     415                                { 0.6032, 0.8016, 0.4 }, { 0.619, 0.8095, 0.4 },
     416                                { 0.6349, 0.8175, 0.4 }, { 0.6508, 0.8254, 0.4 },
     417                                { 0.6667, 0.8333, 0.4 }, { 0.6825, 0.8413, 0.4 },
     418                                { 0.6984, 0.8492, 0.4 }, { 0.7143, 0.8571, 0.4 },
     419                                { 0.7302, 0.8651, 0.4 }, { 0.746, 0.873, 0.4 },
     420                                { 0.7619, 0.881, 0.4 }, { 0.7778, 0.8889, 0.4 },
     421                                { 0.7937, 0.8968, 0.4 }, { 0.8095, 0.9048, 0.4 },
     422                                { 0.8254, 0.9127, 0.4 }, { 0.8413, 0.9206, 0.4 },
     423                                { 0.8571, 0.9286, 0.4 }, { 0.873, 0.9365, 0.4 },
     424                                { 0.8889, 0.9444, 0.4 }, { 0.9048, 0.9524, 0.4 },
     425                                { 0.9206, 0.9603, 0.4 }, { 0.9365, 0.9683, 0.4 },
     426                                { 0.9524, 0.9762, 0.4 }, { 0.9683, 0.9841, 0.4 },
     427                                { 0.9841, 0.9921, 0.4 }, { 1.0, 1.0, 0.4 } };
     428        }
     429
     430        // -------------------------------------------------------
     431        public void setWinter() {
     432                d = new double[][] { { 0.0, 0.0, 1.0 }, { 0.0, 0.0159, 0.9921 },
     433                                { 0.0, 0.0317, 0.9841 }, { 0.0, 0.0476, 0.9762 },
     434                                { 0.0, 0.0635, 0.9683 }, { 0.0, 0.0794, 0.9603 },
     435                                { 0.0, 0.0952, 0.9524 }, { 0.0, 0.1111, 0.9444 },
     436                                { 0.0, 0.127, 0.9365 }, { 0.0, 0.1429, 0.9286 },
     437                                { 0.0, 0.1587, 0.9206 }, { 0.0, 0.1746, 0.9127 },
     438                                { 0.0, 0.1905, 0.9048 }, { 0.0, 0.2063, 0.8968 },
     439                                { 0.0, 0.2222, 0.8889 }, { 0.0, 0.2381, 0.881 },
     440                                { 0.0, 0.254, 0.873 }, { 0.0, 0.2698, 0.8651 },
     441                                { 0.0, 0.2857, 0.8571 }, { 0.0, 0.3016, 0.8492 },
     442                                { 0.0, 0.3175, 0.8413 }, { 0.0, 0.3333, 0.8333 },
     443                                { 0.0, 0.3492, 0.8254 }, { 0.0, 0.3651, 0.8175 },
     444                                { 0.0, 0.381, 0.8095 }, { 0.0, 0.3968, 0.8016 },
     445                                { 0.0, 0.4127, 0.7937 }, { 0.0, 0.4286, 0.7857 },
     446                                { 0.0, 0.4444, 0.7778 }, { 0.0, 0.4603, 0.7698 },
     447                                { 0.0, 0.4762, 0.7619 }, { 0.0, 0.4921, 0.754 },
     448                                { 0.0, 0.5079, 0.746 }, { 0.0, 0.5238, 0.7381 },
     449                                { 0.0, 0.5397, 0.7302 }, { 0.0, 0.5556, 0.7222 },
     450                                { 0.0, 0.5714, 0.7143 }, { 0.0, 0.5873, 0.7063 },
     451                                { 0.0, 0.6032, 0.6984 }, { 0.0, 0.619, 0.6905 },
     452                                { 0.0, 0.6349, 0.6825 }, { 0.0, 0.6508, 0.6746 },
     453                                { 0.0, 0.6667, 0.6667 }, { 0.0, 0.6825, 0.6587 },
     454                                { 0.0, 0.6984, 0.6508 }, { 0.0, 0.7143, 0.6429 },
     455                                { 0.0, 0.7302, 0.6349 }, { 0.0, 0.746, 0.627 },
     456                                { 0.0, 0.7619, 0.619 }, { 0.0, 0.7778, 0.6111 },
     457                                { 0.0, 0.7937, 0.6032 }, { 0.0, 0.8095, 0.5952 },
     458                                { 0.0, 0.8254, 0.5873 }, { 0.0, 0.8413, 0.5794 },
     459                                { 0.0, 0.8571, 0.5714 }, { 0.0, 0.873, 0.5635 },
     460                                { 0.0, 0.8889, 0.5556 }, { 0.0, 0.9048, 0.5476 },
     461                                { 0.0, 0.9206, 0.5397 }, { 0.0, 0.9365, 0.5317 },
     462                                { 0.0, 0.9524, 0.5238 }, { 0.0, 0.9683, 0.5159 },
     463                                { 0.0, 0.9841, 0.5079 }, { 0.0, 1.0, 0.5 } };
     464        }
     465
     466        // -------------------------------------------------------
     467        public void getRGB(double alpha, RGB rgb) {
     468
     469                double d1, d2, d3;
     470                double d1a, d2a, d3a;
     471                double d1b, d2b, d3b;
     472                int index1, index2;
     473
     474                if (alpha == 0) {
     475                        d1 = d[0][0];
     476                        d2 = d[0][1];
     477                        d3 = d[0][2];
     478                } else if (alpha == 1) {
     479                        d1 = d[rowNumber - 1][0];
     480                        d2 = d[rowNumber - 1][1];
     481                        d3 = d[rowNumber - 1][2];
     482                } else {
     483                        index1 = (int) (alpha * (rowNumber - 1));
     484                        index2 = index1 + 1;
     485
     486                        d1a = d[index1][0];
     487                        d2a = d[index1][1];
     488                        d3a = d[index1][2];
     489
     490                        d1b = d[index2][0];
     491                        d2b = d[index2][1];
     492                        d3b = d[index2][2];
     493
     494                        d1 = (d1a + d1b) / 2;
     495                        d2 = (d2a + d2b) / 2;
     496                        d3 = (d3a + d3b) / 2;
    890497                }
    891                 else if (alpha==1){
    892                         d1=d[rowNumber-1][0];
    893                         d2=d[rowNumber-1][1];
    894                         d3=d[rowNumber-1][2];
    895                 }
    896                 else{
    897                         index1=(int)(alpha*(rowNumber-1));
    898                         index2=index1+1;
    899                        
    900                         d1a=d[index1][0];
    901                         d2a=d[index1][1];
    902                         d3a=d[index1][2];
    903 
    904                         d1b=d[index2][0];
    905                         d2b=d[index2][1];
    906                         d3b=d[index2][2];
    907 
    908                         d1=(d1a+d1b)/2;
    909                         d2=(d2a+d2b)/2;
    910                         d3=(d3a+d3b)/2;
    911                 }
    912        
    913                 rgb.setR( (float) d1);
    914                 rgb.setG( (float) d2);
    915                 rgb.setB( (float) d3);
    916         }       
    917 //-------------------------------------------------------
     498
     499                rgb.setR((float) d1);
     500                rgb.setG((float) d2);
     501                rgb.setB((float) d3);
     502        }
     503        // -------------------------------------------------------
    918504} // end class colorMap
    919 /////////////////////////////////////////////////////////
    920 class RGB
    921 {
    922         private float R,G,B;
    923 //-------------------------------------------------------
    924         public void setR(float value) {this.R = value;}
    925         public void setG(float value) {this.G = value;}
    926         public void setB(float value) {this.B = value;}
    927         public float getR() { return R;}
    928         public float getG() { return G;}
    929         public float getB() { return B;}
    930 //-------------------------------------------------------
    931 } //end class RGB       
    932 /////////////////////////////////////////////////////////
     505// ///////////////////////////////////////////////////////
     506
     507class RGB {
     508        private float R, G, B;
     509
     510        // -------------------------------------------------------
     511        public void setR(float value) {
     512                this.R = value;
     513        }
     514
     515        public void setG(float value) {
     516                this.G = value;
     517        }
     518
     519        public void setB(float value) {
     520                this.B = value;
     521        }
     522
     523        public float getR() {
     524                return R;
     525        }
     526
     527        public float getG() {
     528                return G;
     529        }
     530
     531        public float getB() {
     532                return B;
     533        }
     534        // -------------------------------------------------------
     535} // end class RGB
     536// ///////////////////////////////////////////////////////
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ColorMenu.java

    r14472 r17423  
    44import android.widget.Spinner;
    55
    6 public class ColorMenu extends Spinner{
     6public class ColorMenu extends Spinner {
    77
    88        public ColorMenu(Context context) {
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/DisplayNextView.java

    r14563 r17423  
    2020                this.text = text;
    2121        }
    22        
     22
    2323        public DisplayNextView(boolean currentView, ImageView front, ImageView back) {
    2424                mCurrentView = currentView;
     
    3232
    3333        public void onAnimationEnd(Animation animation) {
    34                 if(containTextView)
     34                if (containTextView)
    3535                        mainImage.post(new SwapViews(mCurrentView, mainImage, text));
    3636                else
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/FlipAnimation.java

    r14532 r17423  
    66import android.view.animation.Transformation;
    77
    8 public class FlipAnimation  extends Animation
    9 {
     8public class FlipAnimation extends Animation {
    109        private final float mFromDegrees;
    1110        private final float mToDegrees;
     
    1312        private final float mCenterY;
    1413        private Camera mCamera;
    15        
    16         public FlipAnimation(float fromDegrees, float toDegrees,
    17            float centerX, float centerY)
    18         {
     14
     15        public FlipAnimation(float fromDegrees, float toDegrees, float centerX,
     16                        float centerY) {
    1917                mFromDegrees = fromDegrees;
    2018                mToDegrees = toDegrees;
     
    2220                mCenterY = centerY;
    2321        }
    24                
     22
    2523        @Override
    26         public void initialize(int width, int height, int parentWidth, int parentHeight)
    27         {
     24        public void initialize(int width, int height, int parentWidth,
     25                        int parentHeight) {
    2826                super.initialize(width, height, parentWidth, parentHeight);
    2927                mCamera = new Camera();
    3028        }
    31        
     29
    3230        @Override
    3331        protected void applyTransformation(float interpolatedTime, Transformation t) {
    3432                final float fromDegrees = mFromDegrees;
    35                 float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
    36                
     33                float degrees = fromDegrees
     34                                + ((mToDegrees - fromDegrees) * interpolatedTime);
     35
    3736                final float centerX = mCenterX;
    3837                final float centerY = mCenterY;
    3938                final Camera camera = mCamera;
    40                
     39
    4140                final Matrix matrix = t.getMatrix();
    42                
     41
    4342                camera.save();
    44                
     43
    4544                camera.rotateY(degrees);
    46                
     45
    4746                camera.getMatrix(matrix);
    4847                camera.restore();
    49                
     48
    5049                matrix.preTranslate(-centerX, -centerY);
    5150                matrix.postTranslate(centerX, centerY);
    52        
     51
    5352        }
    5453
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/GalleryAdapter.java

    r15013 r17423  
    1212public class GalleryAdapter extends BaseAdapter {
    1313
    14                 private Activity context;
     14        private Activity context;
    1515
    16                 private static ImageView imageView;
     16        private static ImageView imageView;
    1717
    18                
    19                 private List<Integer> plotsImages;
    20                 private static ViewHolder holder;
    21                
    22                 public GalleryAdapter(Activity context, List<Integer> plotsImages)
    23                 {
    24                                 this.context = context;
    25                                 this.plotsImages = plotsImages;
     18        private List<Integer> plotsImages;
     19        private static ViewHolder holder;
     20
     21        public GalleryAdapter(Activity context, List<Integer> plotsImages) {
     22                this.context = context;
     23                this.plotsImages = plotsImages;
     24        }
     25
     26        @Override
     27        public int getCount() {
     28                return plotsImages.size();
     29        }
     30
     31        @Override
     32        public Object getItem(int position) {
     33                return null;
     34        }
     35
     36        @Override
     37        public long getItemId(int position) {
     38                return 0;
     39        }
     40
     41        @Override
     42        public View getView(int position, View convertView, ViewGroup parent) {
     43
     44                if (convertView == null) {
     45
     46                        holder = new ViewHolder();
     47
     48                        imageView = new ImageView(this.context);
     49
     50                        imageView.setPadding(3, 3, 3, 3);
     51
     52                        convertView = imageView;
     53
     54                        holder.imageView = imageView;
     55
     56                        convertView.setTag(holder);
     57
     58                } else {
     59
     60                        holder = (ViewHolder) convertView.getTag();
    2661                }
    2762
     63                holder.imageView.setImageBitmap(ImageList.getImageList().get(position));
     64                holder.imageView.setScaleType(ImageView.ScaleType.FIT_XY);
     65                holder.imageView.setLayoutParams(new Gallery.LayoutParams(150, 90));
    2866
    29                 @Override
    30                 public int getCount() {
    31                         return plotsImages.size();
    32                 }
     67                return imageView;
     68        }
    3369
    34                 @Override
    35                 public Object getItem(int position) {
    36                         return null;
    37                 }
    38 
    39                 @Override
    40                 public long getItemId(int position) {
    41                         return 0;
    42                 }
    43 
    44                 @Override
    45                 public View getView(int position, View convertView, ViewGroup parent) {
    46 
    47                         if (convertView == null) {
    48 
    49                                 holder = new ViewHolder();
    50 
    51                                 imageView = new ImageView(this.context);
    52 
    53                                 imageView.setPadding(3, 3, 3, 3);
    54 
    55                                 convertView = imageView;
    56 
    57                                 holder.imageView = imageView;
    58 
    59                                 convertView.setTag(holder);
    60 
    61                         } else {
    62 
    63                                 holder = (ViewHolder) convertView.getTag();
    64                         }
    65 
    66                
    67                 holder.imageView.setImageBitmap(ImageList.getImageList().get(position));
    68                         holder.imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    69                         holder.imageView.setLayoutParams(new Gallery.LayoutParams(150, 90));
    70 
    71                         return imageView;
    72                 }
    73 
    74                 private static class ViewHolder {
    75                         ImageView imageView;
    76                 }
     70        private static class ViewHolder {
     71                ImageView imageView;
     72        }
    7773
    7874}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/GalleryDescription.java

    r14661 r17423  
    99
    1010class GalleryDescription
    11 //////////////////////////////////////////////////////////////////
     11// ////////////////////////////////////////////////////////////////
    1212{
    1313        private ArrayList<String> description;
    1414        private String[] rawtext;
    15 //----------------------------------------------------------------
    16         public GalleryDescription(Context context)
    17         {
    18                 description = new ArrayList<String> ();
    19                 InputStreamReader isr = new InputStreamReader(context.getResources().openRawResource(R.raw.text));
     15
     16        // ----------------------------------------------------------------
     17        public GalleryDescription(Context context) {
     18                description = new ArrayList<String>();
     19                InputStreamReader isr = new InputStreamReader(context.getResources()
     20                                .openRawResource(R.raw.text));
    2021                BufferedReader br = new BufferedReader(isr);
    2122                String delimiter = ":";
     
    2324                int index = 0;
    2425                try {
    25                         while ((line = br.readLine()) != null)
    26                         {
    27                                 //this if will continue adding if description is too long to the next line
    28                                 if(!line.contains(delimiter))
    29                                         description.add(index, description.get(index)+" "+line);
    30                                 else
    31                                 {       
    32                                         rawtext = line.split(delimiter);
    33                                         //slot 0 contains the image number, slot 1 contains the description.
     26                        while ((line = br.readLine()) != null) {
     27                                // this if will continue adding if description is too long to
     28                                // the next line
     29                                if (!line.contains(delimiter))
     30                                        description.add(index, description.get(index) + " " + line);
     31                                else {
     32                                        rawtext = line.split(delimiter);
     33                                        // slot 0 contains the image number, slot 1 contains the
     34                                        // description.
    3435                                        index = Integer.parseInt(rawtext[0]);
    3536                                        description.add(index, rawtext[1]);
     
    4041                }
    4142        }
    42 //----------------------------------------------------------------     
    43         public String getDescription(int index)
    44         {
    45                 if(index >= description.size())
    46                 {
     43
     44        // ----------------------------------------------------------------
     45        public String getDescription(int index) {
     46                if (index >= description.size()) {
    4747                        return "There is no detailed description for this image yet!";
    4848                }
     
    5050        }
    5151}
    52 ///////////////////////////////////////////////////////////////////
     52// /////////////////////////////////////////////////////////////////
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/GalleryImage.java

    r15013 r17423  
    11package gov.nasa.jpl.issm;
    22
     3import java.io.BufferedInputStream;
     4import java.io.ByteArrayOutputStream;
     5import java.io.IOException;
     6import java.io.InputStream;
     7import java.nio.DoubleBuffer;
    38import java.util.ArrayList;
    49import java.util.List;
     10import android.annotation.TargetApi;
    511import android.app.Activity;
     12import android.content.Context;
    613import android.content.Intent;
    714import android.graphics.Bitmap;
     15import android.os.Build;
    816import android.os.Bundle;
     17import android.util.Log;
    918import android.view.View;
    1019import android.view.View.OnClickListener;
     20import android.view.ViewGroup.LayoutParams;
    1121import android.view.animation.AccelerateInterpolator;
    1222import android.widget.AdapterView;
    1323import android.widget.AdapterView.OnItemSelectedListener;
     24import android.widget.Button;
     25import android.widget.RelativeLayout;
    1426import android.widget.TextView;
    1527import android.widget.Gallery;
     
    1729import android.widget.ImageView.ScaleType;
    1830
    19 public class GalleryImage extends Activity {
    20        
     31public class GalleryImage extends BaseActivity {
     32
    2133        private GalleryDescription description;
    2234        private ImageView selectedImageView;
     
    2941
    3042        private Gallery gallery;
     43        private Bitmap b;
    3144
    3245        private int selectedImagePosition = 0;
    3346
    34         //private List<Drawable> drawables;
     47        // private List<Drawable> drawables;
    3548        private List<Integer> drawables;
    3649
    3750        private GalleryAdapter galImageAdapter;
    38        
     51
    3952        private boolean isFirstImage = true;
    4053
     
    4356                super.onCreate(savedInstanceState);
    4457                setContentView(R.layout.gallery);
     58                transition();
     59                // int w = getResources().getDisplayMetrics().widthPixels;
     60                // long h = w / 16 * 9;
     61                // LayoutParams params = ((ImageView)
     62                // findViewById(R.id.container)).getLayoutParams();
     63                // params.height = (int) h;
     64                // params.width = (int) w;
     65                // Log.i("Height: ", String.valueOf(params.height));
     66                // Log.i("Width: ", String.valueOf(params.width));
    4567
    4668                getDrawablesList();
     
    5173
    5274                selectedImageView = (ImageView) findViewById(R.id.front_view);
    53                 //selectedTextView = (TextView) findViewById(R.id.back_view);
     75                // selectedTextView = (TextView) findViewById(R.id.back_view);
    5476                selectedTextView = (TextView) findViewById(R.id.description);
    55                 //selectedTextView.setVisibility(View.GONE);
     77                // selectedTextView.setVisibility(View.GONE);
    5678                photoState = (ImageView) findViewById(R.id.photo_stage);
    5779                infoState = (ImageView) findViewById(R.id.info_stage);
     
    6284                gallery = (Gallery) findViewById(R.id.gallery);
    6385                description = new GalleryDescription(this);
    64                
    65                 selectedImageView.setOnClickListener(new View.OnClickListener()
    66                 {
    67                            public void onClick(View view) {
    68                                     Intent i = new Intent(GalleryImage.this, ZoomImageViewActivity.class);
    69                                         i.putExtra("imagePosition", selectedImagePosition);
    70                                 startActivity(i);
    71                                
    72                            }
    73                         });   
    74                
    75                 infoState.setOnClickListener(new View.OnClickListener()
    76                 {
    77                            public void onClick(View view) {
    78                             if (isFirstImage) {       
    79                              applyRotation(0, 90);
    80                              isFirstImage = !isFirstImage;
    81 
    82                             } else {   
    83                              applyRotation(0, -90);
    84                              isFirstImage = !isFirstImage;
    85                             }
    86                            }
    87                         });         
     86                // Go back to the main menu
     87                Button homeTab = (Button) findViewById(R.id.play_tab);
     88                homeTab.setOnClickListener(new View.OnClickListener() {
     89                        public void onClick(View v) {
     90                                Intent i = new Intent(GalleryImage.this, MenuPage.class);
     91                                // i.putExtra("pathToFile", MenuPage.getISSMPath());
     92                                startActivity(i);
     93                                finish();
     94                        }
     95                });
     96                // navigate to youtube video
     97                Button video = (Button) findViewById(R.id.video_tab);
     98                video.setOnClickListener(new View.OnClickListener() {
     99                        public void onClick(View v) {
     100                                // String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
     101                                // Intent i = new Intent(Intent.ACTION_VIEW);
     102                                // i.setData(Uri.parse(url));
     103                                Intent i = new Intent(GalleryImage.this, VideoActivity.class);
     104                                startActivity(i);
     105                                finish();
     106                        }
     107                });
     108                // pop up a text box that contains information about ISSM
     109                final Button intro = (Button) findViewById(R.id.about_tab);
     110                intro.setOnClickListener(new View.OnClickListener() {
     111                        public void onClick(View v) {
     112                                // LayoutInflater layoutInflater =
     113                                // (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
     114                                // View popupView = layoutInflater.inflate(R.layout.popuptext,
     115                                // null);
     116                                // final PopupWindow popupWindow = new PopupWindow( popupView,
     117                                // 400,600, true);
     118                                // popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
     119                                // Button dismiss =
     120                                // (Button)popupView.findViewById(R.id.dismiss);
     121                                // dismiss.setOnClickListener(new Button.OnClickListener()
     122                                // {
     123                                // public void onClick(View v)
     124                                // {
     125                                // popupWindow.dismiss();
     126                                // }
     127                                // });
     128                                Intent i = new Intent(GalleryImage.this, AboutActivity.class);
     129                                startActivity(i);
     130                                finish();
     131                        }
     132                });
     133                // Show Team Website
     134                Button visitus = (Button) findViewById(R.id.team_tab);
     135                visitus.setOnClickListener(new View.OnClickListener() {
     136                        public void onClick(View v) {
     137                                // String url = "http://issm.jpl.nasa.gov/";
     138                                // Intent i = new Intent(Intent.ACTION_VIEW);
     139                                // i.setData(Uri.parse(url));
     140                                // startActivity(i);
     141
     142                                Intent i = new Intent(GalleryImage.this, TeamActivity.class);
     143                                startActivity(i);
     144                                finish();
     145                        }
     146                });
     147
     148                selectedImageView.setOnClickListener(new View.OnClickListener() {
     149                        public void onClick(View view) {
     150                                Intent i = new Intent(GalleryImage.this,
     151                                                ZoomImageViewActivity.class);
     152                                i.putExtra("imagePosition", selectedImagePosition);
     153                                startActivity(i);
     154
     155                        }
     156                });
     157
     158                infoState.setOnClickListener(new View.OnClickListener() {
     159                        public void onClick(View view) {
     160                                if (isFirstImage) {
     161                                        applyRotation(0, 90);
     162                                        isFirstImage = !isFirstImage;
     163
     164                                } else {
     165                                        applyRotation(0, -90);
     166                                        isFirstImage = !isFirstImage;
     167                                }
     168                        }
     169                });
    88170
    89171                leftArrowImageView.setOnClickListener(new OnClickListener() {
     
    94176                                if (selectedImagePosition > 0) {
    95177                                        --selectedImagePosition;
    96 
    97178                                }
    98179
     
    108189                                if (selectedImagePosition < drawables.size() - 1) {
    109190                                        ++selectedImagePosition;
    110 
    111191                                }
    112192
     
    119199
    120200                        @Override
    121                         public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
     201                        public void onItemSelected(AdapterView<?> parent, View view,
     202                                        int pos, long id) {
    122203
    123204                                selectedImagePosition = pos;
    124205
    125                                 if (selectedImagePosition > 0 && selectedImagePosition < drawables.size() - 1) {
    126 
    127                                         leftArrowImageView.setImageDrawable(getResources().getDrawable(R.drawable.arrow_left_enabled));
    128                                         rightArrowImageView.setImageDrawable(getResources().getDrawable(R.drawable.arrow_right_enabled));
    129 
     206                                if (selectedImagePosition > 0
     207                                                && selectedImagePosition < drawables.size() - 1) {
     208
     209                                        leftArrowImageView.setImageDrawable(getResources()
     210                                                        .getDrawable(R.drawable.arrow_left_enabled));
     211                                        rightArrowImageView.setImageDrawable(getResources()
     212                                                        .getDrawable(R.drawable.arrow_right_enabled));
    130213                                } else if (selectedImagePosition == 0) {
    131214
    132                                         leftArrowImageView.setImageDrawable(getResources().getDrawable(R.drawable.arrow_left_disabled));
    133 
     215                                        leftArrowImageView.setImageDrawable(getResources()
     216                                                        .getDrawable(R.drawable.arrow_left_disabled));
    134217                                } else if (selectedImagePosition == drawables.size() - 1) {
    135218
    136                                         rightArrowImageView.setImageDrawable(getResources().getDrawable(R.drawable.arrow_right_disabled));
     219                                        rightArrowImageView.setImageDrawable(getResources()
     220                                                        .getDrawable(R.drawable.arrow_right_disabled));
    137221                                }
    138222
     
    160244                if (drawables.size() == 1) {
    161245
    162                         rightArrowImageView.setImageDrawable(getResources().getDrawable(R.drawable.arrow_right_disabled));
     246                        rightArrowImageView.setImageDrawable(getResources().getDrawable(
     247                                        R.drawable.arrow_right_disabled));
    163248                }
    164249
     
    172257
    173258                        ImageView imageView = (ImageView) gallery.getChildAt(i);
    174                         imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.image_border));
     259                        imageView.setBackgroundDrawable(getResources().getDrawable(
     260                                        R.drawable.image_border));
    175261                        imageView.setPadding(3, 3, 3, 3);
    176262
     
    178264
    179265                ImageView imageView = (ImageView) gallery.getSelectedView();
    180                 imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.selected_image_border));
     266                imageView.setBackgroundDrawable(getResources().getDrawable(
     267                                R.drawable.selected_image_border));
    181268                imageView.setPadding(3, 3, 3, 3);
    182269        }
     
    186273                drawables = new ArrayList<Integer>();
    187274                int resID;
    188                 for (int i = 0; i < 17; i++)
    189                 {
    190                         resID=getResources().getIdentifier("image"+i, "drawable", getPackageName());
     275                for (int i = 0; i < 17; i++) {
     276                        resID = getResources().getIdentifier("image" + i, "drawable",
     277                                        getPackageName());
    191278                        drawables.add(resID);
    192                
     279
    193280                }
    194281        }
    195282
    196283        private void setSelectedImage(int selectedImagePosition) {
    197                
    198                 int width= getResources().getDisplayMetrics().widthPixels;
    199         int height= getResources().getDisplayMetrics().heightPixels;
     284
     285                int width = (int) (getResources().getDisplayMetrics().widthPixels);
     286                int height = (int) (getResources().getDisplayMetrics().heightPixels);
    200287                Bitmap b;
    201                 b = ImageResizer.decodeSampledBitmapFromResource(getResources(), drawables.get(selectedImagePosition), width, height);
    202                 b = Bitmap.createScaledBitmap(b, width, height, true);
     288                // pre-load implementation
     289                b = ImageList.getLargeImages().get(selectedImagePosition);
     290                // b = Bitmap.createScaledBitmap(b, width, height, true);
    203291                selectedImageView.setImageBitmap(b);
    204292                selectedImageView.setScaleType(ScaleType.FIT_XY);
    205                 selectedTextView.setText(description.getDescription(selectedImagePosition ));
    206         }
    207        
    208         private void applyRotation(float start, float end)
    209         {
     293                selectedTextView.setText(description
     294                                .getDescription(selectedImagePosition));
     295                // resource implementation
     296                // b = ImageResizer.decodeSampledBitmapFromResource(getResources(),
     297                // drawables.get(selectedImagePosition), width, height);
     298                // b = Bitmap.createScaledBitmap(b, width, height, true);
     299                // selectedImageView.setImageBitmap(b);
     300                // selectedImageView.setScaleType(ScaleType.FIT_XY);
     301                // selectedTextView.setText(description
     302                // .getDescription(selectedImagePosition));
     303                // asset implementation
     304                // b = ImageResizer.decodeSampledBitmapFromAsset(is,
     305                // width, height);
     306                // selectedImageView.setImageBitmap(Bitmap.createScaledBitmap(b, width,
     307                // height, true));
     308                // selectedImageView.setScaleType(ScaleType.FIT_XY);
     309                // selectedTextView.setText(description
     310                // .getDescription(selectedImagePosition));
     311        }
     312
     313        private void applyRotation(float start, float end) {
    210314                // Find the center of image
    211315                final float centerX = photoState.getWidth() / 2.0f;
     
    214318                // Create a new 3D rotation with the supplied parameter
    215319                // The animation listener is used to trigger the next animation
    216                 final FlipAnimation rotation =
    217                        new FlipAnimation(start, end, centerX, centerY);
    218                 final FlipAnimation rotation2 =
    219                                new FlipAnimation(start, end, centerX, centerY);
     320                final FlipAnimation rotation = new FlipAnimation(start, end, centerX,
     321                                centerY);
     322                final FlipAnimation rotation2 = new FlipAnimation(start, end, centerX,
     323                                centerY);
    220324                rotation.setDuration(500);
    221325                rotation.setFillAfter(true);
    222326                rotation.setInterpolator(new AccelerateInterpolator());
    223                 rotation.setAnimationListener(new DisplayNextView(isFirstImage, infoState, photoState));
     327                rotation.setAnimationListener(new DisplayNextView(isFirstImage,
     328                                infoState, photoState));
    224329                rotation2.setDuration(500);
    225330                rotation2.setFillAfter(true);
    226331                rotation2.setInterpolator(new AccelerateInterpolator());
    227                 rotation2.setAnimationListener(new DisplayNextView(isFirstImage, selectedImageView, selectedTextView));
    228                
    229                
    230 
    231                 if (isFirstImage)
    232                 {
     332                rotation2.setAnimationListener(new DisplayNextView(isFirstImage,
     333                                selectedImageView, selectedTextView));
     334
     335                if (isFirstImage) {
    233336                        infoState.startAnimation(rotation);
    234337                        selectedImageView.startAnimation(rotation2);
     
    239342
    240343        }
     344
     345        @Override
     346        public void onBackPressed() {
     347                Intent i = new Intent(GalleryImage.this, MenuPage.class);
     348                startActivity(i);
     349                finish();
     350        }
    241351}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ISSM.java

    r16078 r17423  
    44import java.nio.ByteOrder;
    55import java.nio.DoubleBuffer;
     6
     7import android.app.ProgressDialog;
     8import android.content.Intent;
    69import android.opengl.GLSurfaceView;
    710import android.os.AsyncTask;
     11import android.os.Build;
    812import android.os.Bundle;
    9 import android.app.Activity;
    10 import android.app.ProgressDialog;
    1113import android.util.DisplayMetrics;
    1214import android.view.GestureDetector;
     15import android.view.GestureDetector.OnDoubleTapListener;
     16import android.view.GestureDetector.OnGestureListener;
    1317import android.view.Gravity;
    1418import android.view.KeyEvent;
    1519import android.view.Menu;
    1620import android.view.MenuInflater;
     21import android.view.MotionEvent;
    1722import android.view.View;
    1823import android.view.View.OnClickListener;
    19 import android.view.GestureDetector.OnDoubleTapListener;
    20 import android.view.GestureDetector.OnGestureListener;
    21 import android.view.MotionEvent;
    2224import android.view.animation.AccelerateInterpolator;
    2325import android.view.animation.Animation;
     
    3335import android.widget.Spinner;
    3436import android.widget.ViewFlipper;
    35 import android.os.Build;
    36 
    37 public class ISSM extends Activity implements OnClickListener, OnGestureListener, OnDoubleTapListener
    38 {
    39         //private static final int INVISIBLE = 0;
     37// private static final int INVISIBLE = 0;
     38// Loading the ISSM library locally
     39// private IssmJni issmNative;
     40// ,sealevel;
     41
     42public class ISSM extends BaseActivity implements OnClickListener,
     43                OnGestureListener, OnDoubleTapListener {
     44        // private static final int INVISIBLE = 0;
    4045        private int screenWidth;
    4146        private int screenHeight;
    4247        private DoubleBuffer buff;
    43         private IssmJni issmNative;
     48        // Loading the ISSM library locally
     49        // private IssmJni issmNative;
    4450        private String mapName;
    4551        private String issmFolder;
    4652        private int size;
    47     private GLSurfaceView mGLView;
     53        private GLSurfaceView mGLView;
    4854        private FrameLayout frame;
    4955        private ColorMap colorMap;
    50         private int friction, temperature;//,sealevel;
     56        private int friction, temperature;// ,sealevel;
    5157        private final int MINIMUM = 90;
    5258        private final int OFFSET = 10;
     
    5763        private SliderMenu sliders;
    5864        private ImageView defaultMap;
    59         private GestureDetector mDetector; 
     65        private GestureDetector mDetector;
    6066        private Spinner spinner;
    6167        private boolean onSimulationScreen = false;
    62         //------------------------------------------------------------------------------------------------   
    63     @Override
    64     public void onCreate(Bundle savedInstanceState)
    65     {
    66         super.onCreate(savedInstanceState);
    67         setContentView(R.layout.main_issm);
    68        
    69         //Set up a listener for double tap.
    70         mDetector = new GestureDetector(this,this);
    71         mDetector.setOnDoubleTapListener(this);
    72        
    73         this.initialize();         
    74     }
    75   //----------------------------------------------------------------------------------------------
    76     private void initialize()
    77     {
    78         Bundle map = getIntent().getExtras();
    79         {
    80                 if(map!= null)
    81                 {
    82                         issmFolder = map.getString("pathToFile");
    83                 }
    84         }
    85         friction = MINIMUM + OFFSET;
    86         //temperature = MINIMUM + OFFSET;
    87         //sealevel = MINIMUM + OFFSET;
    88         frame = (FrameLayout)findViewById(R.id.frame);
    89         viewflipper = (ViewFlipper) findViewById(R.id.flipper);
    90         //Button solve = (Button) super.findViewById(R.id.solve);
    91         //solve.setOnClickListener(this);
    92         //Button back = (Button) super.findViewById(R.id.back);
    93         //back.setOnClickListener(this);
    94         Button play = (Button) super.findViewById(R.id.play);
    95         play.setOnClickListener(this);
    96         ImageButton gl = (ImageButton) findViewById(R.id.greenland);           
     68        private String url = "http://blackhawk2.jpl.nasa.gov/issm/solve?callback=?";
     69
     70        // ------------------------------------------------------------------------------------------------
     71        @Override
     72        public void onCreate(Bundle savedInstanceState) {
     73                super.onCreate(savedInstanceState);
     74                setContentView(R.layout.main_issm);
     75                transition();
     76
     77                // Set up a listener for double tap.
     78                mDetector = new GestureDetector(this, this);
     79                mDetector.setOnDoubleTapListener(this);
     80
     81                this.initialize();
     82        }
     83
     84        // ----------------------------------------------------------------------------------------------
     85        private void initialize() {
     86                Bundle map = getIntent().getExtras();
     87                {
     88                        if (map != null) {
     89                                issmFolder = map.getString("pathToFile");
     90                        }
     91                }
     92                Button homeTab = (Button) findViewById(R.id.play_tab);
     93                homeTab.setOnClickListener(new View.OnClickListener() {
     94
     95                        @Override
     96                        public void onClick(View v) {
     97                                Intent i = new Intent(ISSM.this, MenuPage.class);
     98                                startActivity(i);
     99                                finish();
     100                        }
     101                });
     102
     103                Button galleryTab = (Button) findViewById(R.id.gallery_tab);
     104                galleryTab.setOnClickListener(new View.OnClickListener() {
     105
     106                        @Override
     107                        public void onClick(View v) {
     108                                Intent i = new Intent(ISSM.this, GalleryImage.class);
     109                                startActivity(i);
     110                                finish();
     111                        }
     112                });
     113                Button videoTab = (Button) findViewById(R.id.video_tab);
     114                videoTab.setOnClickListener(new View.OnClickListener() {
     115
     116                        @Override
     117                        public void onClick(View v) {
     118                                // String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
     119                                // Intent i = new Intent(Intent.ACTION_VIEW);
     120                                // i.setData(Uri.parse(url));
     121                                Intent i = new Intent(ISSM.this, VideoActivity.class);
     122                                startActivity(i);
     123                                finish();
     124                        }
     125                });
     126                Button aboutTab = (Button) findViewById(R.id.about_tab);
     127                aboutTab.setOnClickListener(new View.OnClickListener() {
     128
     129                        @Override
     130                        public void onClick(View v) {
     131                                Intent i = new Intent(ISSM.this, AboutActivity.class);
     132                                startActivity(i);
     133                                finish();
     134                        }
     135                });
     136                Button teamTab = (Button) findViewById(R.id.team_tab);
     137                teamTab.setOnClickListener(new View.OnClickListener() {
     138
     139                        @Override
     140                        public void onClick(View v) {
     141                                // String url = "http://issm.jpl.nasa.gov/";
     142                                // Intent i = new Intent(Intent.ACTION_VIEW);
     143                                // i.setData(Uri.parse(url));
     144                                // startActivity(i);
     145
     146                                Intent i = new Intent(ISSM.this, TeamActivity.class);
     147                                startActivity(i);
     148                                finish();
     149                        }
     150                });
     151
     152                friction = MINIMUM + OFFSET;
     153                // temperature = MINIMUM + OFFSET;
     154                // sealevel = MINIMUM + OFFSET;
     155                frame = (FrameLayout) findViewById(R.id.frame);
     156                viewflipper = (ViewFlipper) findViewById(R.id.flipper);
     157                // Button solve = (Button) super.findViewById(R.id.solve);
     158                // solve.setOnClickListener(this);
     159                // Button back = (Button) super.findViewById(R.id.back);
     160                // back.setOnClickListener(this);
     161                Button play = (Button) super.findViewById(R.id.play);
     162                play.setOnClickListener(this);
     163                ImageButton gl = (ImageButton) findViewById(R.id.greenland);
    97164                gl.setOnClickListener(this);
    98165                ImageButton art = (ImageButton) findViewById(R.id.antarctica);
    99166                art.setOnClickListener(this);
    100167                spinner = (Spinner) super.findViewById(R.id.spinner);
    101                 sliders= new SliderMenu(this);
     168                sliders = new SliderMenu(this);
    102169                defaultMap = (ImageView) findViewById(R.id.defaultMap);
    103170                dialog = new ProgressDialog(this);
    104171                colorBar = (ColorBar) findViewById(R.id.colorbar);
    105         //load up the ISSM library and create double buffer in java
    106         //which later on will be pass for native for allocation.
    107         issmNative = new IssmJni();
    108         velocity = new Velocity();
    109        
    110         //set default color map to be HSV
    111         this.colorMap = new ColorMap();
    112         //create colorBar
    113         colorBar.setColorMap(colorMap);
    114         spinner.setOnItemSelectedListener(new OnItemSelectedListener()
    115         {
     172                // load up the ISSM library and create double buffer in java
     173                // which later on will be pass for native for allocation.
     174                // issmNative = new IssmJni();
     175                velocity = new Velocity();
     176
     177                // set default color map to be HSV
     178                this.colorMap = new ColorMap();
     179                // create colorBar
     180                colorBar.setColorMap(colorMap);
     181                spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    116182                        @Override
    117183                        public void onItemSelected(AdapterView<?> arg0, View arg1,
    118184                                        int arg2, long arg3) {
    119185                                int item = spinner.getSelectedItemPosition();
    120                                 if( item!= 0)
    121                                 {
     186                                if (item != 0) {
    122187                                        String color = (String) spinner.getItemAtPosition(item);
    123188                                        colorMap.setColor(color);
    124189                                        colorBar.setColorMap(colorMap);
    125                                         drawFigure();
     190                                        // drawFigure();
    126191                                }
    127192                        }
    128193
    129194                        @Override
    130                         public void onNothingSelected(AdapterView<?> arg0) {}
    131         });
    132            
    133        
    134         DisplayMetrics dm = new DisplayMetrics();
    135         getWindowManager().getDefaultDisplay().getMetrics(dm);
    136         screenWidth = dm.widthPixels;
    137         screenHeight = dm.heightPixels;
    138     }
    139 //------------------------------------------------------------------------------------------------   
    140     public void createModel()
    141     {
    142                 String solution_type="StressbalanceSolution";
    143         String file = "";
    144         if( mapName.equals("greenland"))
    145                 {
    146                 file = "greenland";
    147                 }
    148         else
    149         {
    150                 file = "antarctica";
    151         }
    152 
    153         size = issmNative.createISSMModel(solution_type,issmFolder,file);
    154         buff = ByteBuffer.allocateDirect(size*12*8).order(ByteOrder.nativeOrder()).asDoubleBuffer();
    155     }
    156 //------------------------------------------------------------------------------------------------ 
    157     public boolean onCreateOptionsMenu(Menu menu)
    158     {
    159         MenuInflater menuInflater = getMenuInflater();
    160         menuInflater.inflate(R.menu.issm_menu,menu);
    161        
    162         return true;
    163     }
    164 //---------------------------------------------------------------------------------
    165     @Override
    166     public boolean onKeyDown(int keyCode, KeyEvent event)  {
    167         if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && onSimulationScreen) {
    168                  frame.removeView(mGLView);
    169                          viewflipper.setInAnimation(inFromLeftAnimation());
    170                  viewflipper.setOutAnimation(outToRightAnimation());
    171                  viewflipper.showPrevious();
    172                  onSimulationScreen = false;
    173             return true;
    174         }
    175         // return to menu screen
    176         finish();
    177         return super.onKeyDown(keyCode, event);
    178     }
    179 //---------------------------------------------------------------------------------       
    180     @Override
    181     public boolean onTouchEvent(MotionEvent event){
    182         this.mDetector.onTouchEvent(event);
    183         // Be sure to call the superclass implementation
    184         return super.onTouchEvent(event);
    185     }
    186 //---------------------------------------------------------------------------------
    187     @Override
    188     public boolean onDoubleTap(MotionEvent event) {
    189         ((MyGLSurfaceView) mGLView).resetZoom();
    190         return true;
    191     }
    192    
    193     @Override
    194     public boolean onDoubleTapEvent(MotionEvent event) {
    195        
    196         return true;
    197     }
    198     @Override
    199     public boolean onDown(MotionEvent event) { 
    200         return true;
    201     }
    202     @Override
    203     public boolean onFling(MotionEvent event1, MotionEvent event2,
    204             float velocityX, float velocityY) {
    205         return true;
    206     }
    207 
    208     @Override
    209     public void onLongPress(MotionEvent event) {
    210     }
    211 
    212     @Override
    213     public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,float distanceY)
    214     {
    215         return true;
    216     }
    217 
    218     @Override
    219     public void onShowPress(MotionEvent event)
    220     {
    221     }
    222 
    223     @Override
    224     public boolean onSingleTapUp(MotionEvent event)
    225     {
    226         return true;
    227     }
    228 
    229     @Override
    230     public boolean onSingleTapConfirmed(MotionEvent event)
    231     {
    232         return true;
    233     }
    234 //---------------------------------------------------------------------------------   
    235     public void onClick(View view)
    236         {
    237         switch(view.getId())
    238         {
    239                 case R.id.greenland:
    240                         {
    241                                 mapName= "greenland";
    242 
    243                                 defaultMap.setImageResource(R.drawable.greenland_button);
    244                                 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    245                                 {
    246                                         defaultMap.setScaleX(1.12f);
    247                                         defaultMap.setScaleY(0.92f);
    248                                         defaultMap.setAlpha(1.0f);
     195                        public void onNothingSelected(AdapterView<?> arg0) {
     196                        }
     197                });
     198
     199                DisplayMetrics dm = new DisplayMetrics();
     200                getWindowManager().getDefaultDisplay().getMetrics(dm);
     201                screenWidth = dm.widthPixels;
     202                screenHeight = dm.heightPixels;
     203        }
     204
     205        // ------------------------------------------------------------------------------------------------
     206        public void createModel() {
     207                String solution_type = "StressbalanceSolution";
     208                String file = "";
     209                if (mapName.equals("greenland")) {
     210                        file = "greenland";
     211                } else {
     212                        file = "antarctica";
     213                }
     214
     215                // size = issmNative.createISSMModel(solution_type,issmFolder,file);
     216                buff = ByteBuffer.allocateDirect(size * 12 * 8)
     217                                .order(ByteOrder.nativeOrder()).asDoubleBuffer();
     218        }
     219
     220        // ------------------------------------------------------------------------------------------------
     221        public boolean onCreateOptionsMenu(Menu menu) {
     222                MenuInflater menuInflater = getMenuInflater();
     223                menuInflater.inflate(R.menu.issm_menu, menu);
     224
     225                return true;
     226        }
     227
     228        // ---------------------------------------------------------------------------------
     229        @Override
     230        public boolean onKeyDown(int keyCode, KeyEvent event) {
     231                if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0
     232                                && onSimulationScreen) {
     233                        frame.removeView(mGLView);
     234                        viewflipper.setInAnimation(inFromLeftAnimation());
     235                        viewflipper.setOutAnimation(outToRightAnimation());
     236                        viewflipper.showPrevious();
     237                        onSimulationScreen = false;
     238                        return true;
     239                }
     240                // return to menu screen
     241                finish();
     242                return super.onKeyDown(keyCode, event);
     243        }
     244
     245        // ---------------------------------------------------------------------------------
     246        @Override
     247        public boolean onTouchEvent(MotionEvent event) {
     248                this.mDetector.onTouchEvent(event);
     249                // Be sure to call the superclass implementation
     250                return super.onTouchEvent(event);
     251        }
     252
     253        // ---------------------------------------------------------------------------------
     254        @Override
     255        public boolean onDoubleTap(MotionEvent event) {
     256                ((MyGLSurfaceView) mGLView).resetZoom();
     257                return true;
     258        }
     259
     260        @Override
     261        public boolean onDoubleTapEvent(MotionEvent event) {
     262
     263                return true;
     264        }
     265
     266        @Override
     267        public boolean onDown(MotionEvent event) {
     268                return true;
     269        }
     270
     271        @Override
     272        public boolean onFling(MotionEvent event1, MotionEvent event2,
     273                        float velocityX, float velocityY) {
     274                return true;
     275        }
     276
     277        @Override
     278        public void onLongPress(MotionEvent event) {
     279        }
     280
     281        @Override
     282        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
     283                        float distanceY) {
     284                return true;
     285        }
     286
     287        @Override
     288        public void onShowPress(MotionEvent event) {
     289        }
     290
     291        @Override
     292        public boolean onSingleTapUp(MotionEvent event) {
     293                return true;
     294        }
     295
     296        @Override
     297        public boolean onSingleTapConfirmed(MotionEvent event) {
     298                return true;
     299        }
     300
     301        // ---------------------------------------------------------------------------------
     302        public void onClick(View view) {
     303                switch (view.getId()) {
     304                case R.id.greenland: {
     305                        mapName = "greenland";
     306
     307                        defaultMap.setImageResource(R.drawable.greenland_button);
     308                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
     309                                defaultMap.setScaleX(1.12f);
     310                                defaultMap.setScaleY(0.92f);
     311                                defaultMap.setAlpha(1.0f);
     312                        } else {
     313                                defaultMap.setAlpha(1);
     314                        }
     315                        colorBar.setVisibility(View.INVISIBLE);
     316                        viewflipper.setInAnimation(inFromRightAnimation());
     317                        viewflipper.setOutAnimation(outToLeftAnimation());
     318                        viewflipper.showNext();
     319                        defaultMap.setVisibility(View.VISIBLE);
     320                        onSimulationScreen = true;
     321                        // create FemModel in native code and return the size of the model
     322                        this.createModel();
     323                        break;
     324                }
     325                case R.id.antarctica: {
     326                        mapName = "antarctica";
     327                        defaultMap.setImageResource(R.drawable.antarctica_button);
     328                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
     329                                defaultMap.setAlpha(1.0f);
     330                        } else {
     331                                defaultMap.setAlpha(1);
     332                        }
     333                        colorBar.setVisibility(View.INVISIBLE);
     334                        viewflipper.setInAnimation(inFromRightAnimation());
     335                        viewflipper.setOutAnimation(outToLeftAnimation());
     336                        viewflipper.showNext();
     337                        defaultMap.setVisibility(View.VISIBLE);
     338                        onSimulationScreen = true;
     339                        // create FemModel in native code and return the size of the model
     340                        this.createModel();
     341                        break;
     342                }
     343
     344                /*
     345                 * case R.id.back: { frame.removeView(mGLView);
     346                 * viewflipper.setInAnimation(inFromLeftAnimation());
     347                 * viewflipper.setOutAnimation(outToRightAnimation());
     348                 * viewflipper.showPrevious(); break; }
     349                 */
     350                /*
     351                 * case R.id.solve: { friction = sliders.getFric();
     352                 * System.out.println(friction); new
     353                 * CalculationTask().execute(friction); break; }
     354                 */
     355                case R.id.play: {
     356                        final PopupWindow popupWindow = new PopupWindow(sliders,
     357                                        screenWidth * 4 / 5, screenHeight * 2 / 5, true);
     358                        popupWindow.showAtLocation(sliders, Gravity.CENTER, 0, 0);
     359
     360                        Button dismiss = (Button) sliders.findViewById(R.id.exitSetting);
     361                        dismiss.setOnClickListener(new Button.OnClickListener() {
     362                                public void onClick(View v) {
     363                                        friction = sliders.getFric();
     364                                        temperature = sliders.getTemp();
     365                                        // temperature = sliders.getTemp();
     366                                        // sealevel = sliders.getSea();
     367                                        popupWindow.dismiss();
     368                                        System.out.println("Friction = " + friction);
     369                                        // new CalculationTask().execute(friction,temperature);
    249370                                }
    250                                 else
    251                                 {
    252                                         defaultMap.setAlpha(1);
    253                                 }
    254                                 colorBar.setVisibility(View.INVISIBLE);
    255                                 viewflipper.setInAnimation(inFromRightAnimation());
    256                         viewflipper.setOutAnimation(outToLeftAnimation());
    257                         viewflipper.showNext();
    258                         defaultMap.setVisibility(View.VISIBLE);
    259                         onSimulationScreen = true;
    260                         //create FemModel in native code and return the size of the model
    261                         this.createModel();
    262                         break;
    263                         }
    264                 case R.id.antarctica:
    265                         {
    266                                 mapName= "antarctica";
    267                                 defaultMap.setImageResource(R.drawable.antarctica_button);
    268                                 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    269                                 {
    270                                 defaultMap.setAlpha(1.0f);
    271                                 }
    272                                 else
    273                                 {
    274                                         defaultMap.setAlpha(1);
    275                                 }
    276                                 colorBar.setVisibility(View.INVISIBLE);
    277                                 viewflipper.setInAnimation(inFromRightAnimation());
    278                         viewflipper.setOutAnimation(outToLeftAnimation());
    279                         viewflipper.showNext();
    280                         defaultMap.setVisibility(View.VISIBLE);
    281                         onSimulationScreen = true;
    282                         //create FemModel in native code and return the size of the model
    283                         this.createModel();
    284                         break;
    285                         }
    286                        
    287                 /*case R.id.back:
    288                 {
    289                          frame.removeView(mGLView);
    290                          viewflipper.setInAnimation(inFromLeftAnimation());
    291                          viewflipper.setOutAnimation(outToRightAnimation());
    292                          viewflipper.showPrevious();
    293                          break;
    294                 }*/
    295                 /*case R.id.solve:
    296                 {
    297                         friction = sliders.getFric();
    298                         System.out.println(friction);
    299                         new CalculationTask().execute(friction);
    300                         break;
    301                 }*/
    302                 case R.id.play:
    303                 {
    304                         final PopupWindow popupWindow = new PopupWindow( sliders, screenWidth*4/5,screenHeight*2/5, true);
    305                         popupWindow.showAtLocation(sliders, Gravity.CENTER, 0, 0);
    306                        
    307                         Button dismiss = (Button)sliders.findViewById(R.id.exitSetting);
    308                     dismiss.setOnClickListener(new Button.OnClickListener()
    309                     {
    310                         public void onClick(View v)
    311                         {
    312                                 friction = sliders.getFric();
    313                                 temperature = sliders.getTemp();
    314                             //temperature = sliders.getTemp();
    315                             //sealevel = sliders.getSea();
    316                                 popupWindow.dismiss();
    317                                 System.out.println("Friction = " + friction );
    318                                 new CalculationTask().execute(friction,temperature);
    319                         }
    320                     });
    321                 }
    322         }
    323         }
    324 //----------------------------------------------------------------------------------
    325     public void drawFigure()
    326     {
    327         frame.removeView(mGLView);
    328         mGLView = new MyGLSurfaceView(this, buff, size, colorMap, velocity);
    329         colorBar.setVelocity(velocity.getVmax(), velocity.getVmin());
    330         colorBar.invalidate();
    331         colorBar.setVisibility(View.VISIBLE);
    332         frame.addView(mGLView);
    333     }
    334 //------------------------------------------------------------------------------------
    335    //AsyncTask will allow to display while doing some task in the background
    336    private class CalculationTask extends AsyncTask<Integer,Integer,Boolean>
    337    {
     371                        });
     372                }
     373                }
     374        }
     375
     376        // ----------------------------------------------------------------------------------
     377        public void drawFigure() {
     378                frame.removeView(mGLView);
     379                mGLView = new MyGLSurfaceView(this, buff, size, colorMap, velocity);
     380                colorBar.setVelocity(velocity.getVmax(), velocity.getVmin());
     381                colorBar.invalidate();
     382                colorBar.setVisibility(View.VISIBLE);
     383                frame.addView(mGLView);
     384        }
     385
     386        // ------------------------------------------------------------------------------------
     387        // AsyncTask will allow to display while doing some task in the background
     388        private class CalculationTask extends AsyncTask<Integer, Integer, Boolean> {
    338389                @Override
    339                 protected Boolean doInBackground(Integer... target)
    340                 {
    341                         Thread thread = new Thread()
    342                         {
    343                                 public void run()
    344                                 {
    345                                         for(int i = 0; i <= 100; i+=5)
    346                                         {
     390                protected Boolean doInBackground(Integer... target) {
     391                        Thread thread = new Thread() {
     392                                public void run() {
     393                                        for (int i = 0; i <= 100; i += 5) {
    347394                                                try {
    348395                                                        Thread.sleep(300);
     
    356403                        };
    357404                        thread.start();
    358                         issmNative.solveISSMModel(target[0],buff);
    359                         //System.out.println("temperature = " + target[1]);
    360                         //issmNative.solveISSMModel(target[0],target[1],buff);
     405                        // issmNative.solveISSMModel(target[0],buff);
     406                        // System.out.println("temperature = " + target[1]);
     407                        // issmNative.solveISSMModel(target[0],target[1],buff);
    361408                        return true;
    362409                }
    363                
    364                 protected void onPreExecute()
    365                 {
     410
     411                protected void onPreExecute() {
    366412                        super.onPostExecute(null);
    367413                        dialog.setCancelable(true);
     
    372418                        dialog.show();
    373419                }
    374                 protected void onProgressUpdate(Integer ... value)
    375                 {
     420
     421                protected void onProgressUpdate(Integer... value) {
    376422                        super.onProgressUpdate();
    377423                        dialog.setProgress(value[0]);
    378                         if(value[0] == 100)
    379                         {
     424                        if (value[0] == 100) {
    380425                                dialog.dismiss();
    381                                 if(defaultMap.getDrawable().isVisible() == true )
     426                                if (defaultMap.getDrawable().isVisible() == true)
    382427                                        fadeImage();
    383428                        }
    384429                }
    385                 protected void onPostExecute(Boolean result)
    386                 {
     430
     431                protected void onPostExecute(Boolean result) {
    387432                        super.onPostExecute(result);
    388433                        try {
     
    392437                                e.printStackTrace();
    393438                        }
    394                         if(result)
    395                         {
     439                        if (result) {
    396440                                drawFigure();
    397441                        }
    398                        
    399                 }
    400            
    401    }
    402 //-----------------------------------------------------------------------------------   
    403    private void fadeImage()
    404    {
    405            Animation anim = AnimationUtils.loadAnimation(this, R.anim.fade_out);
    406        anim.reset();
    407        defaultMap.clearAnimation();
    408        defaultMap.startAnimation(anim);
    409        defaultMap.setVisibility(View.GONE);
    410    }
    411    
    412     // Below are implementation for the animation between map selection and core computation
     442
     443                }
     444
     445        }
     446
     447        // -------------------------------------------------------------------------------------
     448
     449        @Override
     450        public void onBackPressed() {
     451                Intent i = new Intent(ISSM.this, MenuPage.class);
     452                startActivity(i);
     453                finish();
     454        }
     455
     456        // -----------------------------------------------------------------------------------
     457        private void fadeImage() {
     458                Animation anim = AnimationUtils.loadAnimation(this, R.anim.fade_out);
     459                anim.reset();
     460                defaultMap.clearAnimation();
     461                defaultMap.startAnimation(anim);
     462                defaultMap.setVisibility(View.GONE);
     463        }
     464
     465        // Below are implementation for the animation between map selection and core
     466        // computation
    413467
    414468        private Animation inFromRightAnimation() {
    415469
    416         Animation inFromRight = new TranslateAnimation(
    417         Animation.RELATIVE_TO_PARENT,  +1.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
    418         Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
    419         );
    420         inFromRight.setDuration(500);
    421         inFromRight.setInterpolator(new AccelerateInterpolator());
    422         return inFromRight;
    423         }
     470                Animation inFromRight = new TranslateAnimation(
     471                                Animation.RELATIVE_TO_PARENT, +1.0f,
     472                                Animation.RELATIVE_TO_PARENT, 0.0f,
     473                                Animation.RELATIVE_TO_PARENT, 0.0f,
     474                                Animation.RELATIVE_TO_PARENT, 0.0f);
     475                inFromRight.setDuration(500);
     476                inFromRight.setInterpolator(new AccelerateInterpolator());
     477                return inFromRight;
     478        }
     479
    424480        private Animation outToLeftAnimation() {
    425         Animation outtoLeft = new TranslateAnimation(
    426           Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  -1.0f,
    427           Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
    428         );
    429         outtoLeft.setDuration(500);
    430         outtoLeft.setInterpolator(new AccelerateInterpolator());
    431         return outtoLeft;
     481                Animation outtoLeft = new TranslateAnimation(
     482                                Animation.RELATIVE_TO_PARENT, 0.0f,
     483                                Animation.RELATIVE_TO_PARENT, -1.0f,
     484                                Animation.RELATIVE_TO_PARENT, 0.0f,
     485                                Animation.RELATIVE_TO_PARENT, 0.0f);
     486                outtoLeft.setDuration(500);
     487                outtoLeft.setInterpolator(new AccelerateInterpolator());
     488                return outtoLeft;
    432489        }
    433490
    434491        private Animation inFromLeftAnimation() {
    435         Animation inFromLeft = new TranslateAnimation(
    436         Animation.RELATIVE_TO_PARENT,  -1.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
    437         Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
    438         );
    439         inFromLeft.setDuration(500);
    440         inFromLeft.setInterpolator(new AccelerateInterpolator());
    441         return inFromLeft;
    442         }
     492                Animation inFromLeft = new TranslateAnimation(
     493                                Animation.RELATIVE_TO_PARENT, -1.0f,
     494                                Animation.RELATIVE_TO_PARENT, 0.0f,
     495                                Animation.RELATIVE_TO_PARENT, 0.0f,
     496                                Animation.RELATIVE_TO_PARENT, 0.0f);
     497                inFromLeft.setDuration(500);
     498                inFromLeft.setInterpolator(new AccelerateInterpolator());
     499                return inFromLeft;
     500        }
     501
    443502        private Animation outToRightAnimation() {
    444         Animation outtoRight = new TranslateAnimation(
    445           Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  +1.0f,
    446           Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
    447         );
    448         outtoRight.setDuration(500);
    449         outtoRight.setInterpolator(new AccelerateInterpolator());
    450         return outtoRight;
    451         }
    452 //-------------------------------------------------------------------------------------------   
     503                Animation outtoRight = new TranslateAnimation(
     504                                Animation.RELATIVE_TO_PARENT, 0.0f,
     505                                Animation.RELATIVE_TO_PARENT, +1.0f,
     506                                Animation.RELATIVE_TO_PARENT, 0.0f,
     507                                Animation.RELATIVE_TO_PARENT, 0.0f);
     508                outtoRight.setDuration(500);
     509                outtoRight.setInterpolator(new AccelerateInterpolator());
     510                return outtoRight;
     511        }
     512        // -------------------------------------------------------------------------------------------
    453513}
    454 /////////////////////////////////////////////////////////////////////////////////////////////
     514// ///////////////////////////////////////////////////////////////////////////////////////////
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ISSMAPP.java

    r15287 r17423  
    66import java.io.InputStream;
    77import java.io.OutputStream;
     8
    89import android.app.Activity;
     10import android.app.AlertDialog;
    911import android.app.ProgressDialog;
     12import android.net.ConnectivityManager;
     13import android.net.NetworkInfo;
    1014import android.os.AsyncTask;
    1115import android.os.Bundle;
    1216import android.os.Environment;
    1317import android.util.Log;
     18import android.view.Window;
    1419import android.view.animation.Animation;
    1520import android.view.animation.AnimationUtils;
     
    1722import android.widget.LinearLayout;
    1823import android.widget.Toast;
     24import android.content.Context;
     25import android.content.DialogInterface;
    1926import android.content.Intent;
    2027import android.content.SharedPreferences;
    2128import android.content.res.AssetManager;
     29
    2230///////////////////////////////////////////////////////////////////////////
    23 public class ISSMAPP extends Activity
    24 {
     31public class ISSMAPP extends Activity {
    2532        ImageList imageList;
    2633        private static final String PREFERENCE_FIRST_RUN = null;
    2734        public static String extStorageDirectory;
    28         private String issmFolder; 
     35        private String issmFolder;
    2936        SharedPreferences settings;
    3037        private ProgressDialog progressDialog;
    31 //------------------------------------------------------------------------     
    32         public void onCreate(Bundle icicle)
    33         {
     38
     39        // ------------------------------------------------------------------------
     40        public void onCreate(Bundle icicle) {
    3441                super.onCreate(icicle);
    35                 setContentView(R.layout.splashscreen);         
    36             settings = this.getSharedPreferences("MenuPage", 0);
    37             boolean firstrun = settings.getBoolean(PREFERENCE_FIRST_RUN, true);
    38             extStorageDirectory = Environment.getExternalStorageDirectory().toString();
    39             issmFolder = extStorageDirectory + "/ISSM/input_files/";
    40             imageList = new ImageList(this);
    41             new CopyDataTask().execute(firstrun);   
    42         }
    43 //-------------------------------------------------------------------------------------------
    44         //Start the splashscreen at beginning while transferring
    45         //data file from Assets folder to SDcard
    46         private class CopyDataTask extends AsyncTask<Boolean,Void,Boolean>
    47            {
    48                         @Override
    49                         protected Boolean doInBackground(Boolean... target)
    50                         {
    51                                 imageList.decodeAndResizeImageFromURL();
    52                                 imageList.decodeAndResizeImage();
    53                                 //not sure why, but target[0] can be true on install! more to be done.
    54                                 //if(target[0] = false)
    55                                 //{
    56                                 SharedPreferences.Editor e = settings.edit();
    57                                 e.putBoolean(PREFERENCE_FIRST_RUN, false);
    58                                
    59                                 e.commit();
    60                                 // If not, run these methods:
    61                                 SetDirectory(issmFolder);
    62                                 //}
    63                                 return true;
     42                requestWindowFeature(Window.FEATURE_NO_TITLE);
     43                setContentView(R.layout.splashscreen);
     44                settings = this.getSharedPreferences("MenuPage", 0);
     45                final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
     46                if (conMgr.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED
     47                                || conMgr.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED) {
     48
     49                        // temporary: display modes without messing with the network to
     50                        // be able to access offline mode
     51                        // AlertDialog.Builder builder = new AlertDialog.Builder(this);
     52                        // builder.setMessage("Pick a mode");
     53                        // CharSequence[] options = { "Native", "Offline", "Online" };
     54                        // builder.setItems(options, new DialogInterface.OnClickListener() {
     55                        // public void onClick(DialogInterface dialog, int which) {
     56                        // switch (which) {
     57                        // case 0:
     58                        // boolean firstrun = settings.getBoolean(
     59                        // PREFERENCE_FIRST_RUN, true);
     60                        // extStorageDirectory = Environment
     61                        // .getExternalStorageDirectory().toString();
     62                        // issmFolder = extStorageDirectory + "/ISSM/input_files/";
     63                        // imageList = new ImageList(ISSMAPP.this);
     64                        // new CopyDataTask().execute(firstrun);
     65                        // break;
     66                        // case 1:
     67                        // Intent j = new Intent(ISSMAPP.this,
     68                        // ISSMWebActivity.class);
     69                        // j.putExtra("mode", 1);
     70                        // startActivity(j);
     71                        // finish();
     72                        // break;
     73                        // case 2:
     74                        // Intent i = new Intent(ISSMAPP.this,
     75                        // ISSMWebActivity.class);
     76                        // i.putExtra("mode", 0);
     77                        // startActivity(i);
     78                        // finish();
     79                        // break;
     80                        // }
     81                        // }
     82                        // });
     83                        // builder.create().show();
     84                        new AlertDialog.Builder(this)
     85                                        .setMessage("Pick a mode")
     86                                        .setCancelable(false)
     87                                        .setPositiveButton("Online",
     88                                                        new DialogInterface.OnClickListener() {
     89                                                                public void onClick(DialogInterface dialog,
     90                                                                                int id) {
     91                                                                        Intent i = new Intent(ISSMAPP.this,
     92                                                                                        ISSMWebActivity.class);
     93                                                                        i.putExtra("mode", 0);
     94                                                                        startActivity(i);
     95                                                                        finish();
     96                                                                }
     97                                                        })
     98                                        .setNeutralButton("Offline",
     99                                                        new DialogInterface.OnClickListener() {
     100                                                                public void onClick(DialogInterface dialog,
     101                                                                                int id) {
     102                                                                        Intent i = new Intent(ISSMAPP.this,
     103                                                                                        ISSMWebActivity.class);
     104                                                                        i.putExtra("mode", 1);
     105                                                                        startActivity(i);
     106                                                                        finish();
     107                                                                }
     108                                                        })
     109                                        .setNegativeButton("Native",
     110                                                        new DialogInterface.OnClickListener() {
     111                                                                public void onClick(DialogInterface dialog,
     112                                                                                int id) {
     113                                                                        boolean firstrun = settings.getBoolean(
     114                                                                                        PREFERENCE_FIRST_RUN, true);
     115                                                                        extStorageDirectory = Environment
     116                                                                                        .getExternalStorageDirectory()
     117                                                                                        .toString();
     118                                                                        issmFolder = extStorageDirectory
     119                                                                                        + "/ISSM/input_files/";
     120                                                                        imageList = new ImageList(ISSMAPP.this);
     121                                                                        new CopyDataTask().execute(firstrun);
     122                                                                }
     123                                                        }).show();
     124
     125                } else {
     126                        boolean firstrun = settings.getBoolean(PREFERENCE_FIRST_RUN, true);
     127                        extStorageDirectory = Environment.getExternalStorageDirectory()
     128                                        .toString();
     129                        issmFolder = extStorageDirectory + "/ISSM/input_files/";
     130                        imageList = new ImageList(this);
     131                        new CopyDataTask().execute(firstrun);
     132                }
     133        }
     134
     135        // -------------------------------------------------------------------------------------------
     136        // Start the splashscreen at beginning while transferring
     137        // data file from Assets folder to SDcard
     138        private class CopyDataTask extends AsyncTask<Boolean, Void, Boolean> {
     139                @Override
     140                protected Boolean doInBackground(Boolean... target) {
     141                        // imageList.decodeAndResizeImageFromURL();
     142                        imageList.decodeAndResizeImage();
     143                        imageList.decodeLargeImage();
     144                        // not sure why, but target[0] can be true on install! more to be
     145                        // done.
     146                        // if(target[0] = false)
     147                        // {
     148                        SharedPreferences.Editor e = settings.edit();
     149                        e.putBoolean(PREFERENCE_FIRST_RUN, false);
     150
     151                        e.commit();
     152                        // If not, run these methods:
     153                        SetDirectory(issmFolder);
     154                        // }
     155                        return true;
     156                }
     157
     158                @Override
     159                protected void onPreExecute() {
     160                        progressDialog = new ProgressDialog(ISSMAPP.this);
     161                        progressDialog.setMessage("Loading Data");
     162                        progressDialog.setIndeterminate(true);
     163                        progressDialog.setCancelable(false);
     164                        progressDialog.show();
     165                }
     166
     167                protected void onPostExecute(Boolean result) {
     168                        progressDialog.dismiss();
     169                        Log.i("imageList size: ",
     170                                        String.valueOf(ImageList.getImageList().size()));
     171                        Log.i("largeImageList size: ",
     172                                        String.valueOf(ImageList.getLargeImages().size()));
     173                        Intent i = new Intent(ISSMAPP.this, MenuPage.class);
     174                        i.putExtra("pathToFile", issmFolder);
     175                        startActivity(i);
     176                }
     177        }
     178
     179        // -------------------------------------------------------------------------------------------
     180        private void SetDirectory(String directory) {
     181                if (android.os.Environment.getExternalStorageState().equals(
     182                                android.os.Environment.MEDIA_MOUNTED)) {
     183                        File txtDirectory = new File(issmFolder);
     184
     185                        // Check and create directory in SDcard
     186                        if (!txtDirectory.exists()) {
     187                                txtDirectory.mkdirs();
    64188                        }
    65                         @Override
    66                         protected void onPreExecute()
    67                         {
    68                                 progressDialog = new ProgressDialog(ISSMAPP.this);
    69                                 progressDialog.setMessage("Loading Data");
    70                                 progressDialog.setIndeterminate(true);
    71                                 progressDialog.setCancelable(false);
    72                                 progressDialog.show();
    73                         }
    74                         protected void onPostExecute(Boolean result)
    75                         {
    76                                 progressDialog.dismiss();
    77                                 Intent i = new Intent(ISSMAPP.this, MenuPage.class);
    78                                 i.putExtra("pathToFile", issmFolder);
    79                         startActivity(i);
    80                         }
    81            }
    82 //-------------------------------------------------------------------------------------------
    83         private void SetDirectory(String directory)
    84         {
    85             if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
    86             {
    87                 File txtDirectory = new File(issmFolder);
    88                
    89                 // Check and create directory in SDcard
    90                 if(!txtDirectory.exists())
    91                 {
    92                         txtDirectory.mkdirs();
    93                 }
    94                 CopyAssets(); // Then run the method to copy the file.
    95 
    96             }
    97             else if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED_READ_ONLY))
    98             {
    99                 Toast toast = Toast.makeText(this.getApplicationContext(), "Memory is not mounted to device", Toast.LENGTH_LONG);
    100                 toast.show();
    101             }
    102 
    103         }
    104 //----------------------------------------------------------------------------
     189                        CopyAssets(); // Then run the method to copy the file.
     190
     191                } else if (android.os.Environment.getExternalStorageState().equals(
     192                                android.os.Environment.MEDIA_MOUNTED_READ_ONLY)) {
     193                        Toast toast = Toast.makeText(this.getApplicationContext(),
     194                                        "Memory is not mounted to device", Toast.LENGTH_LONG);
     195                        toast.show();
     196                }
     197
     198        }
     199
     200        // ----------------------------------------------------------------------------
    105201        /**
    106202         * -- Copy the file from the assets folder to the sdCard
    107203         * ===========================================================
    108204         **/
    109                 private void CopyAssets()
    110                 {
    111                     AssetManager assetManager = getAssets();
    112                     String[] files = null;
    113                     try {
    114                         files = assetManager.list("Map");
    115                     } catch (IOException e) {
    116                         Log.e("tag", e.getMessage());
    117                     }
    118                     for (int i = 0; i < files.length; i++) {
    119                         InputStream in = null;
    120                         OutputStream out = null;
    121                         try {
    122                             in = assetManager.open("Map/"+files[i]);
    123                             out = new FileOutputStream(issmFolder + files[i]);
    124                             copyFile(in, out);
    125                             in.close();
    126                             in = null;
    127                             out.flush();
    128                             out.close();
    129                             out = null;
    130                         } catch (Exception e) {
    131                             Log.e("tag", e.getMessage());
    132                         }
    133                     }
    134                 }
    135 //----------------------------------------------------------------------------
    136                 private void copyFile(InputStream in, OutputStream out) throws IOException
    137                 {
    138                     byte[] buffer = new byte[1024];
    139                     int read;
    140                     while ((read = in.read(buffer)) != -1) {
    141                         out.write(buffer, 0, read);
    142                     }
    143                 }
    144 //----------------------------------------------------------------------------
    145                  private void StartAnimations()
    146                  {
    147                         Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
    148                         anim.reset();
    149                         LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
    150                         l.clearAnimation();
    151                         l.startAnimation(anim);
    152                  
    153                         anim = AnimationUtils.loadAnimation(this, R.anim.translate);
    154                         anim.reset();
    155                         ImageView iv = (ImageView) findViewById(R.id.logo);
    156                         iv.clearAnimation();
    157                         iv.startAnimation(anim);
    158                     }
    159 //-------------------------------------------------------------------------------               
     205        private void CopyAssets() {
     206                AssetManager assetManager = getAssets();
     207                String[] files = null;
     208                try {
     209                        files = assetManager.list("Map");
     210                } catch (IOException e) {
     211                        Log.e("tag", e.getMessage());
     212                }
     213                for (int i = 0; i < files.length; i++) {
     214                        InputStream in = null;
     215                        OutputStream out = null;
     216                        try {
     217                                in = assetManager.open("Map/" + files[i]);
     218                                out = new FileOutputStream(issmFolder + files[i]);
     219                                copyFile(in, out);
     220                                in.close();
     221                                in = null;
     222                                out.flush();
     223                                out.close();
     224                                out = null;
     225                        } catch (Exception e) {
     226                                Log.e("tag", e.getMessage());
     227                        }
     228                }
     229        }
     230
     231        // ----------------------------------------------------------------------------
     232        private void copyFile(InputStream in, OutputStream out) throws IOException {
     233                byte[] buffer = new byte[1024];
     234                int read;
     235                while ((read = in.read(buffer)) != -1) {
     236                        out.write(buffer, 0, read);
     237                }
     238        }
     239
     240        // ----------------------------------------------------------------------------
     241        public void transition() {
     242                overridePendingTransition(R.anim.left_out_fast, R.anim.left_out);
     243        }
     244
     245        // ----------------------------------------------------------------------------
     246        private void StartAnimations() {
     247                Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
     248                anim.reset();
     249                LinearLayout l = (LinearLayout) findViewById(R.id.lin_lay);
     250                l.clearAnimation();
     251                l.startAnimation(anim);
     252
     253                anim = AnimationUtils.loadAnimation(this, R.anim.translate);
     254                anim.reset();
     255                ImageView iv = (ImageView) findViewById(R.id.logo);
     256                iv.clearAnimation();
     257                iv.startAnimation(anim);
     258        }
     259        // -------------------------------------------------------------------------------
    160260}
    161 //////////////////////////////////////////////////////////////////////////////////
     261// ////////////////////////////////////////////////////////////////////////////////
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ImageList.java

    r15287 r17423  
    11package gov.nasa.jpl.issm;
    22
     3import java.io.BufferedInputStream;
    34import java.io.BufferedOutputStream;
    45import java.io.ByteArrayOutputStream;
     
    1112
    1213import android.content.Context;
     14import android.content.res.AssetManager;
    1315import android.graphics.Bitmap;
    1416import android.graphics.BitmapFactory;
    1517import android.util.Log;
    1618
    17 public class ImageList
    18 {
    19         private static ArrayList <Bitmap> imageList;
    20         private static ArrayList <Bitmap> imageListFromURL;
     19public class ImageList {
     20        private static ArrayList<Bitmap> imageList;
     21        private static ArrayList<Bitmap> largeImageList;
     22        private static ArrayList<Bitmap> imageListFromURL;
    2123        private Context context;
    22         final int nImage = 17;
    23 //----------------------------------------------------------   
    24         public ImageList(Context context)
    25         {
    26                 imageList = new ArrayList <Bitmap>();
    27                 imageListFromURL = new ArrayList <Bitmap>();
     24        final int nImage = 17;
     25
     26        // ----------------------------------------------------------
     27        public ImageList(Context context) {
     28                imageList = new ArrayList<Bitmap>();
     29                largeImageList = new ArrayList<Bitmap>();
     30                imageListFromURL = new ArrayList<Bitmap>();
    2831                this.context = context;
    2932        }
    30 //----------------------------------------------------------
    31         public void decodeAndResizeImageFromURL()
    32         {
     33
     34        // ----------------------------------------------------------
     35        public void decodeAndResizeImageFromURL() {
    3336                URL url;
    34                 for(int i =0; i <1; i++)
    35                 {
    36                         try
    37                         {
     37                for (int i = 0; i < 1; i++) {
     38                        try {
    3839                                url = new URL(ImageListFromUrl.imageUrls[0]);
    3940                                URLConnection connection = url.openConnection();
    4041                                HttpURLConnection httpConnection = (HttpURLConnection) connection;
    41                     httpConnection.setRequestMethod("GET");
    42                     httpConnection.connect();
    43          
    44                     if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK)
    45                     {
    46                         imageList.add(ImageResizer.decodeSampledBitmapFromURL(url, 50, 50));
    47                     }
    48                     } catch (IOException e) {
    49                         Log.e("ImageResizer", "Could not load Bitmap from: " + ImageListFromUrl.imageUrls[i]);
    50                     }
     42                                httpConnection.setRequestMethod("GET");
     43                                httpConnection.connect();
     44
     45                                if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
     46                                        imageList.add(ImageResizer.decodeSampledBitmapFromURL(url,
     47                                                        50, 50));
     48                                }
     49                        } catch (IOException e) {
     50                                Log.e("ImageResizer", "Could not load Bitmap from: "
     51                                                + ImageListFromUrl.imageUrls[i]);
     52                        }
    5153                }
    5254        }
    53 //----------------------------------------------------------
    54         public void decodeAndResizeImage()
    55         {
     55
     56        // ----------------------------------------------------------
     57        public void decodeAndResizeImage() {
    5658                int resID;
    57                 for(int i = 1 ; i < nImage; i++)
    58                 {
    59                         resID=context.getResources().getIdentifier("image"+i, "drawable", context.getPackageName());
    60                         imageList.add(ImageResizer.decodeSampledBitmapFromResource(context.getResources(), resID , 50, 50));
     59                InputStream is = null;
     60                for (int i = 0; i < nImage; i++) {
     61                        // asset implementation
     62                        try {
     63                                is = new BufferedInputStream(context.getResources().getAssets()
     64                                                .open("image" + i + ".png"));
     65                                imageList.add(ImageResizer.decodeSampledBitmapFromAsset(is, 50,
     66                                                50));
     67                                // is.close();
     68                        } catch (IOException e) {
     69                                // TODO Auto-generated catch block
     70                                e.printStackTrace();
     71                        }
     72                        // resource implementation
     73                        // resID = context.getResources().getIdentifier("image" + i,
     74                        // "drawable", context.getPackageName());
     75                        // imageList.add(ImageResizer.decodeSampledBitmapFromResource(
     76                        // context.getResources(), resID, 50, 50));
     77                        System.gc();
    6178                }
    6279        }
    63 //----------------------------------------------------------
    64         public static ArrayList<Bitmap> getImageList()
    65         {
     80
     81        // ------------------------------------------------------------------------
     82        // This method is use to pre-load all the large images into a Bitmap
     83        // ArrayList
     84        public void decodeLargeImage() {
     85                int width = (int) (context.getResources().getDisplayMetrics().widthPixels);
     86                int height = (int) (context.getResources().getDisplayMetrics().heightPixels);
     87                InputStream is = null;
     88                for (int i = 0; i < nImage; i++) {
     89                        // asset implementation
     90                        try {
     91                                is = new BufferedInputStream(context.getResources().getAssets()
     92                                                .open("image" + i + ".png"));
     93                                largeImageList.add(ImageResizer.decodeSampledBitmapFromAsset(
     94                                                is, width, height));
     95                                // is.close();
     96                        } catch (IOException e) {
     97                                // TODO Auto-generated catch block
     98                                e.printStackTrace();
     99                        }
     100                        System.gc();
     101                }
     102        }
     103
     104        // public void decodeAndResizeImage() {
     105        // AssetManager assets = context.getAssets();
     106        // InputStream is = null;
     107        // for (int i = 0; i < nImage; i++) {
     108        // try {
     109        // is = new BufferedInputStream(assets.open("image" + i + ".png"));
     110        // } catch (IOException e) {
     111        // // TODO Auto-generated catch block
     112        // e.printStackTrace();
     113        // }
     114        // imageList.add(ImageResizer.decodeSampledBitmapFromAsset(is, 50, 50));
     115        // }
     116        // }
     117
     118        // ----------------------------------------------------------
     119        public static ArrayList<Bitmap> getImageList() {
    66120                return imageList;
    67121        }
    68 //----------------------------------------------------------
    69                 public static ArrayList<Bitmap> getImageListFromURL()
    70                 {
    71                         return imageListFromURL;
    72                 }       
     122
     123        // ----------------------------------------------------------
     124        public static ArrayList<Bitmap> getImageListFromURL() {
     125                return imageListFromURL;
     126        }
     127
     128        public static ArrayList<Bitmap> getLargeImages() {
     129                return largeImageList;
     130        }
    73131}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ImageListFromUrl.java

    r15287 r17423  
    22
    33public class ImageListFromUrl {
    4         public static String[] imageUrls = new String[]
    5         {
    6                 "http://www.csupomona.edu/~lannguyen/image0.png"
    7         };
     4        public static String[] imageUrls = new String[] { "http://www.csupomona.edu/~lannguyen/image0.png" };
    85}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ImageResizer.java

    r15287 r17423  
    11package gov.nasa.jpl.issm;
    22
     3import java.io.BufferedInputStream;
    34import java.io.IOException;
     5import java.io.InputStream;
    46import java.net.URL;
     7import java.nio.ByteBuffer;
     8import java.nio.ByteOrder;
     9import java.nio.DoubleBuffer;
    510
     11import android.content.res.AssetManager;
    612import android.content.res.Resources;
    713import android.graphics.Bitmap;
     
    1016
    1117public class ImageResizer {
    12        
    13         public static Bitmap decodeSampledBitmapFromURL(URL url , int reqWidth, int reqHeight) {
    1418
    15         // First decode with inJustDecodeBounds=true to check dimensions
    16         final BitmapFactory.Options options = new BitmapFactory.Options();
    17         options.inJustDecodeBounds = true;
    18         try
    19         {
    20                 BitmapFactory.decodeStream(url.openConnection().getInputStream(),null, options);
    21                
    22                 // Calculate inSampleSize
    23                 options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
    24        
    25                 // Decode bitmap with inSampleSize set
    26                 options.inJustDecodeBounds = false;
    27                 return BitmapFactory.decodeStream(url.openConnection().getInputStream(), null, options);
    28         }
    29         catch (IOException e) {
    30                 Log.e("Error", "Could not load Bitmap from: " + url.toString());
    31             }
    32         return null;
    33     }
    34        
    35         public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
    36             int reqWidth, int reqHeight) {
     19        private static DoubleBuffer buffer;
    3720
    38         // First decode with inJustDecodeBounds=true to check dimensions
    39         final BitmapFactory.Options options = new BitmapFactory.Options();
    40         options.inJustDecodeBounds = true;
    41         BitmapFactory.decodeResource(res, resId, options);
    42        
    43         // Calculate inSampleSize
    44         options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
     21        public static Bitmap decodeSampledBitmapFromURL(URL url, int reqWidth,
     22                        int reqHeight) {
    4523
    46         // Decode bitmap with inSampleSize set
    47         options.inJustDecodeBounds = false;
    48         return BitmapFactory.decodeResource(res, resId, options);
    49     }
    50    
    51     public static int calculateInSampleSize(
    52             BitmapFactory.Options options, int reqWidth, int reqHeight)
    53     {
    54             // Raw height and width of image
    55             int height = options.outHeight;
    56             int width = options.outWidth;
    57             int inSampleSize = 1;
    58            
    59         if (height > reqHeight || width > reqWidth) {
     24                // First decode with inJustDecodeBounds=true to check dimensions
     25                final BitmapFactory.Options options = new BitmapFactory.Options();
     26                options.inJustDecodeBounds = true;
     27                try {
     28                        BitmapFactory.decodeStream(url.openConnection().getInputStream(),
     29                                        null, options);
    6030
    61             // Calculate ratios of height and width to requested height and width
    62             final int heightRatio = Math.round((float) height / (float) reqHeight);
    63             final int widthRatio = Math.round((float) width / (float) reqWidth);
     31                        // Calculate inSampleSize
     32                        options.inSampleSize = 1;
    6433
    65             // Choose the smallest ratio as inSampleSize value, this will guarantee
    66             // a final image with both dimensions larger than or equal to the
    67             // requested height and width.
    68             inSampleSize = heightRatio > widthRatio ? heightRatio : widthRatio;
    69         }
     34                        // Decode bitmap with inSampleSize set
     35                        options.inJustDecodeBounds = false;
     36                        return BitmapFactory.decodeStream(url.openConnection()
     37                                        .getInputStream(), null, options);
     38                } catch (IOException e) {
     39                        Log.e("Error", "Could not load Bitmap from: " + url.toString());
     40                }
     41                return null;
     42        }
    7043
    71         return inSampleSize;
     44        // public static Bitmap decodeSampledBitmapFromResource(Resources res, int
     45        // resId,
     46        // int reqWidth, int reqHeight) {
     47        //
     48        // // First decode with inJustDecodeBounds=true to check dimensions
     49        // final BitmapFactory.Options options = new BitmapFactory.Options();
     50        // options.inJustDecodeBounds = true;
     51        // BitmapFactory.decodeResource(res, resId, options);
     52        //
     53        // // Calculate inSampleSize
     54        // options.inSampleSize = calculateInSampleSize(options, reqWidth,
     55        // reqHeight);
     56        //
     57        // // Decode bitmap with inSampleSize set
     58        // options.inJustDecodeBounds = false;
     59        // return BitmapFactory.decodeResource(res, resId, options);
     60        // }
    7261
    73     }
     62        public static Bitmap decodeSampledBitmapFromResource(Resources res,
     63                        int resId, int reqWidth, int reqHeight) {
     64                // First decode with inJustDecodeBounds=true to check dimensions
     65                final BitmapFactory.Options options = new BitmapFactory.Options();
     66                options.inJustDecodeBounds = true;
     67                BitmapFactory.decodeResource(res, resId, options);
     68
     69                // Calculate inSampleSize
     70                options.inSampleSize = calculateInSampleSize(options, reqWidth,
     71                                reqHeight);
     72
     73                // Decode bitmap with inSampleSize set
     74                options.inJustDecodeBounds = false;
     75                // buffer =
     76                // ByteBuffer.allocateDirect(options.outWidth*options.outHeight*4).order(ByteOrder.nativeOrder()).asDoubleBuffer();
     77                // Log.i("Buffer size: ", String.valueOf(buffer.capacity()));
     78                return BitmapFactory.decodeResource(res, resId, options);
     79        }
     80
     81        public static Bitmap decodeSampledBitmapFromAsset(InputStream is,
     82                        int reqWidth, int reqHeight) {
     83                byte[] byteArr = new byte[0];
     84                byte[] buffer = new byte[1024];
     85                int len;
     86                int count = 0;
     87
     88                try {
     89                        while ((len = is.read(buffer)) > -1) {
     90                                if (len != 0) {
     91                                        if (count + len > byteArr.length) {
     92                                                byte[] newbuf = new byte[(count + len) * 2];
     93                                                System.arraycopy(byteArr, 0, newbuf, 0, count);
     94                                                byteArr = newbuf;
     95                                        }
     96
     97                                        System.arraycopy(buffer, 0, byteArr, count, len);
     98                                        count += len;
     99                                }
     100                        }
     101
     102                        final BitmapFactory.Options options = new BitmapFactory.Options();
     103                        options.inJustDecodeBounds = true;
     104                        BitmapFactory.decodeByteArray(byteArr, 0, count, options);
     105
     106                        options.inSampleSize = calculateInSampleSize(options, reqWidth,
     107                                        reqHeight);
     108                        options.inPurgeable = true;
     109                        options.inInputShareable = true;
     110                        options.inJustDecodeBounds = false;
     111                        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
     112
     113                        return BitmapFactory.decodeByteArray(byteArr, 0, count, options);
     114
     115                } catch (Exception e) {
     116                        e.printStackTrace();
     117
     118                        return null;
     119                }
     120        }
     121
     122        // public static Bitmap decodeSampledBitmapFromAsset(InputStream is,
     123        // int reqWidth, int reqHeight) {
     124        // return BitmapFactory.decodeStream(is);
     125        // }
     126
     127        public static int calculateInSampleSize(BitmapFactory.Options options,
     128                        int reqWidth, int reqHeight) {
     129                // Raw height and width of image
     130                int height = options.outHeight;
     131                int width = options.outWidth;
     132                // Log.i("pic width: ", String.valueOf(width));
     133                // Log.i("pic height: ", String.valueOf(height));
     134                int inSampleSize = 1;
     135
     136                if (height > reqHeight || width > reqWidth) {
     137
     138                        // Calculate ratios of height and width to requested height and
     139                        // width
     140                        final int heightRatio = Math.round((float) height
     141                                        / (float) reqHeight);
     142                        final int widthRatio = Math.round((float) width / (float) reqWidth);
     143                        // Log.i("width ratio: ", String.valueOf(widthRatio));
     144                        // Log.i("height ratio: ", String.valueOf(heightRatio));
     145
     146                        // Choose the smallest ratio as inSampleSize value, this will
     147                        // guarantee
     148                        // a final image with both dimensions larger than or equal to the
     149                        // requested height and width.
     150                        inSampleSize = heightRatio > widthRatio ? heightRatio : widthRatio;
     151                        inSampleSize = (int) Math
     152                                        .pow(2, Math.floor(Math.log(inSampleSize)));
     153                        // Log.i("sample size: ", String.valueOf(inSampleSize));
     154                }
     155
     156                return inSampleSize;
     157
     158        }
    74159
    75160}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/IssmJni.java

    r16079 r17423  
    11package gov.nasa.jpl.issm;
     2
    23import java.nio.DoubleBuffer;
    34
    4 class IssmJni
    5 {
     5class IssmJni {
    66        public native void solveISSMModel(double alpha, DoubleBuffer buff);
    7         //public native void solveISSMModel(double alpha, double temperature, DoubleBuffer buff);
    8         public native int createISSMModel(String solution_type, String absfile, String relfile);
    9         static
    10         {
    11         System.loadLibrary("IssmJni");
    12     }
     7
     8        // public native void solveISSMModel(double alpha, double temperature,
     9        // DoubleBuffer buff);
     10        public native int createISSMModel(String solution_type, String absfile,
     11                        String relfile);
     12
     13        static {
     14                System.loadLibrary("IssmJni");
     15        }
    1316}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/MenuPage.java

    r15013 r17423  
    11package gov.nasa.jpl.issm;
    22
    3 import android.app.Activity;
    43import android.app.AlertDialog;
    54import android.os.Bundle;
    65import android.view.View;
    76import android.widget.Button;
     7import android.widget.Toast;
    88import android.content.DialogInterface;
    99import android.content.Intent;
    1010
    1111///////////////////////////////////////////////////////////////////////////
    12 public class MenuPage extends Activity
    13 {
    14         ISSM issm = new ISSM();
    15         //GalleryImage gallery = new GalleryImage();
    16         private String issmFolder;
    17 //------------------------------------------------------------------------     
    18         public void onCreate(Bundle icicle)
    19         {
     12public class MenuPage extends BaseActivity {
     13        // ISSM issm = new ISSM();
     14        // GalleryImage gallery = new GalleryImage();
     15        private static String issmFolder;
     16
     17        // ------------------------------------------------------------------------
     18        @Override
     19        public void onCreate(Bundle icicle) {
    2020                super.onCreate(icicle);
    21                 setContentView(R.layout.menupage);             
     21                setContentView(R.layout.menupage);
     22                transition();
    2223                Bundle map = getIntent().getExtras();
    23         {
    24                 if(map!= null)
    25                 {
    26                         issmFolder = map.getString("pathToFile");
    27                 }
    28         }
    29         //start the core implementation of ISSM
    30             Button start = (Button) findViewById(R.id.start);           
    31                 start.setOnClickListener(new View.OnClickListener()
    3224                {
    33                         public void onClick(View v)
    34                         {
     25                        if (map != null) {
     26                                issmFolder = map.getString("pathToFile");
     27                        }
     28                }
     29
     30                // start the core implementation of ISSM
     31                // Button start = (Button) findViewById(R.id.play_tab);
     32                // start.setOnClickListener(new View.OnClickListener() {
     33                // public void onClick(View v) {
     34                // Intent i = new Intent(MenuPage.this, ISSM.class);
     35                // i.putExtra("pathToFile", issmFolder);
     36                // startActivity(i);
     37                // }
     38                // });
     39                // // navigate to youtube video
     40                // Button video = (Button) findViewById(R.id.video_tab);
     41                // video.setOnClickListener(new View.OnClickListener() {
     42                // public void onClick(View v) {
     43                // // String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
     44                // // Intent i = new Intent(Intent.ACTION_VIEW);
     45                // // i.setData(Uri.parse(url));
     46                // Intent i = new Intent(MenuPage.this, VideoActivity.class);
     47                // startActivity(i);
     48                // }
     49                // });
     50                // // pop up a text box that contains information about ISSM
     51                // final Button intro = (Button) findViewById(R.id.about_tab);
     52                // intro.setOnClickListener(new View.OnClickListener() {
     53                // public void onClick(View v) {
     54                // // LayoutInflater layoutInflater =
     55                // //
     56                // //
     57                // (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
     58                // // View popupView = layoutInflater.inflate(R.layout.popuptext,
     59                // // null);
     60                // // final PopupWindow popupWindow = new PopupWindow( popupView,
     61                // // 400,600, true);
     62                // // popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
     63                // // Button dismiss =
     64                // // (Button)popupView.findViewById(R.id.dismiss);
     65                // // dismiss.setOnClickListener(new Button.OnClickListener()
     66                // // {
     67                // // public void onClick(View v)
     68                // // {
     69                // // popupWindow.dismiss();
     70                // // }
     71                // // });
     72                // Intent i = new Intent(MenuPage.this, AboutActivity.class);
     73                // startActivity(i);
     74                // }
     75                // });
     76                // // Show Team Website
     77                // Button visitus = (Button) findViewById(R.id.team_tab);
     78                // visitus.setOnClickListener(new View.OnClickListener() {
     79                // public void onClick(View v) {
     80                // // String url = "http://issm.jpl.nasa.gov/";
     81                // // Intent i = new Intent(Intent.ACTION_VIEW);
     82                // // i.setData(Uri.parse(url));
     83                // // startActivity(i);
     84                //
     85                // Intent i = new Intent(MenuPage.this, TeamActivity.class);
     86                // startActivity(i);
     87                // }
     88                // });
     89                // // start gallery image
     90                // Button galleryImage = (Button) findViewById(R.id.gallery_tab);
     91                // galleryImage.setOnClickListener(new View.OnClickListener() {
     92                // public void onClick(View v) {
     93                // Intent i = new Intent(MenuPage.this, GalleryImage.class);
     94                // startActivity(i);
     95                // }
     96                // });
     97
     98                Button start = (Button) findViewById(R.id.start);
     99                start.setOnClickListener(new View.OnClickListener() {
     100
     101                        @Override
     102                        public void onClick(View v) {
    35103                                Intent i = new Intent(MenuPage.this, ISSM.class);
    36104                                i.putExtra("pathToFile", issmFolder);
    37                         startActivity(i);
     105                                startActivity(i);
     106                                finish();
    38107                        }
    39108                });
    40                 // navigate to youtube video
    41                 Button video = (Button) findViewById(R.id.video);               
    42                 video.setOnClickListener(new View.OnClickListener()
    43                 {
    44                         public void onClick(View v)
    45                         {
    46                                 //String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
    47                                 //Intent i = new Intent(Intent.ACTION_VIEW);
    48                                 //i.setData(Uri.parse(url));
    49                                 Intent i = new Intent(MenuPage.this, VideoActivity.class);
    50                         startActivity(i);
     109
     110                Button galleryTab = (Button) findViewById(R.id.gallery_tab);
     111                galleryTab.setOnClickListener(new View.OnClickListener() {
     112
     113                        @Override
     114                        public void onClick(View v) {
     115                                Intent i = new Intent(MenuPage.this, GalleryImage.class);
     116                                startActivity(i);
     117                                finish();
    51118                        }
    52119                });
    53                 // pop up a text box that contains information about ISSM
    54                 final Button intro = (Button) findViewById(R.id.intro);
    55                 intro.setOnClickListener(new View.OnClickListener()
    56                 {
    57                         public void onClick(View v)
    58                         {
    59                                 //LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE); 
    60                                 //View popupView = layoutInflater.inflate(R.layout.popuptext, null); 
    61                                 //final PopupWindow popupWindow = new PopupWindow( popupView, 400,600, true);
    62                                 //popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
    63                                 //Button dismiss = (Button)popupView.findViewById(R.id.dismiss);
    64                     //dismiss.setOnClickListener(new Button.OnClickListener()
    65                     //{
    66                         //public void onClick(View v)
    67                     //  {
    68                                 //popupWindow.dismiss();
    69                         //}
    70                     //});
    71                                 Intent i = new Intent(MenuPage.this, AboutActivity.class);
    72                         startActivity(i);
     120                Button videoTab = (Button) findViewById(R.id.video_tab);
     121                videoTab.setOnClickListener(new View.OnClickListener() {
     122
     123                        @Override
     124                        public void onClick(View v) {
     125                                // String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
     126                                // Intent i = new Intent(Intent.ACTION_VIEW);
     127                                // i.setData(Uri.parse(url));
     128                                Intent i = new Intent(MenuPage.this, VideoActivity.class);
     129                                startActivity(i);
     130                                finish();
    73131                        }
    74132                });
    75                 //Show Team Website
    76                 Button visitus = (Button) findViewById(R.id.visitus);           
    77                 visitus.setOnClickListener(new View.OnClickListener()
    78                 {
    79                         public void onClick(View v)
    80                         {
    81                                 //String url = "http://issm.jpl.nasa.gov/";
    82                                 //Intent i = new Intent(Intent.ACTION_VIEW);
    83                                 //i.setData(Uri.parse(url));
    84                         //startActivity(i);
    85                                
    86                                 Intent i = new Intent(MenuPage.this, TeamActivity.class);
    87                         startActivity(i);
     133                Button aboutTab = (Button) findViewById(R.id.about_tab);
     134                aboutTab.setOnClickListener(new View.OnClickListener() {
     135
     136                        @Override
     137                        public void onClick(View v) {
     138                                Intent i = new Intent(MenuPage.this, AboutActivity.class);
     139                                startActivity(i);
     140                                finish();
    88141                        }
    89142                });
    90                 //start gallery image
    91             Button galleryImage = (Button) findViewById(R.id.galleryimage);             
    92             galleryImage.setOnClickListener(new View.OnClickListener()
    93                 {
    94                         public void onClick(View v)
    95                         {
    96                                 Intent i = new Intent(MenuPage.this, GalleryImage.class);
    97                         startActivity(i);
     143                Button teamTab = (Button) findViewById(R.id.team_tab);
     144                teamTab.setOnClickListener(new View.OnClickListener() {
     145
     146                        @Override
     147                        public void onClick(View v) {
     148                                // String url = "http://issm.jpl.nasa.gov/";
     149                                // Intent i = new Intent(Intent.ACTION_VIEW);
     150                                // i.setData(Uri.parse(url));
     151                                // startActivity(i);
     152
     153                                Intent i = new Intent(MenuPage.this, TeamActivity.class);
     154                                startActivity(i);
     155                                finish();
    98156                        }
    99157                });
    100158        }
    101 //-------------------------------------------------------------------------------------
    102        
    103          @Override
    104      public void onBackPressed() {
    105          new AlertDialog.Builder(this)
    106                 .setMessage("Are you sure you want to exit?")
    107                 .setCancelable(false)
    108                 .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
    109                     public void onClick(DialogInterface dialog, int id) {
    110                         MenuPage.this.finish();
    111                     }
    112                 })
    113                 .setNegativeButton("No", null)
    114                 .show();
    115      }
     159
     160        // -------------------------------------------------------------------------------------
     161
     162        @Override
     163        public void onBackPressed() {
     164                new AlertDialog.Builder(this)
     165                                .setMessage("Are you sure you want to exit?")
     166                                .setCancelable(false)
     167                                .setPositiveButton("Yes",
     168                                                new DialogInterface.OnClickListener() {
     169                                                        public void onClick(DialogInterface dialog, int id) {
     170                                                                MenuPage.this.finish();
     171                                                        }
     172                                                }).setNegativeButton("No", null).show();
     173        }
     174
     175        // ----------------------------------------------------------------------------------------
     176        public static String getISSMPath() {
     177                return issmFolder;
     178        }
    116179}
    117 /////////////////////////////////////////////////////////////////////////////////////////
     180// ///////////////////////////////////////////////////////////////////////////////////////
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/MyGLRenderer.java

    r14472 r17423  
    1616
    1717package gov.nasa.jpl.issm;
     18
    1819import java.nio.ByteBuffer;
    1920import java.nio.ByteOrder;
     
    2728import android.opengl.Matrix;
    2829
    29 public class MyGLRenderer implements GLSurfaceView.Renderer
    30 {
     30public class MyGLRenderer implements GLSurfaceView.Renderer {
    3131        public volatile float mAngle;
    32         public volatile float mAngleX; /* NEW STUFF*/
     32        public volatile float mAngleX; /* NEW STUFF */
    3333        public volatile float mAngleY;
    34        
    35        
    36     private FloatBuffer[] triangleVert;
    37        
    38         private float[][] mScaleMatrix;  // scaling /* NEW STUFF*/
    39         private float[][] mRotXMatrix;   // rotation x
    40         private float[][] mRotYMatrix;   // rotation x
     34
     35        private FloatBuffer[] triangleVert;
     36
     37        private float[][] mScaleMatrix; // scaling /* NEW STUFF*/
     38        private float[][] mRotXMatrix; // rotation x
     39        private float[][] mRotYMatrix; // rotation x
    4140
    4241        /**
    43          * Store the model matrix. This matrix is used to move models from object space (where each model can be thought
    44          * of being located at the center of the universe) to world space.
     42         * Store the model matrix. This matrix is used to move models from object
     43         * space (where each model can be thought of being located at the center of
     44         * the universe) to world space.
    4545         */
    4646        private float[][] mModelMatrix;
    47        
     47
    4848        /**
    49          * Store the view matrix. This can be thought of as our camera. This matrix transforms world space to eye space;
    50          * it positions things relative to our eye.
     49         * Store the view matrix. This can be thought of as our camera. This matrix
     50         * transforms world space to eye space; it positions things relative to our
     51         * eye.
    5152         */
    5253        private float[][] mViewMatrix;
    5354
    54         /** Store the projection matrix. This is used to project the scene onto a 2D viewport. */
     55        /**
     56         * Store the projection matrix. This is used to project the scene onto a 2D
     57         * viewport.
     58         */
    5559        private float[][] mProjectionMatrix;
    5660
    57         /** Allocate storage for the final combined matrix. This will be passed into the shader program. */
     61        /**
     62         * Allocate storage for the final combined matrix. This will be passed into
     63         * the shader program.
     64         */
    5865        private float[][] mMVPMatrix;
    5966
    6067        /** This will be used to pass in the transformation matrix. */
    6168        private int mMatrixHandle;
    62        
    63     private float[][] triangleData2DArr;
    64    
    65     private int mPositionHandle;
    66    
    67     private int mColorHandle;
    68    
     69
     70        private float[][] triangleData2DArr;
     71
     72        private int mPositionHandle;
     73
     74        private int mColorHandle;
     75
    6976        /** How many bytes per float. */
    70     private final int mBytesPerFloat = 4;
    71 
    72     /** How many elements per vertex. */
    73     private final int mStrideBytes = 7 * mBytesPerFloat;
    74 
    75     /** Offset of the position data. */
    76     private final int mPositionOffset = 0;
    77 
    78     /** Size of the position data in elements. */
    79     private final int mPositionDataSize = 3;
    80 
    81     /** Offset of the color data. */
    82     private final int mColorOffset = 3;
    83 
    84     /** Size of the color data in elements. */
    85     private final int mColorDataSize = 4;       
     77        private final int mBytesPerFloat = 4;
     78
     79        /** How many elements per vertex. */
     80        private final int mStrideBytes = 7 * mBytesPerFloat;
     81
     82        /** Offset of the position data. */
     83        private final int mPositionOffset = 0;
     84
     85        /** Size of the position data in elements. */
     86        private final int mPositionDataSize = 3;
     87
     88        /** Offset of the color data. */
     89        private final int mColorOffset = 3;
     90
     91        /** Size of the color data in elements. */
     92        private final int mColorDataSize = 4;
    8693
    8794        float scaleX = 1.0f;
     
    9299        public float eyeY;
    93100        public float eyeZ;
    94        
    95     public MyGLRenderer(float[][] vertices)
    96     {   
    97         triangleData2DArr = new float[vertices.length][21];
    98  
    99         triangleVert = new FloatBuffer[vertices.length];
    100         mScaleMatrix  = new float[triangleVert.length][16];  // scaling 
    101         mRotXMatrix  = new float[triangleVert.length][16];      // rotation x
    102         mRotYMatrix  = new float[triangleVert.length][16];       // rotation x
    103        
    104         for (int i = 0; i < vertices.length; i++)
    105         {
    106                 for (int j = 0; j < 21; j++)
    107                         triangleData2DArr[i][j] = vertices[i][j];
    108         }
    109            
    110             // initialize vertex byte buffer for shape coordinates
    111         for (int i = 0; i < vertices.length; i++)
    112         {
    113                 triangleVert[i] = ByteBuffer.allocateDirect(triangleData2DArr[i].length * mBytesPerFloat)
    114                                                                                                         .order(ByteOrder.nativeOrder()).asFloatBuffer();
    115                 triangleVert[i].put(triangleData2DArr[i]).position(0);
    116         }
    117     }
    118    
    119         public void changeScale(float scale)
    120         {
    121                 if (scaleX * scale > 3.0f) return;
    122                   scaleX *= scale; scaleY *= scale; scaleZ *= scale;
    123                
    124         }
    125 
    126         public void defaultScale()
    127         {
     101
     102        public MyGLRenderer(float[][] vertices) {
     103                triangleData2DArr = new float[vertices.length][21];
     104
     105                triangleVert = new FloatBuffer[vertices.length];
     106                mScaleMatrix = new float[triangleVert.length][16]; // scaling
     107                mRotXMatrix = new float[triangleVert.length][16]; // rotation x
     108                mRotYMatrix = new float[triangleVert.length][16]; // rotation x
     109
     110                for (int i = 0; i < vertices.length; i++) {
     111                        for (int j = 0; j < 21; j++)
     112                                triangleData2DArr[i][j] = vertices[i][j];
     113                }
     114
     115                // initialize vertex byte buffer for shape coordinates
     116                for (int i = 0; i < vertices.length; i++) {
     117                        triangleVert[i] = ByteBuffer
     118                                        .allocateDirect(
     119                                                        triangleData2DArr[i].length * mBytesPerFloat)
     120                                        .order(ByteOrder.nativeOrder()).asFloatBuffer();
     121                        triangleVert[i].put(triangleData2DArr[i]).position(0);
     122                }
     123        }
     124
     125        public void changeScale(float scale) {
     126                if (scaleX * scale > 3.0f)
     127                        return;
     128                scaleX *= scale;
     129                scaleY *= scale;
     130                scaleZ *= scale;
     131
     132        }
     133
     134        public void defaultScale() {
    128135                scaleX = 1f;
    129136                scaleY = 1f;
    130137                scaleZ = 1f;
    131138        }
    132        
    133     public void onSurfaceCreated(GL10 unused, EGLConfig config)
    134     {
    135         // Set the background frame color
    136         GLES20.glClearColor(0.2f, 0.4f, 1.0f, 1.0f);
    137        
     139
     140        public void onSurfaceCreated(GL10 unused, EGLConfig config) {
     141                // Set the background frame color
     142                GLES20.glClearColor(0.2f, 0.4f, 1.0f, 1.0f);
     143
    138144                // Position the eye behind the origin.
    139145                eyeX = 0.0f;
     
    146152                final float lookZ = -5.0f;
    147153
    148                 // Set our up vector. This is where our head would be pointing were we holding the camera.
     154                // Set our up vector. This is where our head would be pointing were we
     155                // holding the camera.
    149156                final float upX = 0.0f;
    150157                final float upY = 1.0f;
    151158                final float upZ = 0.0f;
    152159
    153                 // Set the view matrix. This matrix can be said to represent the camera position.
    154                 // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
    155                 // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
     160                // Set the view matrix. This matrix can be said to represent the camera
     161                // position.
     162                // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination
     163                // of a model and
     164                // view matrix. In OpenGL 2, we can keep track of these matrices
     165                // separately if we choose.
    156166                mViewMatrix = new float[triangleVert.length][16];
    157                
    158                
     167
    159168                for (int i = 0; i < triangleVert.length; i++)
    160                         Matrix.setLookAtM(mViewMatrix[i], 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);
    161                         //Matrix.setLookAtM(mVMatrix[i], 0, 0, 0, -5.0f, 0.0f, 0f, 0f, 0f, 1.0f, 0.0f);
    162        
    163                 final String vertexShader =
    164                                 "uniform mat4 u_MVPMatrix;      \n"             // A constant representing the combined model/view/projection matrix.
    165                           + "attribute vec4 a_Position;     \n"         // Per-vertex position information we will pass in.
    166                           + "attribute vec4 a_Color;        \n"         // Per-vertex color information we will pass in.                         
    167                           + "varying vec4 v_Color;          \n"         // This will be passed into the fragment shader.
    168                           + "void main()                    \n"         // The entry point for our vertex shader.
    169                           + "{                              \n"
    170                           + "   v_Color = a_Color;          \n"         // Pass the color through to the fragment shader.
    171                          
    172                                                                                                                 // It will be interpolated across the triangle.
    173                           + "   gl_Position = u_MVPMatrix   \n"         // gl_Position is a special variable used to store the final position.
    174                           + "               * a_Position;   \n"     // Multiply the vertex by the matrix to get the final point in                                                                                       
    175                           + "}                              \n";    // normalized screen coordinates.
    176 
    177                         final String fragmentShader =
    178                                 "precision mediump float;       \n"             // Set the default precision to medium. We don't need as high of a                                                                                      // precision in the fragment shader.                           
    179                           + "varying vec4 v_Color;          \n"         // This is the color from the vertex shader interpolated across the
    180                                                                                                                 // triangle per fragment.                         
    181                           + "void main()                    \n"         // The entry point for our fragment shader.
    182                           + "{                              \n"
    183                           + "   gl_FragColor = v_Color;     \n"         // Pass the color directly through the pipeline.                 
    184                           + "}                              \n";                                                                                               
    185 
    186            
    187         int vertexShaderHandle = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
     169                        Matrix.setLookAtM(mViewMatrix[i], 0, eyeX, eyeY, eyeZ, lookX,
     170                                        lookY, lookZ, upX, upY, upZ);
     171                // Matrix.setLookAtM(mVMatrix[i], 0, 0, 0, -5.0f, 0.0f, 0f, 0f, 0f,
     172                // 1.0f, 0.0f);
     173
     174                final String vertexShader = "uniform mat4 u_MVPMatrix;      \n" // A
     175                                                                                                                                                // constant
     176                                                                                                                                                // representing
     177                                                                                                                                                // the
     178                                                                                                                                                // combined
     179                                                                                                                                                // model/view/projection
     180                                                                                                                                                // matrix.
     181                                + "attribute vec4 a_Position;     \n" // Per-vertex position
     182                                                                                                                // information we will
     183                                                                                                                // pass in.
     184                                + "attribute vec4 a_Color;        \n" // Per-vertex color
     185                                                                                                                // information we will
     186                                                                                                                // pass in.
     187                                + "varying vec4 v_Color;          \n" // This will be passed
     188                                                                                                                // into the fragment
     189                                                                                                                // shader.
     190                                + "void main()                    \n" // The entry point for our
     191                                                                                                                // vertex shader.
     192                                + "{                              \n"
     193                                + "   v_Color = a_Color;          \n" // Pass the color through
     194                                                                                                                // to the fragment
     195                                                                                                                // shader.
     196
     197                                // It will be interpolated across the triangle.
     198                                + "   gl_Position = u_MVPMatrix   \n" // gl_Position is a
     199                                                                                                                // special variable used
     200                                                                                                                // to store the final
     201                                                                                                                // position.
     202                                + "               * a_Position;   \n" // Multiply the vertex by
     203                                                                                                                // the matrix to get the
     204                                                                                                                // final point in
     205                                + "}                              \n"; // normalized screen
     206                                                                                                                // coordinates.
     207
     208                final String fragmentShader = "precision mediump float;       \n" // Set
     209                                                                                                                                                        // the
     210                                                                                                                                                        // default
     211                                                                                                                                                        // precision
     212                                                                                                                                                        // to
     213                                                                                                                                                        // medium.
     214                                                                                                                                                        // We
     215                                                                                                                                                        // don't
     216                                                                                                                                                        // need
     217                                                                                                                                                        // as
     218                                                                                                                                                        // high
     219                                                                                                                                                        // of
     220                                                                                                                                                        // a
     221                                                                                                                                                        // //
     222                                                                                                                                                        // precision
     223                                                                                                                                                        // in
     224                                                                                                                                                        // the
     225                                                                                                                                                        // fragment
     226                                                                                                                                                        // shader.
     227                                + "varying vec4 v_Color;          \n" // This is the color from
     228                                                                                                                // the vertex shader
     229                                                                                                                // interpolated across
     230                                                                                                                // the
     231                                                                                                                // triangle per
     232                                                                                                                // fragment.
     233                                + "void main()                    \n" // The entry point for our
     234                                                                                                                // fragment shader.
     235                                + "{                              \n"
     236                                + "   gl_FragColor = v_Color;     \n" // Pass the color directly
     237                                                                                                                // through the pipeline.
     238                                + "}                              \n";
     239
     240                int vertexShaderHandle = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    188241                // Pass in the shader source.
    189242                GLES20.glShaderSource(vertexShaderHandle, vertexShader);
     
    194247                // Get the compilation status.
    195248                final int[] compileStatus1 = new int[1];
    196                 GLES20.glGetShaderiv(vertexShaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus1, 0);
     249                GLES20.glGetShaderiv(vertexShaderHandle, GLES20.GL_COMPILE_STATUS,
     250                                compileStatus1, 0);
    197251
    198252                // If the compilation failed, delete the shader.
    199                 if (compileStatus1[0] == 0)
    200                 {                               
     253                if (compileStatus1[0] == 0) {
    201254                        GLES20.glDeleteShader(vertexShaderHandle);
    202255                        vertexShaderHandle = 0;
    203256                }
    204                
    205          
    206         int fragmentShaderHandle = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
     257
     258                int fragmentShaderHandle = GLES20
     259                                .glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    207260                // Pass in the shader source.
    208261                GLES20.glShaderSource(fragmentShaderHandle, fragmentShader);
     
    213266                // Get the compilation status.
    214267                final int[] compileStatus2 = new int[1];
    215                 GLES20.glGetShaderiv(fragmentShaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus2, 0);
     268                GLES20.glGetShaderiv(fragmentShaderHandle, GLES20.GL_COMPILE_STATUS,
     269                                compileStatus2, 0);
    216270
    217271                // If the compilation failed, delete the shader.
    218                 if (compileStatus2[0] == 0)
    219                 {                               
     272                if (compileStatus2[0] == 0) {
    220273                        GLES20.glDeleteShader(fragmentShaderHandle);
    221274                        fragmentShaderHandle = 0;
    222275                }
    223276
    224        
    225         int mProgram = GLES20.glCreateProgram();
     277                int mProgram = GLES20.glCreateProgram();
    226278                // Bind the vertex shader to the program.
    227                 GLES20.glAttachShader(mProgram, vertexShaderHandle);                   
     279                GLES20.glAttachShader(mProgram, vertexShaderHandle);
    228280
    229281                // Bind the fragment shader to the program.
     
    233285                GLES20.glBindAttribLocation(mProgram, 0, "a_Position");
    234286                GLES20.glBindAttribLocation(mProgram, 1, "a_Color");
    235                
     287
    236288                // Link the two shaders together into a program.
    237289                GLES20.glLinkProgram(mProgram);
     
    242294
    243295                // If the link failed, delete the program.
    244                 if (linkStatus[0] == 0)
    245                 {                               
     296                if (linkStatus[0] == 0) {
    246297                        GLES20.glDeleteProgram(mProgram);
    247298                        mProgram = 0;
    248299                }
    249                
    250                 for (int i = 0; i < triangleVert.length; i++)
    251                 {
    252                         mMatrixHandle = GLES20.glGetUniformLocation(mProgram, "u_MVPMatrix");       
    253                 mPositionHandle = GLES20.glGetAttribLocation(mProgram, "a_Position");
    254                 mColorHandle = GLES20.glGetAttribLocation(mProgram, "a_Color");
    255                 }
    256        
    257         // Add program to OpenGL environment
    258         GLES20.glUseProgram(mProgram);
    259     }
    260     public void onSurfaceChanged(GL10 unused, int width, int height)
    261     {
    262         // Adjust the viewport based on geometry changes,
    263         // such as screen rotation
    264         GLES20.glViewport(0, 0, width, height);
    265        
    266                 // Create a new perspective projection matrix. The height will stay the same
     300
     301                for (int i = 0; i < triangleVert.length; i++) {
     302                        mMatrixHandle = GLES20
     303                                        .glGetUniformLocation(mProgram, "u_MVPMatrix");
     304                        mPositionHandle = GLES20
     305                                        .glGetAttribLocation(mProgram, "a_Position");
     306                        mColorHandle = GLES20.glGetAttribLocation(mProgram, "a_Color");
     307                }
     308
     309                // Add program to OpenGL environment
     310                GLES20.glUseProgram(mProgram);
     311        }
     312
     313        public void onSurfaceChanged(GL10 unused, int width, int height) {
     314                // Adjust the viewport based on geometry changes,
     315                // such as screen rotation
     316                GLES20.glViewport(0, 0, width, height);
     317
     318                // Create a new perspective projection matrix. The height will stay the
     319                // same
    267320                // while the width will vary as per aspect ratio.
    268321                final float ratio = (float) width / height;
    269                
     322
    270323                mProjectionMatrix = new float[triangleVert.length][16];
    271324                for (int i = 0; i < triangleVert.length; i++)
    272                         Matrix.frustumM(mProjectionMatrix[i], 0, -ratio, ratio, -1, 1, 1f, 5);
    273                        
    274     }
    275    
    276     public void onDrawFrame(GL10 glUnused)
    277     {
    278         // Draw background color
    279         GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
    280        
    281         mModelMatrix = new float[triangleVert.length][16];
    282         // Draw the triangle facing straight on.
    283         for (int i = 0; i < triangleVert.length; i++)
    284         {
    285                 Matrix.setIdentityM(mScaleMatrix[i], 0);
    286                 Matrix.scaleM(mScaleMatrix[i], 0, scaleX, scaleY, scaleZ);
    287                
    288                 // Rotation along x
    289                 Matrix.setRotateM(mRotXMatrix[i], 0, this.mAngleY, -1.0f, 0.0f, 0.0f);
    290                 Matrix.setRotateM(mRotYMatrix[i], 0, this.mAngleX, 0.0f, 1.0f, 0.0f);
    291                
    292                 Matrix.setLookAtM(mViewMatrix[i], 0, eyeX, eyeY, eyeZ, 0.0f, 0.0f, -5.0f, 0.0f, 1.0f, 0.0f);
    293        
    294         }
    295                
    296         mMVPMatrix = new float[triangleVert.length][16];
    297         draw(triangleVert);
    298 
    299     }
    300 
    301     private void draw(final FloatBuffer[] aTriangleBuffer)
    302     {
    303         for (int i = 0; i < aTriangleBuffer.length; i++)
    304         {
    305                 // Pass in the position information
    306                 aTriangleBuffer[i].position(mPositionOffset);
    307                 GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false,
    308                                                              mStrideBytes, aTriangleBuffer[i]);
    309                
    310                 GLES20.glEnableVertexAttribArray(mPositionHandle);
    311              
    312                
    313                 // Pass in the color information
    314                 aTriangleBuffer[i].position(mColorOffset);
    315                 GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GL_FLOAT, false,
    316                                                                  mStrideBytes, aTriangleBuffer[i]);
    317                
    318                 GLES20.glEnableVertexAttribArray(mColorHandle);
    319                
    320                 Matrix.setRotateM(mRotXMatrix[i], 0, this.mAngleY, -1.0f, 0.0f, 0.0f);
    321                 Matrix.setRotateM(mRotYMatrix[i], 0, this.mAngleX, 0.0f, 1.0f, 0.0f);
    322 
    323                 float tempMatrix[][] = new float[triangleVert.length][16];
    324                 Matrix.multiplyMM(tempMatrix[i], 0, mRotYMatrix[i], 0, mRotXMatrix[i], 0);
    325                 Matrix.multiplyMM(mModelMatrix[i], 0, mScaleMatrix[i], 0, tempMatrix[i], 0);
    326 
    327                         // This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix
    328                 // (which currently contains model * view).
    329                 Matrix.multiplyMM(mMVPMatrix[i], 0, mViewMatrix[i], 0, mModelMatrix[i], 0);
    330                
    331                 // This multiplies the modelview matrix by the projection matrix, and stores the result in the MVP matrix
    332                 // (which now contains model * view * projection).
    333                 Matrix.multiplyMM(mMVPMatrix[i], 0, mProjectionMatrix[i], 0, mMVPMatrix[i], 0);
    334                
    335                 GLES20.glUniformMatrix4fv(mMatrixHandle, 1, false, mMVPMatrix[i], 0);   
    336 
    337                 // Draw the triangle
    338                 GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
    339                
    340                 // Disable vertex array
    341                 GLES20.glDisableVertexAttribArray(mPositionHandle);
    342         }
    343     }
     325                        Matrix.frustumM(mProjectionMatrix[i], 0, -ratio, ratio, -1, 1, 1f,
     326                                        5);
     327
     328        }
     329
     330        public void onDrawFrame(GL10 glUnused) {
     331                // Draw background color
     332                GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
     333
     334                mModelMatrix = new float[triangleVert.length][16];
     335                // Draw the triangle facing straight on.
     336                for (int i = 0; i < triangleVert.length; i++) {
     337                        Matrix.setIdentityM(mScaleMatrix[i], 0);
     338                        Matrix.scaleM(mScaleMatrix[i], 0, scaleX, scaleY, scaleZ);
     339
     340                        // Rotation along x
     341                        Matrix.setRotateM(mRotXMatrix[i], 0, this.mAngleY, -1.0f, 0.0f,
     342                                        0.0f);
     343                        Matrix.setRotateM(mRotYMatrix[i], 0, this.mAngleX, 0.0f, 1.0f, 0.0f);
     344
     345                        Matrix.setLookAtM(mViewMatrix[i], 0, eyeX, eyeY, eyeZ, 0.0f, 0.0f,
     346                                        -5.0f, 0.0f, 1.0f, 0.0f);
     347
     348                }
     349
     350                mMVPMatrix = new float[triangleVert.length][16];
     351                draw(triangleVert);
     352
     353        }
     354
     355        private void draw(final FloatBuffer[] aTriangleBuffer) {
     356                for (int i = 0; i < aTriangleBuffer.length; i++) {
     357                        // Pass in the position information
     358                        aTriangleBuffer[i].position(mPositionOffset);
     359                        GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize,
     360                                        GLES20.GL_FLOAT, false, mStrideBytes, aTriangleBuffer[i]);
     361
     362                        GLES20.glEnableVertexAttribArray(mPositionHandle);
     363
     364                        // Pass in the color information
     365                        aTriangleBuffer[i].position(mColorOffset);
     366                        GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize,
     367                                        GLES20.GL_FLOAT, false, mStrideBytes, aTriangleBuffer[i]);
     368
     369                        GLES20.glEnableVertexAttribArray(mColorHandle);
     370
     371                        Matrix.setRotateM(mRotXMatrix[i], 0, this.mAngleY, -1.0f, 0.0f,
     372                                        0.0f);
     373                        Matrix.setRotateM(mRotYMatrix[i], 0, this.mAngleX, 0.0f, 1.0f, 0.0f);
     374
     375                        float tempMatrix[][] = new float[triangleVert.length][16];
     376                        Matrix.multiplyMM(tempMatrix[i], 0, mRotYMatrix[i], 0,
     377                                        mRotXMatrix[i], 0);
     378                        Matrix.multiplyMM(mModelMatrix[i], 0, mScaleMatrix[i], 0,
     379                                        tempMatrix[i], 0);
     380
     381                        // This multiplies the view matrix by the model matrix, and stores
     382                        // the result in the MVP matrix
     383                        // (which currently contains model * view).
     384                        Matrix.multiplyMM(mMVPMatrix[i], 0, mViewMatrix[i], 0,
     385                                        mModelMatrix[i], 0);
     386
     387                        // This multiplies the modelview matrix by the projection matrix,
     388                        // and stores the result in the MVP matrix
     389                        // (which now contains model * view * projection).
     390                        Matrix.multiplyMM(mMVPMatrix[i], 0, mProjectionMatrix[i], 0,
     391                                        mMVPMatrix[i], 0);
     392
     393                        GLES20.glUniformMatrix4fv(mMatrixHandle, 1, false, mMVPMatrix[i], 0);
     394
     395                        // Draw the triangle
     396                        GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
     397
     398                        // Disable vertex array
     399                        GLES20.glDisableVertexAttribArray(mPositionHandle);
     400                }
     401        }
    344402
    345403}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/MyGLSurfaceView.java

    r15287 r17423  
    1111import android.view.MotionEvent;
    1212
    13 
    14 public class MyGLSurfaceView extends GLSurfaceView
    15 {
     13public class MyGLSurfaceView extends GLSurfaceView {
    1614        private MyGLRenderer mRend;
    1715        private DoubleBuffer db;
    1816        private int size;
    19         double vmax = 0, vmin=0;
    20         final int firstVelocity = 9; 
     17        double vmax = 0, vmin = 0;
     18        final int firstVelocity = 9;
    2119        ColorMap colorMap;
    2220        Velocity velocity;
     
    2422        float oldDist = 100.0f;
    2523        float newDist;
    26        
     24
    2725        int mode = 0;
    28     public MyGLSurfaceView(Context context, DoubleBuffer db, int size, ColorMap colorMap, Velocity velocity)
    29     {
    30         super(context);
    31         // Create an OpenGL ES 2.0 context.
    32         setEGLContextClientVersion(2);
    33         this.db = db;
    34         this.size = size;
    35         this.colorMap = colorMap;
    36         this.velocity = velocity;
    37         vmin = db.get(firstVelocity);
    38         findMinMaxVelocity();
    39         intialize();
    40         this.velocity.setVmin(vmin);
    41         this.velocity.setVmax(vmax);
    42     }
    43     private void intialize()
    44     {
    45         final int MAX_VERTICES = 21;
    46         float f[][] = new float[size][MAX_VERTICES];
    47         //indexes prefer to velocity at each vertices of triangles.
    48         double alpha1, alpha2, alpha3;
    49                 float  xmin,xmax,ymin,ymax;
    50         final double XSCALE_FACTOR = 1;
    51         final double YSCALE_FACTOR = 1.2;
    52         RGB rgb = new RGB();
     26
     27        public MyGLSurfaceView(Context context, DoubleBuffer db, int size,
     28                        ColorMap colorMap, Velocity velocity) {
     29                super(context);
     30                // Create an OpenGL ES 2.0 context.
     31                setEGLContextClientVersion(2);
     32                this.db = db;
     33                this.size = size;
     34                this.colorMap = colorMap;
     35                this.velocity = velocity;
     36                vmin = db.get(firstVelocity);
     37                findMinMaxVelocity();
     38                intialize();
     39                this.velocity.setVmin(vmin);
     40                this.velocity.setVmax(vmax);
     41        }
     42
     43        private void intialize() {
     44                final int MAX_VERTICES = 21;
     45                float f[][] = new float[size][MAX_VERTICES];
     46                // indexes prefer to velocity at each vertices of triangles.
     47                double alpha1, alpha2, alpha3;
     48                float xmin, xmax, ymin, ymax;
     49                final double XSCALE_FACTOR = 1;
     50                final double YSCALE_FACTOR = 1.2;
     51                RGB rgb = new RGB();
    5352
    5453                for (int i = 0; i < size; i++) {
    55                                 f[i][0] = (float)db.get(12*i+0);
    56                                 f[i][1] = (float)db.get(12*i+1);
    57                                 f[i][2] = (float)db.get(12*i+2);
    58                                 f[i][7] = (float)db.get(12*i+3);
    59                                 f[i][8] = (float)db.get(12*i+4);
    60                                 f[i][9] = (float)db.get(12*i+5);
    61                                 f[i][14] = (float)db.get(12*i+6);
    62                                 f[i][15] = (float)db.get(12*i+7);
    63                                 f[i][16] = (float)db.get(12*i+8);
    64                                
    65                                 f[i][6] = 1.0f;
    66                                 f[i][13] = 1.0f;
    67                                 f[i][20] = 1.0f;
    68                                
    69                                 alpha1 = getAlphaColor(db.get(12*i+9));
    70                                 alpha2 = getAlphaColor(db.get(12*i+10));
    71                                 alpha3 = getAlphaColor(db.get(12*i+11));
    72                                
    73                                 colorMap.getRGB(alpha1, rgb);
    74                                 float r1 = rgb.getR();
    75                                 float g1 = rgb.getG();
    76                                 float b1 = rgb.getB();
    77                                
    78                                 colorMap.getRGB(alpha2, rgb);
    79                                 float r2 = rgb.getR();
    80                                 float g2 = rgb.getG();
    81                                 float b2 = rgb.getB();
    82                                
    83                                 colorMap.getRGB(alpha3, rgb);
    84                                 float r3 = rgb.getR();
    85                                 float g3 = rgb.getG();
    86                                 float b3 = rgb.getB();
    87                                
    88                                
    89                                 f[i][3] = r1;
    90                                 f[i][4] = g1;
    91                                 f[i][5] = b1;
    92                                
    93                                 f[i][10] = r2;
    94                                 f[i][11] = g2;
    95                                 f[i][12] = b2;
    96                                
    97                                 f[i][17] = r3;
    98                                 f[i][18] = g3;
    99                                 f[i][19] = b3;
    100 
    101                 }
    102 
    103        
    104                 xmin=0; ymin=0; xmax=0; ymax=0;
     54                        f[i][0] = (float) db.get(12 * i + 0);
     55                        f[i][1] = (float) db.get(12 * i + 1);
     56                        f[i][2] = (float) db.get(12 * i + 2);
     57                        f[i][7] = (float) db.get(12 * i + 3);
     58                        f[i][8] = (float) db.get(12 * i + 4);
     59                        f[i][9] = (float) db.get(12 * i + 5);
     60                        f[i][14] = (float) db.get(12 * i + 6);
     61                        f[i][15] = (float) db.get(12 * i + 7);
     62                        f[i][16] = (float) db.get(12 * i + 8);
     63
     64                        f[i][6] = 1.0f;
     65                        f[i][13] = 1.0f;
     66                        f[i][20] = 1.0f;
     67
     68                        alpha1 = getAlphaColor(db.get(12 * i + 9));
     69                        alpha2 = getAlphaColor(db.get(12 * i + 10));
     70                        alpha3 = getAlphaColor(db.get(12 * i + 11));
     71
     72                        colorMap.getRGB(alpha1, rgb);
     73                        float r1 = rgb.getR();
     74                        float g1 = rgb.getG();
     75                        float b1 = rgb.getB();
     76
     77                        colorMap.getRGB(alpha2, rgb);
     78                        float r2 = rgb.getR();
     79                        float g2 = rgb.getG();
     80                        float b2 = rgb.getB();
     81
     82                        colorMap.getRGB(alpha3, rgb);
     83                        float r3 = rgb.getR();
     84                        float g3 = rgb.getG();
     85                        float b3 = rgb.getB();
     86
     87                        f[i][3] = r1;
     88                        f[i][4] = g1;
     89                        f[i][5] = b1;
     90
     91                        f[i][10] = r2;
     92                        f[i][11] = g2;
     93                        f[i][12] = b2;
     94
     95                        f[i][17] = r3;
     96                        f[i][18] = g3;
     97                        f[i][19] = b3;
     98
     99                }
     100
     101                xmin = 0;
     102                ymin = 0;
     103                xmax = 0;
     104                ymax = 0;
    105105
    106106                for (int i = 0; i < size; i++) {
    107                         if (f[i][0]<xmin) xmin=f[i][0];
    108                         if (f[i][0]>xmax) xmax=f[i][0];
    109 
    110                         if (f[i][1]<ymin) ymin=f[i][1];
    111                         if (f[i][1]>ymax) ymax=f[i][1];
    112                 }
    113                                
     107                        if (f[i][0] < xmin)
     108                                xmin = f[i][0];
     109                        if (f[i][0] > xmax)
     110                                xmax = f[i][0];
     111
     112                        if (f[i][1] < ymin)
     113                                ymin = f[i][1];
     114                        if (f[i][1] > ymax)
     115                                ymax = f[i][1];
     116                }
     117
    114118                for (int i = 0; i < size; i++) {
    115                                 f[i][0] =  (float)XSCALE_FACTOR*2*(f[i][0]-xmin)/(xmax-xmin)-1;
    116                                 f[i][1] =  (float)YSCALE_FACTOR*2*(f[i][1]-ymin)/(ymax-ymin)-1;
    117                                 f[i][7] =  (float)XSCALE_FACTOR*2*(f[i][7]-xmin)/(xmax-xmin)-1;
    118                                 f[i][8] =  (float)YSCALE_FACTOR*2*(f[i][8]-ymin)/(ymax-ymin)-1;
    119                                 f[i][14] =  (float)XSCALE_FACTOR*2*(f[i][14]-xmin)/(xmax-xmin)-1;
    120                                 f[i][15] =  (float)YSCALE_FACTOR*2*(f[i][15]-ymin)/(ymax-ymin)-1;
    121                 }
    122                                
    123                 File file1 = new File(ISSMAPP.extStorageDirectory + "/ISSM/input_files/coordinate.txt");
    124                 File file2 = new File(ISSMAPP.extStorageDirectory + "/ISSM/input_files/color.txt");
     119                        f[i][0] = (float) XSCALE_FACTOR * 2 * (f[i][0] - xmin)
     120                                        / (xmax - xmin) - 1;
     121                        f[i][1] = (float) YSCALE_FACTOR * 2 * (f[i][1] - ymin)
     122                                        / (ymax - ymin) - 1;
     123                        f[i][7] = (float) XSCALE_FACTOR * 2 * (f[i][7] - xmin)
     124                                        / (xmax - xmin) - 1;
     125                        f[i][8] = (float) YSCALE_FACTOR * 2 * (f[i][8] - ymin)
     126                                        / (ymax - ymin) - 1;
     127                        f[i][14] = (float) XSCALE_FACTOR * 2 * (f[i][14] - xmin)
     128                                        / (xmax - xmin) - 1;
     129                        f[i][15] = (float) YSCALE_FACTOR * 2 * (f[i][15] - ymin)
     130                                        / (ymax - ymin) - 1;
     131                }
     132
     133                File file1 = new File(ISSMAPP.extStorageDirectory
     134                                + "/ISSM/input_files/coordinate.txt");
     135                File file2 = new File(ISSMAPP.extStorageDirectory
     136                                + "/ISSM/input_files/color.txt");
    125137                try {
    126138                        file1.createNewFile();
     
    130142                        FileOutputStream fout2 = new FileOutputStream(file2);
    131143                        OutputStreamWriter write2 = new OutputStreamWriter(fout2);
    132                         for(int i = 0; i < size; i ++)
    133                         {
    134                                 write1.append(f[i][0]+","+f[i][1]+","+f[i][2]+","+f[i][7]+","+f[i][8]+","+f[i][9]+","+f[i][14]+","+f[i][15]+","+f[i][16]+"\n");
    135                                 write2.append(f[i][3]+","+f[i][4]+","+f[i][5]+","+f[i][10]+","+f[i][11]+","+f[i][12]+","+f[i][17]+","+f[i][18]+","+f[i][19]+"\n");
     144                        for (int i = 0; i < size; i++) {
     145                                write1.append(f[i][0] + "," + f[i][1] + "," + f[i][2] + ","
     146                                                + f[i][7] + "," + f[i][8] + "," + f[i][9] + ","
     147                                                + f[i][14] + "," + f[i][15] + "," + f[i][16] + "\n");
     148                                write2.append(f[i][3] + "," + f[i][4] + "," + f[i][5] + ","
     149                                                + f[i][10] + "," + f[i][11] + "," + f[i][12] + ","
     150                                                + f[i][17] + "," + f[i][18] + "," + f[i][19] + "\n");
    136151                        }
    137152                        write1.close();
     
    141156                        e.printStackTrace();
    142157                }
    143                
    144         mRend = new MyGLRenderer(f);
    145         // Set the Renderer for drawing on the GLSurfaceView
    146         setRenderer(mRend);
    147 
    148         // Render the view only when there is a change in the drawing data
    149         setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    150     }
    151     private void findMinMaxVelocity()
    152     {
    153         for(int i = 0; i < size*12; i++)
    154         {
    155                 if(i%12==9 || i%12==10 ||i%12==11 )
    156                 {
    157                         if (db.get(i) <  vmin) vmin = db.get(i);
    158                         if (db.get(i) >= vmax) vmax = db.get(i);
    159                 }
    160                 else continue;
    161         }
    162        
    163     } 
    164     private double getAlphaColor(double velocity)
    165     {
    166         return (velocity-vmin)/(vmax-vmin);
    167     }
    168    
    169     private final float TOUCH_SCALE_FACTOR = 180.0f / 320;
    170     private float mPreviousX;
    171    
    172     private float mPreviousY;
    173  // touch events
    174         private final int NONE = 0;
    175         private final int DRAG = 0;
    176         private final int ZOOM = 0;
    177     @Override
    178     public boolean onTouchEvent(MotionEvent e) /* NEW STUFF*/
     158
     159                mRend = new MyGLRenderer(f);
     160                // Set the Renderer for drawing on the GLSurfaceView
     161                setRenderer(mRend);
     162
     163                // Render the view only when there is a change in the drawing data
     164                setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
     165        }
     166
     167        private void findMinMaxVelocity() {
     168                for (int i = 0; i < size * 12; i++) {
     169                        if (i % 12 == 9 || i % 12 == 10 || i % 12 == 11) {
     170                                if (db.get(i) < vmin)
     171                                        vmin = db.get(i);
     172                                if (db.get(i) >= vmax)
     173                                        vmax = db.get(i);
     174                        } else
     175                                continue;
     176                }
     177
     178        }
     179
     180        private double getAlphaColor(double velocity) {
     181                return (velocity - vmin) / (vmax - vmin);
     182        }
     183
     184        private final float TOUCH_SCALE_FACTOR = 180.0f / 320;
     185        private float mPreviousX;
     186
     187        private float mPreviousY;
     188        // touch events
     189        private final int NONE = 0;
     190        private final int DRAG = 0;
     191        private final int ZOOM = 0;
     192
     193        @Override
     194        public boolean onTouchEvent(MotionEvent e) /* NEW STUFF */
    179195        {
    180196                float x = e.getX();
    181197                float y = e.getY();
    182198                switch (e.getAction()) {
    183                         case MotionEvent.ACTION_DOWN:                   // one touch: drag
    184                       mode = DRAG;
    185                       //mRend.eyeX = e.getX();
    186                       //mRend.eyeY = e.getY();
    187                       break;
    188                      
    189                         case MotionEvent.ACTION_POINTER_DOWN:   // two touches: zoom
    190                                 oldDist = spacing(e);
    191                                 if (oldDist > 10.0f)
    192                                         mode = ZOOM; // zoom
    193                                 break;
    194                                
    195                         case MotionEvent.ACTION_UP:             // no mode
    196                                 mode = NONE;
    197                                 oldDist = 100.0f;
    198                                 break;
    199                                
    200                         case MotionEvent.ACTION_POINTER_UP:             // no mode
    201                                 mode = NONE;
    202                                 oldDist = 100.0f;
    203                                 break;
    204                                
    205                         case MotionEvent.ACTION_MOVE:                                           // rotation
    206                                 if (e.getPointerCount() > 1 && mode == ZOOM)
    207                                 {
    208                                         newDist = spacing(e);
    209                                         if (newDist > 10.0f) {
    210                                                 float scale = newDist/oldDist; // scale
    211                                                
    212                                                 // scale in the renderer
    213                                                 mRend.changeScale(scale);
    214                                                 oldDist = newDist;
    215                                         }
     199                case MotionEvent.ACTION_DOWN: // one touch: drag
     200                        mode = DRAG;
     201                        // mRend.eyeX = e.getX();
     202                        // mRend.eyeY = e.getY();
     203                        break;
     204
     205                case MotionEvent.ACTION_POINTER_DOWN: // two touches: zoom
     206                        oldDist = spacing(e);
     207                        if (oldDist > 10.0f)
     208                                mode = ZOOM; // zoom
     209                        break;
     210
     211                case MotionEvent.ACTION_UP: // no mode
     212                        mode = NONE;
     213                        oldDist = 100.0f;
     214                        break;
     215
     216                case MotionEvent.ACTION_POINTER_UP: // no mode
     217                        mode = NONE;
     218                        oldDist = 100.0f;
     219                        break;
     220
     221                case MotionEvent.ACTION_MOVE: // rotation
     222                        if (e.getPointerCount() > 1 && mode == ZOOM) {
     223                                newDist = spacing(e);
     224                                if (newDist > 10.0f) {
     225                                        float scale = newDist / oldDist; // scale
     226
     227                                        // scale in the renderer
     228                                        mRend.changeScale(scale);
     229                                        oldDist = newDist;
    216230                                }
    217                                 else if (mode == DRAG)
    218                                 {
    219                                         float dx = x - mPreviousX;
    220                                         float dy = y - mPreviousY;
    221                                        
    222                                         mRend.mAngleX += dx * TOUCH_SCALE_FACTOR;
    223                                         mRend.mAngleY += dy * TOUCH_SCALE_FACTOR;
    224 
    225                                         requestRender();
    226                                 }
    227                                 break;
     231                        } else if (mode == DRAG) {
     232                                float dx = x - mPreviousX;
     233                                float dy = y - mPreviousY;
     234
     235                                mRend.mAngleX += dx * TOUCH_SCALE_FACTOR;
     236                                mRend.mAngleY += dy * TOUCH_SCALE_FACTOR;
     237
     238                                requestRender();
     239                        }
     240                        break;
    228241                }
    229242                mPreviousX = x;
     
    231244                return true;
    232245        }
    233        
    234         private float spacing(MotionEvent event) /* NEW STUFF*/
     246
     247        private float spacing(MotionEvent event) /* NEW STUFF */
    235248        {
    236249                float x = event.getX(0) - event.getX(1);
     
    238251                return FloatMath.sqrt(x * x + y * y);
    239252        }
    240        
    241         public void resetZoom()
    242         {
     253
     254        public void resetZoom() {
    243255                mRend.defaultScale();
    244256        }
    245        
     257
    246258}
    247 
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/MyWebViewClient.java

    r14547 r17423  
    11package gov.nasa.jpl.issm;
    22
     3import android.view.View;
    34import android.webkit.WebView;
    45import android.webkit.WebViewClient;
    56
    67public class MyWebViewClient extends WebViewClient {
    7        
     8
    89        @Override
    9     public boolean shouldOverrideUrlLoading(WebView view, String url) {
    10        
    11             // This is my web site, so do not override; let my WebView load the page
    12             return false;
    13    
    14     }
     10        public boolean shouldOverrideUrlLoading(WebView view, String url) {
     11
     12                // This is my web site, so do not override; let my WebView load the page
     13                return false;
     14
     15        }
     16
     17        public void onPageStarted(WebView view, String url) {
     18                // TODO Auto-generated method stub
     19
     20        }
    1521
    1622}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/SliderMenu.java

    r16081 r17423  
    99import android.widget.SeekBar.OnSeekBarChangeListener;
    1010
    11 public class SliderMenu extends RelativeLayout{
     11public class SliderMenu extends RelativeLayout {
    1212
    1313        private SeekBar frictionBar;
     
    1919        final int MINIMUM = 90;
    2020        View view;
     21
    2122        public SliderMenu(Context context) {
    2223                super(context);
    23                 LayoutInflater mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    24                 if( mInflater != null)
    25                 {
     24                LayoutInflater mInflater = (LayoutInflater) context
     25                                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     26                if (mInflater != null) {
    2627                        view = mInflater.inflate(R.layout.settingsmenu, this, true);
    2728                }
    2829                initialize();
    2930        }
    30         public void initialize()
    31         {
     31
     32        public void initialize() {
    3233                frictionBar = (SeekBar) this.findViewById(R.id.frictionBar);
    3334                tempBar = (SeekBar) this.findViewById(R.id.tempBar);
    3435                seaLevelBar = (SeekBar) this.findViewById(R.id.sealvlBar);
    3536                fric = (TextView) this.findViewById(R.id.fric);
    36         temp = (TextView) this.findViewById(R.id.temp);
    37         sealvl  = (TextView) this.findViewById(R.id.sealvl);
    38         tempBar.setVisibility(INVISIBLE);
    39         seaLevelBar.setVisibility(INVISIBLE);
    40         temp.setVisibility(INVISIBLE);
    41         sealvl.setVisibility(INVISIBLE);
    42         friction = MINIMUM + OFFSET;
    43         temperature = MINIMUM + OFFSET;
    44         sealevel = MINIMUM + OFFSET;
    45         setListenner();
     37                temp = (TextView) this.findViewById(R.id.temp);
     38                sealvl = (TextView) this.findViewById(R.id.sealvl);
     39                tempBar.setVisibility(INVISIBLE);
     40                seaLevelBar.setVisibility(INVISIBLE);
     41                temp.setVisibility(INVISIBLE);
     42                sealvl.setVisibility(INVISIBLE);
     43                friction = MINIMUM + OFFSET;
     44                temperature = MINIMUM + OFFSET;
     45                sealevel = MINIMUM + OFFSET;
     46                setListenner();
    4647        }
    47         private void setListenner()
    48         {
    49                 frictionBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
    50         {
    51                 public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
    52                 {
    53                                
    54                         friction = progress + OFFSET;
    55                         fric.setText("Friction: " + friction + "%");
    56                 }
    5748
    58                     @Override
    59                     public void onStartTrackingTouch(SeekBar seekBar) {}
    60        
    61                     @Override
    62                     public void onStopTrackingTouch(SeekBar seekBar) {}
    63         });
    64         tempBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
    65         {
    66                 public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
    67                 {
    68                                
    69                         temperature = progress + OFFSET;
    70                         temp.setText("Temperature: " + temperature + "%");
    71                 }
     49        private void setListenner() {
     50                frictionBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
     51                        public void onProgressChanged(SeekBar seekBar, int progress,
     52                                        boolean fromUser) {
    7253
    73                     @Override
    74                     public void onStartTrackingTouch(SeekBar seekBar) {}
    75        
    76                     @Override
    77                     public void onStopTrackingTouch(SeekBar seekBar) {}
    78         });
    79         seaLevelBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
    80         {
    81                 public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
    82                 {
    83                                
    84                         sealevel = progress + OFFSET;
    85                         sealvl.setText("Sea Level: " + sealevel + "%");
    86                 }
     54                                friction = progress + OFFSET;
     55                                fric.setText("Friction: " + friction + "%");
     56                        }
    8757
    88                     @Override
    89                     public void onStartTrackingTouch(SeekBar seekBar) {}
    90        
    91                     @Override
    92                     public void onStopTrackingTouch(SeekBar seekBar) {}
    93         });
     58                        @Override
     59                        public void onStartTrackingTouch(SeekBar seekBar) {
     60                        }
     61
     62                        @Override
     63                        public void onStopTrackingTouch(SeekBar seekBar) {
     64                        }
     65                });
     66                tempBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
     67                        public void onProgressChanged(SeekBar seekBar, int progress,
     68                                        boolean fromUser) {
     69
     70                                temperature = progress + OFFSET;
     71                                temp.setText("Temperature: " + temperature + "%");
     72                        }
     73
     74                        @Override
     75                        public void onStartTrackingTouch(SeekBar seekBar) {
     76                        }
     77
     78                        @Override
     79                        public void onStopTrackingTouch(SeekBar seekBar) {
     80                        }
     81                });
     82                seaLevelBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
     83                        public void onProgressChanged(SeekBar seekBar, int progress,
     84                                        boolean fromUser) {
     85
     86                                sealevel = progress + OFFSET;
     87                                sealvl.setText("Sea Level: " + sealevel + "%");
     88                        }
     89
     90                        @Override
     91                        public void onStartTrackingTouch(SeekBar seekBar) {
     92                        }
     93
     94                        @Override
     95                        public void onStopTrackingTouch(SeekBar seekBar) {
     96                        }
     97                });
    9498        }
    95         public int getFric() {return friction;}
    96         public int getTemp() {return temperature;}
    97         public int getSea()  {return sealevel;}
     99
     100        public int getFric() {
     101                return friction;
     102        }
     103
     104        public int getTemp() {
     105                return temperature;
     106        }
     107
     108        public int getSea() {
     109                return sealevel;
     110        }
    98111}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/SwapViews.java

    r14563 r17423  
    1212        ImageView infoImage;
    1313        TextView text;
    14        
     14
    1515        public SwapViews(boolean isFirstView, ImageView image, TextView text) {
    16          mIsFirstView = isFirstView;
    17          containTextView = true;
    18          this.mainImage = image;
    19          this.text = text;
     16                mIsFirstView = isFirstView;
     17                containTextView = true;
     18                this.mainImage = image;
     19                this.text = text;
    2020        }
    21        
     21
    2222        public SwapViews(boolean isFirstView, ImageView front, ImageView back) {
    2323                mIsFirstView = isFirstView;
    24                  containTextView = false;
    25                  this.mainImage = front;
    26                  this.infoImage = back;
     24                containTextView = false;
     25                this.mainImage = front;
     26                this.infoImage = back;
    2727        }
    28        
     28
    2929        public void run() {
    30          final float centerX = mainImage.getWidth() / 2.0f;
    31          final float centerY = mainImage.getHeight() / 2.0f;
    32          FlipAnimation rotation;
    33        
    34          if (mIsFirstView)
    35          {
    36                  mainImage.setVisibility(View.GONE);
    37                  if(containTextView)
    38                  {
    39                          text.setVisibility(View.VISIBLE);
    40                          text.requestFocus();
    41                  }
    42                  else
    43                  {
    44                     infoImage.setVisibility(View.VISIBLE);
    45                         infoImage.requestFocus();
    46                  }
    47              rotation = new FlipAnimation(-90, 0, centerX, centerY);
    48          } else
    49          {
    50                  if(containTextView)
    51                  {
    52                          text.setVisibility(View.GONE);
    53                  }
    54                  else infoImage.setVisibility(View.GONE);
    55                  mainImage.setVisibility(View.VISIBLE);
    56                  mainImage.requestFocus();
    57        
    58              rotation = new FlipAnimation(90, 0, centerX, centerY);
    59          }
    60        
    61          rotation.setDuration(500);
    62          rotation.setFillAfter(true);
    63          rotation.setInterpolator(new DecelerateInterpolator());
    64        
    65          if (mIsFirstView)
    66          {
    67                  if(containTextView)
    68                          text.startAnimation(rotation);
    69                  else
    70                          infoImage.setAnimation(rotation);
    71          }
    72          else
    73          {
    74                  mainImage.startAnimation(rotation);
    75          }
    76    }
     30                final float centerX = mainImage.getWidth() / 2.0f;
     31                final float centerY = mainImage.getHeight() / 2.0f;
     32                FlipAnimation rotation;
     33
     34                if (mIsFirstView) {
     35                        mainImage.setVisibility(View.GONE);
     36                        if (containTextView) {
     37                                text.setVisibility(View.VISIBLE);
     38                                text.requestFocus();
     39                        } else {
     40                                infoImage.setVisibility(View.VISIBLE);
     41                                infoImage.requestFocus();
     42                        }
     43                        rotation = new FlipAnimation(-90, 0, centerX, centerY);
     44                } else {
     45                        if (containTextView) {
     46                                text.setVisibility(View.GONE);
     47                        } else
     48                                infoImage.setVisibility(View.GONE);
     49                        mainImage.setVisibility(View.VISIBLE);
     50                        mainImage.requestFocus();
     51
     52                        rotation = new FlipAnimation(90, 0, centerX, centerY);
     53                }
     54
     55                rotation.setDuration(500);
     56                rotation.setFillAfter(true);
     57                rotation.setInterpolator(new DecelerateInterpolator());
     58
     59                if (mIsFirstView) {
     60                        if (containTextView)
     61                                text.startAnimation(rotation);
     62                        else
     63                                infoImage.setAnimation(rotation);
     64                } else {
     65                        mainImage.startAnimation(rotation);
     66                }
     67        }
    7768}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/TeamActivity.java

    r14547 r17423  
    11package gov.nasa.jpl.issm;
    22
    3 import android.app.Activity;
     3import android.app.ProgressDialog;
     4import android.content.Context;
     5import android.content.Intent;
     6import android.net.ConnectivityManager;
     7import android.net.NetworkInfo;
    48//import android.net.Uri;
    59import android.os.Bundle;
     10import android.util.Log;
     11import android.view.Menu;
     12import android.view.MenuItem;
     13import android.view.View;
    614import android.webkit.WebView;
     15import android.widget.Button;
    716import gov.nasa.jpl.issm.MyWebViewClient;
    817
    9 public class TeamActivity extends Activity {
     18public class TeamActivity extends BaseActivity {
    1019
    1120        String SrcPath = "http://issm.jpl.nasa.gov/about/";
    12        
     21
    1322        private WebView myWebView;
    14        
    15            /** Called when the activity is first created. */
    16            @Override       
    17                 public void onCreate(Bundle savedInstanceState) {
    18                         super.onCreate(savedInstanceState);
    19                         setContentView(R.layout.teampage);
    20                        
    21                        
    22          
    23                         //webView = (WebView) findViewById(R.id.teampage);
    24                         myWebView = (WebView) findViewById(R.id.teampage);
    25                         myWebView.setWebViewClient(new MyWebViewClient());
    26                         myWebView.getSettings().setJavaScriptEnabled(true);
    27                         myWebView.loadUrl(SrcPath);
    28            }
    2923
     24        /** Called when the activity is first created. */
     25        @Override
     26        public void onCreate(Bundle savedInstanceState) {
     27                super.onCreate(savedInstanceState);
     28                setContentView(R.layout.teampage);
     29                transition();
     30                final ProgressDialog loading = new ProgressDialog(this);
     31                loading.setMessage("Loading page...");
     32                loading.setCancelable(false);
     33                final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
     34                if (conMgr.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED
     35                                || conMgr.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED) {
     36                        loading.show();
     37                }
     38                // else if (conMgr.getNetworkInfo(0).getState() ==
     39                // NetworkInfo.State.DISCONNECTED
     40                // || conMgr.getNetworkInfo(1).getState() ==
     41                // NetworkInfo.State.DISCONNECTED) {
     42                // }
     43
     44                // Go back to the main menu
     45                Button homeTab = (Button) findViewById(R.id.play_tab);
     46                homeTab.setOnClickListener(new View.OnClickListener() {
     47                        public void onClick(View v) {
     48                                Intent i = new Intent(TeamActivity.this, MenuPage.class);
     49                                startActivity(i);
     50                                finish();
     51                        }
     52                });
     53                // navigate to youtube video
     54                Button video = (Button) findViewById(R.id.video_tab);
     55                video.setOnClickListener(new View.OnClickListener() {
     56                        public void onClick(View v) {
     57                                // String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
     58                                // Intent i = new Intent(Intent.ACTION_VIEW);
     59                                // i.setData(Uri.parse(url));
     60                                Intent i = new Intent(TeamActivity.this, VideoActivity.class);
     61                                startActivity(i);
     62                                finish();
     63                        }
     64                });
     65                // pop up a text box that contains information about ISSM
     66                final Button intro = (Button) findViewById(R.id.about_tab);
     67                intro.setOnClickListener(new View.OnClickListener() {
     68                        public void onClick(View v) {
     69                                // LayoutInflater layoutInflater =
     70                                // (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
     71                                // View popupView = layoutInflater.inflate(R.layout.popuptext,
     72                                // null);
     73                                // final PopupWindow popupWindow = new PopupWindow( popupView,
     74                                // 400,600, true);
     75                                // popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
     76                                // Button dismiss =
     77                                // (Button)popupView.findViewById(R.id.dismiss);
     78                                // dismiss.setOnClickListener(new Button.OnClickListener()
     79                                // {
     80                                // public void onClick(View v)
     81                                // {
     82                                // popupWindow.dismiss();
     83                                // }
     84                                // });
     85                                Intent i = new Intent(TeamActivity.this, AboutActivity.class);
     86                                startActivity(i);
     87                                finish();
     88                        }
     89                });
     90                // Show Team Website
     91                // Button visitus = (Button) findViewById(R.id.team_tab);
     92                // visitus.setOnClickListener(new View.OnClickListener() {
     93                // public void onClick(View v) {
     94                // // String url = "http://issm.jpl.nasa.gov/";
     95                // // Intent i = new Intent(Intent.ACTION_VIEW);
     96                // // i.setData(Uri.parse(url));
     97                // // startActivity(i);
     98                //
     99                // Intent i = new Intent(TeamActivity.this, TeamActivity.class);
     100                // startActivity(i);
     101                // }
     102                // });
     103                // start gallery image
     104                Button galleryImage = (Button) findViewById(R.id.gallery_tab);
     105                galleryImage.setOnClickListener(new View.OnClickListener() {
     106                        public void onClick(View v) {
     107                                Intent i = new Intent(TeamActivity.this, GalleryImage.class);
     108                                startActivity(i);
     109                                finish();
     110                        }
     111                });
     112
     113                // webView = (WebView) findViewById(R.id.teampage);
     114                myWebView = (WebView) findViewById(R.id.teampage);
     115                myWebView.setWebViewClient(new MyWebViewClient() {
     116                        @Override
     117                        public boolean shouldOverrideUrlLoading(WebView view, String url) {
     118
     119                                Log.i("srcUrl: ", SrcPath);
     120                                Log.i("newUrl: ", url);
     121                                if (conMgr.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED
     122                                                || conMgr.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED) {
     123                                        loading.show();
     124                                }
     125                                return false;
     126                        }
     127
     128                        @Override
     129                        public void onPageFinished(WebView view, String url) {
     130                                // hide loading
     131                                loading.dismiss();
     132                        }
     133                });
     134                myWebView.getSettings().setJavaScriptEnabled(true);
     135                myWebView.loadUrl(SrcPath);
     136        }
     137
     138        // -------------------------------------------------------------------------------------
     139
     140        @Override
     141        public void onBackPressed() {
     142                if (myWebView.canGoBack()) {
     143                        myWebView.goBack();
     144                } else {
     145                        Intent i = new Intent(TeamActivity.this, MenuPage.class);
     146                        startActivity(i);
     147                        finish();
     148                }
     149        }
     150
     151        @Override
     152        public boolean onCreateOptionsMenu(Menu menu) {
     153                getMenuInflater().inflate(R.menu.team_menu, menu);
     154                return true;
     155        }
     156
     157        @Override
     158        public boolean onOptionsItemSelected(MenuItem item) {
     159                switch (item.getItemId()) {
     160                case R.id.refresh:
     161                        myWebView.loadUrl(myWebView.getOriginalUrl());
     162                        break;
     163                default:
     164                        break;
     165                }
     166
     167                return true;
     168        }
    30169}
    31 
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/VerticalSeekBar.java

    r14472 r17423  
    99public class VerticalSeekBar extends SeekBar {
    1010
    11     public VerticalSeekBar(Context context) {
    12         super(context);
    13     }
     11        public VerticalSeekBar(Context context) {
     12                super(context);
     13        }
    1414
    15     public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
    16         super(context, attrs, defStyle);
    17     }
     15        public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
     16                super(context, attrs, defStyle);
     17        }
    1818
    19     public VerticalSeekBar(Context context, AttributeSet attrs) {
    20         super(context, attrs);
    21     }
     19        public VerticalSeekBar(Context context, AttributeSet attrs) {
     20                super(context, attrs);
     21        }
    2222
    23     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    24         super.onSizeChanged(h, w, oldh, oldw);
    25     }
     23        protected void onSizeChanged(int w, int h, int oldw, int oldh) {
     24                super.onSizeChanged(h, w, oldh, oldw);
     25        }
    2626
    27     @Override
    28     protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    29         super.onMeasure(heightMeasureSpec, widthMeasureSpec);
    30         setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
    31     }
     27        @Override
     28        protected synchronized void onMeasure(int widthMeasureSpec,
     29                        int heightMeasureSpec) {
     30                super.onMeasure(heightMeasureSpec, widthMeasureSpec);
     31                setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
     32        }
    3233
    33     protected void onDraw(Canvas c) {
    34         c.rotate(-90);
    35         c.translate(-getHeight(),0);
    36         super.onDraw(c);
    37     }
     34        protected void onDraw(Canvas c) {
     35                c.rotate(-90);
     36                c.translate(-getHeight(), 0);
     37                super.onDraw(c);
     38        }
    3839
    39     @Override
    40     public boolean onTouchEvent(MotionEvent event) {
    41         if (!isEnabled()) {
    42             return false;
    43         }
    44         int i = 0;
    45         switch (event.getAction()) {
    46             case MotionEvent.ACTION_DOWN:
    47             case MotionEvent.ACTION_MOVE:
    48             case MotionEvent.ACTION_UP:
    49                 i = getMax() - (int) (getMax() * event.getY() / getHeight());
    50                 setProgress(i);
    51                 onSizeChanged(getWidth(), getHeight(), 0, 0);
    52                 break;
     40        @Override
     41        public boolean onTouchEvent(MotionEvent event) {
     42                if (!isEnabled()) {
     43                        return false;
     44                }
     45                int i = 0;
     46                switch (event.getAction()) {
     47                case MotionEvent.ACTION_DOWN:
     48                case MotionEvent.ACTION_MOVE:
     49                case MotionEvent.ACTION_UP:
     50                        i = getMax() - (int) (getMax() * event.getY() / getHeight());
     51                        setProgress(i);
     52                        onSizeChanged(getWidth(), getHeight(), 0, 0);
     53                        break;
    5354
    54             case MotionEvent.ACTION_CANCEL:
    55                 break;
    56         }
    57         return true;
    58     }
     55                case MotionEvent.ACTION_CANCEL:
     56                        break;
     57                }
     58                return true;
     59        }
    5960}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/VideoActivity.java

    r14608 r17423  
    11package gov.nasa.jpl.issm;
    22
     3import com.google.android.youtube.player.YouTubeBaseActivity;
     4import com.google.android.youtube.player.YouTubeInitializationResult;
     5import com.google.android.youtube.player.YouTubePlayer;
     6import com.google.android.youtube.player.YouTubePlayer.Provider;
     7import com.google.android.youtube.player.YouTubePlayerView;
     8
     9import android.app.ActionBar;
    310import android.app.Activity;
     11import android.content.Intent;
    412import android.net.Uri;
    513import android.os.Bundle;
     14import android.view.KeyEvent;
     15import android.view.View;
     16import android.webkit.WebView;
     17import android.widget.Button;
    618import android.widget.MediaController;
     19import android.widget.TextView;
     20import android.widget.TextView.OnEditorActionListener;
     21import android.widget.Toast;
    722import android.widget.VideoView;
    823
    9 public class VideoActivity extends Activity {
     24public class VideoActivity extends YouTubeBaseActivity implements
     25                YouTubePlayer.OnInitializedListener {
     26        // String SrcPath =
     27        // "rtsp://v2.cache1.c.youtube.com/CjYLENy73wIaLQkXH3-3kcYu1RMYDSANFEIJbXYtZ29vZ2xlSARSBXdhdGNoYI-SyfPGoqqyUQw=/0/0/0/video.3gp";
     28        static private final String DEV_KEY = "AIzaSyBl8llEnYKwVp_myQGPNKtZYtHxvUUkqrc";
     29        static private final String VIDEO = "GuScXQznl9E";
     30        private YouTubePlayerView ytView;
     31        private YouTubePlayer ytPlayer;
    1032
    11         String SrcPath = "rtsp://v2.cache1.c.youtube.com/CjYLENy73wIaLQkXH3-3kcYu1RMYDSANFEIJbXYtZ29vZ2xlSARSBXdhdGNoYI-SyfPGoqqyUQw=/0/0/0/video.3gp";
    12        
    13            /** Called when the activity is first created. */
    14            @Override
    15            public void onCreate(Bundle savedInstanceState) {
    16                super.onCreate(savedInstanceState);
    17                setContentView(R.layout.videopage);         
    18                VideoView myVideoView = (VideoView)findViewById(R.id.videoview);
    19                myVideoView.setVideoURI(Uri.parse(SrcPath));
    20                myVideoView.setMediaController(new MediaController(this));
    21                myVideoView.requestFocus();
    22                myVideoView.start();
    23            }
     33        //
     34        // /** Called when the activity is first created. */
     35        // @Override
     36        // public void onCreate(Bundle savedInstanceState) {
     37        // super.onCreate(savedInstanceState);
     38        // setContentView(R.layout.videopage);
     39        // VideoView myVideoView = (VideoView)findViewById(R.id.videoview);
     40        // myVideoView.setVideoURI(Uri.parse(SrcPath));
     41        // myVideoView.setMediaController(new MediaController(this));
     42        // myVideoView.requestFocus();
     43        // myVideoView.start();
     44        // }
     45        @Override
     46        public void onCreate(Bundle savedInstanceState) {
     47                super.onCreate(savedInstanceState);
     48                getActionBar().setCustomView(R.layout.actionbar_top);
     49                getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
     50                overridePendingTransition(R.anim.right_in, R.anim.left_out);
     51                setContentView(R.layout.videopage);
     52                ytView = (YouTubePlayerView) findViewById(R.id.youtubeplayer);
     53                ytView.initialize(DEV_KEY, this);
     54
     55                // Go back to the main menu
     56                Button start = (Button) findViewById(R.id.play_tab);
     57                start.setOnClickListener(new View.OnClickListener() {
     58                        public void onClick(View v) {
     59                                Intent i = new Intent(VideoActivity.this, MenuPage.class);
     60                                startActivity(i);
     61                                finish();
     62                        }
     63                });
     64                // navigate to youtube video
     65                // Button video = (Button) findViewById(R.id.video_tab);
     66                // video.setOnClickListener(new View.OnClickListener() {
     67                // public void onClick(View v) {
     68                // // String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
     69                // // Intent i = new Intent(Intent.ACTION_VIEW);
     70                // // i.setData(Uri.parse(url));
     71                // Intent i = new Intent(VideoActivity.this, VideoActivity.class);
     72                // startActivity(i);
     73                // finish();
     74                // }
     75                // });
     76                // pop up a text box that contains information about ISSM
     77                final Button intro = (Button) findViewById(R.id.about_tab);
     78                intro.setOnClickListener(new View.OnClickListener() {
     79                        public void onClick(View v) {
     80                                // LayoutInflater layoutInflater =
     81                                // (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
     82                                // View popupView = layoutInflater.inflate(R.layout.popuptext,
     83                                // null);
     84                                // final PopupWindow popupWindow = new PopupWindow( popupView,
     85                                // 400,600, true);
     86                                // popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
     87                                // Button dismiss =
     88                                // (Button)popupView.findViewById(R.id.dismiss);
     89                                // dismiss.setOnClickListener(new Button.OnClickListener()
     90                                // {
     91                                // public void onClick(View v)
     92                                // {
     93                                // popupWindow.dismiss();
     94                                // }
     95                                // });
     96                                Intent i = new Intent(VideoActivity.this, AboutActivity.class);
     97                                startActivity(i);
     98                                finish();
     99                        }
     100                });
     101                // Show Team Website
     102                Button visitus = (Button) findViewById(R.id.team_tab);
     103                visitus.setOnClickListener(new View.OnClickListener() {
     104                        public void onClick(View v) {
     105                                // String url = "http://issm.jpl.nasa.gov/";
     106                                // Intent i = new Intent(Intent.ACTION_VIEW);
     107                                // i.setData(Uri.parse(url));
     108                                // startActivity(i);
     109
     110                                Intent i = new Intent(VideoActivity.this, TeamActivity.class);
     111                                startActivity(i);
     112                                finish();
     113                        }
     114                });
     115                // start gallery image
     116                Button galleryImage = (Button) findViewById(R.id.gallery_tab);
     117                galleryImage.setOnClickListener(new View.OnClickListener() {
     118                        public void onClick(View v) {
     119                                Intent i = new Intent(VideoActivity.this, GalleryImage.class);
     120                                startActivity(i);
     121                                finish();
     122                        }
     123                });
     124
     125        }
     126
     127        @Override
     128        public void onInitializationFailure(Provider provider,
     129                        YouTubeInitializationResult error) {
     130                Toast.makeText(this, "Initialization Fail! " + error.toString(),
     131                                Toast.LENGTH_LONG).show();
     132        }
     133
     134        @Override
     135        public void onInitializationSuccess(Provider provider,
     136                        YouTubePlayer player, boolean bool) {
     137                ytPlayer = player;
     138                Toast.makeText(this, "Initialization  Success.", Toast.LENGTH_LONG)
     139                                .show();
     140                ytPlayer.loadVideo(VIDEO);
     141
     142        }
     143
     144        @Override
     145        public void onBackPressed() {
     146                Intent i = new Intent(VideoActivity.this, MenuPage.class);
     147                startActivity(i);
     148                finish();
     149        }
    24150
    25151}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ZoomImageView.java

    r15013 r17423  
    1616package gov.nasa.jpl.issm;
    1717
     18import java.io.BufferedInputStream;
     19import java.io.IOException;
     20import java.io.InputStream;
     21
    1822import android.content.Context;
     23import android.content.Intent;
    1924import android.graphics.Bitmap;
    2025import android.graphics.Canvas;
     
    2631import android.view.View;
    2732
     33public class ZoomImageView extends View {
     34        private static final int INVALID_POINTER_ID = -1;
     35        private Bitmap b;
     36        private Drawable mIcon;
     37        private float mPosX;
     38        private float mPosY;
     39        private float mLastTouchX;
     40        private float mLastTouchY;
     41        private int mActivePointerId = INVALID_POINTER_ID;
    2842
    29 public class ZoomImageView extends View {
    30     private static final int INVALID_POINTER_ID = -1;
    31     private Bitmap b;
    32     private Drawable mIcon;
    33     private float mPosX;
    34     private float mPosY;
    35     private float mLastTouchX;
    36     private float mLastTouchY;
    37     private int mActivePointerId = INVALID_POINTER_ID;
    38    
    39     private ScaleGestureDetector mScaleDetector;
    40     private float mScaleFactor = 1.f;
    41    
    42    
    43     public ZoomImageView(Context context, int i) {
    44         this(context, null, 0, i);
    45     }
    46    
    47     public ZoomImageView(Context context, AttributeSet attrs, int i) {
    48         this(context, attrs, 0 ,i);
    49     }
    50    
    51    
    52     public ZoomImageView(Context context, AttributeSet attrs, int defStyle, int i) {
    53         super(context, attrs, defStyle);
    54         int resID2 = getResources().getIdentifier("image"+i, "drawable", context.getPackageName());
    55         //mIcon = getResources().getDrawable(resID);
    56         int width= context.getResources().getDisplayMetrics().widthPixels;
    57         int height= context.getResources().getDisplayMetrics().heightPixels;
    58        
    59        
    60         b = ImageResizer.decodeSampledBitmapFromResource(getResources(), resID2, width, height);
    61         b = Bitmap.createScaledBitmap(b, width, height, true);
    62         mIcon = new BitmapDrawable(getResources(), b);
    63         mIcon.setBounds(0, 0, width, height);
    64         mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
    65     }
     43        private ScaleGestureDetector mScaleDetector;
     44        private float mScaleFactor = 1.f;
     45
     46        public ZoomImageView(Context context, int i) {
     47                this(context, null, 0, i);
     48        }
     49
     50        public ZoomImageView(Context context, AttributeSet attrs, int i) {
     51                this(context, attrs, 0, i);
     52        }
     53
     54        public ZoomImageView(Context context, AttributeSet attrs, int defStyle,
     55                        int i) {
     56                super(context, attrs, defStyle);
     57                int resId = getResources().getIdentifier("image" + i, "drawable",
     58                                context.getPackageName());
     59                // mIcon = getResources().getDrawable(resID);
     60                int width = context.getResources().getDisplayMetrics().widthPixels;
     61                int height = context.getResources().getDisplayMetrics().heightPixels;
     62
     63                // replace with i to represent the image#.png in assets
     64                InputStream is = null;
     65                try {
     66                        is = new BufferedInputStream(context.getAssets().open(
     67                                        "image" + i + ".png"));
     68                } catch (IOException e) {
     69                        // TODO Auto-generated catch block
     70                        e.printStackTrace();
     71                }
     72                // pre-load
     73                b = ImageList.getLargeImages().get(i);
     74                // asset
     75                // b = ImageResizer.decodeSampledBitmapFromAsset(is, width, height);
     76                // resource
     77                // b =
     78                // ImageResizer.decodeSampledBitmapFromResource(context.getResources(),
     79                // resId, width, height);
     80                // b = Bitmap.createScaledBitmap(b, width, height, true);
     81                mIcon = new BitmapDrawable(getResources(), b);
     82                mIcon.setBounds(0, 0, width, height);
     83                mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
     84        }
    6685
    6786        @Override
    68     public boolean onTouchEvent(MotionEvent ev) {
    69         // Let the ScaleGestureDetector inspect all events.
    70         mScaleDetector.onTouchEvent(ev);
    71        
    72         final int action = ev.getAction();
    73         switch (action & MotionEvent.ACTION_MASK) {
    74         case MotionEvent.ACTION_DOWN: {
    75             final float x = ev.getX();
    76             final float y = ev.getY();
    77            
    78             mLastTouchX = x;
    79             mLastTouchY = y;
    80             mActivePointerId = ev.getPointerId(0);
    81             break;
    82         }
    83            
    84         case MotionEvent.ACTION_MOVE: {
    85             final int pointerIndex = ev.findPointerIndex(mActivePointerId);
    86            
    87             final float x = ev.getX(pointerIndex);
    88             final float y = ev.getY(pointerIndex);
     87        public boolean onTouchEvent(MotionEvent ev) {
     88                // Let the ScaleGestureDetector inspect all events.
     89                mScaleDetector.onTouchEvent(ev);
    8990
    90             // Only move if the ScaleGestureDetector isn't processing a gesture.
    91             if (!mScaleDetector.isInProgress()) {
    92                 final float dx = x - mLastTouchX;
    93                 final float dy = y - mLastTouchY;
     91                final int action = ev.getAction();
     92                switch (action & MotionEvent.ACTION_MASK) {
     93                case MotionEvent.ACTION_DOWN: {
     94                        final float x = ev.getX();
     95                        final float y = ev.getY();
    9496
    95                 mPosX += dx;
    96                 mPosY += dy;
     97                        mLastTouchX = x;
     98                        mLastTouchY = y;
     99                        mActivePointerId = ev.getPointerId(0);
     100                        break;
     101                }
    97102
    98                 invalidate();
    99             }
     103                case MotionEvent.ACTION_MOVE: {
     104                        final int pointerIndex = ev.findPointerIndex(mActivePointerId);
    100105
    101             mLastTouchX = x;
    102             mLastTouchY = y;
     106                        final float x = ev.getX(pointerIndex);
     107                        final float y = ev.getY(pointerIndex);
    103108
    104             break;
    105         }
    106            
    107         case MotionEvent.ACTION_UP: {
    108             mActivePointerId = INVALID_POINTER_ID;
    109             break;
    110         }
    111            
    112         case MotionEvent.ACTION_CANCEL: {
    113             mActivePointerId = INVALID_POINTER_ID;
    114             break;
    115         }
    116        
    117         case MotionEvent.ACTION_POINTER_UP: {
    118             final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK)
    119                     >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
    120             final int pointerId = ev.getPointerId(pointerIndex);
    121             if (pointerId == mActivePointerId) {
    122                 // This was our active pointer going up. Choose a new
    123                 // active pointer and adjust accordingly.
    124                 final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
    125                 mLastTouchX = ev.getX(newPointerIndex);
    126                 mLastTouchY = ev.getY(newPointerIndex);
    127                 mActivePointerId = ev.getPointerId(newPointerIndex);
    128             }
    129             break;
    130         }
    131         }
    132        
    133         return true;
    134     }
     109                        // Only move if the ScaleGestureDetector isn't processing a gesture.
     110                        if (!mScaleDetector.isInProgress()) {
     111                                final float dx = x - mLastTouchX;
     112                                final float dy = y - mLastTouchY;
    135113
    136     @Override
    137     public void onDraw(Canvas canvas) {
    138         super.onDraw(canvas);
    139        
    140         canvas.save();
    141         canvas.translate(mPosX, mPosY);
    142         canvas.scale(mScaleFactor, mScaleFactor);
    143         mIcon.draw(canvas);
    144        // canvas.drawBitmap(b,0,0,null);
    145         canvas.restore();
    146     }
     114                                mPosX += dx;
     115                                mPosY += dy;
    147116
    148     private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
    149         @Override
    150         public boolean onScale(ScaleGestureDetector detector) {
    151             mScaleFactor *= detector.getScaleFactor();
    152            
    153             // Don't let the object get too small or too large.
    154             mScaleFactor = Math.max(0.1f, Math.min(mScaleFactor, 5.0f));
     117                                invalidate();
     118                        }
    155119
    156             invalidate();
    157             return true;
    158         }
    159     }
     120                        mLastTouchX = x;
     121                        mLastTouchY = y;
     122
     123                        break;
     124                }
     125
     126                case MotionEvent.ACTION_UP: {
     127                        mActivePointerId = INVALID_POINTER_ID;
     128                        break;
     129                }
     130
     131                case MotionEvent.ACTION_CANCEL: {
     132                        mActivePointerId = INVALID_POINTER_ID;
     133                        break;
     134                }
     135
     136                case MotionEvent.ACTION_POINTER_UP: {
     137                        final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
     138                        final int pointerId = ev.getPointerId(pointerIndex);
     139                        if (pointerId == mActivePointerId) {
     140                                // This was our active pointer going up. Choose a new
     141                                // active pointer and adjust accordingly.
     142                                final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
     143                                mLastTouchX = ev.getX(newPointerIndex);
     144                                mLastTouchY = ev.getY(newPointerIndex);
     145                                mActivePointerId = ev.getPointerId(newPointerIndex);
     146                        }
     147                        break;
     148                }
     149                }
     150
     151                return true;
     152        }
     153
     154        @Override
     155        public void onDraw(Canvas canvas) {
     156                super.onDraw(canvas);
     157
     158                canvas.save();
     159                canvas.translate(mPosX, mPosY);
     160                canvas.scale(mScaleFactor, mScaleFactor);
     161                mIcon.draw(canvas);
     162                // canvas.drawBitmap(b,0,0,null);
     163                canvas.restore();
     164        }
     165
     166        private class ScaleListener extends
     167                        ScaleGestureDetector.SimpleOnScaleGestureListener {
     168                @Override
     169                public boolean onScale(ScaleGestureDetector detector) {
     170                        mScaleFactor *= detector.getScaleFactor();
     171
     172                        // Don't let the object get too small or too large.
     173                        mScaleFactor = Math.max(0.1f, Math.min(mScaleFactor, 5.0f));
     174
     175                        invalidate();
     176                        return true;
     177                }
     178        }
    160179}
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ZoomImageViewActivity.java

    r14844 r17423  
    1717
    1818import android.app.Activity;
     19import android.content.Intent;
    1920import android.os.Bundle;
    2021import android.view.KeyEvent;
    2122import android.view.ViewGroup;
     23import android.view.Window;
    2224
    2325public class ZoomImageViewActivity extends Activity {
    24     /** Called when the activity is first created. */
    25        
     26        /** Called when the activity is first created. */
     27
    2628        private int position = 0;
    27        
    28     @Override
    29     public void onCreate(Bundle savedInstanceState) {
    30         super.onCreate(savedInstanceState);
    31         Bundle image = getIntent().getExtras();
    32         {
    33                 if(image!= null)
    34                 {
    35                         position = image.getInt("imagePosition");
    36                 }
    37         }
    38         ZoomImageView view = new ZoomImageView(this,position);
    39         view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
    40                 ViewGroup.LayoutParams.MATCH_PARENT));
    41        
    42         setContentView(view);
    43     }
    44     public boolean onKeyDown(int keyCode, KeyEvent event)
    45     {
    46         if (keyCode == KeyEvent.KEYCODE_BACK)
    47                 finish();
    48         return true;
    49     }
     29
     30        @Override
     31        public void onCreate(Bundle savedInstanceState) {
     32                super.onCreate(savedInstanceState);
     33                super.requestWindowFeature(Window.FEATURE_NO_TITLE);
     34                Bundle image = getIntent().getExtras();
     35                {
     36                        if (image != null) {
     37                                position = image.getInt("imagePosition");
     38                        }
     39                }
     40                ZoomImageView view = new ZoomImageView(this, position);
     41                view.setLayoutParams(new ViewGroup.LayoutParams(
     42                                ViewGroup.LayoutParams.MATCH_PARENT,
     43                                ViewGroup.LayoutParams.MATCH_PARENT));
     44
     45                setContentView(view);
     46        }
     47
     48        public boolean onKeyDown(int keyCode, KeyEvent event) {
     49                if (keyCode == KeyEvent.KEYCODE_BACK)
     50                        finish();
     51                return true;
     52        }
     53
     54        @Override
     55        public void onBackPressed() {
     56                Intent i = new Intent(ZoomImageViewActivity.this, GalleryImage.class);
     57                startActivity(i);
     58                finish();
     59        }
    5060}
Note: See TracChangeset for help on using the changeset viewer.