@Override
  protected void onDraw(Canvas canvas) {
    // The main mechanism to display scale animation, you can customize it
    // as your needs
    int w = this.getWidth();
    int h = this.getHeight();
    canvas.scale(scale, scale, w / 2, h / 2);

    super.onDraw(canvas);
  }
 @Override
 protected void onDraw(Canvas canvas) {
   if (mDivider != null) {
     if (getOrientation() == VERTICAL) {
       drawDividersVertical(canvas);
     } else {
       drawDividersHorizontal(canvas);
     }
   }
   super.onDraw(canvas);
 }
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   if (isInEditMode()) {
     mDebugPaint.setColor(Color.WHITE);
     mDebugPaint.setTextSize(
         TypedValue.applyDimension(
             TypedValue.COMPLEX_UNIT_SP, 16, getResources().getDisplayMetrics()));
     mDebugPaint.setStyle(Paint.Style.STROKE);
     canvas.drawText("banner is here", 20, getHeight() * 2 / 3, mDebugPaint);
   }
 }
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // One time call to generate the pressed/focused state -- must be called
    // after
    // measure/layout
    if (mImageView == null) {
      mImageView = (ImageView) findViewById(mImageViewId);
    }
    mHolographicHelper.generatePressedFocusedStates(mImageView);
  }
Exemple #5
0
  @Override
  protected void onDraw(Canvas canvas) {

    super.onDraw(canvas);
    Rect rec = canvas.getClipBounds();
    RectF rectF = new RectF(rec);
    Paint paint = new Paint();
    paint.setColor(Color.parseColor("#C7D0D2"));
    paint.setAntiAlias(true);
    paint.setStrokeWidth(2);
    paint.setStyle(Paint.Style.STROKE);
    canvas.drawRoundRect(rectF, 2, 2, paint);
  }
  @Override
  public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (isFrist && topRefreshView.getHeight() > 0) {
      LayoutParams lp = (LayoutParams) topRefreshView.getLayoutParams();
      lp.topMargin = -topRefreshView.getHeight();
      topRefreshView.setLayoutParams(lp);
      isFrist = false;
    }

    if (animIsOver) {
      startAnim();
    }
  }
Exemple #7
0
  @Override
  protected void onDraw(final Canvas c) {
    c.drawColor(backgroundColor);

    final int color =
        Color.HSVToColor(
            alphaSelector.getSelectedAlpha(),
            new float[] {hueSelector.getHue(), satValSelector.getSat(), satValSelector.getVal()});

    satValSelector.setColor(color);
    alphaSelector.setColor(color);
    sizeSelector.setColor(color);
    penDisplay.setColor(color);
    penDisplay.setSize(sizeSelector.getSelectedSize());

    super.onDraw(c);
  }
  @SuppressLint("DrawAllocation")
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (gridHeight == 0) {
      LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.getLayoutParams();
      int w = this.getWidth();
      gridHeight = w / 10;
      layoutParams.height = gridHeight * days;
      gridWidth = w / gridSize;
      textSize = dip2px(this.context, 15);
      this.getParent().requestLayout();
    }

    if (c != 0) this.setbg(c);
    if (resid != 0) this.setBackgroundResource(resid);

    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

    // 竖线
    for (int i = 0; i < gridSize; i++) {
      if (i == 0 || i == 3 || i == 4 || i == 7) {
        paint.setColor(gridColor3);
      } else {
        paint.setColor(gridColor1);
      }

      paint.setStyle(Style.FILL);
      canvas.drawRect(gridWidth * i, 0, gridWidth * (i + 1), getHeight(), paint);
      if (i > 0) {
        paint.setColor(bgColor);
        paint.setStrokeWidth(1);
        if (i == 5 || i == 6) {
          canvas.drawLine(gridWidth * i + 1, 0, gridWidth * i + 1, getHeight(), paint);
        } else {
          canvas.drawLine(gridWidth * i, 0, gridWidth * i, getHeight(), paint);
        }
      }
    }
    // 划横线
    for (int i = 1; i <= days; i++) {
      paint.setColor(bgColor);
      canvas.drawLine(0, gridHeight * i, getWidth(), gridHeight * i, paint);

      drawString("" + i, 0 + gridWidth / 2, gridHeight * (i - 1) + gridHeight / 2, canvas);
      // canvas.drawRect(gridWidth*i, 0, gridWidth*i+blwidh, getHeight(),
      // paint);
    }
    if (values != null) {
      for (int i = 0; i < values.length; i++) {
        for (int j = 0; j < values[i].length; j++) {
          if (values[i][j] > 0) {
            drawString(
                "" + values[i][j],
                gridWidth + gridWidth * j + gridWidth / 2,
                gridHeight * i + gridHeight / 2,
                canvas);
          }
        }
      }
    }
  }
