Esempio n. 1
0
  @SuppressWarnings("deprecation")
  public void drawGraph(
      XYPlot plot, List<Number> xseries, List<Number> yseries, String datatitle, String title) {
    //		Log.d(SystemInfo.TIG, TAG + "::drawGraph()");

    // set up data series
    plot.removeSeries(series);

    series = new SimpleXYSeries(xseries, yseries, datatitle);

    // create a formatter
    // TODO solve deprecation waring
    LineAndPointFormatter format =
        new LineAndPointFormatter(
            Color.rgb(0, 200, 0) // line color
            ,
            Color.rgb(0, 100, 0) // point color
            ,
            Color.rgb(150, 190, 150)); // fill color (optional)

    // add series1 and series2 to the XYPlot
    plot.addSeries(series, format);

    // Reduce the number of range labels
    plot.setTicksPerRangeLabel(3);
    plot.getBackgroundPaint().setAlpha(0);
    plot.getGraphWidget().getBackgroundPaint().setAlpha(0);
    plot.getGraphWidget().getGridBackgroundPaint().setAlpha(0);

    // TODO implement an on-the-fly refresh of the plot
    // this is just a small "stubbed" redraw for demonstration purposes
    plot.setDomainStepMode(XYStepMode.SUBDIVIDE);
    plot.setDomainStepValue(1);
    plot.setGridPadding(0, 5, 0, 5);

    plot.setDomainLabel("Time [s]");
    if (title.equals(SystemInfo.DB_TABLENAME_BATTERY)) {
      plot.setTitle(SystemInfo.DB_TABLENAME_BATTERY);
      plot.setRangeLabel("[%]");
      plot.setRangeBoundaries(0, 100, BoundaryMode.FIXED);

    } else if (title.equals(SystemInfo.DB_TABLENAME_WIFI)) {
      plot.setTitle(SystemInfo.DB_TABLENAME_WIFI);
      plot.setRangeLabel("[~mW]");
      plot.setRangeBoundaries(0, 500, BoundaryMode.FIXED);

    } else if (title.equals(SystemInfo.DB_TABLENAME_THREEG)) {
      plot.setTitle(SystemInfo.DB_TABLENAME_THREEG);
      plot.setRangeLabel("[~mW]");
      plot.setRangeBoundaries(0, 500, BoundaryMode.FIXED);

    } else if (title.equals(SystemInfo.DB_TABLENAME_BLUETOOTH)) {
      plot.setTitle(SystemInfo.DB_TABLENAME_BLUETOOTH);
      plot.setRangeLabel("[~mW]");
      plot.setRangeBoundaries(0, 500, BoundaryMode.FIXED); // XXX scale
    }
    plot.redraw();
  }
Esempio n. 2
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);
    }
  }
Esempio n. 3
0
  /**
   * DESCRIPTION: Called when one or more plot preferences have changed.
   *
   * @see
   *     android.content.SharedPreferences.OnSharedPreferenceChangeListener#onSharedPreferenceChanged(android.content.SharedPreferences,
   *     java.lang.String)
   */
  @Override
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

    if (key.equals(Settings.KEY_PLOT_DATE_RANGE)) {
      // plot date range changed
      redrawPlot();
    }

    if (key.equals(Settings.KEY_PLOT_FONT_SIZE)) {
      // plot font size changed
      redrawPlot();
    }

    if (key.equals(Settings.KEY_UNITS)) {

      // get new units of measurement
      units = new Units(Settings.KEY_UNITS);

      // update the plot to reflect new units
      plot.setRangeLabel(units.getLiquidVolumeLabel());

      // redraw the plot
      redrawPlot();
    }
  }
