Guest User

graph

a guest
Nov 21st, 2012
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.94 KB | None | 0 0
  1. package com.int
  2. import android.R.layout;
  3. import android.app.Activity;
  4. import android.app.ProgressDialog;
  5. import android.os.Bundle;
  6. import android.text.Editable;
  7. import android.text.TextWatcher;
  8. import android.view.Display;
  9. import android.view.View;
  10. import android.view.WindowManager;
  11. import android.view.View.OnClickListener;
  12. import android.view.inputmethod.InputMethodManager;
  13. import android.widget.Button;
  14. import android.widget.EditText;
  15. import android.widget.ImageView;
  16.  
  17. import net.astesana.javaluator.DoubleEvaluator;
  18.  
  19. import android.content.Context;
  20. import android.content.Intent;
  21. import android.graphics.Color;
  22. import android.graphics.Point;
  23. /**
  24. *
  25. * @package Graph.java
  26. * @version 1.0
  27. * @created 23. November 2011
  28. * @updated 16. November 2012
  29. * @copyright (c) 2011-2012 S. Ditlefsen
  30. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  31. * @about
  32. *
  33. */
  34.  
  35. public class Graph extends Activity {
  36.  
  37.     // Holding variables for input
  38.     private String equation;
  39.     private EditText editTextEquation;
  40.  
  41.     GraphDrawer graphView;
  42.    
  43.     @Override
  44.     public void onCreate(Bundle savedInstanceState) {
  45.         super.onCreate(savedInstanceState);
  46.         setContentView(R.layout.graph);
  47.  
  48.        
  49.         /*- Get variables from layout graph.xml ------------------------------------- */
  50.         editTextEquation = (EditText) findViewById(R.id.editTextEquation);
  51.         editTextEquation.addTextChangedListener(watcherEditTextEquation);
  52.        
  53.         /*- Draw pressed ------------------------------------------------------------ */
  54.         Button buttonDraw = (Button)findViewById(R.id.buttonDraw);
  55.         buttonDraw.setOnClickListener(buttonDrawWatcher); // Register the onClick listener
  56.      
  57.      
  58.     }
  59.    
  60.     /*- Update string variable -------------------------- */
  61.     private TextWatcher watcherEditTextEquation = new TextWatcher(){
  62.         public void onTextChanged(CharSequence s, int start, int before, int count) {
  63.             // Try to get string
  64.             try{
  65.                 dataEditTextEquation = s.toString();
  66.             } // end try
  67.             catch(NumberFormatException e){
  68.                 dataEditTextEquation = "";
  69.             } // end catch
  70.         }
  71.         public void afterTextChanged(Editable s) {
  72.         }
  73.         public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  74.         }
  75.     }; // end editText
  76.  
  77.     /*- table button was pressed ---------------------------------------------------- */
  78.     private OnClickListener buttonDrawWatcher = new OnClickListener() {
  79.          public void onClick(View v) {
  80.  
  81.  
  82.             if(dataEditTextEquation != null){
  83.                     generate_table_and_graph();
  84.             } // if
  85.            
  86.          } // onClick
  87.      }; // onClickListner
  88.      
  89.      
  90.      private void generate_table_and_graph(){
  91.          graphView = new GraphDrawer(this);
  92.          graphView.putExtra(tempDataEditTextEquation);
  93.          graphView.setBackgroundColor(Color.WHITE);
  94.          setContentView(graphView);
  95.      } // generate_table_and_graph
  96.  
  97.    
  98. }
Advertisement
Add Comment
Please, Sign In to add comment