Ejemplo n.º 1
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);
  }
  @Override
  public void draw(Canvas canvas, Paint paint) {
    float circleSpacing = 12;
    float x = getWidth() / 2;
    float y = getHeight() / 2;

    // draw fill circle
    canvas.save();
    canvas.translate(x, y);
    canvas.scale(scaleFloat1, scaleFloat1);
    paint.setStyle(Paint.Style.FILL);
    canvas.drawCircle(0, 0, x / 2.5f, paint);

    canvas.restore();

    canvas.translate(x, y);
    canvas.scale(scaleFloat2, scaleFloat2);
    canvas.rotate(degrees);

    paint.setStrokeWidth(3);
    paint.setStyle(Paint.Style.STROKE);

    // draw two arc
    float[] startAngles = new float[] {225, 45};
    for (int i = 0; i < 2; i++) {
      RectF rectF =
          new RectF(-x + circleSpacing, -y + circleSpacing, x - circleSpacing, y - circleSpacing);
      canvas.drawArc(rectF, startAngles[i], 90, false, paint);
    }
  }
Ejemplo n.º 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);
  }
    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);
    }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
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);
  }
Ejemplo n.º 7
0
  private void drawPointerArrow(Canvas canvas) {

    int centerX = getWidth() / 2;
    int centerY = getHeight() / 2;

    double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
    double leftAngle = tipAngle + Math.PI / 96;
    double rightAngle = tipAngle - Math.PI / 96;

    double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
    double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
    double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
    double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
    double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
    double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);

    arrowPointerPath.reset();
    arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
    arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
    arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
    arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);

    valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
    valuePointerArrowPaint.setStyle(Style.FILL);
    canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

    valuePointerArrowPaint.setStyle(Style.STROKE);
    valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
    valuePointerArrowPaint.setColor(Color.BLACK);
    canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
  }
Ejemplo n.º 8
0
  /**
   * 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);
  }
 /** Initialize draw objects */
 private void initDraw(
     int textColor,
     float textSize,
     int selectedColor,
     boolean selectedBold,
     float selectedSize,
     float footerLineHeight,
     int footerColor) {
   paintText = new Paint();
   paintText.setColor(textColor);
   paintText.setTextSize(textSize);
   paintText.setAntiAlias(true);
   paintSelected = new Paint();
   paintSelected.setColor(selectedColor);
   paintSelected.setTextSize(selectedSize);
   paintSelected.setFakeBoldText(selectedBold);
   paintSelected.setAntiAlias(true);
   paintFooterLine = new Paint();
   paintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
   paintFooterLine.setStrokeWidth(footerLineHeight);
   paintFooterLine.setColor(footerColor);
   paintFooterTriangle = new Paint();
   paintFooterTriangle.setStyle(Paint.Style.FILL_AND_STROKE);
   paintFooterTriangle.setColor(footerColor);
 }
  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);
  }
Ejemplo n.º 11
0
  public CircleProgressBar(Context context, AttributeSet attrs) {
    super(context, attrs);
    pathPaint = new Paint();
    // 设置是否抗锯齿
    pathPaint.setAntiAlias(true);
    // 帮助消除锯齿
    pathPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    // 设置中空的样式
    pathPaint.setStyle(Paint.Style.STROKE);
    pathPaint.setDither(true);
    pathPaint.setStrokeJoin(Paint.Join.ROUND);

    fillArcPaint = new Paint();
    // 设置是否抗锯齿
    fillArcPaint.setAntiAlias(true);
    // 帮助消除锯齿
    fillArcPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    // 设置中空的样式
    fillArcPaint.setStyle(Paint.Style.STROKE);
    fillArcPaint.setDither(true);
    fillArcPaint.setStrokeJoin(Paint.Join.ROUND);

    oval = new RectF();
    emboss = new EmbossMaskFilter(direction, light, specular, blur);
    mBlur = new BlurMaskFilter(20, BlurMaskFilter.Blur.NORMAL);
    anim = new BarAnimation();
  }
Ejemplo n.º 12
0
  private void init() {
    mFrontPointsList = new ArrayList<>();
    mBackPointsList = new ArrayList<>();

    mFrontPaint = new Paint();
    mFrontPaint.setAntiAlias(true);
    mFrontPaint.setStyle(Paint.Style.FILL);
    mFrontPaint.setColor(Color.parseColor("#cccc669b"));

    mBackPaint = new Paint();
    mBackPaint.setAntiAlias(true);
    mBackPaint.setStyle(Paint.Style.FILL);
    mBackPaint.setColor(Color.parseColor("#4dcc669b"));

    mOutBorderPaint = new Paint();
    mOutBorderPaint.setAntiAlias(true);
    mOutBorderPaint.setStrokeWidth(OkUtils.dp2px(getContext(), 1));
    mOutBorderPaint.setStyle(Paint.Style.STROKE);
    mOutBorderPaint.setColor(Color.parseColor("#cccc669b"));

    mWhitePaint = new Paint();
    mWhitePaint.setAntiAlias(true);
    mWhitePaint.setStyle(Paint.Style.FILL);
    mWhitePaint.setColor(Color.parseColor("#ffffff"));

    //        mOutBorderPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));//
    // 选择交集去上层图片

    mFrontPath = new Path();
    mBackPath = new Path();
    mOutBorderPath = new Path();
  }
