PostList

2015년 8월 23일 일요일

8월 23일 자바

package com.example.han.graph2;

import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;

import org.achartengine.ChartFactory;
import org.achartengine.GraphicalView;
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;

import java.util.ArrayList;


public class MainActivity extends ActionBarActivity {


    ArrayList<Double> SFD = new ArrayList<Double>();
    ArrayList<Double> BMD = new ArrayList<Double>();
    ArrayList<Double> DIS = new ArrayList<Double>();

    //SFD 배열 변수 생성    Double iSFD,iBMD;
    int MAX;
    Double ShearMax, ShearMin,BMMax,BMMin;

    ViewFlipper vFlipper;

    String M1, M2, M3, M4, M5;
    String W1, W2, W3, W4, W5;
    String T1, T2, T3, T4, T5;
    String P1, P2, P3, P4, P5;
    EditText E1, E2, E3, E4, E5;
    EditText D1, D2, D3, D4, D5;
    EditText DRa, DRb, Dis;
    Double Ra, Rb;

    String E11, E22, E33, E44, E55;
    String D11, D22, D33, D44, D55;
    String T11, T22, T33, T44, T55;

    Spinner TV1, TV2, TV3, TV4, TV5;

    ArrayAdapter<CharSequence> adapter;

    TextView test;

    int Scale = 101;

