Android Open Source - HzGrapher Curve Graph Activity






From Project

Back to project page HzGrapher.

License

The source code is released under:

Apache License

If you think the Android project HzGrapher listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.handstudio.android.hzgrapher;
/*  www.  j a  v a  2s. c o m*/
import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup;

import com.handstudio.android.hzgrapherlib.animation.GraphAnimation;
import com.handstudio.android.hzgrapherlib.graphview.CurveGraphView;
import com.handstudio.android.hzgrapherlib.vo.GraphNameBox;
import com.handstudio.android.hzgrapherlib.vo.curvegraph.CurveGraph;
import com.handstudio.android.hzgrapherlib.vo.curvegraph.CurveGraphVO;

public class CurveGraphActivity extends Activity {

  private ViewGroup layoutGraphView;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_graph);
    
    layoutGraphView = (ViewGroup) findViewById(R.id.layoutGraphView);

    setCurveGraph();
  }

  private void setCurveGraph() {
    //all setting
    CurveGraphVO vo = makeCurveGraphAllSetting();
    
    //default setting
//    CurveGraphVO vo = makeCurveGraphDefaultSetting();
    
    layoutGraphView.addView(new CurveGraphView(this, vo));
  }
  
  /**
   * make simple Curve graph
   * @return
   */
  private CurveGraphVO makeCurveGraphDefaultSetting() {
    
    String[] legendArr   = {"1","2","3","4","5"};
    float[] graph1     = {500,100,300,200,100};
    float[] graph2     = {000,100,200,100,200};
    float[] graph3     = {200,500,300,400,000};
    
    List<CurveGraph> arrGraph     = new ArrayList<CurveGraph>();
    arrGraph.add(new CurveGraph("android", 0xaa66ff33, graph1));
    arrGraph.add(new CurveGraph("ios", 0xaa00ffff, graph2));
    arrGraph.add(new CurveGraph("tizen", 0xaaff0066, graph3));
    
    CurveGraphVO vo = new CurveGraphVO(legendArr, arrGraph);
    return vo;
  }

  /**
   * make Curve graph using options
   * @return
   */
  private CurveGraphVO makeCurveGraphAllSetting() {
    //BASIC LAYOUT SETTING
    //padding
    int paddingBottom   = CurveGraphVO.DEFAULT_PADDING;
    int paddingTop     = CurveGraphVO.DEFAULT_PADDING;
    int paddingLeft   = CurveGraphVO.DEFAULT_PADDING;
    int paddingRight   = CurveGraphVO.DEFAULT_PADDING;

    //graph margin
    int marginTop     = CurveGraphVO.DEFAULT_MARGIN_TOP;
    int marginRight   = CurveGraphVO.DEFAULT_MARGIN_RIGHT;

    //max value
    int maxValue     = CurveGraphVO.DEFAULT_MAX_VALUE;

    //increment
    int increment     = CurveGraphVO.DEFAULT_INCREMENT;
    
    //GRAPH SETTING
    String[] legendArr   = {"1","2","3","4","5"};
    float[] graph1     = {500,100,300,200,100};
    float[] graph2     = {000,100,200,100,200};
    float[] graph3     = {200,500,300,400,000};
    
    List<CurveGraph> arrGraph     = new ArrayList<CurveGraph>();
    
    arrGraph.add(new CurveGraph("android", 0xaa66ff33, graph1, R.drawable.ic_launcher));
    arrGraph.add(new CurveGraph("ios", 0xaa00ffff, graph2));
    arrGraph.add(new CurveGraph("tizen", 0xaaff0066, graph3));
    
    CurveGraphVO vo = new CurveGraphVO(
        paddingBottom, paddingTop, paddingLeft, paddingRight,
        marginTop, marginRight, maxValue, increment, legendArr, arrGraph);
    
    //set animation
    vo.setAnimation(new GraphAnimation(GraphAnimation.LINEAR_ANIMATION, GraphAnimation.DEFAULT_DURATION));
    //set graph name box
    vo.setGraphNameBox(new GraphNameBox());
    //set draw graph region
//    vo.setDrawRegion(true);
    
    //use icon
//    arrGraph.add(new Graph(0xaa66ff33, graph1, R.drawable.icon1));
//    arrGraph.add(new Graph(0xaa00ffff, graph2, R.drawable.icon2));
//    arrGraph.add(new Graph(0xaaff0066, graph3, R.drawable.icon3));
    
//    CurveGraphVO vo = new CurveGraphVO(
//        paddingBottom, paddingTop, paddingLeft, paddingRight,
//        marginTop, marginRight, maxValue, increment, legendArr, arrGraph, R.drawable.bg);
    return vo;
  }
}




Java Source Code List

