@Override
  protected void onDraw(Canvas canvas) {
    // TODO: 16/3/29
    mPaint.setColor(Color.YELLOW);
    canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), mPaint);

    mPaint.setColor(mTitleColor);
    canvas.drawText(
        mTitleText,
        getWidth() / 2 - mBound.width() / 2,
        getHeight() / 2 + mBound.height() / 2,
        mPaint);

    // TODO: 16/4/23 绘画 奥运五环
    mPaint.setColor(Color.LTGRAY);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(10);
    canvas.drawCircle(130, 150, 60, mPaint);

    mPaint.setColor(Color.BLACK);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(10);
    canvas.drawCircle((float) 175.5, 150, 60, mPaint);

    mPaint.setColor(Color.GRAY);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(10);
    canvas.drawCircle(245, 150, 60, mPaint);
  }
  /** Set the properties of the paints we're using to draw the progress wheel */
  private void setupPaints() {
    barPaint.setColor(barColor);
    barPaint.setAntiAlias(true);
    barPaint.setStyle(Style.STROKE);
    barPaint.setStrokeWidth(barWidth);

    rimPaint.setColor(rimColor);
    rimPaint.setAntiAlias(true);
    rimPaint.setStyle(Style.STROKE);
    rimPaint.setStrokeWidth(rimWidth);

    circlePaint.setColor(circleColor);
    circlePaint.setAntiAlias(true);
    circlePaint.setStyle(Style.FILL);

    textPaint.setColor(textColor);
    textPaint.setStyle(Style.FILL);
    textPaint.setAntiAlias(true);
    textPaint.setTextSize(textSize);

    contourPaint.setColor(contourColor);
    contourPaint.setAntiAlias(true);
    contourPaint.setStyle(Style.STROKE);
    contourPaint.setStrokeWidth(contourSize);
  }
Beispiel #3
0
  public DrawView(Context context) {
    super(context);
    axisPaint.setDither(true);
    axisPaint.setStyle(Paint.Style.STROKE);
    axisPaint.setStrokeJoin(Paint.Join.ROUND);
    axisPaint.setStrokeCap(Paint.Cap.ROUND);
    axisPaint.setColor(getContext().getResources().getColor(R.color.text));
    axisPaint.setStrokeWidth(strokeWidth);

    withPaint.setDither(true);
    withPaint.setStyle(Paint.Style.STROKE);
    withPaint.setStrokeJoin(Paint.Join.ROUND);
    withPaint.setStrokeCap(Paint.Cap.ROUND);
    withPaint.setColor(getContext().getResources().getColor(R.color.with));
    withPaint.setStrokeWidth(strokeWidth);

    withTextPaint.setColor(getContext().getResources().getColor(R.color.with));
    withTextPaint.setTextSize(TEXT_SIZE);
    withTextPaint.setTextAlign(Align.RIGHT);

    withoutPaint.setDither(true);
    withoutPaint.setStyle(Paint.Style.STROKE);
    withoutPaint.setStrokeJoin(Paint.Join.ROUND);
    withoutPaint.setStrokeCap(Paint.Cap.ROUND);
    withoutPaint.setColor(getContext().getResources().getColor(R.color.without));
    withoutPaint.setStrokeWidth(strokeWidth);

    withoutTextPaint.setColor(getContext().getResources().getColor(R.color.without));
    withoutTextPaint.setTextSize(TEXT_SIZE);
    withoutTextPaint.setTextAlign(Align.RIGHT);

    textPaint.setColor(getContext().getResources().getColor(R.color.text));
    textPaint.setTextSize(TEXT_SIZE);
  }
  @Override
  protected void onElementDraw(Canvas canvas) {
    // set transparent background
    canvas.drawColor(Color.TRANSPARENT);

    paint.setTextSize(getPercent(getWidth(), 30));
    paint.setTextAlign(Paint.Align.CENTER);
    paint.setStrokeWidth(getDefaultStrokeWidth());

    paint.setColor(isPressed() ? pressedColor : getDefaultColor());
    paint.setStyle(Paint.Style.STROKE);
    canvas.drawRect(
        paint.getStrokeWidth(),
        paint.getStrokeWidth(),
        getWidth() - paint.getStrokeWidth(),
        getHeight() - paint.getStrokeWidth(),
        paint);

    if (icon != -1) {
      Drawable d = getResources().getDrawable(icon);
      d.setBounds(5, 5, getWidth() - 5, getHeight() - 5);
      d.draw(canvas);
    } else {
      paint.setStyle(Paint.Style.FILL_AND_STROKE);
      paint.setStrokeWidth(getDefaultStrokeWidth() / 2);
      canvas.drawText(text, getPercent(getWidth(), 50), getPercent(getHeight(), 63), paint);
    }
  }
