Example usage for android.graphics Paint ANTI_ALIAS_FLAG

List of usage examples for android.graphics Paint ANTI_ALIAS_FLAG

Introduction

In this page you can find the example usage for android.graphics Paint ANTI_ALIAS_FLAG.

Prototype

int ANTI_ALIAS_FLAG

To view the source code for android.graphics Paint ANTI_ALIAS_FLAG.

Click Source Link

Document

Paint flag that enables antialiasing when drawing.

Usage

From source file:com.journeyapps.barcodescanner.WXViewfinderView.java

public WXViewfinderView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Initialize these once for performance rather than calling them every time in onDraw().
    maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    borderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    cornerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    Resources resources = getResources();

    // Get setted attributes on view
    TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.zxing_WXViewfinderView);

    this.maskColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_mask_color,
            Color.parseColor("#8c000000"));
    this.laserColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_laser_color,
            Color.parseColor("#d90000"));
    this.cornerColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_corner_color,
            Color.parseColor("#d90000"));
    this.borderColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_border_color,
            Color.parseColor("#dfdfdf"));
    this.borderWidth = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_border_width, 1);
    this.cornerWidth = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_corner_width, 3);
    this.cornerLength = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_corner_length, 12);
    this.statusText = attributes.getString(R.styleable.zxing_WXViewfinderView_zxing_status_text);
    if (statusText == null) {
        statusText = "?????";
    }//  w w w.j a v  a  2s.co  m
    this.statusTextColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_status_color,
            Color.parseColor("#b6b0b0"));
    this.statusTextPadding = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_status_padding,
            32);
    this.statusTextSize = attributes.getDimensionPixelSize(R.styleable.zxing_WXViewfinderView_zxing_status_size,
            24);
    maskPaint.setStyle(Paint.Style.FILL);
    maskPaint.setColor(maskColor);
    borderPaint.setStyle(Paint.Style.STROKE);
    borderPaint.setStrokeWidth(borderWidth);
    borderPaint.setColor(borderColor);
    cornerPaint.setStrokeWidth(cornerWidth);
    cornerPaint.setColor(cornerColor);
    cornerPaint.setStyle(Paint.Style.STROKE);
    textPaint.setTextSize(statusTextSize);
    textPaint.setColor(statusTextColor);
    attributes.recycle();
}

From source file:com.example.accessibility.FeedbackClickView.java

public FeedbackClickView(Context context) {

    super(context);

    paintWhite.setColor(Color.WHITE);

    paintWhite.setStrokeWidth(4);//from   w  w  w.j  av  a2  s . co  m
    paintWhite.setARGB(128, 255, 255, 255);
    paintWhite.setStyle(Paint.Style.FILL_AND_STROKE);
    paintWhite.setAntiAlias(true);

    paintBlack.setStrokeWidth(4);
    paintBlack.setARGB(128, 0, 0, 0);
    paintBlack.setStyle(Paint.Style.FILL_AND_STROKE);
    paintBlack.setAntiAlias(true);

    mGreen = new Paint(Paint.ANTI_ALIAS_FLAG);
    mGreen.setARGB(128, 0, 255, 0);
    mGreen.setStyle(Style.FILL);

    mYellow.setStyle(Style.FILL_AND_STROKE);
    mYellow.setStrokeWidth(3);
    mYellow.setColor(Color.YELLOW);

    mBlack.setStyle(Style.FILL_AND_STROKE);
    mBlack.setStrokeWidth(3);
    mBlack.setColor(Color.BLACK);

    mButton = "clear";
    oval = new RectF(50, 50, 150, 150);
    deg = 0;

}

