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); }
public AbstractChartRenderer(Context context, Chart chart) { this.density = context.getResources().getDisplayMetrics().density; this.scaledDensity = context.getResources().getDisplayMetrics().scaledDensity; this.chart = chart; this.computator = chart.getChartComputator(); labelMargin = ChartUtils.dp2px(density, DEFAULT_LABEL_MARGIN_DP); labelOffset = labelMargin; labelPaint.setAntiAlias(true); labelPaint.setStyle(Paint.Style.FILL); labelPaint.setTextAlign(Align.LEFT); labelPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); labelPaint.setColor(Color.WHITE); labelBackgroundPaint.setAntiAlias(true); labelBackgroundPaint.setStyle(Paint.Style.FILL); }
public PieChartRenderer(Context context, Chart chart, PieChartDataProvider dataProvider) { super(context, chart); this.dataProvider = dataProvider; touchAdditional = ChartUtils.dp2px(density, DEFAULT_TOUCH_ADDITIONAL_DP); slicePaint.setAntiAlias(true); slicePaint.setStyle(Paint.Style.FILL); centerCirclePaint.setAntiAlias(true); centerCirclePaint.setStyle(Paint.Style.FILL); centerCirclePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); centerCircleText1Paint.setAntiAlias(true); centerCircleText1Paint.setTextAlign(Align.CENTER); centerCircleText2Paint.setAntiAlias(true); centerCircleText2Paint.setTextAlign(Align.CENTER); separationLinesPaint.setAntiAlias(true); separationLinesPaint.setStyle(Paint.Style.STROKE); separationLinesPaint.setStrokeCap(Paint.Cap.ROUND); separationLinesPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); separationLinesPaint.setColor(Color.TRANSPARENT); }
private void initAxisTextAlignment(Axis axis, int position) { namePaintTab[position].setTextAlign(Align.CENTER); if (TOP == position || BOTTOM == position) { labelPaintTab[position].setTextAlign(Align.CENTER); } else if (LEFT == position) { if (axis.isInside()) { labelPaintTab[position].setTextAlign(Align.LEFT); } else { labelPaintTab[position].setTextAlign(Align.RIGHT); } } else if (RIGHT == position) { if (axis.isInside()) { labelPaintTab[position].setTextAlign(Align.RIGHT); } else { labelPaintTab[position].setTextAlign(Align.LEFT); } } }
public DataRenderer(ChartAnimator animator, ViewPortHandler viewPortHandler) { super(viewPortHandler); this.mAnimator = animator; mRenderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mRenderPaint.setStyle(Style.FILL); mDrawPaint = new Paint(Paint.DITHER_FLAG); mValuePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mValuePaint.setColor(Color.rgb(63, 63, 63)); mValuePaint.setTextAlign(Align.CENTER); mValuePaint.setTextSize(Utils.convertDpToPixel(9f)); mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mHighlightPaint.setStyle(Paint.Style.STROKE); mHighlightPaint.setStrokeWidth(2f); mHighlightPaint.setColor(Color.rgb(255, 187, 115)); }
public PieChartRenderer(Context context, Chart chart, PieChartDataProvider dataProvider) { super(context, chart); this.dataProvider = dataProvider; this.touchAdditional = ChartUtils.dp2px(this.density, 8); this.slicePaint.setAntiAlias(true); this.slicePaint.setStyle(Style.FILL); this.centerCirclePaint.setAntiAlias(true); this.centerCirclePaint.setStyle(Style.FILL); this.centerCirclePaint.setXfermode(new PorterDuffXfermode(Mode.SRC)); this.centerCircleText1Paint.setAntiAlias(true); this.centerCircleText1Paint.setTextAlign(Align.CENTER); this.centerCircleText2Paint.setAntiAlias(true); this.centerCircleText2Paint.setTextAlign(Align.CENTER); this.separationLinesPaint.setAntiAlias(true); this.separationLinesPaint.setStyle(Style.STROKE); this.separationLinesPaint.setStrokeCap(Cap.ROUND); this.separationLinesPaint.setXfermode(new PorterDuffXfermode(Mode.CLEAR)); this.separationLinesPaint.setColor(0); }
protected void drawKeyPopupHint(@Nonnull final Key key, @Nonnull final Canvas canvas, @Nonnull final Paint paint, @Nonnull final KeyDrawParams params) { if (TextUtils.isEmpty(mKeyPopupHintLetter)) { return; } final int keyWidth = key.getDrawWidth(); final int keyHeight = key.getHeight(); paint.setTypeface(params.mTypeface); paint.setTextSize(params.mHintLetterSize); paint.setColor(params.mHintLabelColor); paint.setTextAlign(Align.CENTER); final float hintX = keyWidth - mKeyHintLetterPadding - TypefaceUtils.getReferenceCharWidth(paint) / 2.0f; final float hintY = keyHeight - mKeyPopupHintLetterPadding; canvas.drawText(mKeyPopupHintLetter, hintX, hintY, paint); }
private void initPaintTools() { satValPaint = new Paint(); satValTrackerPaint = new Paint(); hueAlphaTrackerPaint = new Paint(); alphaPaint = new Paint(); alphaTextPaint = new Paint(); borderPaint = new Paint(); satValTrackerPaint.setStyle(Style.STROKE); satValTrackerPaint.setStrokeWidth(DrawingUtils.dpToPx(getContext(), 2)); satValTrackerPaint.setAntiAlias(true); hueAlphaTrackerPaint.setColor(sliderTrackerColor); hueAlphaTrackerPaint.setStyle(Style.STROKE); hueAlphaTrackerPaint.setStrokeWidth(DrawingUtils.dpToPx(getContext(), 2)); hueAlphaTrackerPaint.setAntiAlias(true); alphaTextPaint.setColor(0xff1c1c1c); alphaTextPaint.setTextSize(DrawingUtils.dpToPx(getContext(), 14)); alphaTextPaint.setAntiAlias(true); alphaTextPaint.setTextAlign(Align.CENTER); alphaTextPaint.setFakeBoldText(true); }
private void init(Context context) { setLayerType(1, null); this.mContext = context; this.lineHeight = DensityUtil.dip2px(context, (float) this.lineHeight); this.textSize = DensityUtil.dip2px(context, (float) this.textSize); this.textPaint = new Paint(); this.textPaint.setAntiAlias(true); this.textPaint.setTextSize((float) this.textSize); this.textPaint.setTextAlign(Align.LEFT); this.textPaint.setColor(AbstractWheelTextAdapter.DEFAULT_TEXT_COLOR); this.dividerPaint = new Paint(); this.dividerPaint.setAntiAlias(true); this.dividerPaint.setTextSize((float) this.textSize); this.dividerPaint.setTextAlign(Align.LEFT); this.dividerPaint.setColor(-1); this.dividerPaint.setStrokeWidth(2.0f); this.backgroundPaint = new Paint(); this.backgroundPaint.setAntiAlias(true); this.backgroundPaint.setStyle(Style.FILL_AND_STROKE); this.backgroundPaint.setStrokeCap(Cap.ROUND); }
private void initAxisTextAlignment(Axis axis, int position) { this.namePaintTab[position].setTextAlign(Align.CENTER); if (position == 0 || 3 == position) { this.labelPaintTab[position].setTextAlign(Align.CENTER); } else if (1 == position) { if (axis.isInside()) { this.labelPaintTab[position].setTextAlign(Align.LEFT); } else { this.labelPaintTab[position].setTextAlign(Align.RIGHT); } } else if (2 != position) { } else { if (axis.isInside()) { this.labelPaintTab[position].setTextAlign(Align.RIGHT); } else { this.labelPaintTab[position].setTextAlign(Align.LEFT); } } }
private void initPaintTools(){ mSatValPaint = new Paint(); mSatValTrackerPaint = new Paint(); mHueAlphaTrackerPaint = new Paint(); mAlphaPaint = new Paint(); mAlphaTextPaint = new Paint(); mBorderPaint = new Paint(); mSatValTrackerPaint.setStyle(Style.STROKE); mSatValTrackerPaint.setStrokeWidth(DrawingUtils.dpToPx(getContext(), 2)); mSatValTrackerPaint.setAntiAlias(true); mHueAlphaTrackerPaint.setColor(mSliderTrackerColor); mHueAlphaTrackerPaint.setStyle(Style.STROKE); mHueAlphaTrackerPaint.setStrokeWidth(DrawingUtils.dpToPx(getContext(), 2)); mHueAlphaTrackerPaint.setAntiAlias(true); mAlphaTextPaint.setColor(0xff1c1c1c); mAlphaTextPaint.setTextSize(DrawingUtils.dpToPx(getContext(), 14)); mAlphaTextPaint.setAntiAlias(true); mAlphaTextPaint.setTextAlign(Align.CENTER); mAlphaTextPaint.setFakeBoldText(true); }
/** * Draws the chart tick lines. * * @param canvas the canvas * @param min the minimum chart value * @param max the maximum chart value * @param minAngle the minimum chart angle value * @param maxAngle the maximum chart angle value * @param centerX the center x value * @param centerY the center y value * @param longRadius the long radius * @param shortRadius the short radius * @param ticks the tick spacing * @param paint the paint settings * @param labels paint the labels * @return the angle */ private void drawTicks(Canvas canvas, double min, double max, double minAngle, double maxAngle, int centerX, int centerY, double longRadius, double shortRadius, double ticks, Paint paint, boolean labels) { for (double i = min; i <= max; i += ticks) { double angle = getAngleForValue(i, minAngle, maxAngle, min, max); double sinValue = Math.sin(angle); double cosValue = Math.cos(angle); int x1 = Math.round(centerX + (float) (shortRadius * sinValue)); int y1 = Math.round(centerY + (float) (shortRadius * cosValue)); int x2 = Math.round(centerX + (float) (longRadius * sinValue)); int y2 = Math.round(centerY + (float) (longRadius * cosValue)); canvas.drawLine(x1, y1, x2, y2, paint); if (labels) { paint.setTextAlign(Align.LEFT); if (x1 <= x2) { paint.setTextAlign(Align.RIGHT); } String text = i + ""; if (Math.round(i) == (long) i) { text = (long) i + ""; } canvas.drawText(text, x1, y1, paint); } } }
public void initAxesRange(int scales) { mYTitle = new String[scales]; yLabelsAlign = new Align[scales]; yAxisAlign = new Align[scales]; mYLabelsColor = new int[scales]; mMinX = new double[scales]; mMaxX = new double[scales]; mMinY = new double[scales]; mMaxY = new double[scales]; mGridColors = new int[scales]; for (int i = 0; i < scales; i++) { mYLabelsColor[i] = TEXT_COLOR; mGridColors[i] = Color.argb(75, 200, 200, 200); initAxesRangeForScale(i); } }
public BatteryLevelView(Context context) { super(context); // canvas paint paintCanvas = new Paint(); paintCanvas.setStyle(Paint.Style.FILL); paintCanvas.setColor(Color.BLACK); paintCanvas.setAlpha(128); // text paint paintTextLevel = new Paint(); paintTextLevel.setAntiAlias(true); paintTextLevel.setFakeBoldText(true); paintTextLevel.setTextSize(150); paintTextLevel.setTextAlign(Align.CENTER); paintTextLevel.setShadowLayer(5, 0, 0, Color.BLACK); paintTextLevel.setColor(Color.WHITE); }
/** * Creates a new drawable, which allows to display the number of tabs, which are currently * contained by a {@link TabSwitcher}. * * @param context * The context, which should be used by the drawable, as an instance of the class {@link * Context}. The context may not be null */ public TabSwitcherDrawable(@NonNull final Context context) { ensureNotNull(context, "The context may not be null"); Resources resources = context.getResources(); size = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_size); textSizeNormal = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_normal); textSizeSmall = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_small); background = ContextCompat.getDrawable(context, R.drawable.tab_switcher_drawable_background) .mutate(); paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); paint.setTextAlign(Align.CENTER); paint.setTextSize(textSizeNormal); paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)); label = Integer.toString(0); int tint = ThemeUtil.getColor(context, android.R.attr.textColorPrimary); setColorFilter(tint, PorterDuff.Mode.MULTIPLY); }
public MapClusterOptionsProvider(Resources resources) { int poiSize = resources.getDimensionPixelSize(R.dimen.map_poi_size); Drawable d = ResourcesCompat.getDrawable(resources, R.drawable.ic_wrapper_poi_cluster, null); d.setBounds(0, 0, poiSize, poiSize); Bitmap bitmap = Bitmap.createBitmap(poiSize, poiSize, Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); d.draw(canvas); baseBitmap = bitmap; littleFontPaint.setColor(Color.BLACK); littleFontPaint.setTextAlign(Align.CENTER); littleFontPaint.setFakeBoldText(true); littleFontPaint.setTextSize(resources.getDimension(R.dimen.map_marker_cluster_text_size_small)); bigFontPaint.setColor(Color.BLACK); bigFontPaint.setTextAlign(Align.CENTER); bigFontPaint.setFakeBoldText(true); bigFontPaint.setTextSize(resources.getDimension(R.dimen.map_marker_cluster_text_size_big)); }
public AbstractChartRenderer(Context context, Chart chart) { this.context = context; this.density = context.getResources().getDisplayMetrics().density; this.scaledDensity = context.getResources().getDisplayMetrics().scaledDensity; this.chart = chart; this.computator = chart.getChartComputator(); this.resources = context.getResources(); this.labelMargin = ChartUtils.dp2px(this.density, this.DEFAULT_LABEL_MARGIN_DP); this.labelOffset = this.labelMargin; this.labelPaint.setAntiAlias(true); this.labelPaint.setStyle(Style.FILL); this.labelPaint.setTextAlign(Align.LEFT); this.labelPaint.setTypeface(Typeface.defaultFromStyle(1)); this.labelPaint.setColor(-1); this.labelBackgroundPaint.setAntiAlias(true); this.labelBackgroundPaint.setStyle(Style.FILL); }
public void initialize(Context context, int amOrPm) { if (mIsInitialized) { Log.e(TAG, "AmPmCirclesView may only be initialized once."); return; } final ResourceLoader res = new ResourceLoader(context); mUnselectedColor = res.getColor(android.R.color.white); mSelectedColor = res.getColor(R.color.blue); mAmPmTextColor = res.getColor(R.color.ampm_text_color); mSelectedAlpha = SELECTED_ALPHA; String typefaceFamily = res.getString(R.string.sans_serif); Typeface tf = Typeface.create(typefaceFamily, Typeface.NORMAL); mPaint.setTypeface(tf); mPaint.setAntiAlias(true); mPaint.setTextAlign(Align.CENTER); mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier)); mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.ampm_circle_radius_multiplier)); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; setAmOrPm(amOrPm); mAmOrPmPressed = -1; mIsInitialized = true; }
public LegendRenderer(ViewPortHandler viewPortHandler, Legend legend) { super(viewPortHandler); this.mLegend = legend; mLegendLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mLegendLabelPaint.setTextSize(Utils.convertDpToPixel(9f)); mLegendLabelPaint.setTextAlign(Align.LEFT); mLegendFormPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mLegendFormPaint.setStyle(Paint.Style.FILL); }
private void init() { this.mCirclePaint.setFakeBoldText(true); this.mCirclePaint.setAntiAlias(true); this.mCirclePaint.setColor(this.mCircleColor); this.mCirclePaint.setTextAlign(Align.CENTER); this.mCirclePaint.setStyle(Style.FILL); this.mCirclePaint.setAlpha(255); }
public XAxisRenderer(ViewPortHandler viewPortHandler, XAxis xAxis, Transformer trans) { super(viewPortHandler, trans, xAxis); this.mXAxis = xAxis; mAxisLabelPaint.setColor(Color.BLACK); mAxisLabelPaint.setTextAlign(Align.CENTER); mAxisLabelPaint.setTextSize(Utils.convertDpToPixel(10f)); }
private void init(Context context){ mScroller = ScrollerCompat.create(context); mMiniVelocityFling = ViewConfiguration.get(getContext()).getScaledMinimumFlingVelocity(); mScaledTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); if(mTextSizeNormal == 0) mTextSizeNormal = sp2px(context, DEFAULT_TEXT_SIZE_NORMAL_SP); if(mTextSizeSelected == 0) mTextSizeSelected = sp2px(context, DEFAULT_TEXT_SIZE_SELECTED_SP); if(mTextSizeHint == 0) mTextSizeHint = sp2px(context, DEFAULT_TEXT_SIZE_HINT_SP); if(mMarginStartOfHint == 0) mMarginStartOfHint = dp2px(context, DEFAULT_MARGIN_START_OF_HINT_DP); if(mMarginEndOfHint == 0) mMarginEndOfHint = dp2px(context, DEFAULT_MARGIN_END_OF_HINT_DP); mPaintDivider.setColor(mDividerColor); mPaintDivider.setAntiAlias(true); mPaintDivider.setStyle(Paint.Style.STROKE); mPaintDivider.setStrokeWidth(mDividerHeight); mPaintText.setColor(mTextColorNormal); mPaintText.setAntiAlias(true); mPaintText.setTextAlign(Align.CENTER); mPaintHint.setColor(mTextColorHint); mPaintHint.setAntiAlias(true); mPaintHint.setTextAlign(Align.CENTER); mPaintHint.setTextSize(mTextSizeHint); if(mShowCount % 2 == 0){ mShowCount++; } if(mMinShowIndex == -1 || mMaxShowIndex == -1){ updateValueForInit(); } initHandler(); }
private void init() { timer = new Timer(); mDataList = new ArrayList<>(); //第一个paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Style.FILL); mPaint.setTextAlign(Align.CENTER); mPaint.setColor(ContextCompat.getColor(context, R.color.text1)); //第二个paint nPaint = new Paint(Paint.ANTI_ALIAS_FLAG); nPaint.setStyle(Style.FILL); nPaint.setTextAlign(Align.CENTER); nPaint.setColor(ContextCompat.getColor(context, R.color.text2)); }
/** * Returns the {@link Align} according to the position in the dropdown. * * @param position * the position in the dropdown. * @return the according {@link Align}. */ private Align returnAlign(int position) { switch (position) { case 0: return Align.CENTER; case 1: return Align.RIGHT; case 2: return Align.LEFT; default: return Align.CENTER; } }
public void initialize(Context context, int amOrPm) { if (mIsInitialized) { Log.e(TAG, "AmPmCirclesView may only be initialized once."); return; } Resources res = context.getResources(); mWhite = res.getColor(R.color.white); mAmPmTextColor = res.getColor(R.color.ampm_text_color); mBlue = res.getColor(R.color.blue); String typefaceFamily = res.getString(R.string.sans_serif); Typeface tf = Typeface.create(typefaceFamily, Typeface.NORMAL); mPaint.setTypeface(tf); mPaint.setAntiAlias(true); mPaint.setTextAlign(Align.CENTER); mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier)); mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.ampm_circle_radius_multiplier)); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; setAmOrPm(amOrPm); mAmOrPmPressed = -1; mIsInitialized = true; }
public void initialize(Context context, TimePickerController controller, int amOrPm) { if (this.mIsInitialized) { Log.e(TAG, "AmPmCirclesView may only be initialized once."); return; } Resources res = context.getResources(); if (controller.isThemeDark()) { this.mUnselectedColor = res.getColor(R.color.mdtp_circle_background_dark_theme); this.mAmPmTextColor = res.getColor(R.color.mdtp_white); this.mSelectedAlpha = 255; } else { this.mUnselectedColor = res.getColor(R.color.mdtp_white); this.mAmPmTextColor = res.getColor(R.color.mdtp_ampm_text_color); this.mSelectedAlpha = 255; } this.mSelectedColor = controller.getAccentColor(); this.mTouchedColor = Utils.darkenColor(this.mSelectedColor); this.mAmPmSelectedTextColor = res.getColor(R.color.mdtp_white); this.mPaint.setTypeface(Typeface.create(res.getString(R.string.mdtp_sans_serif), 0)); this.mPaint.setAntiAlias(true); this.mPaint.setTextAlign(Align.CENTER); this.mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string .mdtp_circle_radius_multiplier)); this.mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string .mdtp_ampm_circle_radius_multiplier)); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); this.mAmText = amPmTexts[0]; this.mPmText = amPmTexts[1]; setAmOrPm(amOrPm); this.mAmOrPmPressed = -1; this.mIsInitialized = true; }
protected void initView() { this.mMonthTitlePaint = new Paint(); this.mMonthTitlePaint.setFakeBoldText(true); this.mMonthTitlePaint.setAntiAlias(true); this.mMonthTitlePaint.setTextSize((float) MONTH_LABEL_TEXT_SIZE); this.mMonthTitlePaint.setTypeface(Typeface.create(this.mMonthTitleTypeface, 1)); this.mMonthTitlePaint.setColor(this.mDayTextColor); this.mMonthTitlePaint.setTextAlign(Align.CENTER); this.mMonthTitlePaint.setStyle(Style.FILL); this.mSelectedCirclePaint = new Paint(); this.mSelectedCirclePaint.setFakeBoldText(true); this.mSelectedCirclePaint.setAntiAlias(true); this.mSelectedCirclePaint.setColor(this.mTodayNumberColor); this.mSelectedCirclePaint.setTextAlign(Align.CENTER); this.mSelectedCirclePaint.setStyle(Style.FILL); this.mSelectedCirclePaint.setAlpha(255); this.mMonthDayLabelPaint = new Paint(); this.mMonthDayLabelPaint.setAntiAlias(true); this.mMonthDayLabelPaint.setTextSize((float) MONTH_DAY_LABEL_TEXT_SIZE); this.mMonthDayLabelPaint.setColor(this.mMonthDayTextColor); this.mMonthDayLabelPaint.setTypeface(TypefaceHelper.get(getContext(), "Roboto-Medium")); this.mMonthDayLabelPaint.setStyle(Style.FILL); this.mMonthDayLabelPaint.setTextAlign(Align.CENTER); this.mMonthDayLabelPaint.setFakeBoldText(true); this.mMonthNumPaint = new Paint(); this.mMonthNumPaint.setAntiAlias(true); this.mMonthNumPaint.setTextSize((float) MINI_DAY_NUMBER_TEXT_SIZE); this.mMonthNumPaint.setStyle(Style.FILL); this.mMonthNumPaint.setTextAlign(Align.CENTER); this.mMonthNumPaint.setFakeBoldText(false); }
/** * Construct a CandidateView for showing suggested words for completion. * @param context * @param attrs */ public CandidateView(Context context, AttributeSet attrs) { super(context, attrs); mSelectionHighlight = context.getResources().getDrawable( R.drawable.list_selector_background_pressed); LayoutInflater inflate = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); Resources res = context.getResources(); mPreviewPopup = new PopupWindow(context); mPreviewText = (TextView) inflate.inflate(R.layout.candidate_preview, null); mPreviewPopup.setWindowLayoutMode(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mPreviewPopup.setContentView(mPreviewText); mPreviewPopup.setBackgroundDrawable(null); mPreviewPopup.setAnimationStyle(R.style.KeyPreviewAnimation); mColorNormal = res.getColor(R.color.candidate_normal); mColorRecommended = res.getColor(R.color.candidate_recommended); mColorOther = res.getColor(R.color.candidate_other); mDivider = res.getDrawable(R.drawable.keyboard_suggest_strip_divider); mAddToDictionaryHint = res.getString(R.string.hint_add_to_dictionary); mPaint = new Paint(); mPaint.setColor(mColorNormal); mPaint.setAntiAlias(true); mPaint.setTextSize(mPreviewText.getTextSize()); mPaint.setStrokeWidth(0); mPaint.setTextAlign(Align.CENTER); mDescent = (int) mPaint.descent(); mMinTouchableWidth = (int)res.getDimension(R.dimen.candidate_min_touchable_width); mGestureDetector = new GestureDetector( new CandidateStripGestureListener(mMinTouchableWidth)); setWillNotDraw(false); setHorizontalScrollBarEnabled(false); setVerticalScrollBarEnabled(false); scrollTo(0, getScrollY()); }
private void init() { timer = new Timer(); mDataList = new ArrayList<>(); //the first paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Style.FILL); mPaint.setTextAlign(Align.CENTER); mPaint.setColor(ContextCompat.getColor(context, R.color.text1)); //the second paint nPaint = new Paint(Paint.ANTI_ALIAS_FLAG); nPaint.setStyle(Style.FILL); nPaint.setTextAlign(Align.CENTER); nPaint.setColor(ContextCompat.getColor(context, R.color.text2)); }
/** * Sets up the text and style properties for painting. Override this if you * want to use a different paint. */ protected void initView() { mMonthTitlePaint = new Paint(); mMonthTitlePaint.setFakeBoldText(true); mMonthTitlePaint.setAntiAlias(true); mMonthTitlePaint.setTextSize(MONTH_LABEL_TEXT_SIZE); mMonthTitlePaint.setTypeface(Typeface.create(mMonthTitleTypeface, Typeface.BOLD)); mMonthTitlePaint.setColor(mDayTextColor); mMonthTitlePaint.setTextAlign(Align.CENTER); mMonthTitlePaint.setStyle(Style.FILL); mSelectedCirclePaint = new Paint(); mSelectedCirclePaint.setFakeBoldText(true); mSelectedCirclePaint.setAntiAlias(true); mSelectedCirclePaint.setColor(mTodayNumberColor); mSelectedCirclePaint.setTextAlign(Align.CENTER); mSelectedCirclePaint.setStyle(Style.FILL); mSelectedCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA); mMonthDayLabelPaint = new Paint(); mMonthDayLabelPaint.setAntiAlias(true); mMonthDayLabelPaint.setTextSize(MONTH_DAY_LABEL_TEXT_SIZE); mMonthDayLabelPaint.setColor(mMonthDayTextColor); // mMonthDayLabelPaint.setTypeface(TypefaceHelper.get(getContext(),"Roboto-Medium")); mMonthDayLabelPaint.setStyle(Style.FILL); mMonthDayLabelPaint.setTextAlign(Align.CENTER); mMonthDayLabelPaint.setFakeBoldText(true); mMonthNumPaint = new Paint(); mMonthNumPaint.setAntiAlias(true); mMonthNumPaint.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE); mMonthNumPaint.setStyle(Style.FILL); mMonthNumPaint.setTextAlign(Align.CENTER); mMonthNumPaint.setFakeBoldText(false); }
private void init() { mCirclePaint.setFakeBoldText(true); mCirclePaint.setAntiAlias(true); mCirclePaint.setColor(mCircleColor); mCirclePaint.setTextAlign(Align.CENTER); mCirclePaint.setStyle(Style.FILL); mCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA); }
public Paint getTextPaint() { mPaint.setAntiAlias(true); mPaint.setTextAlign(Align.CENTER); mPaint.setTextSize(mGesturePreviewTextSize); mPaint.setColor(mGesturePreviewTextColor); return mPaint; }
private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) { final Keyboard keyboard = getKeyboard(); if (keyboard == null) { return; } final int width = key.getWidth(); final int height = key.getHeight(); paint.setTextAlign(Align.CENTER); paint.setTypeface(Typeface.DEFAULT); paint.setTextSize(mLanguageOnSpacebarTextSize); final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width); // Draw language text with shadow final float descent = paint.descent(); final float textHeight = -paint.ascent() + descent; final float baseline = height / 2 + textHeight / 2; if (mLanguageOnSpacebarTextShadowRadius > 0.0f) { paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0, mLanguageOnSpacebarTextShadowColor); } else { paint.clearShadowLayer(); } paint.setColor(mLanguageOnSpacebarTextColor); paint.setAlpha(mLanguageOnSpacebarAnimAlpha); canvas.drawText(language, width / 2, baseline - descent, paint); paint.clearShadowLayer(); paint.setTextScaleX(1.0f); }
private void init() { timer = new Timer(); mDataList = new ArrayList<String>(); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Style.FILL); mPaint.setTextAlign(Align.CENTER); mPaint.setColor(mColorText); }
private void init() { mColorWheelRectangle = new RectF(); circleStrokeWidth = DensityUtil.dip2px(getContext(), 10); mTextSize = DensityUtil.dip2px(getContext(), 40); mColorWheelPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mColorWheelPaint.setColor(mWheelColor); mColorWheelPaint.setStyle(Paint.Style.STROKE); mColorWheelPaint.setStrokeWidth(circleStrokeWidth); mDefaultWheelPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mDefaultWheelPaint.setColor(mWheelColorDefault); mDefaultWheelPaint.setStyle(Paint.Style.STROKE); mDefaultWheelPaint.setStrokeWidth(circleStrokeWidth); textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); textPaint.setColor(textColor); textPaint.setStyle(Style.FILL_AND_STROKE); textPaint.setTextAlign(Align.LEFT); textPaint.setTextSize(mTextSize); mText = 0; mSweepAngle = 0; anim = new myProgressBarAnimation(); anim.setDuration(mAnimDuration); }