    LinearLayout BMDGraphLayout,SFDGraphLayout;



    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        vFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);

        DRa = (EditText) findViewById(R.id.Ra);
        DRb = (EditText) findViewById(R.id.Rb);

        Dis = (EditText) findViewById(R.id.Dis);

        //Button button = (Button) findViewById(R.id.button);
        SFDGraphLayout = (LinearLayout) findViewById(R.id.SFDGraphLayout);
        BMDGraphLayout = (LinearLayout) findViewById(R.id.BMDGraphLayout);


        test = (TextView) findViewById(R.id.textView);

        E1 = (EditText) findViewById(R.id.E1);
        E2 = (EditText) findViewById(R.id.E2);
        E3 = (EditText) findViewById(R.id.E3);
        E4 = (EditText) findViewById(R.id.E4);
        E5 = (EditText) findViewById(R.id.E5);

        D1 = (EditText) findViewById(R.id.D1);
        D2 = (EditText) findViewById(R.id.D2);
        D3 = (EditText) findViewById(R.id.D3);
        D4 = (EditText) findViewById(R.id.D4);
        D5 = (EditText) findViewById(R.id.D5);


        //스피너        TV1 = (Spinner) findViewById(R.id.TV1);
        TV2 = (Spinner) findViewById(R.id.TV2);
        TV3 = (Spinner) findViewById(R.id.TV3);
        TV4 = (Spinner) findViewById(R.id.TV4);
        TV5 = (Spinner) findViewById(R.id.TV5);

        adapter = ArrayAdapter.createFromResource(this, R.array.cccccc, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        TV1.setAdapter(adapter);
        TV1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            }

            @Override            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        TV2.setAdapter(adapter);
        TV2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            }

            @Override            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        TV3.setAdapter(adapter);
        TV3.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            }

            @Override            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        TV4.setAdapter(adapter);
        TV4.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            }

            @Override            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        TV5.setAdapter(adapter);
        TV5.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            }

            @Override            public void onNothingSelected(AdapterView<?> parent) {

            }
        });




    }

    // 거리 오름차순해야됨

    public void Calculate(View V) {


        E11 = E1.getText().toString();
        E22 = E2.getText().toString();
        E33 = E3.getText().toString();
        E44 = E4.getText().toString();
        E55 = E5.getText().toString();

        D11 = D1.getText().toString();
        D22 = D2.getText().toString();
        D33 = D3.getText().toString();
        D44 = D4.getText().toString();
        D55 = D5.getText().toString();


        switch ((String) TV1.getSelectedItem()) {
            case "M":
                M1 = E11;
                W1 = "0";
                T1 = "0";
                P1 = "0";
                break;
            case "D F":
                M1 = "0";
                W1 = E11;
                T1 = "0";
                P1 = "0";
                break;
            case "Tri-D F":
                M1 = "0";
                W1 = "0";
                T1 = E11;
                P1 = "0";
                break;
            case "C F":
                M1 = "0";
                W1 = "0";
                T1 = "0";
                P1 = E11;
                break;
        }
        switch ((String) TV2.getSelectedItem()) {
            case "M":
                M2 = E22;
                W2 = "0";
                T2 = "0";
                P2 = "0";
                break;
            case "D F":
                M2 = "0";
                W2 = E22;
                T2 = "0";
                P2 = "0";
                break;
            case "Tri-D F":
                M2 = "0";
                W2 = "0";
                T2 = E22;
                P2 = "0";
                break;
            case "C F":
                M2 = "0";
                W2 = "0";
                T2 = "0";
                P2 = E22;
                break;
        }
        switch ((String) TV3.getSelectedItem()) {
            case "M":
                M3 = E33;
                W3 = "0";
                T3 = "0";
                P3 = "0";
                break;
            case "D F":
                M3 = "0";
                W3 = E33;
                T3 = "0";
                P3 = "0";
                break;
            case "Tri-D F":
                M3 = "0";
                W3 = "0";
                T3 = E33;
                P3 = "0";
                break;
            case "C F":
                M3 = "0";
                W3 = "0";
                T3 = "0";
                P3 = E33;
                break;
        }
        switch ((String) TV4.getSelectedItem()) {
            case "M":
                M4 = E44;
                W4 = "0";
                T4 = "0";
                P4 = "0";
                break;
            case "D F":
                M4 = "0";
                W4 = E44;
                T4 = "0";
                P4 = "0";
                break;
            case "Tri-D F":
                M4 = "0";
                W4 = "0";
                T4 = E44;
                P4 = "0";
                break;
            case "C F":
                M4 = "0";
                W4 = "0";
                T4 = "0";
                P4 = E44;
                break;
        }
        switch ((String) TV5.getSelectedItem()) {
            case "M":
                M5 = E55;
                W5 = "0";
                T5 = "0";
                P5 = "0";
                break;
            case "D F":
                M5 = "0";
                W5 = E55;
                T5 = "0";
                P5 = "0";
                break;
            case "Tri-D F":
                M5 = "0";
                W5 = "0";
                T5 = E55;
                P5 = "0";
                break;
            case "C F":
                M5 = "0";
                W5 = "0";
                T5 = "0";
                P5 = E55;
                break;
        }

        Double C ,D;
        //Ra Rb 반력구하기        C =Double.parseDouble(P1)+Double.parseDouble(P2)+Double.parseDouble(P3)+Double.parseDouble(P4)+Double.parseDouble(P5)
                +Double.parseDouble(W1)*(Double.parseDouble(Dis.getText().toString())-Double.parseDouble(D11))
                +Double.parseDouble(W2)*(Double.parseDouble(Dis.getText().toString())-Double.parseDouble(D22))
                +Double.parseDouble(W3)*(Double.parseDouble(Dis.getText().toString())-Double.parseDouble(D33))
                +Double.parseDouble(W4)*(Double.parseDouble(Dis.getText().toString())-Double.parseDouble(D44))
                +Double.parseDouble(W5)*(Double.parseDouble(Dis.getText().toString())-Double.parseDouble(D55))
                +Double.parseDouble(T1)*Math.pow(Double.parseDouble(Dis.getText().toString()) - Double.parseDouble(D11),2)/2                +Double.parseDouble(T2)*Math.pow(Double.parseDouble(Dis.getText().toString()) - Double.parseDouble(D22),2)/2                +Double.parseDouble(T3)*Math.pow(Double.parseDouble(Dis.getText().toString()) - Double.parseDouble(D33),2)/2                +Double.parseDouble(T4)*Math.pow(Double.parseDouble(Dis.getText().toString()) - Double.parseDouble(D44),2)/2                +Double.parseDouble(T5)*Math.pow(Double.parseDouble(Dis.getText().toString()) - Double.parseDouble(D55),2)/2;


        D = -Double.parseDouble(M1)-Double.parseDouble(M2)-Double.parseDouble(M3)-Double.parseDouble(M4)-Double.parseDouble(M5)
                +Double.parseDouble(P1)*Double.parseDouble(D11)+Double.parseDouble(P2)*Double.parseDouble(D22)+Double.parseDouble(P3)*Double.parseDouble(D33)+Double.parseDouble(P4)*Double.parseDouble(D44)+Double.parseDouble(P5)*Double.parseDouble(D55)
                +Double.parseDouble(W1)*(Math.pow(Double.parseDouble(Dis.getText().toString()),2)-Math.pow(Double.parseDouble(D11),2))/2                +Double.parseDouble(W2)*(Math.pow(Double.parseDouble(Dis.getText().toString()),2)-Math.pow(Double.parseDouble(D22),2))/2                +Double.parseDouble(W3)*(Math.pow(Double.parseDouble(Dis.getText().toString()),2)-Math.pow(Double.parseDouble(D33),2))/2                +Double.parseDouble(W4)*(Math.pow(Double.parseDouble(Dis.getText().toString()),2)-Math.pow(Double.parseDouble(D44),2))/2                +Double.parseDouble(W5)*(Math.pow(Double.parseDouble(Dis.getText().toString()),2)-Math.pow(Double.parseDouble(D55),2))/2                +Double.parseDouble(T1)*(2*Math.pow(Double.parseDouble(Dis.getText().toString()),3)-3*Double.parseDouble(D11)*Math.pow(Double.parseDouble(Dis.getText().toString()),2)
                +Math.pow(Double.parseDouble(D11), 3))/6                +Double.parseDouble(T2)*(2*Math.pow(Double.parseDouble(Dis.getText().toString()),3)-3*Double.parseDouble(D22)*Math.pow(Double.parseDouble(Dis.getText().toString()),2)
                +Math.pow(Double.parseDouble(D22), 3))/6                +Double.parseDouble(T3)*(2*Math.pow(Double.parseDouble(Dis.getText().toString()),3)-3*Double.parseDouble(D33)*Math.pow(Double.parseDouble(Dis.getText().toString()),2)
                +Math.pow(Double.parseDouble(D33), 3))/6                +Double.parseDouble(T4)*(2*Math.pow(Double.parseDouble(Dis.getText().toString()),3)-3*Double.parseDouble(D44)*Math.pow(Double.parseDouble(Dis.getText().toString()),2)
                +Math.pow(Double.parseDouble(D44), 3))/6                +Double.parseDouble(T5)*(2*Math.pow(Double.parseDouble(Dis.getText().toString()),3)-3*Double.parseDouble(D55)*Math.pow(Double.parseDouble(Dis.getText().toString()),2)
                +Math.pow(Double.parseDouble(D55), 3))/6;




        Rb=(D-Double.parseDouble(DRa.getText().toString())*C)/(Double.parseDouble(DRa.getText().toString())-Double.parseDouble(DRb.getText().toString()));
        Ra=-Rb-C;


        //최대거리        //MAX = Math.max(Math.max(Math.max(Math.max(Integer.parseInt(D55), Integer.parseInt(D44)), Integer.parseInt(D33)), Integer.parseInt(D22)), Integer.parseInt(D11));



        ShearMax=0.0;
        ShearMin=0.0;
        BMMax=0.0;
        BMMin=0.0;

        if (Integer.parseInt(Dis.getText().toString()) == 0)//MAX 0값 오류        {
            Toast.makeText(getApplicationContext(), "보의 길이를 지정하시오", Toast.LENGTH_LONG).show();
        } else {

            // S.F.D 계산            for (int x = 0; x < (int)Math.floor(Double.parseDouble(Dis.getText().toString()) * Scale); x++) {
                iSFD = 0.000;
                iBMD = 0.000;


                if (x >= Double.parseDouble(DRa.getText().toString()) * Scale)
                    iSFD += Ra;


                if (x >= Double.parseDouble(DRb.getText().toString()) * Scale)
                    iSFD += Rb;
                iSFD+=SFD(x,D11,P1,W1,T1)+SFD(x,D22,P2,W2,T2)+SFD(x,D33,P3,W3,T3)+SFD(x,D44,P4,W4,T4)+SFD(x,D55,P5,W5,T5);
                iBMD+=BMD(x,D11,M1,P1,W1,T1)+BMD(x,D22,M2,P2,W2,T2)+BMD(x,D33,M3,P3,W3,T3)+BMD(x,D44,M4,P4,W4,T4)+BMD(x,D55,M5,P5,W5,T5);


                /*                if (x >= Double.parseDouble(D11) * Scale) {                    iSFD += Double.parseDouble(P1) * Math.pow(x - Double.parseDouble(D11) * Scale, 0) +                            Double.parseDouble(W1) * Math.pow(x - Double.parseDouble(D11) * Scale, 1) / Math.pow(Scale, 1) +                            Double.parseDouble(T1) * Math.pow(x - Double.parseDouble(D11) * Scale, 2) /(2*Math.pow(Scale, 2));
                }
                if (x >= Double.parseDouble(D22) * Scale) {                    iSFD += Double.parseDouble(P2) * Math.pow(x - Double.parseDouble(D22) * Scale, 0) +                            Double.parseDouble(W2) * Math.pow(x - Double.parseDouble(D22) * Scale, 1) / Math.pow(Scale, 1) +                            Double.parseDouble(T2) * Math.pow(x - Double.parseDouble(D22) * Scale, 2) / (2*Math.pow(Scale, 2));
                }                if (x >= Double.parseDouble(D33) * Scale) {                    iSFD += Double.parseDouble(P3) * Math.pow(x - Double.parseDouble(D33) * Scale, 0) +                            Double.parseDouble(W3) * Math.pow(x - Double.parseDouble(D33) * Scale, 1) / Math.pow(Scale, 1) +                            Double.parseDouble(T3) * Math.pow(x - Double.parseDouble(D33) * Scale, 2) / (2*Math.pow(Scale, 2));
                }                if (x >= Double.parseDouble(D44) * Scale) {                    iSFD += Double.parseDouble(P4) * Math.pow(x - Double.parseDouble(D44) * Scale, 0) +                            Double.parseDouble(W4) * Math.pow(x - Double.parseDouble(D44) * Scale, 1) / Math.pow(Scale, 1) +                            Double.parseDouble(T4) * Math.pow(x - Double.parseDouble(D44) * Scale, 2) / (2*Math.pow(Scale, 2));
                }                if (x >= Double.parseDouble(D55) * Scale) {                    iSFD += Double.parseDouble(P5) * Math.pow(x - Double.parseDouble(D55) * Scale, 0) +                            Double.parseDouble(W5) * Math.pow(x - Double.parseDouble(D55) * Scale, 1) / Math.pow(Scale, 1) +                            Double.parseDouble(T5) * Math.pow(x - Double.parseDouble(D55) * Scale, 2) / (2*Math.pow(Scale, 2));                }*/

                // B.M.D 계산
                if (x >= Double.parseDouble(DRa.getText().toString()) * Scale)
                    iBMD += Ra*Math.pow(x - Double.parseDouble(DRa.getText().toString()) * Scale, 1) / Math.pow(Scale, 1);


                if (x >= Double.parseDouble(DRb.getText().toString()) * Scale)
                    iBMD += Rb*Math.pow(x - Double.parseDouble(DRb.getText().toString()) * Scale, 1) / Math.pow(Scale, 1);



                /*
                if (x >= Double.parseDouble(D11) * Scale) {                    iBMD += Double.parseDouble(M1) * Math.pow(x - Double.parseDouble(D11) * Scale, 0) +                            Double.parseDouble(P1) * Math.pow(x - Double.parseDouble(D11) * Scale, 1) / Math.pow(Scale, 1) +                            Double.parseDouble(W1) * Math.pow(x - Double.parseDouble(D11) * Scale, 2) /(2*Math.pow(Scale, 2))+                            Double.parseDouble(T1) * Math.pow(x - Double.parseDouble(D11) * Scale, 3) /(6*Math.pow(Scale, 3));
                }
                if (x >= Double.parseDouble(D22) * Scale) {                    iBMD += Double.parseDouble(M2) * Math.pow(x - Double.parseDouble(D22) * Scale, 0) +                            Double.parseDouble(P2) * Math.pow(x - Double.parseDouble(D22) * Scale, 1) / Math.pow(Scale, 1) +                            Double.parseDouble(W2) * Math.pow(x - Double.parseDouble(D22) * Scale, 2) /(2*Math.pow(Scale, 2))+                            Double.parseDouble(T2) * Math.pow(x - Double.parseDouble(D22) * Scale, 3) /(6*Math.pow(Scale, 3));
                }                if (x >= Double.parseDouble(D33) * Scale) {                    iBMD += Double.parseDouble(M3) * Math.pow(x - Double.parseDouble(D33) * Scale, 0) +                            Double.parseDouble(P3) * Math.pow(x - Double.parseDouble(D33) * Scale, 1) / Math.pow(Scale, 1) +                            Double.parseDouble(W3) * Math.pow(x - Double.parseDouble(D33) * Scale, 2) /(2*Math.pow(Scale, 2))+                            Double.parseDouble(T3) * Math.pow(x - Double.parseDouble(D33) * Scale, 3) /(6*Math.pow(Scale, 3));
                }                if (x >= Double.parseDouble(D44) * Scale) {                    iBMD += Double.parseDouble(M4) * Math.pow(x - Double.parseDouble(D44) * Scale, 0) +                            Double.parseDouble(P4) * Math.pow(x - Double.parseDouble(D44) * Scale, 1) / Math.pow(Scale, 1) +                            Double.parseDouble(W4) * Math.pow(x - Double.parseDouble(D44) * Scale, 2) /(2*Math.pow(Scale, 2))+                            Double.parseDouble(T4) * Math.pow(x - Double.parseDouble(D44) * Scale, 3) /(6*Math.pow(Scale, 3));
                }                if (x >= Double.parseDouble(D55) * Scale) {                    iBMD += Double.parseDouble(M5) * Math.pow(x - Double.parseDouble(D55) * Scale, 0) +                            Double.parseDouble(P5) * Math.pow(x - Double.parseDouble(D55) * Scale, 1) / Math.pow(Scale, 1) +                            Double.parseDouble(W5) * Math.pow(x - Double.parseDouble(D55) * Scale, 2) /(2*Math.pow(Scale, 2))+                            Double.parseDouble(T5) * Math.pow(x - Double.parseDouble(D55) * Scale, 3) /(6*Math.pow(Scale, 3));                }*/                //                SFD.add(iSFD);
                BMD.add(iBMD);
                DIS.add((double)x/Scale);

                if(ShearMax<=iSFD)
                    ShearMax=iSFD;

                if(ShearMin>=iSFD)
                    ShearMin=iSFD;

                if(BMMax<=iBMD)
                    BMMax=iBMD;

                if(BMMin>=iBMD)
                    BMMin=iBMD;
            }
        }



        //표현 인덱스        test.setText("거리 : " + Integer.parseInt(Dis.getText().toString())+"\nRa :"+Ra+"Rb :" +Rb+
                "\n최대 :"+ShearMax+"최소 :" +ShearMin+
                "\nC :"+C+"D :" +D);


        /*        XYSeries sSFD = new XYSeries("SFD");        XYSeries sBMD = new XYSeries("BMD");
        for(int i =0;i<MAX*Scale;i++) {            sSFD.add(i, SFD.get(i));          //  sBMD.add(i, BMD.get(i));        }*/


        GraphicalView SFD_chart = ChartFactory.getLineChartView(this, Dataset("SFD", SFD), XYMRenderer("Shear Force Diagram", "Shear Force (N)",ShearMax,ShearMin));
        SFDGraphLayout.addView(SFD_chart);

        GraphicalView BMD_chart = ChartFactory.getLineChartView(this,Dataset("BMD",BMD),XYMRenderer("Bending Moment Diagram","Bending Moment (N*m)",BMMax,BMMin));
        BMDGraphLayout.addView(BMD_chart);

    }

    private double BMD(int x,String DD,String M, String P,String W,String T){

        Double BMD=0.0;
        if (x >= Double.parseDouble(DD) * Scale) {
            BMD += Double.parseDouble(M) * Math.pow(x - Double.parseDouble(DD) * Scale, 0) +
                    Double.parseDouble(P) * Math.pow(x - Double.parseDouble(DD) * Scale, 1) / Math.pow(Scale, 1) +
                    Double.parseDouble(W) * Math.pow(x - Double.parseDouble(DD) * Scale, 2) /(2*Math.pow(Scale, 2))+
                    Double.parseDouble(T) * Math.pow(x - Double.parseDouble(DD) * Scale, 3) /(6*Math.pow(Scale, 3));

        }
        return  BMD;
    }

    private double SFD(int x,String DD, String P,String W,String T){
        Double SFD=0.0;
        if (x >= Double.parseDouble(DD) * Scale) {
            SFD += Double.parseDouble(P) * Math.pow(x - Double.parseDouble(DD) * Scale, 0) +
                    Double.parseDouble(W) * Math.pow(x - Double.parseDouble(DD) * Scale, 1) / Math.pow(Scale, 1) +
                    Double.parseDouble(T) * Math.pow(x - Double.parseDouble(DD) * Scale, 2) /(2*Math.pow(Scale, 2));

        }
        return SFD;
    }

    private XYMultipleSeriesRenderer XYMRenderer(String ChartTitle,String YTitle,Double MAX,Double MIN){

        XYMultipleSeriesRenderer XYMRenderer = new XYMultipleSeriesRenderer();

        //차트 타이틀 & 크기        XYMRenderer.setChartTitle(ChartTitle);
        XYMRenderer.setChartTitleTextSize(50);

        //마진 top, left, bottom, right        XYMRenderer.setMargins(new int[]{10, 100, 10, 10});

        //X축 & Y축 최대 최소        XYMRenderer.setXAxisMax(Double.parseDouble(Dis.getText().toString())); // x축 최대값        XYMRenderer.setXAxisMin(0);//최소값
        if(Math.abs(MAX)>=Math.abs(MIN)){
            XYMRenderer.setYAxisMax(MAX*2);
            XYMRenderer.setYAxisMin(-1*MAX*2);}
        else{
            XYMRenderer.setYAxisMax(-1*MIN*2);
            XYMRenderer.setYAxisMin(MIN*2);
        }

        //축 타이틀        XYMRenderer.setXTitle("Distance(mm)");
        XYMRenderer.setYTitle(YTitle);
        XYMRenderer.setAxisTitleTextSize(40);

        //XY 축 글씨 정렬방향 RIGHT > 0 축 LEFT > 축 0        XYMRenderer.setYLabelsAlign(Paint.Align.RIGHT);
        XYMRenderer.setXLabelsAlign(Paint.Align.RIGHT);
        //XY 축 위치       // XYMRenderer.setXAxisAlign
        // 라벨 글씨크기        XYMRenderer.setLabelsTextSize(30);

        //줌버튼        XYMRenderer.setZoomButtonsVisible(true);

        //색상        //XYMRenderer.setApplyBackgroundColor(false);        //dlrpXYMRenderer.setGridColor(Color.BLACK);        //XYMRenderer.setBackgroundColor(Color.WHITE);        XYMRenderer.setMarginsColor(Color.WHITE);
        XYMRenderer.setXLabelsColor(Color.BLUE);//x축 100 ~200..등 색깔        XYMRenderer.setYLabelsColor(0, Color.BLUE);
        XYMRenderer.setLabelsColor(Color.BLACK);//타이틀 x축 타이틀 y축타이틀 색        //XYMRenderer.setShowAxes(true);        XYMRenderer.setAxesColor(Color.BLUE);


        // 스크롤&줌        XYMRenderer.setPanEnabled(false, false);
        XYMRenderer.setZoomEnabled(false, false);

        XYMRenderer.addSeriesRenderer(XYRenderer());
        return XYMRenderer;
    }

    private XYSeriesRenderer XYRenderer(){
        XYSeriesRenderer XYRenderer = new XYSeriesRenderer();
        XYRenderer.setColor(Color.rgb(103, 153, 255));
        XYRenderer.setPointStyle(PointStyle.CIRCLE);
        //XYRenderer.setFillPoints(true);        XYRenderer.setLineWidth(10);
        //XYRenderer.setDisplayChartValues(true);        XYRenderer.setChartValuesTextSize(40);
        XYRenderer.setDisplayBoundingPoints(true);
        XYRenderer.setHighlighted(true);
        XYRenderer.setFillBelowLine(true);
        XYRenderer.setFillBelowLineColor(Color.rgb(212, 244, 250));

        return XYRenderer;
    }


    private XYMultipleSeriesDataset Dataset(String XTitle,ArrayList<Double> Data) {

        XYSeries XYS = new XYSeries(XTitle);

        for (int i = 0; i < (int)Math.floor(Double.parseDouble(Dis.getText().toString()) * Scale); i++) {
            XYS.add(DIS.get(i), Data.get(i));
        }

        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        dataset.addSeries(XYS);
        return dataset;
    }


    public void BMDGraph(View v){

    }
    public void SFDGraph(View v){

    }

    public void btnPrev(View v) {
        vFlipper.showPrevious();
    }

    public void btnNext(View v) {
        vFlipper.showNext();
    }


    @Override    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        getMenuInflater().inflate(R.menu.menu, menu);

    }

    @Override    public boolean onContextItemSelected(MenuItem item) {
        switch (item.getItemId()) {

            case R.id.Moment:
                Toast.makeText(getApplicationContext(), "모멘트", Toast.LENGTH_LONG).show();
                break;
            case R.id.CF:
                Toast.makeText(getApplicationContext(), "집중하중", Toast.LENGTH_LONG).show();
                break;
            case R.id.DF:
                Toast.makeText(getApplicationContext(), "분포하중", Toast.LENGTH_LONG).show();
                break;
        }
        return super.onContextItemSelected(item);

    }

    @Override    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will        // automatically handle clicks on the Home/Up button, so long        // as you specify a parent activity in AndroidManifest.xml.        int id = item.getItemId();

        //noinspection SimplifiableIfStatement        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

댓글 없음:

댓글 쓰기