Home | History | Annotate | Download | only in interactivechart
      1 /*
      2  * Copyright 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *     http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.example.android.interactivechart;
     18 
     19 import android.app.Activity;
     20 import android.os.Bundle;
     21 import android.view.Menu;
     22 import android.view.MenuItem;
     23 
     24 public class MainActivity extends Activity {
     25     private InteractiveLineGraphView mGraphView;
     26 
     27     protected void onCreate(Bundle savedInstanceState) {
     28         super.onCreate(savedInstanceState);
     29         setContentView(R.layout.activity_main);
     30         mGraphView = (InteractiveLineGraphView) findViewById(R.id.chart);
     31     }
     32 
     33     @Override
     34     public boolean onCreateOptionsMenu(Menu menu) {
     35         super.onCreateOptionsMenu(menu);
     36         getMenuInflater().inflate(R.menu.main, menu);
     37         return true;
     38     }
     39 
     40     @Override
     41     public boolean onOptionsItemSelected(MenuItem item) {
     42         switch (item.getItemId()) {
     43             case R.id.action_zoom_in:
     44                 mGraphView.zoomIn();
     45                 return true;
     46 
     47             case R.id.action_zoom_out:
     48                 mGraphView.zoomOut();
     49                 return true;
     50 
     51             case R.id.action_pan_left:
     52                 mGraphView.panLeft();
     53                 return true;
     54 
     55             case R.id.action_pan_right:
     56                 mGraphView.panRight();
     57                 return true;
     58 
     59             case R.id.action_pan_up:
     60                 mGraphView.panUp();
     61                 return true;
     62 
     63             case R.id.action_pan_down:
     64                 mGraphView.panDown();
     65                 return true;
     66         }
     67 
     68         return super.onOptionsItemSelected(item);
     69     }
     70 }
     71