From source file:com.aniruddhc.acemusic.player.Dialogs.ViewPlaylistInformationDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    parentActivity = getActivity();/*w w w .  j  a  v  a  2 s.c o  m*/
    dialogFragment = this;

    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.dialog_playlist_information, null);

    playlistName = getArguments().getString("PLAYLIST_NAME");
    playlistFilePath = getArguments().getString("PLAYLIST_FILE_PATH");

    //Header text declarations.
    playlistNameText = (TextView) rootView.findViewById(R.id.playlist_name_text);
    playlistNameText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistNameText.setPaintFlags(playlistNameText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistFormatText = (TextView) rootView.findViewById(R.id.playlist_format_text);
    playlistFormatText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistFormatText.setPaintFlags(playlistFormatText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistLocationText = (TextView) rootView.findViewById(R.id.playlist_location_text);
    playlistLocationText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistLocationText.setPaintFlags(playlistLocationText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistNumberOfSongsText = (TextView) rootView.findViewById(R.id.playlist_number_of_songs_text);
    playlistNumberOfSongsText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistNumberOfSongsText.setPaintFlags(playlistNumberOfSongsText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistLastModifiedText = (TextView) rootView.findViewById(R.id.playlist_last_modified_text);
    playlistLastModifiedText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistLastModifiedText.setPaintFlags(playlistLastModifiedText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistAddedToLibraryText = (TextView) rootView.findViewById(R.id.playlist_added_to_library_text);
    playlistAddedToLibraryText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistAddedToLibraryText.setPaintFlags(playlistAddedToLibraryText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistCreatedText = (TextView) rootView.findViewById(R.id.playlist_created_text);
    playlistCreatedText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistCreatedText.setPaintFlags(playlistCreatedText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    //Values declarations.
    playlistNameValue = (TextView) rootView.findViewById(R.id.playlist_name_value);
    playlistNameValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistNameValue.setPaintFlags(
            playlistNameValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistFormatValue = (TextView) rootView.findViewById(R.id.playlist_format_value);
    playlistFormatValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistFormatValue.setPaintFlags(
            playlistFormatValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistLocationValue = (TextView) rootView.findViewById(R.id.playlist_location_value);
    playlistLocationValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistLocationValue.setPaintFlags(
            playlistLocationValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistNumberOfSongsValue = (TextView) rootView.findViewById(R.id.playlist_number_of_songs_value);
    playlistNumberOfSongsValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistNumberOfSongsValue.setPaintFlags(
            playlistNumberOfSongsValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistLastModifiedValue = (TextView) rootView.findViewById(R.id.playlist_last_modified_value);
    playlistLastModifiedValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistLastModifiedValue.setPaintFlags(
            playlistLastModifiedValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistAddedToLibraryValue = (TextView) rootView.findViewById(R.id.playlist_added_to_library_value);
    playlistAddedToLibraryValue
            .setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistAddedToLibraryValue.setPaintFlags(
            playlistAddedToLibraryValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistCreatedValue = (TextView) rootView.findViewById(R.id.playlist_created_value);
    playlistCreatedValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistCreatedValue.setPaintFlags(
            playlistCreatedValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //Set the playlist name and the file format.
    playlistNameValue.setText(playlistName);

    int extensionDotIndex = playlistFilePath.lastIndexOf(".");

    String extension = "";
    if (!playlistFilePath.isEmpty()) {
        extension = playlistFilePath.substring(extensionDotIndex, playlistFilePath.length());
    } else {
        extension = "Unknown";
    }
    playlistFormatValue.setText(extension);

    /*//Retrieve the information that needs to tbe displayed in the dialog.
    DBAccessHelper dbHelper = new DBAccessHelper(parentActivity);
    Cursor cursor = dbHelper.getPlaylistByFilePath(playlistFilePath);
            
    if (cursor.getCount() > 0) {
       //Get the number of songs in the playlist.
       playlistNumberOfSongs = cursor.getCount() + "";
       playlistNumberOfSongsValue.setText(playlistNumberOfSongs);
               
       //Get the date that the playlist was added to the library.
       cursor.moveToFirst();
               
       //Note that addTime isn't the actual "Last modification" date. It's actually the date the playlist was added to the library.
       long addTime = cursor.getLong(cursor.getColumnIndex(DBAccessHelper.PLAYLIST_LAST_MODIFIED));
       Date addDate = new Date(addTime);
               
       SimpleDateFormat addDateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm aa", Locale.getDefault());
       addDateFormat.setTimeZone(TimeZone.getDefault());
       playlistAddedToLibrary = addDateFormat.format(addDate);
               
       playlistAddedToLibraryValue.setText(playlistAddedToLibrary);
               
    }
            
    //Get a File that points to the playlist file on the filesystem.
    File file = new File(playlistFilePath);
    long lastModifiedTime = file.lastModified();
            
    if (lastModifiedTime==0) {
       playlistLastModifiedValue.setText("Unknown");
    } else {
       Date lastModifiedDate = new Date(lastModifiedTime);
               
       SimpleDateFormat lastModifiedDateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm aa", Locale.getDefault());
       lastModifiedDateFormat.setTimeZone(TimeZone.getDefault());
               
       playlistLastModified = lastModifiedDateFormat.format(lastModifiedDate);
       playlistLastModifiedValue.setText(playlistLastModified);
       playlistCreatedValue.setText(playlistLastModified);
    }*/

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Set the dialog title.
    builder.setTitle(playlistName);
    builder.setView(rootView);
    builder.setNegativeButton(R.string.done, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();

        }

    });

    return builder.create();
}

From source file:com.androidmapsextensions.DefaultClusterOptionsProvider.java

private Paint createCircleShadowPaint(Resources resources) {
    Paint paint = null;/*w  w w  . jav a2  s  . com*/
    float circleShadowBlurRadius = resources
            .getDimension(R.dimen.ame_default_cluster_circle_shadow_blur_radius);
    if (circleShadowBlurRadius > 0.0f) {
        paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        float offsetX = resources.getDimension(R.dimen.ame_default_cluster_circle_shadow_offset_x);
        float offsetY = resources.getDimension(R.dimen.ame_default_cluster_circle_shadow_offset_y);
        int color = resources.getColor(R.color.ame_default_cluster_circle_shadow_color);
        paint.setShadowLayer(circleShadowBlurRadius, offsetX, offsetY, color);
    }
    return paint;
}

From source file:android.support.design.widget.ShadowDrawableWrapper.java

public ShadowDrawableWrapper(Context context, Drawable content, float radius, float shadowSize,
        float maxShadowSize) {
    super(content);

    mShadowStartColor = ContextCompat.getColor(context, R.color.design_fab_shadow_start_color);
    mShadowMiddleColor = ContextCompat.getColor(context, R.color.design_fab_shadow_mid_color);
    mShadowEndColor = ContextCompat.getColor(context, R.color.design_fab_shadow_end_color);

    mCornerShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mCornerShadowPaint.setStyle(Paint.Style.FILL);
    mCornerRadius = Math.round(radius);
    mContentBounds = new RectF();
    mEdgeShadowPaint = new Paint(mCornerShadowPaint);
    mEdgeShadowPaint.setAntiAlias(false);
    setShadowSize(shadowSize, maxShadowSize);
}

From source file:com.example.waitou.rxjava.LoadingView.java

public LoadingView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mRing = new Ring();
    bounds = new Rect();
    mPaint = new Paint();
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(mRing.strokeWidth);

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LoadingView, 0, 0);
        setColor(a.getInt(R.styleable.LoadingView_loadding_color, DEFAULT_COLOR));
        setRingStyle(a.getInt(R.styleable.LoadingView_ring_style, RING_STYLE_SQUARE));
        setProgressStyle(a.getInt(R.styleable.LoadingView_progress_style, PROGRESS_STYLE_MATERIAL));
        setStrokeWidth(a.getDimension(R.styleable.LoadingView_ring_width, dp2px(STROKE_WIDTH)));
        setCenterRadius(a.getDimension(R.styleable.LoadingView_ring_radius, dp2px(CENTER_RADIUS)));
        a.recycle();//from   w ww .  ja v  a  2  s .  com
    }
}

From source file:com.github.barteksc.pdfviewpager.view.ScrollBar.java

private void init() {

    indicator = new ScrollBarPageIndicator(getContext());
    setIndicatorPage(currentPage);/* w ww .j  a v a  2  s .co m*/
    indicator.setBackgroundColor(indicatorColor);
    indicator.setTextColor(indicatorTextColor);

    addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {
            indicator.addToScrollBar(ScrollBar.this);
            ScrollBar.this.removeOnLayoutChangeListener(this);
        }
    });

    handlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    handlePaint.setStyle(Paint.Style.FILL);
    handlePaint.setColor(handleColor);

    if (getBackground() == null) {
        setBackgroundColor(Color.LTGRAY);
    }

    handlePos = new PointF(0, 0);

    viewWidth = Util.getDP(getContext(), 30);
}

From source file:io.plaidapp.ui.widget.FabOverlapTextView.java

private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FabOverlapTextView);

    float defaultTextSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, DEFAULT_TEXT_SIZE_SP,
            getResources().getDisplayMetrics());

    setFabOverlapGravity(a.getInt(R.styleable.FabOverlapTextView_fabGravity, Gravity.BOTTOM | Gravity.RIGHT));
    setFabOverlapHeight(a.getDimensionPixelSize(R.styleable.FabOverlapTextView_fabOverlayHeight, 0));
    setFabOverlapWidth(a.getDimensionPixelSize(R.styleable.FabOverlapTextView_fabOverlayWidth, 0));

    if (a.hasValue(R.styleable.FabOverlapTextView_android_textAppearance)) {
        final int textAppearance = a.getResourceId(R.styleable.FabOverlapTextView_android_textAppearance,
                android.R.style.TextAppearance);
        TypedArray atp = getContext().obtainStyledAttributes(textAppearance, R.styleable.FontTextAppearance);
        paint.setColor(atp.getColor(R.styleable.FontTextAppearance_android_textColor, Color.BLACK));
        paint.setTextSize(atp.getDimensionPixelSize(R.styleable.FontTextAppearance_android_textSize,
                (int) defaultTextSize));
        if (atp.hasValue(R.styleable.FontTextAppearance_font)) {
            paint.setTypeface(FontUtil.get(getContext(), atp.getString(R.styleable.FontTextAppearance_font)));
        }//from  w  ww . j ava 2s .  c o m
        atp.recycle();
    }

    if (a.hasValue(R.styleable.FabOverlapTextView_font)) {
        setFont(a.getString(R.styleable.FabOverlapTextView_font));
    }

    if (a.hasValue(R.styleable.FabOverlapTextView_android_textColor)) {
        setTextColor(a.getColor(R.styleable.FabOverlapTextView_android_textColor, 0));
    }
    if (a.hasValue(R.styleable.FabOverlapTextView_android_textSize)) {
        setTextSize(a.getDimensionPixelSize(R.styleable.FabOverlapTextView_android_textSize,
                (int) defaultTextSize));
    }

    lineHeightHint = a.getDimensionPixelSize(R.styleable.FabOverlapTextView_lineHeightHint, 0);
    topPaddingHint = a.getDimensionPixelSize(R.styleable.FabOverlapTextView_topPaddingHint, 0);

    breakStrategy = a.getInt(R.styleable.FabOverlapTextView_android_breakStrategy,
            Layout.BREAK_STRATEGY_BALANCED);

    a.recycle();
}

From source file:com.jakewharton.android.viewpagerindicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle,
            R.style.Widget_CirclePageIndicator);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke/*from   ww  w . j  a  v a  2 s  .c  o m*/
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    a.recycle();
}

From source file:cn.refactor.ultraindicator.lib.UltraIndicatorView.java

private void init(AttributeSet attrs) {
    TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.UltraIndicatorView);
    mCheckedColor = ta.getColor(R.styleable.UltraIndicatorView_checkedColor, DEFAULT_CHECKED_COLOR);
    mUnCheckedColor = ta.getColor(R.styleable.UltraIndicatorView_uncheckedColor, DEFAULT_UNCHECKED_COLOR);
    mAnimDuration = ta.getInt(R.styleable.UltraIndicatorView_duration, DEFAULT_ANIM_DURATION);
    ta.recycle();// w w  w.j a  v  a  2 s .  com

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStyle(Paint.Style.FILL);
}