Exemple #9
0
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
 }
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    int width = getWidth();

    int left = 0;

    int right = left + (int) (width * mRedRatio);
    int right2 = right + (int) (width * mYellowRatio);
    int right3 = right2 + (int) (width * mGreenRatio);

    int indicatorLeft, indicatorRight;
    if (mShowingGreen) {
      indicatorLeft = right2;
      indicatorRight = right3;
    } else {
      indicatorLeft = right;
      indicatorRight = right2;
    }

    if (mLastInterestingLeft != indicatorLeft || mLastInterestingRight != indicatorRight) {
      mColorPath.reset();
      mEdgePath.reset();
      if (indicatorLeft < indicatorRight) {
        final int midTopY = mRect.top;
        final int midBottomY = 0;
        final int xoff = 2;
        mColorPath.moveTo(indicatorLeft, mRect.top);
        mColorPath.cubicTo(indicatorLeft, midBottomY, -xoff, midTopY, -xoff, 0);
        mColorPath.lineTo(width + xoff - 1, 0);
        mColorPath.cubicTo(
            width + xoff - 1, midTopY, indicatorRight, midBottomY, indicatorRight, mRect.top);
        mColorPath.close();
        final float lineOffset = mLineWidth + .5f;
        mEdgePath.moveTo(-xoff + lineOffset, 0);
        mEdgePath.cubicTo(
            -xoff + lineOffset,
            midTopY,
            indicatorLeft + lineOffset,
            midBottomY,
            indicatorLeft + lineOffset,
            mRect.top);
        mEdgePath.moveTo(width + xoff - 1 - lineOffset, 0);
        mEdgePath.cubicTo(
            width + xoff - 1 - lineOffset,
            midTopY,
            indicatorRight - lineOffset,
            midBottomY,
            indicatorRight - lineOffset,
            mRect.top);
      }
      mLastInterestingLeft = indicatorLeft;
      mLastInterestingRight = indicatorRight;
    }

    if (!mEdgePath.isEmpty()) {
      canvas.drawPath(mEdgePath, mEdgeGradientPaint);
      canvas.drawPath(mColorPath, mColorGradientPaint);
    }

    if (left < right) {
      mRect.left = left;
      mRect.right = right;
      mPaint.setColor(mLeftColor);
      canvas.drawRect(mRect, mPaint);
      width -= (right - left);
      left = right;
    }

    right = right2;

    if (left < right) {
      mRect.left = left;
      mRect.right = right;
      mPaint.setColor(mMiddleColor);
      canvas.drawRect(mRect, mPaint);
      width -= (right - left);
      left = right;
    }

    right = left + width;
    if (left < right) {
      mRect.left = left;
      mRect.right = right;
      mPaint.setColor(mRightColor);
      canvas.drawRect(mRect, mPaint);
    }
  }
 @Override
 public void onDraw(Canvas canvas) {
   canvas.clipRect(0, 0, horizontalClipping, canvas.getHeight());
   super.onDraw(canvas);
 }
  @Override
  public void onDraw(Canvas c) {

    // System.out.println("XYZ:ZANaviLinearLayout -> onDraw");

    //		if (2 == 1 + 1)
    //		{
    //			return;
    //		}

    if (this.need_size_change) {
      // System.out.println("XYZ:ZANaviLinearLayout -> onDraw [need_size_change]");

      int w = this.getWidth();
      int h = this.getHeight();

      float draw_factor = 1.0f;
      if (Navit.my_display_density.compareTo("mdpi") == 0) {
        draw_factor = 1.0f;
      } else if (Navit.my_display_density.compareTo("ldpi") == 0) {
        draw_factor = 0.7f;
      } else if (Navit.my_display_density.compareTo("hdpi") == 0) {
        draw_factor = 1.5f;
      }

      float draw_factor2 = draw_factor;
      // correct for ultra high DPI
      if (Navit.metrics.densityDpi >= 320) // && (Navit.PREF_shrink_on_high_dpi))
      {
        draw_factor2 = 1.8f * Navit.metrics.densityDpi / NavitGraphics.Global_want_dpi_other;
        NavitOSDJava.NavitStreetFontLetterWidth =
            (int)
                ((float) NavitOSDJava.NavitStreetFontLetterWidth_base
                    * Navit.metrics.densityDpi
                    / NavitGraphics.Global_want_dpi_other);
      }

      float real_factor = draw_factor2 / 1.5f;
      //
      //
      //

      sat_status_lt_w = (int) (8f * draw_factor);
      sat_status_lt_h = (int) (h * 0.35);
      sat_status_lt_x = (int) (2f * draw_factor);
      sat_status_lt_y = (int) ((h / 2) - (sat_status_lt_h / 2));

      r1.set(
          sat_status_lt_x,
          sat_status_lt_y,
          sat_status_lt_x + sat_status_lt_w,
          sat_status_lt_y + sat_status_lt_h);

      int mCanvasWidth = w;
      int mCanvasHeight = h;

      LayoutParams params = null;

      //
      child1 = Navit.Global_Navit_Object.findViewById(R.id.top_bar);
      child2 = Navit.Global_Navit_Object.findViewById(R.id.osd_compass_new);
      child3 = Navit.Global_Navit_Object.findViewById(R.id.osd_nextturn_new);
      child4 = Navit.Global_Navit_Object.findViewById(R.id.osd_timetoturn_new);
      child5 = Navit.Global_Navit_Object.findViewById(R.id.osd_timetodest_new);
      child6 = Navit.Global_Navit_Object.findViewById(R.id.osd_roaddistance_new);
      child7 = Navit.Global_Navit_Object.findViewById(R.id.osd_eta_new);
      child8 = Navit.Global_Navit_Object.findViewById(R.id.view_speeding);
      child9 = Navit.Global_Navit_Object.findViewById(R.id.view_laneassist);
      //

      this.need_size_change = false;
    }

    super.onDraw(c);

    // System.out.println("onDraw:ZANaviLinearLayout");

    try {
      if (!Navit.PAINT_OLD_API) {
        child1.postInvalidate();
        child2.postInvalidate();
        child3.postInvalidate();
        child4.postInvalidate();
        child5.postInvalidate();
        child6.postInvalidate();
        child7.postInvalidate();
        child8.postInvalidate();
        child9.postInvalidate();
      } else {
        //				child1.postInvalidate();
        //				child2.postInvalidate();
        //				child3.postInvalidate();
        //				child4.postInvalidate();
        //				child5.postInvalidate();
        //				child6.postInvalidate();
        //				child7.postInvalidate();
        //				child8.postInvalidate();
        //				child9.postInvalidate();
      }
    } catch (Exception e) {
    }

    try {
      if (Navit.p.PREF_show_sat_status) {
        if (Navit.sats > sat_status_max_sats) {
          sat_status_max_sats = Navit.sats;
        }

        // old status
        NavitVehicle.sat_status_icon_last = NavitVehicle.sat_status_icon_now;

        // get new status
        // if (Navit.satsInFix > 3)
        if (Navit.isGPSFix) {
          // GPS found position
          NavitVehicle.sat_status_icon_now = 1;
        } else {
          // GPS lost position
          NavitVehicle.sat_status_icon_now = 0;
        }

        if (NavitVehicle.sat_status_icon_now != NavitVehicle.sat_status_icon_last) {
          try {
            // if (NavitVehicle.sat_status_icon_now == 1)
            if (Navit.isGPSFix) {
              Navit.Global_Navit_Object.getSupportActionBar()
                  .setIcon(R.drawable.ic_action_location_found);
            } else {
              Navit.Global_Navit_Object.getSupportActionBar()
                  .setIcon(R.drawable.ic_action_location_searching);
            }
          } catch (Exception e) {
            e.printStackTrace();
          }
        }

        r2.set(
            sat_status_lt_x,
            sat_status_lt_y
                + sat_status_lt_h
                - (sat_status_lt_h / sat_status_max_sats * Navit.sats),
            sat_status_lt_x + sat_status_lt_w,
            sat_status_lt_y + sat_status_lt_h);
        r3.set(
            sat_status_lt_x,
            sat_status_lt_y
                + sat_status_lt_h
                - (sat_status_lt_h / sat_status_max_sats * Navit.satsInFix),
            sat_status_lt_x + sat_status_lt_w,
            sat_status_lt_y + sat_status_lt_h);
        r4.set(
            sat_status_lt_x,
            sat_status_lt_y,
            sat_status_lt_x + sat_status_lt_w,
            sat_status_lt_y + sat_status_lt_h);

        // fill rect
        paint_sat_status.setColor(Color.GRAY);
        paint_sat_status.setStyle(Paint.Style.FILL);
        paint_sat_status.setStrokeWidth(0);
        paint_sat_status.setAntiAlias(true);
        c.drawRect(r1, paint_sat_status);

        // fill inactive sats
        paint_sat_status.setColor(Color.YELLOW);
        paint_sat_status.setStyle(Paint.Style.FILL);
        paint_sat_status.setStrokeWidth(0);
        paint_sat_status.setAntiAlias(true);
        c.drawRect(r2, paint_sat_status);

        // fill active sats
        paint_sat_status.setColor(Color.GREEN);
        paint_sat_status.setStyle(Paint.Style.FILL);
        paint_sat_status.setStrokeWidth(0);
        paint_sat_status.setAntiAlias(true);
        c.drawRect(r3, paint_sat_status);

        // black rect around it all
        paint_sat_status.setColor(Color.BLACK);
        paint_sat_status.setStyle(Paint.Style.STROKE);
        paint_sat_status.setStrokeWidth(1);
        paint_sat_status.setAntiAlias(true);
        c.drawRect(r4, paint_sat_status);
      } else
      // sat status is turned off!
      {
        // old status
        NavitVehicle.sat_status_icon_last = NavitVehicle.sat_status_icon_now;

        // get new status
        NavitVehicle.sat_status_icon_now = -1;

        if (NavitVehicle.sat_status_icon_now != NavitVehicle.sat_status_icon_last) {
          try {
            Navit.Global_Navit_Object.getSupportActionBar().setIcon(R.drawable.icon);
          } catch (Exception e) {
          }
        }
      }
    } catch (Exception e) {
      // e.printStackTrace();
    }

    if (!Navit.p.PREF_follow_gps) {
      if (!NavitGraphics.MAP_DISPLAY_OFF) {
        // show cross hair
        delta_1 = 8;
        delta_2 = 35;
        if (Navit.metrics.densityDpi >= 320) // && (Navit.PREF_shrink_on_high_dpi))
        {
          paint_crosshair.setStrokeWidth(2);
          delta_1 = 8 * 2;
          delta_2 = 35 * 2;
        } else {
          paint_crosshair.setStrokeWidth(1);
        }
        paint_crosshair.setAntiAlias(true);
        c.drawLine(wm - delta_1, hm, wm - delta_2, hm, paint_crosshair);
        c.drawLine(wm + delta_1, hm, wm + delta_2, hm, paint_crosshair);
        c.drawLine(wm, hm - delta_1, wm, hm - delta_2, paint_crosshair);
        c.drawLine(wm, hm + delta_1, wm, hm + delta_2, paint_crosshair);
      }
    }
  }
Exemple #13
0
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   drawBackground(canvas);
 }
 public void onDraw(Canvas c) {
   super.onDraw(c);
   if (locMap != null) c.drawBitmap(locMap, matrix, null);
 }