Esempio n. 4
0
  public void onSensorChanged(SensorEvent event) {
    String valuesString = "";
    int counter = 0;
    for (float value : event.values) {
      valuesString += String.format("%d) %f ", counter++, value);
    }
    valuesString += " , " + pressureHistory.size();
    textViewPressure.setText(valuesString);

    double value = pressureSmoothingWin.push((double) event.values[0]);
    // Number[] series1Numbers = {event.values[0], event.values[1],
    // event.values[2]};
    // get rid the oldest sample in history:
    if (pressureHistory.size() > HISTORY_SIZE) {
      pressureHistory.removeFirst();
    }
    // add the latest history sample:
    pressureHistory.addLast(value); // event.values[0]);

    value = altitudeSmoothingWin.push((double) event.values[1]);
    if (altitudeHistory.size() > HISTORY_SIZE) {
      altitudeHistory.removeFirst();
    }
    altitudeHistory.addLast(value); // event.values[0]);

    value = tempSmoothingWin.push((double) event.values[2]);
    if (tempHistory.size() > HISTORY_SIZE) {
      tempHistory.removeFirst();
    }
    tempHistory.addLast(value);
    if (cooler++ % 2 == 0) return;
    // update the plot with the updated history Lists:
    if (sensorId == 0) {
      pressureHistorySeries.setModel(pressureHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
      preHistoryPlot.setRangeLabel("Pressure (hPa)");
    } else if (sensorId == 1) {
      pressureHistorySeries.setModel(altitudeHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
      preHistoryPlot.setRangeLabel("Altitude (m)");
    } else {
      pressureHistorySeries.setModel(tempHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
      preHistoryPlot.setRangeLabel("Temperature (ºC)");
    }

    // redraw the Plots:
    preHistoryPlot.redraw();
  }
Esempio n. 5
0
 private void plotTemperatureHistory() {
   SensorHistory temperatureLongHistory =
       new SensorHistory(
           Environment.getExternalStorageDirectory().getPath() + "/Sensors/temperature.dat");
   longHistoryPlot.setRangeLabel("Temperature (ºC)");
   longHistoryPlot.getRangeLabelWidget().pack();
   longHistorySeries.setModel(temperatureLongHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
   longHistoryPlot.redraw();
 }
Esempio n. 6
0
 private void plotAltitudeHistory() {
   SensorHistory altitudeLongHistory =
       new SensorHistory(
           Environment.getExternalStorageDirectory().getPath() + "/Sensors/altitude.dat");
   longHistoryPlot.setRangeLabel("Altitude (m)");
   longHistoryPlot.getRangeLabelWidget().pack();
   longHistorySeries.setModel(altitudeLongHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
   longHistoryPlot.redraw();
 }
Esempio n. 7
0
  /**
   * DESCRIPTION: Creates the graph.
   *
   * @see android.app.Activity#onCreate(android.os.Bundle)
   */
  public void onCreate(Bundle savedInstanceState, Activity parent, XYPlot xyplot) {
    this.activity = parent;
    this.plot = xyplot;

    // get current units of measurement
    units = new Units(Settings.KEY_UNITS);

    // create a formatter to use for drawing the plot series
    plotFormatter =
        new BarFormatter(
            activity.getResources().getColor(R.color.plot_fill_color),
            activity.getResources().getColor(R.color.plot_line_color));

    // create a formatter for average label
    float hOffset = 50f;
    float vOffset = -10f;
    avgLabelFormatter =
        new PointLabelFormatter(
            activity.getResources().getColor(R.color.plot_avgline_color), hOffset, vOffset);

    // create a formatter to use for drawing the average line
    avgFormatter =
        new LineAndPointFormatter(
            activity.getResources().getColor(R.color.plot_avgline_color),
            null,
            null,
            avgLabelFormatter);

    // white background for the plot
    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);

    // remove the series legend
    plot.getLayoutManager().remove(plot.getLegendWidget());

    // make room for bigger labels
    // TODO: is there a better way to do this?
    float width = plot.getGraphWidget().getRangeLabelWidth() * 2f;
    plot.getGraphWidget().setRangeLabelWidth(width);
    width = plot.getGraphWidget().getDomainLabelWidth() * 1.5f;
    plot.getGraphWidget().setDomainLabelWidth(width);
    float margin = plot.getGraphWidget().getMarginTop() * 3f;
    plot.getGraphWidget().setMarginTop(margin);
    margin = plot.getGraphWidget().getMarginBottom() * 3f;
    plot.getGraphWidget().setMarginBottom(margin);

    // define plot axis labels
    plot.setRangeLabel(units.getLiquidVolumeLabel());
    plot.setDomainLabel(activity.getString(R.string.months_label));

    // specify format of axis value labels
    plot.setRangeValueFormat(ylabels);
    plot.setDomainValueFormat(xlabels);

    // plot the data
    drawPlot();
  }
    // 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();
    }
Esempio n. 9
0
  public GraphUpdater(Activity activity) {
    this.activity = activity;
    wifi = (WifiManager) activity.getSystemService(Context.WIFI_SERVICE);
    plot = (XYPlot) activity.findViewById(R.id.graph);
    hash = new HashMap<String, WifiStrengthXYSeries>();

    plot.setTitle("");
    plot.setTicksPerRangeLabel(2);
    plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1);
    plot.setDomainBoundaries(-1, 15, BoundaryMode.FIXED);
    plot.setDomainLabel("Channel");
    DecimalFormat df = new DecimalFormat("#0");
    df.setParseIntegerOnly(true);
    plot.setDomainValueFormat(df);
    plot.setRangeBoundaries(-100, -20, BoundaryMode.FIXED);
    plot.setRangeLabel("Strength");
    plot.getLegendWidget().setVisible(false);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.zoomscrollgraph);
    mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
    mySimpleXYPlot.setOnTouchListener(this);

    // Plot layout configurations
    mySimpleXYPlot.getGraphWidget().setTicksPerRangeLabel(1);
    mySimpleXYPlot.getGraphWidget().setTicksPerDomainLabel(1);
    mySimpleXYPlot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##"));
    mySimpleXYPlot.getGraphWidget().setDomainValueFormat(new DecimalFormat("#####.##"));
    mySimpleXYPlot.getGraphWidget().setRangeLabelWidth(25);
    mySimpleXYPlot.setRangeLabel("");
    mySimpleXYPlot.setDomainLabel("");
    mySimpleXYPlot.disableAllMarkup();

    // Creation of the series
    final Vector<Double> vector = new Vector<Double>();
    for (double x = 0.0; x < Math.PI * 5; x += Math.PI / 20) {
      vector.add(x);
      vector.add(Math.sin(x));
    }
    mySeries = new SimpleXYSeries(vector, ArrayFormat.Y_VALS_ONLY, "Series Name");

    // colors: (line, vertex, fill)
    mySimpleXYPlot.addSeries(
        mySeries,
        LineAndPointRenderer.class,
        new LineAndPointFormatter(
            Color.rgb(0, 200, 0), Color.rgb(200, 0, 0), Color.argb(100, 0, 0, 100)));

    // Enact all changes
    mySimpleXYPlot.redraw();

    // Set of internal variables for keeping track of the boundaries
    mySimpleXYPlot.calculateMinMaxVals();
    m_viewPort = new Viewport(mySimpleXYPlot);
  }
Esempio n. 11
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.poincare);

    // Rellenar vector RR1
    for (int i = 1; i < Representar.RR.size(); i++) {
      RR1.add(Representar.RR.get(i));
    }
    // Rellenar vector RRaux
    for (int i = 0; i < Representar.RR.size() - 1; i++) {
      RRaux.add(Representar.RR.get(i));

      Log.i("RRaux", String.valueOf(Representar.RR.get(i)));
    }

    // Declarar el Plot
    mySimpleXYPlot = (XYPlot) findViewById(R.id.plotPoincare);

    // Configurar el Plot
    XYSeries series1 =
        new SimpleXYSeries(
            RRaux, // Vector a representar en el eje X
            RR1, // Vector a representar en el eje Y
            "Poincaré"); // Etiqueta

    LineAndPointFormatter series1Format =
        new LineAndPointFormatter(
            Color.TRANSPARENT, // Color de la línea
            Color.rgb(
                Representar.color0, Representar.color1, Representar.color2), // Color de los puntos
            null); // Color de relleno

    // Propiedades para configurar el Plot
    mySimpleXYPlot.addSeries(series1, series1Format);
    mySimpleXYPlot.setTicksPerRangeLabel(4);
    mySimpleXYPlot.disableAllMarkup();
    mySimpleXYPlot.getBackgroundPaint().setAlpha(0);
    mySimpleXYPlot.getGraphWidget().getBackgroundPaint().setAlpha(0);
    mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setAlpha(0);
    // Redibujar el Plot
    mySimpleXYPlot.redraw();

    // Configuración boundaries
    mySimpleXYPlot.calculateMinMaxVals();
    // Cálculo del valor mínimo y máximo
    minXY =
        new PointF(
            mySimpleXYPlot.getCalculatedMinX().floatValue(),
            mySimpleXYPlot.getCalculatedMinY().floatValue());
    maxXY =
        new PointF(
            mySimpleXYPlot.getCalculatedMaxX().floatValue(),
            mySimpleXYPlot.getCalculatedMaxY().floatValue());
    mySimpleXYPlot.setScrollbarFadingEnabled(true);
    mySimpleXYPlot.setScrollContainer(true);

    mySimpleXYPlot.getLayoutManager().remove(mySimpleXYPlot.getLegendWidget());
    // Etiquetas vertical y horizontal
    mySimpleXYPlot.setRangeLabel("RR N+1");
    mySimpleXYPlot.setDomainLabel("RR N");
    mySimpleXYPlot.getLayoutManager().remove(mySimpleXYPlot.getTitleWidget());
    // Márgenes del Plot
    mySimpleXYPlot.setPlotMargins(10, 10, 10, 10);
    mySimpleXYPlot.setPlotPadding(10, 10, 10, 10);
    // Comienzo y fin del plot
    mySimpleXYPlot.setDomainBoundaries(
        mySimpleXYPlot.getCalculatedMinX().floatValue() - 10.0,
        mySimpleXYPlot.getCalculatedMaxX().floatValue() + 10.0,
        BoundaryMode.FIXED);
    mySimpleXYPlot.setRangeBoundaries(
        mySimpleXYPlot.getCalculatedMinY().floatValue() - 10.0,
        mySimpleXYPlot.getCalculatedMaxY().floatValue() + 10.0,
        BoundaryMode.FIXED);
  }