Ejemplo n.º 13
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);
  }
Ejemplo n.º 14
0
  private void drawEllipse(byte[] packetData) {
    try {
      int x1 = xCoordinateMap(myConvertByteArrToInt_bigend(packetData, 4));
      int y1 = yCoordinateMap(myConvertByteArrToInt_bigend(packetData, 8));
      int x2 = xCoordinateMap(myConvertByteArrToInt_bigend(packetData, 12));
      int y2 = yCoordinateMap(myConvertByteArrToInt_bigend(packetData, 16));
      int penWidthNum = myConvertByteArrToInt_bigend(packetData, 20);
      int penColorNum = myConvertByteArrToInt_bigend(packetData, 24);
      int isFill = myConvertByteArrToInt_bigend(packetData, 28);

      Paint paint = getAPaint();
      paint.setStrokeWidth(penWidthMap.get(penWidthNum));
      paint.setColor(penColorMap.get(penColorNum));
      if (isFill == 0) {
        paint.setStyle(Style.STROKE);
      } else {
        paint.setStyle(Style.FILL_AND_STROKE);
      }

      Path path = new Path();
      path.addOval(new RectF(x1, y1, x2, y2), Direction.CW);

      HistoryItem item = new HistoryItem(HistoryItem.TYPE_PATH, paint, path, null, null);
      undoPathList.add(item);

      mCacheCanvas.drawPath(path, paint);

      handler.sendEmptyMessage(CustomDrawViewCH_INVALIDATE);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @Override
  protected void drawMyLocation(
      Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when) {
    if (!bugged) {
      try {
        super.drawMyLocation(canvas, mapView, lastFix, myLocation, when);
      } catch (Exception e) {
        // we found a buggy phone, draw the location icons ourselves
        bugged = true;
      }
    }

    if (bugged) {
      if (drawable == null) {

        accuracyPaint = new Paint();
        accuracyPaint.setAntiAlias(true);
        accuracyPaint.setStrokeWidth(2.0f);

        drawable =
            mapView
                .getContext()
                .getResources()
                .getDrawable(R.drawable.ic_maps_indicator_current_position);
        width = drawable.getIntrinsicWidth();
        height = drawable.getIntrinsicHeight();
        center = new Point();
        left = new Point();
      }

      Projection projection = mapView.getProjection();
      double latitude = lastFix.getLatitude();
      double longitude = lastFix.getLongitude();
      float accuracy = lastFix.getAccuracy();

      float[] result = new float[1];

      Location.distanceBetween(latitude, longitude, latitude, longitude + 1, result);
      float longitudeLineDistance = result[0];

      GeoPoint leftGeo =
          new GeoPoint(
              (int) (latitude * 1e6), (int) ((longitude - accuracy / longitudeLineDistance) * 1e6));
      projection.toPixels(leftGeo, left);
      projection.toPixels(myLocation, center);
      int radius = center.x - left.x;

      accuracyPaint.setColor(0xff6666ff);
      accuracyPaint.setStyle(Style.STROKE);
      canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

      accuracyPaint.setColor(0x186666ff);
      accuracyPaint.setStyle(Style.FILL);
      canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

      drawable.setBounds(
          center.x - width / 2, center.y - height / 2, center.x + width / 2, center.y + height / 2);
      drawable.draw(canvas);
    }
  }
Ejemplo n.º 16
0
 public LegendPainter() {
   labelPaint.setColor(Color.BLACK);
   backgroundPaint.setColor(Color.argb(200, 200, 200, 200));
   backgroundPaint.setStyle(Paint.Style.FILL_AND_STROKE);
   borderPaint.setColor(Color.BLACK);
   borderPaint.setStyle(Paint.Style.STROKE);
 }
Ejemplo n.º 17
0
  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);
  }
Ejemplo n.º 18
0
  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);
  }
Ejemplo n.º 19
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();
  }
