Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.int
- import android.R.layout;
- import android.app.Activity;
- import android.app.ProgressDialog;
- import android.os.Bundle;
- import android.text.Editable;
- import android.text.TextWatcher;
- import android.view.Display;
- import android.view.View;
- import android.view.WindowManager;
- import android.view.View.OnClickListener;
- import android.view.inputmethod.InputMethodManager;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.ImageView;
- import net.astesana.javaluator.DoubleEvaluator;
- import android.content.Context;
- import android.content.Intent;
- import android.graphics.Color;
- import android.graphics.Point;
- /**
- *
- * @package Graph.java
- * @version 1.0
- * @created 23. November 2011
- * @updated 16. November 2012
- * @copyright (c) 2011-2012 S. Ditlefsen
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @about
- *
- */
- public class Graph extends Activity {
- // Holding variables for input
- private String equation;
- private EditText editTextEquation;
- GraphDrawer graphView;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.graph);
- /*- Get variables from layout graph.xml ------------------------------------- */
- editTextEquation = (EditText) findViewById(R.id.editTextEquation);
- editTextEquation.addTextChangedListener(watcherEditTextEquation);
- /*- Draw pressed ------------------------------------------------------------ */
- Button buttonDraw = (Button)findViewById(R.id.buttonDraw);
- buttonDraw.setOnClickListener(buttonDrawWatcher); // Register the onClick listener
- }
- /*- Update string variable -------------------------- */
- private TextWatcher watcherEditTextEquation = new TextWatcher(){
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- // Try to get string
- try{
- dataEditTextEquation = s.toString();
- } // end try
- catch(NumberFormatException e){
- dataEditTextEquation = "";
- } // end catch
- }
- public void afterTextChanged(Editable s) {
- }
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
- }; // end editText
- /*- table button was pressed ---------------------------------------------------- */
- private OnClickListener buttonDrawWatcher = new OnClickListener() {
- public void onClick(View v) {
- if(dataEditTextEquation != null){
- generate_table_and_graph();
- } // if
- } // onClick
- }; // onClickListner
- private void generate_table_and_graph(){
- graphView = new GraphDrawer(this);
- graphView.putExtra(tempDataEditTextEquation);
- graphView.setBackgroundColor(Color.WHITE);
- setContentView(graphView);
- } // generate_table_and_graph
- }
Advertisement
Add Comment
Please, Sign In to add comment