Android Open Source - AndroidGraph Curve Graph






From Project

Back to project page AndroidGraph.

License

The source code is released under:

MIT License

If you think the Android project AndroidGraph 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.nimble.android_graph.Graph;
/* ww w  . j a v a  2s  .  c  o  m*/
import android.content.Context;
import android.graphics.*;

import java.util.ArrayList;

import com.nimble.android_graph.Graph_Base.GraphView;

/**
 * Created by Michael Leith on 22/07/2014.
 */
public class CurveGraph extends GraphView {

    ArrayList<Path> paths; // Terribly implemented by google. Grr. Why can't I access only a segment (nicely) of it?!?!
    ArrayList<Integer> pathColour;
    ArrayList<com.nimble.android_graph.Graph_Base.Point> previousPoint;

    int startPoint = 0;

    CurveGraph(Context context)
    {
        super(context);
        paths = new ArrayList<Path>();
        previousPoint = new ArrayList<com.nimble.android_graph.Graph_Base.Point>();
        pathColour = new ArrayList<Integer>();
    }

    public int newPath(int colour)
    {
        Path path = new Path();
       // path.moveTo(start.x, start.y);

        pathColour.add(colour);
        paths.add(path);
        //previousPoint.add(start);
        return (paths.size() - 1);
    }

    public void addPoint(com.nimble.android_graph.Graph_Base.Point point, int path)
    {
        com.nimble.android_graph.Graph_Base.Point point1;
        if(point.x > graphWidth.y) //simplified. Not correct.
            startPoint++;
        if(previousPoint.size() > 0) {
            point1 = previousPoint.get(path);
            paths.get(path).quadTo(point1.x, point1.y, point.x, point.y);
            previousPoint.set(path, point);
        }
        else {
            paths.get(path).moveTo(point.x, point.y);
            previousPoint.add(path, point);
        }
    }
    @Override
    public void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);

        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeCap(Paint.Cap.ROUND);
        paint.setStrokeWidth(3.0f);
        paint.setAntiAlias(true);

        for(int i = 0; i < paths.size(); i++)
        {
            paint.setColor(pathColour.get(i));
            canvas.drawPath(paths.get(i), paint);
        }
        invalidate();
    }


}




Java Source Code List

Nimble.com.androidgraph.ApplicationTest.java
com.nimble.android_graph.Activities.FragmentList.java
com.nimble.android_graph.Activities.GraphActivity.java
com.nimble.android_graph.Activities.GraphFragment.java
com.nimble.android_graph.Activities.GroupsFragment.java
com.nimble.android_graph.Graph.CurveGraph.java
com.nimble.android_graph.Graph.LineGraph.java
com.nimble.android_graph.Graph.Line.java
com.nimble.android_graph.Graph.ScatterGraph.java
com.nimble.android_graph.Graph.SineWave.java
com.nimble.android_graph.Graph_Base.Coord2d.java
com.nimble.android_graph.Graph_Base.GraphDataSettings.java
com.nimble.android_graph.Graph_Base.GraphDrawBackground.java
com.nimble.android_graph.Graph_Base.GraphRelateToScreen.java
com.nimble.android_graph.Graph_Base.GraphThreading.java
com.nimble.android_graph.Graph_Base.GraphTouchEvent.java
com.nimble.android_graph.Graph_Base.GraphViewDimensions.java
com.nimble.android_graph.Graph_Base.GraphView.java
com.nimble.android_graph.Graph_Base.Point.java
com.nimble.android_graph.Graph_Base.Range2d.java
com.nimble.android_graph.Graph.sine_scatter.java
com.nimble.android_graph.generics.Methods.java
com.nimble.android_graph.generics.ViewManipulators.java
com.nimble.android_graph.generics.testingSuite.java