List of usage examples for android.graphics Paint ANTI_ALIAS_FLAG
int ANTI_ALIAS_FLAG
To view the source code for android.graphics Paint ANTI_ALIAS_FLAG.
Click Source Link
From source file:in.sc9.discreteslider.DiscreteSlider.java
private void drawTextArray(Canvas canvas, int thumbWidth, int halfThumb, float yPos, int left, float intervel) { int lenTextArray = textArray.length; if (lenTextArray == 0) return;/*from www . j av a2s . c o m*/ float currentLeft = left; Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setTextAlign(Paint.Align.LEFT); paint.setColor(mtextColor); paint.setTextSize(mTextSize); //paint.setTypeface(); //TODO setTypeface in Discrete Seek Bar //elloWorldTextView2.setTextSize(activity.pixelsToSp(activity, textSize)); //paint.m for (int i = 0; i < lenTextArray; i++) { /*if((int)getThumbValue(0)==i*(int)scaleStep) paint.setColor(Color.parseColor("#ffff0000")); else paint.setColor(Color.parseColor("#ff22445b"));*/ float textLen = paint.measureText(textArray[i]); if (i == 0) { if (textStyle != NONE && (textStyle == ODD || textStyle == EXTREMES || textStyle == ALL)) canvas.drawText(textArray[i], currentLeft, yPos, paint); } else if (i == lenTextArray - 1) { if (textStyle != NONE) if ((textStyle == ALL) || (i % 2 == 0 && textStyle == ODD) || (i % 2 != 0 && textStyle == EVEN) || (textStyle == EXTREMES)) canvas.drawText(textArray[i], currentLeft - textLen, yPos, paint); } else { if (textStyle != 0 && textStyle != 3) { if ((textStyle == ALL) || (i % 2 == 0 && textStyle == ODD) || (i % 2 != 0 && textStyle == EVEN)) canvas.drawText(textArray[i], currentLeft - (textLen / 2), yPos, paint); } } currentLeft += intervel; } }
From source file:kr.wdream.storyshop.AndroidUtilities.java
private static Intent createShortcutIntent(long did, boolean forDelete) { Intent shortcutIntent = new Intent(ApplicationLoader.applicationContext, OpenChatReceiver.class); int lower_id = (int) did; int high_id = (int) (did >> 32); TLRPC.User user = null;//from w w w . j a v a 2 s.c o m TLRPC.Chat chat = null; if (lower_id == 0) { shortcutIntent.putExtra("encId", high_id); TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(high_id); if (encryptedChat == null) { return null; } user = MessagesController.getInstance().getUser(encryptedChat.user_id); } else if (lower_id > 0) { shortcutIntent.putExtra("userId", lower_id); user = MessagesController.getInstance().getUser(lower_id); } else if (lower_id < 0) { chat = MessagesController.getInstance().getChat(-lower_id); shortcutIntent.putExtra("chatId", -lower_id); } else { return null; } if (user == null && chat == null) { return null; } String name; TLRPC.FileLocation photo = null; if (user != null) { name = ContactsController.formatName(user.first_name, user.last_name); if (user.photo != null) { photo = user.photo.photo_small; } } else { name = chat.title; if (chat.photo != null) { photo = chat.photo.photo_small; } } shortcutIntent.setAction("com.tmessages.openchat" + did); shortcutIntent.addFlags(0x4000000); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name); addIntent.putExtra("duplicate", false); if (!forDelete) { Bitmap bitmap = null; if (photo != null) { try { File path = FileLoader.getPathToAttach(photo, true); bitmap = BitmapFactory.decodeFile(path.toString()); if (bitmap != null) { int size = AndroidUtilities.dp(58); Bitmap result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); result.eraseColor(Color.TRANSPARENT); Canvas canvas = new Canvas(result); BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); if (roundPaint == null) { roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); bitmapRect = new RectF(); } float scale = size / (float) bitmap.getWidth(); canvas.save(); canvas.scale(scale, scale); roundPaint.setShader(shader); bitmapRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight()); canvas.drawRoundRect(bitmapRect, bitmap.getWidth(), bitmap.getHeight(), roundPaint); canvas.restore(); Drawable drawable = ApplicationLoader.applicationContext.getResources() .getDrawable(R.drawable.book_logo); int w = AndroidUtilities.dp(15); int left = size - w - AndroidUtilities.dp(2); int top = size - w - AndroidUtilities.dp(2); drawable.setBounds(left, top, left + w, top + w); drawable.draw(canvas); try { canvas.setBitmap(null); } catch (Exception e) { //don't promt, this will crash on 2.x } bitmap = result; } } catch (Throwable e) { FileLog.e("tmessages", e); } } if (bitmap != null) { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap); } else { if (user != null) { if (user.bot) { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource .fromContext(ApplicationLoader.applicationContext, R.drawable.book_bot)); } else { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource .fromContext(ApplicationLoader.applicationContext, R.drawable.book_user)); } } else if (chat != null) { if (ChatObject.isChannel(chat) && !chat.megagroup) { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource .fromContext(ApplicationLoader.applicationContext, R.drawable.book_channel)); } else { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource .fromContext(ApplicationLoader.applicationContext, R.drawable.book_group)); } } } } return addIntent; }
From source file:net.droidsolutions.droidcharts.core.plot.XYPlot.java
/** * Creates a new plot with the specified dataset, axes and renderer. Any of * the arguments can be <code>null</code>, but in that case you should take * care to specify the value before using the plot (otherwise a * <code>NullPointerException</code> may be thrown). * //from www . j av a2 s .c o m * @param dataset * the dataset (<code>null</code> permitted). * @param domainAxis * the domain axis (<code>null</code> permitted). * @param rangeAxis * the range axis (<code>null</code> permitted). * @param renderer * the renderer (<code>null</code> permitted). */ public XYPlot(XYDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, XYItemRenderer renderer) { super(); this.orientation = PlotOrientation.VERTICAL; this.weight = 1; // only relevant when this is a subplot this.axisOffset = RectangleInsets.ZERO_INSETS; // allocate storage for datasets, axes and renderers (all optional) this.domainAxes = new ObjectList(); this.domainAxisLocations = new ObjectList(); this.foregroundDomainMarkers = new HashMap(); this.backgroundDomainMarkers = new HashMap(); this.rangeAxes = new ObjectList(); this.rangeAxisLocations = new ObjectList(); this.foregroundRangeMarkers = new HashMap(); this.backgroundRangeMarkers = new HashMap(); this.datasets = new ObjectList(); this.renderers = new ObjectList(); this.datasetToDomainAxesMap = new TreeMap(); this.datasetToRangeAxesMap = new TreeMap(); this.annotations = new java.util.ArrayList(); this.datasets.set(0, dataset); if (dataset != null) { // dataset.addChangeListener(this); } this.renderers.set(0, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } this.domainAxes.set(0, domainAxis); this.mapDatasetToDomainAxis(0, 0); if (domainAxis != null) { domainAxis.setPlot(this); // domainAxis.addChangeListener(this); } this.domainAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); this.rangeAxes.set(0, rangeAxis); this.mapDatasetToRangeAxis(0, 0); if (rangeAxis != null) { rangeAxis.setPlot(this); // rangeAxis.addChangeListener(this); } this.rangeAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); configureDomainAxes(); configureRangeAxes(); Paint white = new Paint(Paint.ANTI_ALIAS_FLAG); white.setColor(Color.WHITE); Paint black = new Paint(Paint.ANTI_ALIAS_FLAG); white.setColor(Color.BLACK); this.domainGridlinesVisible = true; this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.domainMinorGridlinesVisible = false; this.domainMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainMinorGridlinePaint = white; this.domainZeroBaselineVisible = false; this.domainZeroBaselinePaint = black; this.domainZeroBaselineStroke = 1f; this.rangeGridlinesVisible = true; this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeMinorGridlinesVisible = false; this.rangeMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeMinorGridlinePaint = white; this.rangeZeroBaselineVisible = false; this.rangeZeroBaselinePaint = black; this.rangeZeroBaselineStroke = 1f; this.domainCrosshairVisible = false; this.domainCrosshairValue = 0.0; this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.rangeCrosshairVisible = false; this.rangeCrosshairValue = 0.0; this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; }
From source file:com.ferdi2005.secondgram.AndroidUtilities.java
private static Intent createShortcutIntent(long did, boolean forDelete) { Intent shortcutIntent = new Intent(ApplicationLoader.applicationContext, OpenChatReceiver.class); int lower_id = (int) did; int high_id = (int) (did >> 32); TLRPC.User user = null;/*from ww w . j a va 2s . co m*/ TLRPC.Chat chat = null; if (lower_id == 0) { shortcutIntent.putExtra("encId", high_id); TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(high_id); if (encryptedChat == null) { return null; } user = MessagesController.getInstance().getUser(encryptedChat.user_id); } else if (lower_id > 0) { shortcutIntent.putExtra("userId", lower_id); user = MessagesController.getInstance().getUser(lower_id); } else if (lower_id < 0) { chat = MessagesController.getInstance().getChat(-lower_id); shortcutIntent.putExtra("chatId", -lower_id); } else { return null; } if (user == null && chat == null) { return null; } String name; TLRPC.FileLocation photo = null; if (user != null) { name = ContactsController.formatName(user.first_name, user.last_name); if (user.photo != null) { photo = user.photo.photo_small; } } else { name = chat.title; if (chat.photo != null) { photo = chat.photo.photo_small; } } shortcutIntent.setAction("com.tmessages.openchat" + did); shortcutIntent.addFlags(0x4000000); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name); addIntent.putExtra("duplicate", false); if (!forDelete) { Bitmap bitmap = null; if (photo != null) { try { File path = FileLoader.getPathToAttach(photo, true); bitmap = BitmapFactory.decodeFile(path.toString()); if (bitmap != null) { int size = AndroidUtilities.dp(58); Bitmap result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); result.eraseColor(Color.TRANSPARENT); Canvas canvas = new Canvas(result); BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); if (roundPaint == null) { roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); bitmapRect = new RectF(); } float scale = size / (float) bitmap.getWidth(); canvas.save(); canvas.scale(scale, scale); roundPaint.setShader(shader); bitmapRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight()); canvas.drawRoundRect(bitmapRect, bitmap.getWidth(), bitmap.getHeight(), roundPaint); canvas.restore(); Drawable drawable = ApplicationLoader.applicationContext.getResources() .getDrawable(R.drawable.book_logo); int w = AndroidUtilities.dp(15); int left = size - w - AndroidUtilities.dp(2); int top = size - w - AndroidUtilities.dp(2); drawable.setBounds(left, top, left + w, top + w); drawable.draw(canvas); try { canvas.setBitmap(null); } catch (Exception e) { //don't promt, this will crash on 2.x } bitmap = result; } } catch (Throwable e) { FileLog.e(e); } } if (bitmap != null) { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap); } else { if (user != null) { if (user.bot) { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource .fromContext(ApplicationLoader.applicationContext, R.drawable.book_bot)); } else { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource .fromContext(ApplicationLoader.applicationContext, R.drawable.book_user)); } } else if (chat != null) { if (ChatObject.isChannel(chat) && !chat.megagroup) { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource .fromContext(ApplicationLoader.applicationContext, R.drawable.book_channel)); } else { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource .fromContext(ApplicationLoader.applicationContext, R.drawable.book_group)); } } } } return addIntent; }
From source file:com.nextgis.mobile.fragment.MapFragment.java
protected void drawScaleRuler() { int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, 10, getResources().getDisplayMetrics()); int notch = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, 1, getResources().getDisplayMetrics()); Bitmap ruler = Bitmap.createBitmap(px, px, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(ruler); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(ContextCompat.getColor(getActivity(), R.color.primary_dark)); paint.setStrokeWidth(4);//from w ww. ja v a 2s . c o m paint.setStyle(Paint.Style.STROKE); canvas.drawLine(0, px, px, px, paint); canvas.drawLine(0, px, 0, 0, paint); canvas.drawLine(0, 0, notch, 0, paint); canvas.drawLine(px, px, px, px - notch, paint); mScaleRuler.setImageBitmap(ruler); }
From source file:com.elpstudio.player.EqualizerActivity.java
/** * Builds the "Save Preset" dialog. Does not call the show() method, so you * should do this manually when calling this method. * //from w ww . j a v a2 s .c om * @return A fully built AlertDialog reference. */ private AlertDialog buildSavePresetDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); View dialogView = getLayoutInflater().inflate(R.layout.add_new_equalizer_preset_dialog_layout, null); final EditText newPresetNameField = (EditText) dialogView.findViewById(R.id.new_preset_name_text_field); //newPresetNameField.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light")); newPresetNameField.setPaintFlags( newPresetNameField.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); //Set the dialog title. builder.setTitle("Save Preset"); builder.setView(dialogView); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { dialog.dismiss(); } }); builder.setPositiveButton("Done", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Get the preset name from the text field. if (newPresetNameField.getText().toString().trim().length() > 0) { String presetName = newPresetNameField.getText().toString(); //Add the preset and it's values to the DB. mApp.getDBAccessHelper().addNewEQPreset(presetName, fiftyHertzLevel, oneThirtyHertzLevel, threeTwentyHertzLevel, eightHundredHertzLevel, twoKilohertzLevel, fiveKilohertzLevel, twelvePointFiveKilohertzLevel, (short) virtualizerSeekBar.getProgress(), (short) bassBoostSeekBar.getProgress(), (short) reverbSpinner.getSelectedItemPosition()); Toast.makeText(mContext, "Saved .. commented", Toast.LENGTH_SHORT).show(); dialog.dismiss(); } } }); return builder.create(); }
From source file:com.songcode.materialnotes.ui.NoteEditActivity.java
private View getListItem(String item, int index) { View view = LayoutInflater.from(this).inflate(R.layout.note_edit_list_item, null); final NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text); edit.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId)); CheckBox cb = ((CheckBox) view.findViewById(R.id.cb_edit_item)); cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } else { edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG); }/* w ww. j a v a 2s . c o m*/ } }); if (item.startsWith(TAG_CHECKED)) { cb.setChecked(true); edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); item = item.substring(TAG_CHECKED.length(), item.length()).trim(); } else if (item.startsWith(TAG_UNCHECKED)) { cb.setChecked(false); edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG); item = item.substring(TAG_UNCHECKED.length(), item.length()).trim(); } edit.setOnTextViewChangeListener(this); edit.setIndex(index); edit.setText(getHighlightQueryResult(item, mUserQuery)); return view; }
From source file:com.aniruddhc.acemusic.player.EqualizerActivity.EqualizerActivity.java
/** * Builds the "Save Preset" dialog. Does not call the show() method, so you * should do this manually when calling this method. * /*from www . jav a 2s .c o m*/ * @return A fully built AlertDialog reference. */ private AlertDialog buildSavePresetDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); View dialogView = getLayoutInflater().inflate(R.layout.add_new_equalizer_preset_dialog_layout, null); final EditText newPresetNameField = (EditText) dialogView.findViewById(R.id.new_preset_name_text_field); newPresetNameField.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light")); newPresetNameField.setPaintFlags( newPresetNameField.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); //Set the dialog title. builder.setTitle(R.string.save_preset); builder.setView(dialogView); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { dialog.dismiss(); } }); builder.setPositiveButton(R.string.done, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Get the preset name from the text field. String presetName = newPresetNameField.getText().toString(); //Add the preset and it's values to the DB. mApp.getDBAccessHelper().addNewEQPreset(presetName, fiftyHertzLevel, oneThirtyHertzLevel, threeTwentyHertzLevel, eightHundredHertzLevel, twoKilohertzLevel, fiveKilohertzLevel, twelvePointFiveKilohertzLevel, (short) virtualizerSeekBar.getProgress(), (short) bassBoostSeekBar.getProgress(), (short) reverbSpinner.getSelectedItemPosition()); Toast.makeText(mContext, R.string.preset_saved, Toast.LENGTH_SHORT).show(); dialog.dismiss(); } }); return builder.create(); }
From source file:info.tellmetime.TellmetimeActivity.java
/** * Generates rainbow gradient and sets it as #mSeekBarHighlight progress drawable. *///from w w w. j av a 2 s . c o m private void drawRainbow() { float gradientWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 256, getResources().getDisplayMetrics()); int[] colors = { 0xFFFFFFFF, 0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF00FF, 0xFF888888, 0xFF000000 }; LinearGradient rainbowGradient = new LinearGradient(0f, 0f, gradientWidth, 0f, colors, null, Shader.TileMode.CLAMP); float r = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); ShapeDrawable shape = new ShapeDrawable( new RoundRectShape(new float[] { r, r, r, r, r, r, r, r }, null, null)); shape.getPaint().setShader(rainbowGradient); mSeekBarHighlight.setProgressDrawable(shape); // Generate bitmap with the same rainbow gradient and cache it for later use to retrieve color at given position. Bitmap bitmap = Bitmap.createBitmap((int) gradientWidth, 1, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Paint.Style.FILL); paint.setShader(rainbowGradient); canvas.drawRect(0, 0, gradientWidth, 1, paint); mRainbow = bitmap; // Set max value to gradient's width and restore relative position. mSeekBarHighlight.setMax((int) (gradientWidth - 1)); mSeekBarHighlight.setProgress((int) ((gradientWidth - 1) * mHighlightPosition)); }
From source file:com.nextgis.maplibui.overlay.EditLayerOverlay.java
protected Bitmap getMarker() { float scaledDensity = mContext.getResources().getDisplayMetrics().scaledDensity; int size = (int) (12 * scaledDensity); Bitmap marker = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(marker); Paint p = new Paint(Paint.ANTI_ALIAS_FLAG); //noinspection deprecation p.setColor(mContext.getResources().getColor(R.color.accent)); p.setAlpha(128);/*from w ww . j ava 2 s. c om*/ c.drawOval(new RectF(0, 0, size * 3 / 4, size * 3 / 4), p); return marker; }