Esempio n. 12
0
  private void ShowPlot() {
    mySimpleXYPlot = (XYPlot) findViewById(R.id.chartPlot);
    mySimpleXYPlot.setTitle("Weight");

    if (plotLine != null) mySimpleXYPlot.removeSeries(plotLine);

    mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);
    mySimpleXYPlot.getGraphWidget().getGridLinePaint().setColor(Color.BLACK);
    mySimpleXYPlot
        .getGraphWidget()
        .getGridLinePaint()
        .setPathEffect(new DashPathEffect(new float[] {1, 1}, 1));
    mySimpleXYPlot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    mySimpleXYPlot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);

    mySimpleXYPlot.setBorderStyle(Plot.BorderStyle.SQUARE, null, null);
    mySimpleXYPlot.getBorderPaint().setStrokeWidth(1);
    mySimpleXYPlot.getBorderPaint().setAntiAlias(false);
    mySimpleXYPlot.getBorderPaint().setColor(Color.WHITE);
    mySimpleXYPlot.getGraphWidget().setPaddingRight(5);

    // Create a formatter to use for drawing a series using LineAndPointRenderer:
    LineAndPointFormatter series1Format =
        new LineAndPointFormatter(
            Color.rgb(0, 100, 0), // line color
            Color.rgb(0, 100, 0), // point color
            Color.rgb(100, 200, 0)); // fill color

    // setup our line fill paint to be a slightly transparent gradient:
    Paint lineFill = new Paint();
    lineFill.setAlpha(200);
    lineFill.setShader(
        new LinearGradient(0, 0, 0, 250, Color.WHITE, Color.GREEN, Shader.TileMode.MIRROR));

    LineAndPointFormatter formatter =
        new LineAndPointFormatter(Color.rgb(0, 0, 0), Color.BLUE, Color.RED);
    formatter.setFillPaint(lineFill);

    plotLine = new SimpleXYSeries(Arrays.asList(dates), Arrays.asList(weights), "Weight over time");
    mySimpleXYPlot.addSeries(plotLine, formatter);
    mySimpleXYPlot.redraw();

    // draw a domain tick for each year:
    int min = DomainMin();
    int max = DomainMax();
    int domainStep = domainStep(min, max);
    mySimpleXYPlot.setDomainStep(XYStepMode.SUBDIVIDE, domainStep);
    // mySimpleXYPlot.setDomainBoundaries(min, max, BoundaryMode.AUTO);

    // customize our domain/range labels
    mySimpleXYPlot.setDomainLabel("Date");
    mySimpleXYPlot.setRangeLabel("Weight");

    Double minimum = FindMinimum();
    Double maximum = FindMaximum();
    Double stepSize = FindStep(maximum, minimum);
    mySimpleXYPlot.setRangeBoundaries(minimum, maximum, BoundaryMode.FIXED);
    mySimpleXYPlot.setRangeStep(XYStepMode.INCREMENT_BY_VAL, stepSize);

    mySimpleXYPlot.setDomainValueFormat(
        new Format() {
          private SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM");

          @Override
          public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {

            // because our timestamps are in seconds and SimpleDateFormat expects milliseconds
            // we multiply our timestamp by 1000:
            long timestamp = ((Number) obj).longValue() * 1000;
            Date date = new Date(timestamp);
            return dateFormat.format(date, toAppendTo, pos);
          }

          @Override
          public Object parseObject(String source, ParsePosition pos) {
            return null;
          }
        });

    // by default, AndroidPlot displays developer guides to aid in laying out your plot.
    // To get rid of them call disableAllMarkup():
    mySimpleXYPlot.disableAllMarkup();
  }
