Android Open Source - AndroidGraph Graph Fragment






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.Activities;
/*from w  ww  .  ja  va  2 s  . c o m*/
import android.content.Context;
import android.widget.LinearLayout;

import java.util.ArrayList;
import java.util.List;

import com.nimble.android_graph.Graph.SineWave;

/**
 * Created by Michael Leith on 25/07/2014.
 */
public class GraphFragment {

    static final int NUM_GRAPHS = 2;
    static final String[] yLables = {"Voltage", "Current"};

    List<SineWave> waves;

    List<LinearLayout> layouts;

    public GraphFragment(Context context)
    {
        waves = new ArrayList<SineWave>();
        layouts = new ArrayList<LinearLayout>();

        waves.add( new SineWave(context, "Time", yLables[0]) );
        waves.add ( new SineWave(context, "Time", yLables[1], false ));

    }

    public void setLayouts(LinearLayout... layout)
    {
        for(int i = 0; i < NUM_GRAPHS; i++)
            layouts.add(layout[i]);
    }

    public void start()
    {
        for(int i = 0; i < NUM_GRAPHS; i++)
        {
            waves.get(i).start();
            layouts.get(i).addView(waves.get(i));
        }
    }

    public void start(LinearLayout layout1, LinearLayout layout2)
    {
        setLayouts(layout1, layout2);
        start();
    }

    public void onPause()
    {
        for(int i = 0; i < NUM_GRAPHS; i++)
        {
            waves.get(i).stop();
            layouts.get(i).removeView(waves.get(i));
        }
    }

    public void onStop()
    {
        for(int i = 0; i < NUM_GRAPHS; i++)
            waves.get(i).onStop();
    }
}




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