Android Open Source - HzGrapher Scatter 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;
//from w w w .  jav a2  s  .  c o  m
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

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

import com.handstudio.android.hzgrapherlib.animation.GraphAnimation;
import com.handstudio.android.hzgrapherlib.graphview.ScatterGraphView;
import com.handstudio.android.hzgrapherlib.vo.GraphNameBox;
import com.handstudio.android.hzgraphlib.vo.scattergraph.ScatterGraph;
import com.handstudio.android.hzgraphlib.vo.scattergraph.ScatterGraphVO;

public class ScatterGraphActivity extends Activity 
{
  public static final String TAG = ScatterGraphActivity.class.getSimpleName();
  
  private ViewGroup layoutGraphView;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) 
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_graph);
    
    setScatterGraph();
    
  }
  
  
  private void setScatterGraph()
  {
    ScatterGraphVO vo = getScatterGraphInfo();
    
    layoutGraphView = (ViewGroup) findViewById(R.id.layoutGraphView);
    layoutGraphView.addView(new ScatterGraphView(this, vo));
    
  }
  
  
  private ScatterGraphVO getScatterGraphInfo()
  {
    int paddingBottom = ScatterGraphVO.DEFAULT_PADDING;
    int paddingTop = ScatterGraphVO.DEFAULT_PADDING;
    int paddingLeft = ScatterGraphVO.DEFAULT_PADDING;
    int paddingRight = ScatterGraphVO.DEFAULT_PADDING;
    int marginTop = ScatterGraphVO.DEFAULT_MARGIN_TOP;
    int marginRight = 10;
    int maxValueX = 100;
    int maxValueY = 200;
    int incrementX = 20;
    int incrementY = 50;
  
    
    Random random = new Random();
    int count = 100;
      
    List<ScatterGraph> arrGraph = new ArrayList<ScatterGraph>();
    for(int i=0; i<count; i++){
      int caseId = random.nextInt(2);
      switch(caseId){
        case 0:
          float x = random.nextInt(maxValueY);
          float y = random.nextInt(maxValueX);
          arrGraph.add(new ScatterGraph("Android", Color.GREEN, new float[]{x, y}));
          break;
          
        case 1:
          float xios = random.nextInt(maxValueY);
          float yios = random.nextInt(maxValueX);
          arrGraph.add(new ScatterGraph("iOS", Color.BLUE, new float[]{xios, yios}));
          break;
      }      
    }
        
    ScatterGraphVO vo = new ScatterGraphVO(new String[]{"Android","iOS"}, arrGraph,
                          paddingTop, paddingBottom, paddingLeft, paddingRight,
                          marginTop, marginRight, maxValueX, maxValueY,
                          incrementX, incrementY);
    vo.setAnimation(new GraphAnimation());
    vo.setGraphNameBox(new GraphNameBox());
    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