Esempio n. 13
0
  void generatePlot() {
    TextView tv = (TextView) findViewById(R.id.plotViewTitle);
    tv.setText(
        "Avistamientos durante " + meses[actualMonth - 1] + " del " + String.valueOf(actualYear));

    SQLiteDatabase myDB = null;

    myDB = this.openOrCreateDatabase(DB_NAME, 1, null);

    myDB.execSQL(
        "CREATE TABLE IF NOT EXISTS "
            + TABLE
            + " ("
            + ADDR_DB
            + " TEXT NOT NULL PRIMARY KEY, "
            + COORD_X_DB
            + " INTEGER NOT NULL, "
            + COORD_Y_DB
            + " INTEGER NOT NULL, "
            + INF_DB
            + " TEXT, "
            + DAY_DB
            + " INTEGER, "
            + MONTH_DB
            + " INTEGER, "
            + YEAR_DB
            + " INTEGER);");

    /*
     * Solo obtendremos los días donde se han visto avistamientos ordenados por menor a mayor.
     */
    String[] FROM = {DAY_DB};
    String ORDER_BY = YEAR_DB + " DESC, " + MONTH_DB + " DESC, " + DAY_DB + " DESC";

    Cursor c =
        myDB.query(
            TABLE,
            FROM,
            MONTH_DB + "=" + actualMonth + " AND " + YEAR_DB + "=" + actualYear,
            null,
            null,
            null,
            ORDER_BY);

    /*
     * Preparamos el vector de Number dependiendo del mes que tengamos que mostrar
     */
    Number[] series1Numbers;
    int daysOfMonth = 0;

    if (actualMonth == 1
        || actualMonth == 3
        || actualMonth == 5
        || actualMonth == 7
        || actualMonth == 8
        || actualMonth == 10
        || actualMonth == 12) {
      daysOfMonth = 32;
      series1Numbers = new Number[daysOfMonth];
      for (int i = 0; i < daysOfMonth; ++i) series1Numbers[i] = 0;
    } else if (actualMonth == 2) {
      daysOfMonth = 29;
      series1Numbers = new Number[daysOfMonth];
      for (int i = 0; i < daysOfMonth; ++i) series1Numbers[i] = 0;
    } else {
      daysOfMonth = 31;
      series1Numbers = new Number[daysOfMonth];
      for (int i = 0; i < daysOfMonth; ++i) series1Numbers[i] = 0;
    }

    int max = 0; // sirve para establecer el máximo Y valor del gráfico
    int aux = 0;
    int dayAux = 0;

    startManagingCursor(c);
    while (c.moveToNext()) {
      int dayDB = c.getInt(0);
      if (max < aux) max = aux;
      if (dayAux == 0) {
        dayAux = dayDB;
        ++aux;
      } else {
        if (dayAux == dayDB) ++aux;
        else {
          series1Numbers[dayAux] = aux;
          aux = 1;
          dayAux = dayDB;
        }
      }
    }
    if (dayAux != 0) series1Numbers[dayAux] = aux;

    c.close();

    if (myDB != null) {
      myDB.close();
    }

    // Inicializamos el objeto XYPlot búscandolo desde el layout:
    mySimpleXYPlot = (XYPlot) findViewById(R.id.plot);
    mySimpleXYPlot.clear();
    mySimpleXYPlot.setDomainLabel("Días de " + meses[actualMonth - 1]);
    mySimpleXYPlot.setRangeLabel("Número de avistamientos");

    // Añadimos Línea Número UNO:
    XYSeries series1 =
        new SimpleXYSeries(
            Arrays.asList(series1Numbers), // Array de datos
            SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Valores verticales
            "Número de avistamientos"); // Nombre de la serie

    // Modificamos los colores de la primera serie
    LineAndPointFormatter series1Format =
        new LineAndPointFormatter(
            Color.rgb(200, 0, 0), // Color de la l�nea
            Color.rgb(0, 0, 0), // Color del punto
            Color.rgb(190, 150, 150)); // Relleno

    // Una vez definida la serie (datos y estilo), la añadimos al panel
    mySimpleXYPlot.addSeries(series1, series1Format);

    if (max == 0) ++max;

    // Tuneamos el grafico
    mySimpleXYPlot.setDomainValueFormat(new DecimalFormat("#"));
    mySimpleXYPlot.setDomainBoundaries(1, daysOfMonth - 1, BoundaryMode.FIXED);
    mySimpleXYPlot.setDomainStepValue(daysOfMonth);
    if (daysOfMonth == 32) {
      mySimpleXYPlot.setTicksPerDomainLabel(2);
    } else if (daysOfMonth == 31) {
      mySimpleXYPlot.setTicksPerDomainLabel(3);
    } else if (daysOfMonth == 28) {
      mySimpleXYPlot.setTicksPerDomainLabel(2);
    }
    mySimpleXYPlot.setRangeUpperBoundary(max + 2, BoundaryMode.FIXED);
    mySimpleXYPlot.setRangeStepValue(max + 3);
    mySimpleXYPlot.setTicksPerRangeLabel(1);
    mySimpleXYPlot.disableAllMarkup();

    /*
     * Generamos la vista de nueva para mostrar la nueva gráfica
     */
    ScrollView sv = (ScrollView) findViewById(R.id.scrollView);
    sv.postInvalidate();
  }