Ejemplo n.º 20
0
    protected void onDraw(Canvas canvas) {
      canvas.drawRGB(255, 255, 255);
      paint.setColor(Color.RED);
      canvas.drawLine(0, 0, canvas.getWidth() - 1, canvas.getHeight() - 1, paint);

      paint.setStyle(Style.STROKE);
      paint.setColor(0xff00ff00);
      canvas.drawCircle(canvas.getWidth() / 2, canvas.getHeight() / 2, 40, paint);

      paint.setStyle(Style.FILL);
      paint.setColor(0x770000ff);
      canvas.drawRect(
          canvas.getWidth() / 4,
          canvas.getHeight() / 4,
          (canvas.getWidth() / 4) + 100,
          (canvas.getHeight() / 4) + 50,
          paint);

      paint.setStyle(Style.FILL_AND_STROKE);
      paint.setColor(0x55ff0000);
      canvas.drawRect(
          3 * (canvas.getWidth() / 4),
          3 * (canvas.getHeight() / 4),
          3 * (canvas.getWidth() / 4) + 50,
          3 * (canvas.getHeight() / 4) + 25,
          paint);

      invalidate();
    }
Ejemplo n.º 21
0
  private void init() {

    count = 0;
    i = 0f;
    j = (int) 0.5;
    check = false;

    if (isStatic) {
      isAnimated = false;
    } else {
      isAnimated = true;
    }
    paintCloud = new Paint();
    paintFog = new Paint();

    // Setting paint for cloud
    paintCloud.setColor(strokeColor);
    paintCloud.setAntiAlias(true);
    paintCloud.setStrokeCap(Paint.Cap.ROUND);
    paintCloud.setStrokeJoin(Paint.Join.ROUND);
    paintCloud.setStyle(Paint.Style.STROKE);
    paintCloud.setShadowLayer(0, 0, 0, Color.BLACK);

    // Setting paint for fog
    paintFog.setColor(strokeColor);
    paintFog.setAntiAlias(true);
    paintFog.setStrokeCap(Paint.Cap.ROUND);
    paintFog.setStrokeJoin(Paint.Join.ROUND);
    paintFog.setStyle(Paint.Style.FILL_AND_STROKE);
    paintFog.setShadowLayer(0, 0, 0, Color.BLACK);

    cloud = new Cloud();
  }
  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);
  }
    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);
    }
Ejemplo n.º 24
0
  public void init(HTextView hTextView, AttributeSet attrs, int defStyle) {
    mHTextView = hTextView;

    mText = "";
    mOldText = "";

    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(textColor);
    paint.setStyle(Paint.Style.FILL);

    oldPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    oldPaint.setColor(textColor);
    oldPaint.setStyle(Paint.Style.FILL);

    backPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    backPaint.setColor(((ColorDrawable) mHTextView.getBackground()).getColor());
    backPaint.setStyle(Paint.Style.FILL);

    metrics = new DisplayMetrics();
    WindowManager windowManger =
        (WindowManager) hTextView.getContext().getSystemService(Context.WINDOW_SERVICE);
    windowManger.getDefaultDisplay().getMetrics(metrics);

    textSize = hTextView.getTextSize();

    sparkBitmap = BitmapFactory.decodeResource(hTextView.getResources(), R.drawable.fire);
  }
Ejemplo n.º 25
0
  @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);
    }
  }
Ejemplo n.º 26
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);
 }
Ejemplo n.º 27
0
  /** 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);
  }
Ejemplo n.º 28
0
  private void initGame() {

    holder = getHolder();
    holder.addCallback(this);
    // To store the initially colored shapes (Rect--> integer map)
    initiallyColoredShapes = new LinkedHashMap<>();
    initiallyColoredShapes.clear();
    // Default background color
    background = getResources().getColor(R.color.mondrian_background);
    // To store used colors (once)
    chosenColors = new HashSet<>();
    chosenColors.clear();
    // Lines are drawn in black with a stroke
    stroke = new Paint();
    stroke.setAntiAlias(true);
    stroke.setStrokeWidth(getResources().getDimension(R.dimen.gv_line_width));
    stroke.setColor(getResources().getColor(R.color.line_color));
    stroke.setStyle(Paint.Style.STROKE);
    // The shapes are filled with colors
    fill = new Paint();
    fill.setAntiAlias(true);
    fill.setStyle(Paint.Style.FILL);
    // To bring out adjacent shapes with the same color (game over)
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.game_over_stripes);
    BitmapShader bitmapshader =
        new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
    // If you lose, shapes are drawn with striped lines
    striped = new Paint();
    striped.setAntiAlias(true);
    striped.setStyle(Paint.Style.FILL);
    striped.setShader(bitmapshader);
    DEFAULT_BACKGROUND = getResources().getColor(R.color.mondrian_background);
  }
Ejemplo n.º 29
0
  @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();
  }
Ejemplo n.º 30
0
  @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);
  }