Beispiel #5
0
 /**
  * Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode.
  *
  * @param barcode A bitmap of the captured image.
  * @param scaleFactor amount by which thumbnail was scaled
  * @param rawResult The decoded results which contains the points to draw.
  */
 private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) {
   ResultPoint[] points = rawResult.getResultPoints();
   if (points != null && points.length > 0) {
     Canvas canvas = new Canvas(barcode);
     Paint paint = new Paint();
     paint.setColor(getResources().getColor(R.color.result_points));
     if (points.length == 2) {
       paint.setStrokeWidth(4.0f);
       drawLine(canvas, paint, points[0], points[1], scaleFactor);
     } else if (points.length == 4
         && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A
             || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
       // Hacky special case -- draw two lines, for the barcode and metadata
       drawLine(canvas, paint, points[0], points[1], scaleFactor);
       drawLine(canvas, paint, points[2], points[3], scaleFactor);
     } else {
       paint.setStrokeWidth(10.0f);
       for (ResultPoint point : points) {
         if (point != null) {
           canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(), paint);
         }
       }
     }
   }
 }
    public NormalBatteryMeterDrawable(Resources res, boolean horizontal) {
      super();
      mHorizontal = horizontal;
      mDisposed = false;

      mFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mFramePaint.setColor(res.getColor(R.color.batterymeter_frame_color));
      mFramePaint.setDither(true);
      mFramePaint.setStrokeWidth(0);
      mFramePaint.setStyle(Paint.Style.FILL_AND_STROKE);
      mFramePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP));

      mBatteryPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mBatteryPaint.setDither(true);
      mBatteryPaint.setStrokeWidth(0);
      mBatteryPaint.setStyle(Paint.Style.FILL_AND_STROKE);

      mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mTextPaint.setColor(res.getColor(R.color.batterymeter_bolt_color));
      Typeface font = Typeface.create("sans-serif-condensed", Typeface.BOLD);
      mTextPaint.setTypeface(font);
      mTextPaint.setTextAlign(Paint.Align.CENTER);

      mWarningTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mWarningTextPaint.setColor(mColors[1]);
      font = Typeface.create("sans-serif", Typeface.BOLD);
      mWarningTextPaint.setTypeface(font);
      mWarningTextPaint.setTextAlign(Paint.Align.CENTER);

      mBoltPaint = new Paint();
      mBoltPaint.setAntiAlias(true);
      mBoltPaint.setColor(res.getColor(R.color.batterymeter_bolt_color));
      mBoltPoints = loadBoltPoints(res);
    }
    /**
     * initializes all size dependent variables sets stroke width and text size of all involved
     * paints YES! i think the method name is appropriate
     */
    private void initSizeBasedStuff() {
      mCircleSize = Math.min(getMeasuredWidth(), getMeasuredHeight());
      mTextPaint.setTextSize(mCircleSize / 2f);

      float strokeWidth = mCircleSize / STROKE_WITH;
      mFrontPaint.setStrokeWidth(strokeWidth);
      mBackPaint.setStrokeWidth(strokeWidth);

      // calculate rectangle for drawArc calls
      int pLeft = getPaddingLeft();
      mRectLeft =
          new RectF(
              pLeft + strokeWidth / 2.0f,
              0 + strokeWidth / 2.0f,
              mCircleSize - strokeWidth / 2.0f + pLeft,
              mCircleSize - strokeWidth / 2.0f);

      // calculate Y position for text
      Rect bounds = new Rect();
      mTextPaint.getTextBounds("99", 0, "99".length(), bounds);
      mTextX = mCircleSize / 2.0f + getPaddingLeft();
      // the +1dp at end of formula balances out rounding issues.works out on all resolutions
      mTextY =
          mCircleSize / 2.0f
              + (bounds.bottom - bounds.top) / 2.0f
              - strokeWidth / 2.0f
              + getResources().getDisplayMetrics().density;
    }
  private void drawDebug(Canvas canvas) {
    float posX = 10;
    float posY = 20;

    Paint paint = new Paint();
    paint.setStrokeWidth(5);
    paint.setStyle(Style.FILL);

    paint.setColor(Color.BLACK);

    canvas.drawCircle(mOrigin.x, mOrigin.y, getWidth(), paint);

    paint.setStrokeWidth(3);
    paint.setColor(Color.RED);
    canvas.drawCircle(mOrigin.x, mOrigin.y, getWidth(), paint);

    paint.setStrokeWidth(5);
    paint.setColor(Color.BLACK);
    canvas.drawLine(mOrigin.x, mOrigin.y, mMovement.x, mMovement.y, paint);

    paint.setStrokeWidth(3);
    paint.setColor(Color.RED);
    canvas.drawLine(mOrigin.x, mOrigin.y, mMovement.x, mMovement.y, paint);

    posY = debugDrawPoint(canvas, "A", mA, Color.RED, posX, posY);
    posY = debugDrawPoint(canvas, "B", mB, Color.GREEN, posX, posY);
    posY = debugDrawPoint(canvas, "C", mC, Color.BLUE, posX, posY);
    posY = debugDrawPoint(canvas, "D", mD, Color.CYAN, posX, posY);
    posY = debugDrawPoint(canvas, "E", mE, Color.YELLOW, posX, posY);
    posY = debugDrawPoint(canvas, "F", mF, Color.LTGRAY, posX, posY);
    posY = debugDrawPoint(canvas, "Mov", mMovement, Color.DKGRAY, posX, posY);
    posY = debugDrawPoint(canvas, "Origin", mOrigin, Color.MAGENTA, posX, posY);

    /**/
  }
  protected void initJoystickView() {
    mainCircle = new Paint(Paint.ANTI_ALIAS_FLAG);
    mainCircle.setColor(Color.TRANSPARENT);
    mainCircle.setStyle(Paint.Style.FILL_AND_STROKE);

    secondaryCircle = new Paint();
    secondaryCircle.setColor(Color.GREEN);
    secondaryCircle.setStyle(Paint.Style.STROKE);

    verticalLine = new Paint();
    verticalLine.setStrokeWidth(5);
    verticalLine.setColor(Color.RED);

    rollLine = new Paint();
    rollLine.setStrokeWidth(5);
    rollLine.setColor(Color.GREEN);
    rollLine.setStyle(Paint.Style.STROKE);
    rollLine.setStrokeWidth(9f);

    horizontalLine = new Paint();
    horizontalLine.setStrokeWidth(2);
    horizontalLine.setColor(Color.BLACK);

    button = new Paint(Paint.ANTI_ALIAS_FLAG);
    // if(tLMode == true){
    // button.setColor(Color.YELLOW);
    // }else{
    button.setColor(Color.RED);
    // }
    button.setStyle(Paint.Style.FILL);
  }
