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:org.telegram.ui.Cells.AboutLinkCell.java

public AboutLinkCell(Context context) {
    super(context);

    setElevation(AndroidUtilities.dp(2));
    setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));

    textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(AndroidUtilities.dp(16));
    textPaint.setColor(ContextCompat.getColor(context, R.color.primary_text));
    textPaint.linkColor = Theme.MSG_LINK_TEXT_COLOR;

    urlPaint = new Paint();
    urlPaint.setColor(Theme.MSG_LINK_SELECT_BACKGROUND_COLOR);

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(imageView,/*  ww  w .  j a v a 2s  .co  m*/
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT,
                    (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
                    LocaleController.isRTL ? 0 : 16, 5, LocaleController.isRTL ? 16 : 0, 0));
    setWillNotDraw(false);
}

From source file:com.ceabie.EffectiveLib.EffectImageView.java

private void initView(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.EffectImageView);
        mEffectDrawable = array.getDrawable(R.styleable.EffectImageView_EffectMark);
        array.recycle();/*w  ww.ja v  a  2  s.c o  m*/
    }

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    mHardware = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            && (ViewCompat.getLayerType(this) != ViewCompat.LAYER_TYPE_SOFTWARE);
    if (mHardware) {
        // ?
        ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_HARDWARE, mPaint);
    }
}

From source file:com.google.android.apps.santatracker.doodles.shared.physics.Polygon.java

public Polygon(List<Vector2D> vertices) {
    this.vertices = vertices;
    min = Vector2D.get(0, 0);//from  ww  w.  j  a v a2 s  .  c  o m
    max = Vector2D.get(0, 0);

    vertexPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    vertexPaint.setColor(Color.RED);

    midpointPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    midpointPaint.setColor(Color.GREEN);
    midpointPaint.setAlpha(100);

    linePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    linePaint.setColor(Color.WHITE);
    linePaint.setStrokeWidth(5);

    updateExtents();
    updateInversionStatus();
    calculateNormals();
}

From source file:de.hs_bremen.aurora_hunter.ui.views.KpIndexChartView.java

public KpIndexChartView(Context context, AttributeSet attributeSet) {
    super(context, attributeSet);
    setFocusable(true);//  w ww.j a v  a  2s  .  c  o m
    setFocusableInTouchMode(true);

    setOnTouchListener(this);

    int colorBg = ContextCompat.getColor(getContext(), R.color.colorBackgroundChart);
    int colorFg = ContextCompat.getColor(getContext(), R.color.colorKPChart);

    mGraphPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    //mGraphPaint.setStyle(Paint.Style.STROKE);
    mGraphPaint.setStrokeWidth(STROKE_WIDTH);
    mGraphPaint.setColor(colorBg);
    mGraphPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    //mGraphPaint.setShader(new LinearGradient(0, 0, 0, getHeight(), colorFg, colorBg, Shader.TileMode.MIRROR));

    mGraphPaint.setDither(true); // set the dither to true
    mGraphPaint.setStrokeJoin(Paint.Join.ROUND); // set the join to round you want
    mGraphPaint.setStrokeCap(Paint.Cap.ROUND); // set the mGraphPaint cap to round too
    mGraphPaint.setAntiAlias(true);
    mGraphPaint.setAlpha(100);

    paintG1Line.setStrokeWidth(1f);
    paintG1Line.setColor(Color.BLACK);
    paintG1Line.setStyle(Paint.Style.STROKE);
    paintG1Line.setDither(true); // set the dither to true
    paintG1Line.setAntiAlias(true);
    paintG1Line.setAlpha(100);

    paintTxt.setStrokeWidth(10f);
    paintTxt.setDither(true); // set the dither to true
    paintTxt.setStrokeJoin(Paint.Join.ROUND); // set the join to round you want
    paintTxt.setStrokeCap(Paint.Cap.ROUND); // set the mGraphPaint cap to round too
    paintTxt.setPathEffect(new CornerPathEffect(10)); // set the path effect when they join.
    paintTxt.setAntiAlias(true);
    paintTxt.setColor(Color.BLACK);
    paintTxt.setTextSize(20);
    paintTxt.setFakeBoldText(true);
    paintTxt.setAlpha(150);

}

From source file:org.mariotaku.twidere.view.TintedStatusFrameLayout.java

public TintedStatusFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TintedStatusLayout);
    setSetPaddingEnabled(a.getBoolean(R.styleable.TintedStatusLayout_setPadding, false));
    a.recycle();/*from w  w  w  .j  a  va 2s. c o m*/
    mColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mSystemWindowsInsets = new Rect();
    setWillNotDraw(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_STABLE | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        ViewCompat.setOnApplyWindowInsetsListener(this,
                new android.support.v4.view.OnApplyWindowInsetsListener() {
                    @Override
                    public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                        final int top = insets.getSystemWindowInsetTop();
                        final int left = insets.getSystemWindowInsetLeft();
                        final int right = insets.getSystemWindowInsetRight();
                        final int bottom = insets.getSystemWindowInsetBottom();
                        if (mSetPadding) {
                            setPadding(left, top, right, bottom);
                        }
                        setStatusBarHeight(top);
                        if (mWindowInsetsListener != null) {
                            mWindowInsetsListener.onApplyWindowInsets(left, top, right, bottom);
                        }
                        return insets.consumeSystemWindowInsets();
                    }
                });
    }
}

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

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    parentActivity = getActivity();//  w w w .  j  ava2  s.c  o m
    dialog = this;

    //Retrieve the arguments.
    final String PLAYLIST_NAME = getArguments().getString("PLAYLIST_NAME");
    final String PLAYLIST_FILE_PATH = getArguments().getString("PLAYLIST_FILE_PATH");
    final String PLAYLIST_FOLDER_PATH = getArguments().getString("PLAYLIST_FOLDER_PATH");

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    dialogView = parentActivity.getLayoutInflater().inflate(R.layout.rename_playlist_dialog_layout, null);

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

    playlistNameField = (EditText) dialogView.findViewById(R.id.rename_playlist_text_field);
    playlistNameField.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistNameField.setPaintFlags(
            playlistNameField.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistNameField.setText(PLAYLIST_NAME);

    //Set the dialog title.
    builder.setTitle(R.string.rename_playlist);
    builder.setView(dialogView);
    builder.setNegativeButton(R.string.cancel, new OnClickListener() {

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

        }

    });

    builder.setPositiveButton(R.string.done, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {

            //Create a File that points to the playlist on the filesystem.
            File file = new File(PLAYLIST_FILE_PATH);

            //Retrieve the name and file path for the playlist.
            String playlistName = playlistNameField.getText().toString();

            //Replace illegal characters in the playlistName.
            if (playlistName.contains("/")) {
                playlistName = playlistName.replace("/", "_");
            }

            if (playlistName.contains("\\")) {
                playlistName = playlistName.replace("\\", "_");
            }

            //Create another File that points to the renamed playlist file.
            File newFile = new File(PLAYLIST_FOLDER_PATH + "/" + playlistName + ".m3u");
            file.renameTo(newFile);

            /*//Update the database with the new file path and playlist name.
            DBAccessHelper playlistsDBHelper = new DBAccessHelper(parentActivity);
            playlistsDBHelper.renamePlaylist(PLAYLIST_FILE_PATH, playlistName, newFile.getAbsolutePath());
                    
            //Delete any instances of the old DB entries.
            playlistsDBHelper.deleteSpecificPlaylist(PLAYLIST_NAME, PLAYLIST_FILE_PATH);*/

            Toast.makeText(parentActivity, R.string.playlist_renamed, Toast.LENGTH_SHORT).show();

            //Refresh the playlists list view.
            //PlaylistsFragment playlistsFragment = new PlaylistsFragment();
            //playlistsFragment.refreshPlaylists();

            //playlistsDBHelper.close();
            dialog.dismiss();
        }

    });

    return builder.create();
}

From source file:com.Duo.music.player.Dialogs.GooglePlayMusicAuthenticationDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    parentActivity = getActivity();// ww w.ja v a  2  s.  co  m
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    sharedPreferences = parentActivity.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
    View rootView = parentActivity.getLayoutInflater().inflate(R.layout.dialog_google_authentication_layout,
            null);

    //Check if this dialog was called from the Welcome sequence.
    mFirstRun = getArguments().getBoolean(Common.FIRST_RUN);

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

    final AccountManager accountManager = AccountManager.get(getActivity().getApplicationContext());
    final Account[] accounts = accountManager.getAccountsByType("com.google");
    final int size = accounts.length;
    String[] accountNames = new String[size];

    for (int i = 0; i < size; i++) {
        accountNames[i] = accounts[i].name;
    }

    //Set the dialog title.
    builder.setTitle(R.string.sign_in_google_play_music);
    builder.setCancelable(false);
    builder.setItems(accountNames, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            account = accounts[which];
            sharedPreferences.edit().putString("GOOGLE_PLAY_MUSIC_ACCOUNT", account.name).commit();
            AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(
                    parentActivity.getApplicationContext(), parentActivity, mFirstRun, account.name);

            task.execute();

        }

    });

    return builder.create();
}

