예제 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pressure_monitor);
    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    pressuremeter = sensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE);
    textViewPressure = (TextView) findViewById(R.id.textViewPressure);
    radioGroup = (RadioGroup) findViewById(R.id.radioGroup1);
    radioGroup.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.preasure) sensorId = 0;
            else if (checkedId == R.id.altitude) sensorId = 1;
            else sensorId = 2;
            plotLongHistory();
          }
        });
    setTitle("Pressure");

    // setup the APR History plot:
    preHistoryPlot = (XYPlot) findViewById(R.id.pressurePlot);
    preHistoryPlot.setRangeBoundaries(900, 1300, BoundaryMode.AUTO);
    preHistoryPlot.setDomainBoundaries(0, 100, BoundaryMode.AUTO); // FIXED);
    preHistoryPlot.addSeries(
        pressureHistorySeries,
        new LineAndPointFormatter(
            Color.BLACK, Color.RED, null, new PointLabelFormatter(Color.TRANSPARENT)));
    preHistoryPlot.setDomainStepValue(5);
    preHistoryPlot.setTicksPerRangeLabel(3);
    // preHistoryPlot.setDomainLabel("Sample Index");
    preHistoryPlot.getDomainLabelWidget().pack();
    preHistoryPlot.setRangeLabel("Temperature (ºC)");
    preHistoryPlot.getRangeLabelWidget().pack();
    preHistoryPlot.setRangeLabel("Pressure (hPa)");

    longHistoryPlot = (XYPlot) findViewById(R.id.longHistoryPlot);
    longHistoryPlot.setRangeBoundaries(900, 1300, BoundaryMode.AUTO);
    longHistoryPlot.setDomainBoundaries(0, 100, BoundaryMode.AUTO); // FIXED);
    longHistoryPlot.addSeries(
        longHistorySeries,
        new LineAndPointFormatter(
            Color.BLACK, Color.BLUE, null, new PointLabelFormatter(Color.TRANSPARENT)));
    longHistoryPlot.setDomainStepValue(5);
    longHistoryPlot.setTicksPerRangeLabel(3);
    longHistoryPlot.getDomainLabelWidget().pack();
    longHistoryPlot.setRangeLabel("Temperature (ºC)");
    longHistoryPlot.getRangeLabelWidget().pack();
    longHistoryPlot.setRangeLabel("Pressure (hPa)");

    // TEST
    if (!SamplingService.isRunning(this)) {
      SamplingAlarm.SetAlarm(this);
    }
  }
    // Constructor sets up the series
    public mPlotUpdater(XYPlot plot) {
      this.plot = plot;
      // only display whole numbers in domain labels
      plot.getGraphWidget().setDomainValueFormat(new DecimalFormat("0"));

      // Line plot
      if (dispForm == "WAVE") {
        LineAndPointFormatter maxFormat =
            new LineAndPointFormatter(
                Color.rgb(0, 25, 250), // line color
                Color.rgb(0, 25, 250), // point color
                null); // fill color (optional)

        LineAndPointFormatter minFormat =
            new LineAndPointFormatter(
                Color.rgb(250, 25, 0), // line color
                Color.rgb(250, 25, 0), // point color
                null); // fill color (optional)

        LineAndPointFormatter audioFormat =
            new LineAndPointFormatter(
                Color.rgb(25, 250, 0), // line color
                Color.rgb(25, 250, 0), // point color
                null); // fill color (optional)

        plot.addSeries(audioHistSeries, audioFormat);
        plot.addSeries(maxSeries, maxFormat);
        plot.addSeries(minSeries, minFormat);
      }
      // Bar plot
      if (dispForm == "FFT") {
        plot.addSeries(
            audioHistSeries,
            BarRenderer.class,
            new BarFormatter(Color.argb(100, 0, 200, 0), Color.rgb(0, 80, 0)));
      }

      // thin out domain/range tick labels so they don't overlap each other:
      plot.setGridPadding(5, 0, 5, 0);
      plot.setTicksPerDomainLabel(5);
      plot.setTicksPerRangeLabel(3);
      plot.disableAllMarkup();

      // freeze the range boundaries:
      plot.setDomainStepMode(XYStepMode.INCREMENT_BY_VAL);
      plot.setDomainStepValue(1);
      plot.setTicksPerRangeLabel(6);
      if (dispForm == "WAVE") plot.setDomainLabel("Time");
      if (dispForm == "FFT ") plot.setDomainLabel("Frequency");
      plot.getDomainLabelWidget().pack();
      plot.setRangeLabel("Amplitude");
      plot.getRangeLabelWidget().pack();
      plot.disableAllMarkup();
    }
예제 #3
0
  /** DESCRIPTION: Adjust font sizes used for plot labels to reflect shared preferences. */
  private void setPlotFontSizes() {
    PlotFontSize size = new PlotFontSize(activity, Settings.KEY_PLOT_FONT_SIZE);

    // plot title label
    PaintUtils.setFontSizeDp(plot.getTitleWidget().getLabelPaint(), size.getSizeDp());
    plot.getTitleWidget().pack();

    // axis step value labels
    PaintUtils.setFontSizeDp(plot.getGraphWidget().getRangeLabelPaint(), size.getSizeDp());
    PaintUtils.setFontSizeDp(plot.getGraphWidget().getDomainLabelPaint(), size.getSizeDp());

    // axis origin value labels
    PaintUtils.setFontSizeDp(plot.getGraphWidget().getRangeOriginLabelPaint(), size.getSizeDp());
    PaintUtils.setFontSizeDp(plot.getGraphWidget().getDomainOriginLabelPaint(), size.getSizeDp());

    // axis title labels
    PaintUtils.setFontSizeDp(plot.getRangeLabelWidget().getLabelPaint(), size.getSizeDp());
    PaintUtils.setFontSizeDp(plot.getDomainLabelWidget().getLabelPaint(), size.getSizeDp());
    plot.getRangeLabelWidget().pack();
    plot.getDomainLabelWidget().pack();

    // average point label
    avgLabelFormatter.getTextPaint().setTextSize(PixelUtils.dpToPix(size.getSizeDp()));
  }