Beispiel #10
0
  private void init() {
    circlePickedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    circleUnPickPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    linePickedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    linePickedPaint.setStrokeWidth(5);
    lineUnPickPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    lineUnPickPaint.setStrokeWidth(5);
    stepTextPaint = new Paint();
    stepTextPaint.setStrokeWidth(3);
    stepTextPaint.setTextSize(textSize);

    stepTextPaint.setTextAlign(Paint.Align.LEFT);
    descPaint = new Paint();
    descPaint.setStrokeWidth(3);
    descPaint.setTextSize(descSize);
    descPaint.setTextAlign(Paint.Align.LEFT);

    linePickedPaint.setColor(pickedColor);
    circlePickedPaint.setColor(pickedColor);
    circleUnPickPaint.setColor(unPickColor);
    lineUnPickPaint.setColor(unPickColor);
    stepTextPaint.setColor(stepTextColor);
    descPaint.setColor(descColor);
  }
Beispiel #11
0
  private void init() {

    Resources resources = getResources();

    radius = resources.getDimension(R.dimen.node_radius);
    padding = (int) resources.getDimension(R.dimen.graph_padding);
    paddingText = (int) resources.getDimension(R.dimen.node_text_padding);

    paintNode = new Paint(Paint.ANTI_ALIAS_FLAG);
    paintNode.setColor(Color.BLUE);
    paintNode.setStyle(Paint.Style.STROKE);
    paintNode.setStrokeWidth(5f);

    paintLapse = new Paint(paintNode);
    paintLapse.setStyle(Paint.Style.FILL);

    paintEdge = new Paint(paintNode);
    paintEdge.setColor(Color.CYAN);

    paintArc = new Paint(paintEdge);

    paintText = new Paint(Paint.ANTI_ALIAS_FLAG);
    paintText.setStyle(Paint.Style.FILL);
    paintText.setStrokeWidth(2f);
    paintText.setTextSize(resources.getDimension(R.dimen.node_text_size));
    paintText.setColor(Color.RED);
  }
Beispiel #12
0
  private void draw_ruled(Canvas c, Transformation t, float lineSpacing, float margin) {

    float spacingMm = lineSpacing;
    float vertLineMm = margin;

    int shade = 0xaa;
    float threshold = 1500;
    if (t.scale < threshold) shade += (int) ((threshold - t.scale) / threshold * (0xff - shade));
    paint.setARGB(0xff, shade, shade, shade);

    paint.setStrokeWidth(0);
    int n = (int) Math.floor((heightMm - 2 * marginMm) / spacingMm) - 2;
    float x0 = t.applyX(marginMm / heightMm);
    float x1 = t.applyX((widthMm - marginMm) / heightMm);
    for (int i = 1; i <= n; i++) {
      float y = t.applyY(((heightMm - n * spacingMm) / 2 + i * spacingMm) / heightMm);
      c.drawLine(x0, y, x1, y, paint);
    }

    // Paint margin
    if (margin > 0.0f) {
      paint.setARGB(0xff, 0xff, shade, shade);
      paint.setStrokeWidth(0);
      float y0 = t.applyY(marginMm / heightMm);
      float y1 = t.applyY((heightMm - marginMm) / heightMm);
      float x = t.applyX(vertLineMm / widthMm);
      c.drawLine(x, y0, x, y1, paint);
    }
  }
