Ejemplo n.º 1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.showsugar);

    int exist = 1; //

    //    double ig = gic.calculateGlycemicIndex();

    estimator = BloodGlucoseEstimator.getInstance();
    TextView sugarLevel = (TextView) findViewById(R.id.sugarLevel);
    try {
      sugarLevel.setText(String.format("%.2f", estimator.getlastValue(0)));
      drawEstimationGraph();
    } catch (Exception e) {
      sugarLevel.setText(e.getMessage());
      exist = 0;
    }

    Button refresh = (Button) findViewById(R.id.refresh);
    refresh.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            TextView sugarLevel = (TextView) findViewById(R.id.sugarLevel);
            try {
              sugarLevel.setText(String.format("%.2f", estimator.getlastValue(0)));
              drawEstimationGraph();
            } catch (Exception e) {
              sugarLevel.setText(e.getMessage());
            }
          }
        });
  }
Ejemplo n.º 2
0
  private void drawEstimationGraph() {
    double output[] = estimator.getEstimataion();

    GraphViewData data[] = new GraphViewData[output.length];
    for (int i = 0; i < output.length; ++i) {
      data[i] = new GraphViewData(i, output[i]);
    }

    // init example series data
    GraphViewSeries exampleSeries = new GraphViewSeries(data);

    // granica hiperglikemiczna
    data = new GraphViewData[output.length];
    for (int i = 0; i < output.length; ++i) {
      data[i] = new GraphViewData(i, 130);
    }

    GraphViewSeries hyperglycemicSeries1 =
        new GraphViewSeries("Hiperglikemia 1", Color.rgb(200, 50, 00), data);

    data = new GraphViewData[output.length];
    for (int i = 0; i < output.length; ++i) {
      data[i] = new GraphViewData(i, 180);
    }

    GraphViewSeries hyperglycemicSeries2 =
        new GraphViewSeries("Hiperglikemia 2", Color.rgb(220, 20, 60), data);

    data = new GraphViewData[output.length];
    for (int i = 0; i < output.length; ++i) {
      data[i] = new GraphViewData(i, 50);
    }

    GraphViewSeries lowSeries = new GraphViewSeries("Dolna granica", Color.rgb(255, 215, 00), data);

    GraphView graphView = new LineGraphView(this, "Poziom cukru [mg/dl]");

    graphView.setHorizontalLabels(new String[] {"0h", "1h", "2h", "3h", "4h", "5h", "6h"});

    graphView.addSeries(hyperglycemicSeries1);
    graphView.addSeries(hyperglycemicSeries2);
    graphView.addSeries(lowSeries);
    graphView.addSeries(exampleSeries); // data

    graphView.setViewPort(0, 360);

    LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
    layout.addView(graphView);
  }