From source file:com.jelly.music.player.Dialogs.GooglePlayMusicAuthenticationDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    parentActivity = getActivity();//from w  w  w .j a va2 s  .  c o  m
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    sharedPreferences = parentActivity.getSharedPreferences("com.jelly.music.player", Context.MODE_PRIVATE);
    View rootView = parentActivity.getLayoutInflater().inflate(R.layout.dialog_google_authentication_layout,
            null);

    //Check if this dialog was called from the Welcome sequence.
    mFirstRun = getArguments().getBoolean(Common.FIRST_RUN);

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

    final AccountManager accountManager = AccountManager.get(getActivity().getApplicationContext());
    final Account[] accounts = accountManager.getAccountsByType("com.google");
    final int size = accounts.length;
    String[] accountNames = new String[size];

    for (int i = 0; i < size; i++) {
        accountNames[i] = accounts[i].name;
    }

    //Set the dialog title.
    builder.setTitle(R.string.sign_in_google_play_music);
    builder.setCancelable(false);
    builder.setItems(accountNames, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            account = accounts[which];
            sharedPreferences.edit().putString("GOOGLE_PLAY_MUSIC_ACCOUNT", account.name).commit();
            AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(
                    parentActivity.getApplicationContext(), parentActivity, mFirstRun, account.name);

            task.execute();

        }

    });

    return builder.create();
}

From source file:Main.java

/**
 * Draw input bitmap in shadow color and offset. Assumes offset is positive.
 *
 * @param inBitmap//www .j  av a 2  s .c o m
 * @param offsetX
 * @param offsetY
 * @param blurRadius        Not used
 * @param shadowColor
 * @return
 */
public static Bitmap shadowBitmap(Bitmap inBitmap, int offsetX, int offsetY, float blurRadius,
        int shadowColor) {

    int imgWidth = inBitmap.getWidth();
    int imgHeight = inBitmap.getHeight();

    Bitmap bottomBm = Bitmap.createBitmap(imgWidth, imgHeight, Bitmap.Config.ARGB_8888);
    Canvas bottomCanvas = new Canvas(bottomBm);
    // bottomCanvas.drawColor(shadowColor);

    Paint bottomPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    bottomPaint.setColor(shadowColor);
    bottomCanvas.drawRect(offsetX, offsetY, imgWidth, imgHeight, bottomPaint);

    //    MaskFilter filter = new BlurMaskFilter(Math.max(0.5f, blurRadius), BlurMaskFilter.Blur.NORMAL);
    bottomPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP));
    //    bottomPaint.setShadowLayer(blurRadius, offsetX, offsetX, shadowColor);
    //    bottomPaint.setMaskFilter(filter);
    bottomCanvas.drawBitmap(inBitmap, offsetX, offsetY, bottomPaint);

    return bottomBm;
}

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

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    parentActivity = getActivity();/* w w  w.  j  a  v a 2  s. c  o m*/
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    sharedPreferences = parentActivity.getSharedPreferences("com.aniruddhc.acemusic.player",
            Context.MODE_PRIVATE);
    View rootView = parentActivity.getLayoutInflater().inflate(R.layout.dialog_google_authentication_layout,
            null);

    //Check if this dialog was called from the Welcome sequence.
    mFirstRun = getArguments().getBoolean(Common.FIRST_RUN);

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

    final AccountManager accountManager = AccountManager.get(getActivity().getApplicationContext());
    final Account[] accounts = accountManager.getAccountsByType("com.google");
    final int size = accounts.length;
    String[] accountNames = new String[size];

    for (int i = 0; i < size; i++) {
        accountNames[i] = accounts[i].name;
    }

    //Set the dialog title.
    builder.setTitle(R.string.sign_in_google_play_music);
    builder.setCancelable(false);
    builder.setItems(accountNames, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            account = accounts[which];
            sharedPreferences.edit().putString("GOOGLE_PLAY_MUSIC_ACCOUNT", account.name).commit();
            AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(
                    parentActivity.getApplicationContext(), parentActivity, mFirstRun, account.name);

            task.execute();

        }

    });

    return builder.create();
}