Beispiel #13
0
  public ScanMaskView(Context context, AttributeSet attrs) {
    super(context, attrs);
    // this.context = context;
    mFrameSpace = ScreenUtil.dp2px(FRAME_SPACE);
    mOutFrameStokeWidth = ScreenUtil.dp2px(OUT_FRAME_STROKE_WIDTH);
    mInnerFrameStokeWidth = ScreenUtil.dp2px(INNER_FRAME_STROKE_WIDTH);
    mTextMarginTop = ScreenUtil.dp2px(TEXT_MARGIN_TOP);
    // mTextMarginButtom = ScreenUtil.dp2px(TEXT_MARGIN_BUTTOM);
    mIntervalText = ScreenUtil.dp2px(INTERVAL_TEXT);
    mInnerFrameCornerLength = getResources().getDimensionPixelSize(R.dimen.scan_blueline_length);
    mTextSize = getResources().getDimension(R.dimen.textsize_18px);

    // mHintStr = getResources().getString(R.string.scan_hint);
    mScanLine = getResources().getDrawable(R.drawable.qrcode_move_line);

    textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(mTextSize);
    textPaint.setTextAlign(Paint.Align.CENTER);
    textPaint.setColor(getResources().getColor(R.color.scan_text_color));

    innerFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    innerFramePaint.setStrokeWidth(mInnerFrameStokeWidth);
    innerFramePaint.setColor(getResources().getColor(R.color.scan_inner_frame));
    innerFramePaint.setStyle(Paint.Style.STROKE);

    outFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    outFramePaint.setStrokeWidth(mOutFrameStokeWidth);
    outFramePaint.setColor(getResources().getColor(R.color.scan_out_frame));
    outFramePaint.setStyle(Paint.Style.STROKE);

    shadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    shadowPaint.setColor(getResources().getColor(R.color.scan_mask_color));
    shadowPaint.setStyle(Paint.Style.FILL);
  }
  /**
   * @param color Color of result points
   * @return {@link Bitmap} with result points on it, or plain bitmap, if no result points
   */
  public Bitmap getBitmapWithResultPoints(int color) {
    Bitmap bitmap = getBitmap();
    Bitmap barcode = bitmap;
    ResultPoint[] points = mResult.getResultPoints();

    if (points != null && points.length > 0 && bitmap != null) {
      barcode = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
      Canvas canvas = new Canvas(barcode);
      canvas.drawBitmap(bitmap, 0, 0, null);
      Paint paint = new Paint();
      paint.setColor(color);
      if (points.length == 2) {
        paint.setStrokeWidth(PREVIEW_LINE_WIDTH);
        drawLine(canvas, paint, points[0], points[1], mScaleFactor);
      } else if (points.length == 4
          && (mResult.getBarcodeFormat() == BarcodeFormat.UPC_A
              || mResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
        // Hacky special case -- draw two lines, for the barcode and metadata
        drawLine(canvas, paint, points[0], points[1], mScaleFactor);
        drawLine(canvas, paint, points[2], points[3], mScaleFactor);
      } else {
        paint.setStrokeWidth(PREVIEW_DOT_WIDTH);
        for (ResultPoint point : points) {
          if (point != null) {
            canvas.drawPoint(point.getX() / mScaleFactor, point.getY() / mScaleFactor, paint);
          }
        }
      }
    }
    return barcode;
  }
Beispiel #15
0
  private void init() {

    colorPointerPaint = new Paint();
    colorPointerPaint.setStyle(Style.STROKE);
    colorPointerPaint.setStrokeWidth(2f);
    colorPointerPaint.setARGB(128, 0, 0, 0);

    valuePointerPaint = new Paint();
    valuePointerPaint.setStyle(Style.STROKE);
    valuePointerPaint.setStrokeWidth(2f);

    valuePointerArrowPaint = new Paint();

    colorWheelPaint = new Paint();
    colorWheelPaint.setAntiAlias(true);
    colorWheelPaint.setDither(true);

    valueSliderPaint = new Paint();
    valueSliderPaint.setAntiAlias(true);
    valueSliderPaint.setDither(true);

    colorViewPaint = new Paint();
    colorViewPaint.setAntiAlias(true);

    colorViewPath = new Path();
    valueSliderPath = new Path();
    arrowPointerPath = new Path();

    outerWheelRect = new RectF();
    innerWheelRect = new RectF();

    colorPointerCoords = new RectF();
  }
  /**
   * Constructor.
   *
   * @param mapView the mapview reference.
   * @param doCut if <code>true</code>, do cut as opposed to extend.
   */
  public CutExtendTool(MapView mapView, boolean doCut) {
    super(mapView);
    this.doCut = doCut;
    editingViewProjection =
        new SliderDrawProjection(mapView, EditManager.INSTANCE.getEditingView());

    point = new Point();
    positionBeforeDraw = new Point();

    // Context context = GeopaparazziApplication.getInstance().getApplicationContext();
    // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    drawingPaintFill.setAntiAlias(true);
    drawingPaintFill.setColor(Color.RED);
    // drawingPaintFill.setAlpha(80);
    drawingPaintFill.setStyle(Paint.Style.FILL);
    drawingPaintStroke.setAntiAlias(true);
    drawingPaintStroke.setStrokeWidth(5f);
    drawingPaintStroke.setColor(Color.RED);
    drawingPaintStroke.setStyle(Paint.Style.STROKE);

    int previewStroke = ColorUtilities.getColor(ColorUtilities.preview_stroke);
    int previewFill = ColorUtilities.getColor(ColorUtilities.preview_fill);
    selectedPreviewGeometryPaintFill.setAntiAlias(true);
    selectedPreviewGeometryPaintFill.setColor(previewFill);
    selectedPreviewGeometryPaintFill.setAlpha(180);
    selectedPreviewGeometryPaintFill.setStyle(Paint.Style.FILL);
    selectedPreviewGeometryPaintStroke.setAntiAlias(true);
    selectedPreviewGeometryPaintStroke.setStrokeWidth(5f);
    selectedPreviewGeometryPaintStroke.setColor(previewStroke);
    selectedPreviewGeometryPaintStroke.setStyle(Paint.Style.STROKE);
  }
Beispiel #17
0
  private void addBezier(Bezier curve, float startWidth, float endWidth) {
    ensureSignatureBitmap();
    float originalWidth = mPaint.getStrokeWidth();
    float widthDelta = endWidth - startWidth;
    float drawSteps = (float) Math.floor(curve.length());

    for (int i = 0; i < drawSteps; i++) {
      // Calculate the Bezier (x, y) coordinate for this step.
      float t = ((float) i) / drawSteps;
      float tt = t * t;
      float ttt = tt * t;
      float u = 1 - t;
      float uu = u * u;
      float uuu = uu * u;

      float x = uuu * curve.startPoint.x;
      x += 3 * uu * t * curve.control1.x;
      x += 3 * u * tt * curve.control2.x;
      x += ttt * curve.endPoint.x;

      float y = uuu * curve.startPoint.y;
      y += 3 * uu * t * curve.control1.y;
      y += 3 * u * tt * curve.control2.y;
      y += ttt * curve.endPoint.y;

      // Set the incremental stroke width and draw.
      mPaint.setStrokeWidth(startWidth + ttt * widthDelta);
      mSignatureBitmapCanvas.drawPoint(x, y, mPaint);
      expandDirtyRect(x, y);
    }

    mPaint.setStrokeWidth(originalWidth);
  }
Beispiel #18
0
  public void Draw(Canvas canvas) {
    canvas.drawBitmap(ret, pos.x, canvas.getHeight() - (pos.y + scale.y), null);

    // testing line------------------------------------------------//
    if (state == STATE.DRAGGING) {
      paint.setColor(Color.RED);
      paint.setStrokeWidth(10);

      // From startPos to current dragging pos
      canvas.drawLine(
          startPos.x,
          canvas.getHeight() - startPos.y,
          fingerPos.x,
          canvas.getHeight() - fingerPos.y,
          paint);
    }

    // draw the rubbish------------------------------------------//
    for (int i = 0; i < totalDragged; ++i) {
      if (rubbishPile.get(i).GetActive()) rubbishPile.get(i).Draw(canvas);
    }

    paint.setARGB(255, 255, 0, 0);
    paint.setStrokeWidth(120); // how thick you want the text to be in terms of pixel
    paint.setTextSize(60);
    canvas.drawText("Active: " + totalDragged, 130, 80, paint);

    bound.DrawDebug(canvas);
  }
    public CircleBatteryMeterDrawable(Resources res) {
      super();
      mDisposed = false;

      mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mTextPaint.setColor(res.getColor(R.color.status_bar_clock_color));
      Typeface font = Typeface.create("sans-serif-condensed", Typeface.NORMAL);
      mTextPaint.setTypeface(font);
      mTextPaint.setTextAlign(Paint.Align.CENTER);

      mFrontPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mFrontPaint.setStrokeCap(Paint.Cap.BUTT);
      mFrontPaint.setDither(true);
      mFrontPaint.setStrokeWidth(0);
      mFrontPaint.setStyle(Paint.Style.STROKE);
      mFrontPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP));

      mBackPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mBackPaint.setColor(res.getColor(R.color.batterymeter_frame_color));
      mBackPaint.setStrokeCap(Paint.Cap.BUTT);
      mBackPaint.setDither(true);
      mBackPaint.setStrokeWidth(0);
      mBackPaint.setStyle(Paint.Style.STROKE);
      mBackPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.XOR));

      mBoltPaint = new Paint();
      mBoltPaint.setAntiAlias(true);
      mBoltPaint.setColor(getColorForLevel(50));
      mBoltPoints = loadBoltPoints(res);
    }
  private void initJoystickView() {
    setFocusable(true);

    dbgPaint1 = new Paint(Paint.ANTI_ALIAS_FLAG);
    dbgPaint1.setColor(Color.RED);
    dbgPaint1.setStrokeWidth(1);
    dbgPaint1.setStyle(Paint.Style.STROKE);

    dbgPaint2 = new Paint(Paint.ANTI_ALIAS_FLAG);
    dbgPaint2.setColor(Color.GREEN);
    dbgPaint2.setStrokeWidth(1);
    dbgPaint2.setStyle(Paint.Style.STROKE);

    bgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    bgPaint.setColor(Color.GRAY);
    bgPaint.setStrokeWidth(1);
    bgPaint.setAlpha(80);
    bgPaint.setStyle(Paint.Style.FILL_AND_STROKE);

    handlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    handlePaint.setColor(Color.DKGRAY);
    handlePaint.setStrokeWidth(1);
    handlePaint.setStyle(Paint.Style.FILL_AND_STROKE);

    innerPadding = 10;

    setMovementRange(10);
    setMoveResolution(1.0f);
    setClickThreshold(0.4f);
    setYAxisInverted(true);
    setUserCoordinateSystem(COORDINATE_CARTESIAN);
    setAutoReturnToCenter(true);
  }
 private void initPaints() {
   mDefShadowOffset = getDimen(R.dimen.def_shadow_offset);
   /** 圆环画笔 */
   mWheelPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
   mWheelPaint.setColor(mUnreachedColor);
   mWheelPaint.setStyle(Paint.Style.STROKE);
   mWheelPaint.setStrokeWidth(mUnreachedWidth);
   if (isHasWheelShadow) {
     mWheelPaint.setShadowLayer(
         mWheelShadowRadius, mDefShadowOffset, mDefShadowOffset, Color.DKGRAY);
   }
   /** 选中区域画笔 */
   mReachedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
   mReachedPaint.setColor(mReachedColor);
   mReachedPaint.setStyle(Paint.Style.STROKE);
   mReachedPaint.setStrokeWidth(mReachedWidth);
   if (isHasReachedCornerRound) {
     mReachedPaint.setStrokeCap(Paint.Cap.ROUND);
   }
   /** 锚点画笔 */
   mPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
   mPointerPaint.setColor(mPointerColor);
   mPointerPaint.setStyle(Paint.Style.FILL);
   if (isHasPointerShadow) {
     mPointerPaint.setShadowLayer(
         mPointerShadowRadius, mDefShadowOffset, mDefShadowOffset, Color.DKGRAY);
   }
   /** 选中区域两头的圆角画笔 */
   mReachedEdgePaint = new Paint(mReachedPaint);
   mReachedEdgePaint.setStyle(Paint.Style.FILL);
 }
  private TextDrawable(Builder builder) {
    super(builder.shape);

    // shape properties
    shape = builder.shape;
    height = builder.height;
    width = builder.width;
    radius = builder.radius;

    // text and color
    text = builder.toUpperCase ? builder.text.toUpperCase() : builder.text;
    color = builder.color;

    // text paint settings
    fontSize = builder.fontSize;
    textPaint = new Paint();
    textPaint.setColor(builder.textColor);
    textPaint.setAntiAlias(true);
    textPaint.setFakeBoldText(builder.isBold);
    textPaint.setStyle(Paint.Style.FILL);
    textPaint.setTypeface(builder.font);
    textPaint.setTextAlign(Paint.Align.CENTER);
    textPaint.setStrokeWidth(builder.borderThickness);

    // border paint settings
    borderThickness = builder.borderThickness;
    borderPaint = new Paint();
    borderPaint.setColor(getDarkerShade(color));
    borderPaint.setStyle(Paint.Style.STROKE);
    borderPaint.setStrokeWidth(borderThickness);

    // drawable paint color
    Paint paint = getPaint();
    paint.setColor(color);
  }
  /** Setting defaults */
  {
    tickColor = new Paint();
    tickColor.setARGB(255, 220, 220, 220);
    tickColor.setStrokeWidth(3.f);
    tickColor.setAntiAlias(true);
    tickColor.setStrokeCap(Paint.Cap.SQUARE);

    spaceColor = new Paint();
    spaceColor.setARGB(255, 110, 110, 110);
    spaceColor.setStrokeWidth(3.f);
    spaceColor.setAntiAlias(true);
    spaceColor.setStrokeCap(Paint.Cap.SQUARE);

    tickHighlightColor = new Paint();
    tickHighlightColor.setARGB(255, 0, 126, 255);
    tickHighlightColor.setStrokeWidth(3.f);
    tickHighlightColor.setAntiAlias(true);
    tickHighlightColor.setStrokeCap(Paint.Cap.SQUARE);

    getTickHighlightColorAmbient = new Paint();
    getTickHighlightColorAmbient.setARGB(255, 100, 100, 100);
    getTickHighlightColorAmbient.setStrokeWidth(3.f);
    getTickHighlightColorAmbient.setAntiAlias(true);
    getTickHighlightColorAmbient.setStrokeCap(Paint.Cap.SQUARE);

    blackPaint = new Paint(Color.BLACK);
    blackPaint.setAntiAlias(true);
    blackPaint.setStrokeCap(Paint.Cap.SQUARE);
  }
