示例#1
0
  private static void paintImageText(
      Context context,
      WidgetLayoutDetails widgetLayoutDetails,
      Canvas canvas,
      WindData windData,
      int xOffset,
      int yOffset) {
    int xPosText = xOffset + (int) widgetLayoutDetails.spotImageHeight + 30;
    int yPosTextTime = yOffset + (int) (widgetLayoutDetails.spotImageHeight / 4) * 1;
    int yPosTextWind = yOffset + (int) (widgetLayoutDetails.spotImageHeight / 4) * 2;
    int yPosTextAngle = yOffset + (int) (widgetLayoutDetails.spotImageHeight / 4) * 3;

    // paint text data
    Paint textPaint = new Paint();
    textPaint.setColor(Color.DKGRAY);
    textPaint.setTextSize(30);

    String timeStr = context.getResources().getString(R.string.graphics_no_data);
    String windStr = context.getResources().getString(R.string.graphics_no_data);
    String angleStr = context.getResources().getString(R.string.graphics_no_data);
    if (windData != null) {
      int wind = (int) Math.round(windData.getWind());
      int gust = (int) Math.round(windData.getGust());
      timeStr = windData.getTimeStr();
      windStr = wind + " - " + gust + " " + context.getResources().getString(R.string.graphics_mps);
      angleStr =
          windData.getAngle() + " " + context.getResources().getString(R.string.graphics_degrees);
    }

    canvas.drawText(timeStr, xPosText, yPosTextTime, textPaint);
    canvas.drawText(windStr, xPosText, yPosTextWind, textPaint);
    canvas.drawText(angleStr, xPosText, yPosTextAngle, textPaint);
  }
示例#2
0
  public static Set<Bar> createGustGraph(
      SpotWindData spotDayData, int startX, int startY, int endX, int endY) {
    Set<Bar> path = new LinkedHashSet<Bar>();
    double xDiff = endX - startX;
    double yDiff = endY - startY;
    for (WindData windData : spotDayData.getWindDatas()) {
      double wind = windData.getWind();
      double gust = windData.getGust();
      if (wind > MAXWIND) wind = MAXWIND;
      if (gust > MAXWIND) gust = MAXWIND;
      double time2 = (double) windData.getEndHour() + (double) windData.getEndMinute() / 60;
      double time1 = (double) windData.getStartHour() + (double) windData.getStartMinute() / 60;
      double xProcent2 = time2 / 24;
      double yProcent2 = wind / MAXWIND;
      double yProcent1 = gust / MAXWIND;
      double xProcent1 = time1 / 24;
      double x1 = startX + xProcent1 * xDiff;
      double y1 = endY - yProcent1 * yDiff;
      double y2 = endY - yProcent2 * yDiff;
      double x2 = startX + xProcent2 * xDiff;
      if (x1 > x2) x1 = startX; // in case startTime was from the day before.

      Bar bar = new Bar();
      bar.setX1((int) x1);
      bar.setX2((int) x2);
      bar.setY1((int) y1);
      bar.setY2((int) y2);
      path.add(bar);
    }

    return path;
  }
 public void InsertWindStat(WindData windStat, DbHandle handle) {
   SQLiteDatabase db = handle.getDb();
   ContentValues cv = new ContentValues();
   cv.put(COL_SPOT, windStat.getSpotID());
   cv.put(COL_DAY, windStat.getDay());
   cv.put(COL_HOUR, windStat.getEndHour());
   cv.put(COL_MINUTE, windStat.getEndMinute());
   cv.put(COL_START_HOUR, windStat.getStartHour());
   cv.put(COL_START_MINUTE, windStat.getStartMinute());
   cv.put(COL_WIND, windStat.getWind());
   cv.put(COL_GUST, windStat.getGust());
   cv.put(COL_ANGLE, windStat.getAngle());
   cv.put(COL_LAST_MODIFIED, windStat.getLastModified());
   db.insert(WINDTABLE, null, cv);
 }
 public void UpdateWindStat(WindData windStat, int id, DbHandle handle) {
   SQLiteDatabase db = handle.getDb();
   ContentValues cv = new ContentValues();
   cv.put(COL_DAY, windStat.getDay());
   cv.put(COL_SPOT, windStat.getSpotID());
   cv.put(COL_HOUR, windStat.getEndHour());
   cv.put(COL_MINUTE, windStat.getEndMinute());
   cv.put(COL_START_HOUR, windStat.getStartHour());
   cv.put(COL_START_MINUTE, windStat.getStartMinute());
   cv.put(COL_WIND, windStat.getWind());
   cv.put(COL_GUST, windStat.getGust());
   cv.put(COL_ANGLE, windStat.getAngle());
   cv.put(COL_LAST_MODIFIED, windStat.getLastModified());
   db.update(WINDTABLE, cv, COL_ID + "=?", new String[] {"" + id});
 }
示例#5
0
  private static WIND_POWER calculateWindPower(Context context, WindData windData) {
    if (windData.getAngle() == -1 || windData.getWind() == -1 || windData.getGust() == -1) {
      return WIND_POWER.OUTDATED;
    }

    double wind = windData.getWind();
    double minWind = LocalStorage.getMinimalWind(context);
    double optimalWind = LocalStorage.getOptimalWind(context);
    double muchWind = LocalStorage.getMuchWind(context);
    double tooMuchWind = LocalStorage.getToomuchWind(context);

    if (wind <= minWind) return WIND_POWER.TOO_SHORT;
    if ((wind > minWind) && (wind <= optimalWind)) return WIND_POWER.OK;
    if ((wind > optimalWind) && (wind <= muchWind)) return WIND_POWER.GOOD;
    if ((wind > muchWind) && (wind <= tooMuchWind)) return WIND_POWER.WARNING;
    if (wind > tooMuchWind) return WIND_POWER.DANGER;
    return WIND_POWER.DANGER; // should never happen
  }