Example #1
0
  /** @param canvas */
  private void drawTFR(Canvas canvas) {
    mPaint.setColor(Color.RED);
    mPaint.setShadowLayer(0, 0, 0, 0);

    /*
     * Draw TFRs, weather
     */
    if (mPref.shouldTFRAndMETARShow()) {

      LinkedList<TFRShape> shapes = null;
      if (null != mService) {
        shapes = mService.getTFRShapes();
      }
      if (null != shapes) {
        mPaint.setColor(Color.RED);
        mPaint.setStrokeWidth(8);
        mPaint.setShadowLayer(0, 0, 0, 0);
        for (int shape = 0; shape < shapes.size(); shape++) {
          TFRShape cshape = shapes.get(shape);
          if (cshape.isVisible()) {
            /*
             * Find offsets of TFR then draw it
             */
            cshape.drawShape(canvas, mOrigin, mScale, mMovement, mPaint, mFace);
          }
        }
      }
    }
  }
Example #2
0
    /* (non-Javadoc)
     * @see android.view.GestureDetector.SimpleOnGestureListener#onLongPress(android.view.MotionEvent)
     */
    @Override
    public void onLongPress(MotionEvent e) {
      /*
       * on long press, find a point where long press was done
       */
      double x = mCurrTouchPoint.getX();
      double y = mCurrTouchPoint.getY();

      double lon2 = mOrigin.getLongitudeOf(x);
      double lat2 = mOrigin.getLatitudeOf(y);
      Projection p =
          new Projection(mGpsParams.getLongitude(), mGpsParams.getLatitude(), lon2, lat2);

      double brg = p.getBearing();
      String text = null;

      /*
       * Get TFR text if touched on its top
       */
      LinkedList<TFRShape> shapes = null;
      if (null != mService) {
        shapes = mService.getTFRShapes();
      }
      if (null != shapes) {
        for (int shape = 0; shape < shapes.size(); shape++) {
          TFRShape cshape = shapes.get(shape);
          if (cshape.isVisible()) {

            /*
             * Hijack weather color
             */
            mWeatherColor = Color.RED;
            text = cshape.getTextIfTouched(x, y);
            if (null != text) {
              break;
            }
          }
        }
      }

      /*
       * Draw distance from point
       */
      mPoint =
          ""
              + (int) p.getDistance()
              + "nm "
              + p.getGeneralDirectionFrom()
              + ","
              + Math.round(brg)
              + '\u00B0'
              + mContext.getString(R.string.To);

      if (mPref.shouldTFRAndMETARShow()) {
        /*
         * If weather shows
         */
        if (text == null) {
          new AirportTask().execute(lon2, lat2);
        } else {
          /*
           * Take TFR text over weather text
           */
          mTextPaint.setColor(Color.WHITE);
          mWeatherLayout =
              new StaticLayout(
                  text.trim(), mTextPaint, getWidth(), Layout.Alignment.ALIGN_NORMAL, 1, 0, true);
        }
      }
    }