Beispiel #24
0
 public Cling(Context context) {
   this(context, null, 0);
   //        bmp = Bitmap.createBitmap(Utils3D.getScreenWidth(), Utils3D.getScreenHeight(),
   //                Bitmap.Config.ARGB_8888);
   //        canvas = new Canvas(bmp);
   grad =
       new GradientDrawable( // 渐变色
           Orientation.TOP_BOTTOM, new int[] {Color.BLACK, Color.WHITE});
   options = new BitmapFactory.Options();
   options.inPreferredConfig = Bitmap.Config.RGB_565;
   src1 = new Rect();
   dst1 = new Rect();
   src2 = new Rect();
   dst2 = new Rect();
   mErasePaint = new Paint();
   mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
   //        mErasePaint.setColor(0xFF18b7de);
   mErasePaint.setAlpha(0);
   mErasePaint.setAntiAlias(true);
   mErasePaint.setStyle(Paint.Style.FILL);
   mErasePaint.setStrokeWidth(4);
   normalPaint = new Paint();
   normalPaint.setAntiAlias(true);
   normalPaint.setStyle(Paint.Style.STROKE);
   normalPaint.setStrokeWidth(strokeWidth);
   normalPaint.setColor(strokeColor);
 }
Beispiel #25
0
 private void refresh(Canvas canvas, Paint p) {
   String s = sharedPrefs.getString("list", "-1");
   if ((s.equals("2")) && (ColorTheme.isLightTheme)) {
     ColorTheme.setDarkTheme();
   } else if ((s.equals("1") && (ColorTheme.isDarkTheme))) {
     ColorTheme.setLightTheme();
   }
   if (!coordinateSystemCreated) {
     setSystemInformation();
     coordinateSystem = new CoordinateSystem();
     coordinateSystemCreated = true;
   }
   canvas.drawColor(ColorTheme.DARK_COLOR);
   paint.setStrokeWidth(4);
   for (ShapeList shape : shapes) {
     shape.draw(canvas, p);
     if (paint.getStrokeWidth() == 4) {
       paint.setStrokeWidth(1);
     }
   }
   if (shapes.size() != 0) {
     paint.setStrokeWidth(4);
     shapes.get(FIRST_SHAPE_IN_LIST).draw(canvas, paint);
   }
   if (shapes.size() > 0) {
     canvas.drawText(shapes.get(FIRST_SHAPE_IN_LIST).toString(), 30, 15, p);
   }
   if (sharedPrefs.getBoolean("checkBox", false)) {
     coordinateSystem.draw(canvas);
   }
 }
  private void initPaintTools() {

    mSatValPaint = new Paint();
    mSatValTrackerPaint = new Paint();
    mHuePaint = new Paint();
    mHueTrackerPaint = new Paint();
    mAlphaPaint = new Paint();
    mAlphaTextPaint = new Paint();
    mBorderPaint = new Paint();

    mSatValTrackerPaint.setStyle(Style.STROKE);
    mSatValTrackerPaint.setStrokeWidth(2f * mDensity);
    mSatValTrackerPaint.setAntiAlias(true);

    mHueTrackerPaint.setColor(mSliderTrackerColor);
    mHueTrackerPaint.setStyle(Style.STROKE);
    mHueTrackerPaint.setStrokeWidth(2f * mDensity);
    mHueTrackerPaint.setAntiAlias(true);

    mAlphaTextPaint.setColor(0xff1c1c1c);
    mAlphaTextPaint.setTextSize(14f * mDensity);
    mAlphaTextPaint.setAntiAlias(true);
    mAlphaTextPaint.setTextAlign(Align.CENTER);
    mAlphaTextPaint.setFakeBoldText(true);
  }
  protected void drawResultPoints(Bitmap barcode, Result rawResult) {
    ResultPoint[] points = rawResult.getResultPoints();
    if (points != null && points.length > 0) {
      Canvas canvas = new Canvas(barcode);
      Paint paint = new Paint();
      paint.setColor(getResources().getColor(R.color.result_image_border));
      paint.setStrokeWidth(3.0f);
      paint.setStyle(Paint.Style.STROKE);
      Rect border = new Rect(2, 2, barcode.getWidth() - 2, barcode.getHeight() - 2);
      canvas.drawRect(border, paint);

      paint.setColor(getResources().getColor(R.color.result_points));
      if (points.length == 2) {
        paint.setStrokeWidth(4.0f);
        drawLine(canvas, paint, points[0], points[1]);
      } else if (points.length == 4
          && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A
              || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
        // Hacky special case -- draw two lines, for the barcode and
        // metadata
        drawLine(canvas, paint, points[0], points[1]);
        drawLine(canvas, paint, points[2], points[3]);
      } else {
        paint.setStrokeWidth(10.0f);
        for (ResultPoint point : points) {
          canvas.drawPoint(point.getX(), point.getY(), paint);
        }
      }
    }
  }