com.handstudio.android.hzgrapher.BarGraphActivity.java
com.handstudio.android.hzgrapher.BubbleGraphActivity.java
com.handstudio.android.hzgrapher.BubbleGraphActivity.java
com.handstudio.android.hzgrapher.CircleGraphActivity.java
com.handstudio.android.hzgrapher.CircleGraphActivity.java
com.handstudio.android.hzgrapher.CurveCompareGraphActivity.java
com.handstudio.android.hzgrapher.CurveCompareGraphActivity.java
com.handstudio.android.hzgrapher.CurveGraphActivity.java
com.handstudio.android.hzgrapher.CurveGraphActivity.java
com.handstudio.android.hzgrapher.CurveGraphWithRegionActivity.java
com.handstudio.android.hzgrapher.CurveGraphWithRegionActivity.java
com.handstudio.android.hzgrapher.LineCompareGraphActivity.java
com.handstudio.android.hzgrapher.LineCompareGraphActivity.java
com.handstudio.android.hzgrapher.LineGraphActivity.java
com.handstudio.android.hzgrapher.LineGraphActivity.java
com.handstudio.android.hzgrapher.LineGraphWithRegionActivity.java
com.handstudio.android.hzgrapher.LineGraphWithRegionActivity.java
com.handstudio.android.hzgrapher.MainActivity.java
com.handstudio.android.hzgrapher.MainActivity.java
com.handstudio.android.hzgrapher.PieGraphActivity.java
com.handstudio.android.hzgrapher.PieGraphActivity.java
com.handstudio.android.hzgrapher.RadarGraphActivity.java
com.handstudio.android.hzgrapher.RadarGraphActivity.java
com.handstudio.android.hzgrapher.ScatterGraphActivity.java
com.handstudio.android.hzgrapher.ScatterGraphActivity.java
com.handstudio.android.hzgrapherlib.animation.GraphAnimation.java
com.handstudio.android.hzgrapherlib.canvas.GraphCanvasWrapper.java
com.handstudio.android.hzgrapherlib.error.ErrorCode.java
com.handstudio.android.hzgrapherlib.error.ErrorDetector.java
com.handstudio.android.hzgrapherlib.graphview.BarGraphView.java
com.handstudio.android.hzgrapherlib.graphview.BubbleGraphView.java
com.handstudio.android.hzgrapherlib.graphview.CircleGraphView.java
com.handstudio.android.hzgrapherlib.graphview.CurveCompareGraphView.java
com.handstudio.android.hzgrapherlib.graphview.CurveGraphView.java
com.handstudio.android.hzgrapherlib.graphview.LineCompareGraphView.java
com.handstudio.android.hzgrapherlib.graphview.LineGraphView.java
com.handstudio.android.hzgrapherlib.graphview.RadarGraphView.java
com.handstudio.android.hzgrapherlib.graphview.ScatterGraphView.java
com.handstudio.android.hzgrapherlib.path.GraphPath.java
com.handstudio.android.hzgrapherlib.util.Converter.java
com.handstudio.android.hzgrapherlib.util.EuclidLine.java
com.handstudio.android.hzgrapherlib.util.EuclidPoint.java
com.handstudio.android.hzgrapherlib.util.IntersectFinder.java
com.handstudio.android.hzgrapherlib.util.MatrixTranslator.java
com.handstudio.android.hzgrapherlib.util.Spline.java
com.handstudio.android.hzgrapherlib.vo.GraphNameBox.java
com.handstudio.android.hzgrapherlib.vo.Graph.java
com.handstudio.android.hzgrapherlib.vo.bargraph.BarGraphVO.java
com.handstudio.android.hzgrapherlib.vo.bargraph.BarGraph.java
com.handstudio.android.hzgrapherlib.vo.bubblegraph.BubbleGraphVO.java
com.handstudio.android.hzgrapherlib.vo.bubblegraph.BubbleGraph.java
com.handstudio.android.hzgrapherlib.vo.circlegraph.CircleGraphVO.java
com.handstudio.android.hzgrapherlib.vo.circlegraph.CircleGraph.java
com.handstudio.android.hzgrapherlib.vo.curvegraph.CurveGraphVO.java
com.handstudio.android.hzgrapherlib.vo.curvegraph.CurveGraph.java
com.handstudio.android.hzgrapherlib.vo.linegraph.LineGraphVO.java
com.handstudio.android.hzgrapherlib.vo.linegraph.LineGraph.java
com.handstudio.android.hzgrapherlib.vo.radargraph.RadarGraphVO.java
com.handstudio.android.hzgrapherlib.vo.radargraph.RadarGraph.java
com.handstudio.android.hzgraphlib.vo.scattergraph.ScatterGraphVO.java
com.handstudio.android.hzgraphlib.vo.scattergraph.ScatterGraph.java