Android Open Source - SmartEPW_Android_App Chart Initialization






From Project

Back to project page SmartEPW_Android_App.

License

The source code is released under:

MIT License

If you think the Android project SmartEPW_Android_App 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.example.android.SmartEPW.util;
/*from w  w  w  . ja va 2 s .  c  o m*/
import android.graphics.Color;
import android.graphics.Paint;

import org.achartengine.chart.PointStyle;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.model.XYSeries;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYSeriesRenderer;

/**
 * Created by jackabk on 3/1/14.
 */
public class ChartInitialization
{
    // ?????????
    public void setChartSettings(XYMultipleSeriesRenderer renderer, String title, String xTitle,
                                    String yTitle, double xMin, double xMax, double yMin, double yMax, int axesColor , int labelsColor) {
        renderer.setChartTitle(title); // ???????
        renderer.setChartTitleTextSize(50); // ????????????
        renderer.setXTitle(xTitle); // X?????
        renderer.setYTitle(yTitle); // Y?????
        renderer.setXAxisMin(xMin); // X???????
        renderer.setXAxisMax(xMax); // X??????
        renderer.setXLabelsColor(Color.BLACK); // X?????
        renderer.setYAxisMin(yMin); // Y???????
        renderer.setYAxisMax(yMax); // Y??????
        renderer.setAxesColor(axesColor); // ??????????
        renderer.setYLabelsColor(0, Color.BLACK); // Y?????
        renderer.setLabelsColor(Color.BLACK); // ???????
        renderer.setMarginsColor(Color.WHITE); // ???????
        renderer.setShowGrid(true); // ????
        renderer.setInScroll(true);
        renderer.setXLabels(20);  /*i.e. the value 5 is means (max x value)/5 = one Grid*/
        renderer.setYLabels(20);  /*i.e. the value 5 is means (max y value)/5 = one Grid*/

        renderer.setAxisTitleTextSize(15.0f); /*x and y of title text size*/

        renderer.setLabelsColor(labelsColor);
        renderer.setXLabelsAlign(Paint.Align.RIGHT);
        renderer.setYLabelsAlign(Paint.Align.RIGHT);
        renderer.setZoomButtonsVisible(true);
        renderer.setPanLimits(new double[] { -10, 20, -10, 40 });
        renderer.setZoomLimits(new double[] { -10, 20, -10, 40 });
    }




    // ?????????
    public XYMultipleSeriesRenderer buildRenderer(int[] colors, PointStyle[] styles, boolean fill) {
        XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
        int length = colors.length;
        for (int i = 0; i < length; i++) {
            XYSeriesRenderer r = new XYSeriesRenderer();
            r.setColor(colors[i]);
            r.setPointStyle(styles[i]);
            r.setFillPoints(fill);
            renderer.addSeriesRenderer(r); //?????????????
        }
        return renderer;
    }


    // ??????
    public XYMultipleSeriesDataset buildDatset(String[] titles ) {

        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();

        int length = titles.length; // ?????
        for (int i = 0; i < length; i++) {
            XYSeries series = new XYSeries(titles[i]); // ???????????????
            dataset.addSeries(series);
        }
        return dataset;
    }

}




Java Source Code List

com.example.android.SmartEPW.BluetoothChatService.java
com.example.android.SmartEPW.ControlEPW_Fragment.java
com.example.android.SmartEPW.Debug_Fragment.java
com.example.android.SmartEPW.DeviceListActivity.java
com.example.android.SmartEPW.Help_Fragment.java
com.example.android.SmartEPW.Home_Fragment.java
com.example.android.SmartEPW.MenuActivity.java
com.example.android.SmartEPW.ResideMenuItem.java
com.example.android.SmartEPW.ResideMenu.java
com.example.android.SmartEPW.util.ChartInitialization.java
com.example.android.SmartEPW.util.FormatConvert.java
com.example.android.SmartEPW.widget.VerticalSeekBar_Reverse.java
com.example.android.SmartEPW.widget.VerticalSeekBar.java