Beispiel #28
0
  private void initDirectionPaint(int c) {
    // Text
    mPaint = new Paint();
    mPaint.setColor(c);
    mPaint.setAlpha(100);
    mPaint.setStyle(Style.STROKE);
    mPaint.setStrokeWidth(3);
    // Geo Point
    mGeoPointPaint = new Paint();
    mGeoPointPaint.setAntiAlias(true);
    mGeoPointPaint.setColor(c);
    mGeoPointPaint.setStyle(Style.FILL_AND_STROKE);
    mGeoPointPaint.setStrokeWidth(3);
    // Geo Point
    mGeoPointOldPaint = new Paint(mGeoPointPaint);
    mGeoPointOldPaint.setAlpha(80);

    // Localisation
    mGeoPointAccuracyCirclePaint = new Paint();
    mGeoPointAccuracyCirclePaint.setColor(c);
    mGeoPointAccuracyCirclePaint.setAntiAlias(true);
    mGeoPointAccuracyCirclePaint.setAlpha(50);
    mGeoPointAccuracyCirclePaint.setStyle(Style.FILL);

    mGeoPointAccuracyCirclePaintBorder = new Paint(mGeoPointAccuracyCirclePaint);
    mGeoPointAccuracyCirclePaintBorder.setAlpha(150);
    mGeoPointAccuracyCirclePaintBorder.setStyle(Style.STROKE);
  }
  @Override
  protected void onDraw(Canvas canvas) {
    // avoids drawing too much
    canvas.drawBitmap(mBitmap, xoffset, yoffset, mBitmapPaint);
    Paint paintBlue = new Paint();
    paintBlue.setStyle(Paint.Style.STROKE);
    paintBlue.setStrokeWidth(3);
    paintBlue.setTextSize(ROW_HEIGHT);
    paintBlue.setColor(Color.WHITE);
    canvas.drawText("X:" + x0, 10, VERTICAL_MARGIN, paintBlue);
    canvas.drawText("Y:" + y0, 10, VERTICAL_MARGIN + 32, paintBlue);
    canvas.drawText("scale:" + scale, 10, VERTICAL_MARGIN + 32 * 2, paintBlue);

    if (mode == ZOOM) {
      float w = width / scaleFactor;
      float h = height / scaleFactor;
      Paint paint = new Paint();
      paint.setStyle(Paint.Style.STROKE);
      paint.setStrokeWidth(3);
      paint.setTextSize(ROW_HEIGHT);
      paint.setColor(Color.RED);
      canvas.drawCircle(mid.x, mid.y, Math.min(w, h), paint);
      canvas.drawCircle(mid.x, mid.y, 5, paint);
      canvas.drawText("Scale:" + scale * scaleFactor, width / 2, height * 0.95f, paint);
      canvas.drawText("Mid:" + mid.x + "," + mid.y, width / 2, height * 0.95f + ROW_HEIGHT, paint);
    }
    // stops only after drawing a last time
    invalidate();
  }
  private void init() {
    COMMON_RADIUS = dip2px(getContext(), COMMON_RADIUS_VALUE);
    initCircleRadius();

    mInPaint.setColor(Color.parseColor(CIRCLE_COLOR_IN));
    mInPaint.setAntiAlias(true);
    mInPaint.setStyle(Paint.Style.FILL);

    mInStrokePaint.setColor(Color.parseColor(CIRCLE_COLOR_OUT));
    mInStrokePaint.setAntiAlias(true);
    mInStrokePaint.setStyle(Paint.Style.STROKE);
    mInStrokePaint.setStrokeWidth(dip2px(getContext(), STROKE_WIDTH));

    mOutPaint.setColor(Color.parseColor(CIRCLE_COLOR_IN));
    mOutPaint.setAntiAlias(true);
    mOutPaint.setStyle(Paint.Style.FILL);

    mOutStrokePaint.setColor(Color.parseColor(CIRCLE_COLOR_OUT));
    mOutStrokePaint.setAntiAlias(true);
    mOutStrokePaint.setStyle(Paint.Style.STROKE);
    mOutStrokePaint.setStrokeWidth(dip2px(getContext(), STROKE_WIDTH));

    mOutAlpha = mOutPaint.getAlpha();
    mOutStrokeAlpha = mOutStrokePaint.getAlpha();
  }