Java Code Examples for android.graphics.Paint.Align

The following examples show how to use android.graphics.Paint.Align. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: LB-Launcher   Source File: TiledImageView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Bitmap getTile(int level, int x, int y, Bitmap bitmap) {
    int tileSize = getTileSize();
    if (bitmap == null) {
        bitmap = Bitmap.createBitmap(tileSize, tileSize,
                Bitmap.Config.ARGB_8888);
    }
    mCanvas.setBitmap(bitmap);
    mCanvas.drawColor(COLORS[level]);
    mPaint.setColor(Color.BLACK);
    mPaint.setTextSize(20);
    mPaint.setTextAlign(Align.CENTER);
    mCanvas.drawText(x + "x" + y, 128, 128, mPaint);
    tileSize <<= level;
    x /= tileSize;
    y /= tileSize;
    mCanvas.drawText(x + "x" + y + " @ " + level, 128, 30, mPaint);
    mCanvas.setBitmap(null);
    return bitmap;
}
 
Example 2
Source Project: loaned-android   Source File: ItemLoanPieChartView.java    License: Apache License 2.0 6 votes vote down vote up
private void init(Context c){
	Log.d(TAG,"Init called");
	// Create the colour array
	mColours = new int[6];
	mColours[0] = Color.parseColor("#1bc5a4");
	mColours[1] = Color.parseColor("#9b59b6");
	mColours[2] = Color.parseColor("#2ecc71");
	mColours[3] = Color.parseColor("#e74c3c");
	mColours[4] = Color.parseColor("#3498db");
	mColours[5] = Color.parseColor("#e67e22");

	mCentreCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mCentreCirclePaint.setColor(Color.parseColor("#f3f3f3"));
	mCentreCirclePaint.setStyle(Paint.Style.FILL);

	mCentreTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mCentreTextPaint.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
	mCentreTextPaint.setColor(mColours[0]);
	mCentreTextPaint.setTextAlign(Align.CENTER);
	mCentreTextPaint.setTextSize(80);
	mCentreNumberPaint = new Paint(mCentreTextPaint);
	mCentreNumberPaint.setTextSize(190);
	mCentreNumberPaint.setColor(c.getResources().getColor(R.color.text_main));
	mCentreNumberPaint.setTypeface(Typeface.create("sans-serif-thin", Typeface.NORMAL));
	mRect = new RectF();
}
 
Example 3
Source Project: loaned-android   Source File: PersonBarChartView.java    License: Apache License 2.0 6 votes vote down vote up
private void init(Context c){
	Log.d(TAG, "init called");
	// Create the colour array
	mColours = new int[6];
	mColours[4] = Color.parseColor("#1bc5a4");
	mColours[1] = Color.parseColor("#9b59b6");
	mColours[0] = Color.parseColor("#2ecc71");
	mColours[2] = Color.parseColor("#e74c3c");
	mColours[3] = Color.parseColor("#3498db");

	mBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mBarPaint.setStyle(Paint.Style.FILL);

	mBarNumberPaint = new Paint();
	mBarNumberPaint.setTypeface(Typeface.create("sans-serif-thin", Typeface.NORMAL));
	mBarNumberPaint.setColor(c.getResources().getColor(R.color.text_main));
	mBarNumberPaint.setTextSize(100);
	mBarNumberPaint.setTextAlign(Align.CENTER);

	mNameLabelPaint = new Paint();
	mNameLabelPaint.setTypeface(Typeface.create("sans-serif-thin", Typeface.NORMAL));
	mNameLabelPaint.setColor(c.getResources().getColor(R.color.text_main));
	mNameLabelPaint.setTextAlign(Align.CENTER);
	mNameLabelPaint.setTextSize(140);
}
 
Example 4
Source Project: tindroid   Source File: LetterTileDrawable.java    License: Apache License 2.0 6 votes vote down vote up
public LetterTileDrawable(final Context context) {
    Resources res = context.getResources();
    if (sColorsLight == null) {
        sColorsLight = res.obtainTypedArray(R.array.letter_tile_colors_light);
        sColorsDark = res.obtainTypedArray(R.array.letter_tile_colors_dark);
        sDefaultColor = res.getColor(R.color.grey);
        sTileFontColorLight = res.getColor(R.color.letter_tile_text_color_light);
        sTileFontColorDark = res.getColor(R.color.letter_tile_text_color_dark);
        sLetterToTileRatio = 0.75f;
        DEFAULT_PERSON_AVATAR = getBitmapFromVectorDrawable(context, R.drawable.ic_person_white);
        DEFAULT_GROUP_AVATAR = getBitmapFromVectorDrawable(context, R.drawable.ic_group_white);
        sPaint.setTextAlign(Align.CENTER);
        sPaint.setAntiAlias(true);
    }
    mPaint = new Paint();
    mPaint.setFilterBitmap(true);
    mPaint.setDither(true);
    mColor = sDefaultColor;
}
 
Example 5
Source Project: XCL-Charts   Source File: ArcLineChart01View.java    License: Apache License 2.0 6 votes vote down vote up
private void addAttrInfo()
{
	/////////////////////////////////////////////////////////////
	//设置附加信息
	Paint paintLib = new Paint();
	paintLib.setColor(Color.rgb(46, 164, 212)); 
	paintLib.setTextAlign(Align.CENTER);
	paintLib.setTextSize(30);		
	paintLib.setAntiAlias(true);
	chart.getPlotAttrInfo().addAttributeInfo(XEnum.Location.TOP, "圆弧式条形图", 0.1f, paintLib);			
	chart.getPlotAttrInfo().addAttributeInfo(XEnum.Location.BOTTOM, "XCL-Charts", 0.4f, paintLib);
		
	Paint paintSrc = new Paint();		
	paintSrc.setTextAlign(Align.CENTER);
	paintSrc.setTextSize(25);
	paintSrc.setAntiAlias(true);
	paintSrc.setColor(Color.rgb(41, 34, 102));
	chart.getPlotAttrInfo().addAttributeInfo(XEnum.Location.BOTTOM, 
							"ExcelPro", 0.2f, paintSrc);		
	/////////////////////////////////////////////////////////////
}
 
Example 6
Source Project: TurboLauncher   Source File: TiledImageView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Bitmap getTile(int level, int x, int y, Bitmap bitmap) {
    int tileSize = getTileSize();
    if (bitmap == null) {
        bitmap = Bitmap.createBitmap(tileSize, tileSize,
                Bitmap.Config.ARGB_8888);
    }
    mCanvas.setBitmap(bitmap);
    mCanvas.drawColor(COLORS[level]);
    mPaint.setColor(Color.BLACK);
    mPaint.setTextSize(20);
    mPaint.setTextAlign(Align.CENTER);
    mCanvas.drawText(x + "x" + y, 128, 128, mPaint);
    tileSize <<= level;
    x /= tileSize;
    y /= tileSize;
    mCanvas.drawText(x + "x" + y + " @ " + level, 128, 30, mPaint);
    mCanvas.setBitmap(null);
    return bitmap;
}
 
Example 7
Source Project: hellocharts-android   Source File: AxesRenderer.java    License: Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example 8
Source Project: MVPAndroidBootstrap   Source File: JustifiedTextView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {

    rowIndex=getPaddingTop();
    if (getAlignment()==Align.RIGHT)
        colIndex=getPaddingLeft()+getTextAreaWidth();
    else
        colIndex=getPaddingLeft();

    for (int i=0;i<lineList.size();i++){
        rowIndex+=getLineHeight()+getLineSpace();

        canvas.drawText(lineList.get(i), colIndex,rowIndex , getTextPaint());
    }

}
 
Example 9
Source Project: StockChart-MPAndroidChart   Source File: DataRenderer.java    License: MIT License 6 votes vote down vote up
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));
}
 
Example 10
Source Project: itracing2   Source File: CircleDisplay.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void init()
{

    mBoxSetup = false;

    mArcPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mArcPaint.setStyle(Style.FILL);
    mArcPaint.setColor(Color.rgb(192, 255, 140));

    mInnerCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mInnerCirclePaint.setStyle(Style.FILL);
    mInnerCirclePaint.setColor(Color.WHITE);

    mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setStyle(Style.STROKE);
    mTextPaint.setTextAlign(Align.CENTER);
    mTextPaint.setColor(Color.BLACK);
    mTextPaint.setTextSize(Utils.convertDpToPixel(getResources(), 24f));

    mDrawAnimator = ObjectAnimator.ofFloat(this, "phase", mPhase, 1.0f).setDuration(3000);
    mDrawAnimator.setInterpolator(new AccelerateDecelerateInterpolator());

    mGestureDetector = new GestureDetector(getContext(), this);
}
 
Example 11
Source Project: BesselChart   Source File: BesselChartView.java    License: Apache License 2.0 6 votes vote down vote up
/** 绘制横轴 */
private void drawHorLabels(Canvas canvas) {
    paint.setStyle(Paint.Style.FILL);
    paint.setStrokeWidth(2);
    paint.setColor(style.getHorizontalLabelTextColor());
    paint.setTextSize(style.getHorizontalLabelTextSize());
    paint.setTextAlign(Align.CENTER);
    float endCoordinateX = calculator.xAxisWidth;
    float coordinateY = getHeight() - calculator.xAxisHeight;
    canvas.drawLine(0, coordinateY, endCoordinateX, coordinateY, paint);
    for (Label label : data.getXLabels()) {
        // 绘制橫坐标文本
        canvas.drawText(label.text, label.x, label.y,
                paint);
    }
}
 
Example 12
Source Project: XCL-Charts   Source File: BarChart08View.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void render(Canvas canvas) {
    try{
        chart.render(canvas);
        
        
        paint.setTextSize(22);
        paint.setColor(Color.RED);
        
        float textHeight = DrawHelper.getInstance().getPaintFontHeight(paint);
        paint.setTextAlign(Align.LEFT);
        canvas.drawText("Y轴标题",chart.getPlotArea().getLeft(), chart.getPlotArea().getTop() - textHeight ,paint);
        
        paint.setTextAlign(Align.RIGHT);
        canvas.drawText("X轴标题",chart.getPlotArea().getRight(), chart.getPlotArea().getBottom() + textHeight ,paint);
        
    } catch (Exception e){
    	Log.e(TAG, e.toString());
    }
}
 
Example 13
Source Project: XCL-Charts   Source File: BarChart.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void dataAxisDefaultSetting()
{		
	if(null == dataAxis) return;
		
	switch (mDirection) {
		case HORIZONTAL:					
				dataAxis.setHorizontalTickAlign(Align.CENTER);
				dataAxis.getTickLabelPaint().setTextAlign(Align.CENTER);
				dataAxis.setVerticalTickPosition(XEnum.VerticalAlign.BOTTOM);
				
				setDataAxisLocation(XEnum.AxisLocation.BOTTOM);
			break;
		case VERTICAL: 					
				dataAxis.setHorizontalTickAlign(Align.LEFT);
				dataAxis.getTickLabelPaint().setTextAlign(Align.RIGHT);	
				dataAxis.setVerticalTickPosition(XEnum.VerticalAlign.MIDDLE);
				
				setDataAxisLocation(XEnum.AxisLocation.LEFT);										
			break;
	}
}
 
Example 14
Source Project: Game   Source File: RSCBitmapSurfaceView.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void drawTextBox(String line2, byte var2, String line1) {
	Canvas canvas = new Canvas(currentFrame);

	Paint paint = new Paint();

	paint.setColor(Color.rgb(132, 132, 132));
	if (this.m_hb) {
		paint.setColor(Color.rgb(220, 0, 0));
	}

	int x = 512 / 2 - 140;
	int y = 334 / 2 - 25;
	paint.setStyle(Paint.Style.FILL);
	canvas.drawRect(x, y, x + 280, y + 50, paint);
	paint.setStyle(Paint.Style.STROKE);
	paint.setColor(Color.WHITE);
	canvas.drawRect(x, y, x + 280, y + 50, paint);

	paint.setTextAlign(Align.CENTER);
	canvas.drawText(line1, client_width / 2, client_height / 2 - 10, paint);
	canvas.drawText(line2, client_width / 2, 10 + client_height / 2, paint);
	paint.setColor(Color.BLACK);
}
 
Example 15
Source Project: JNChartDemo   Source File: PieChartRenderer.java    License: Apache License 2.0 6 votes vote down vote up
public PieChartRenderer(PieChart chart, ChartAnimator animator,
                        ViewPortHandler viewPortHandler) {
    super(animator, viewPortHandler);
    mChart = chart;

    mHolePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mHolePaint.setColor(Color.WHITE);
    mHolePaint.setStyle(Style.FILL);

    mTransparentCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTransparentCirclePaint.setColor(Color.WHITE);
    mTransparentCirclePaint.setStyle(Style.FILL);
    mTransparentCirclePaint.setAlpha(105);

    mCenterTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mCenterTextPaint.setColor(Color.BLACK);
    mCenterTextPaint.setTextSize(Utils.convertDpToPixel(12f));

    mValuePaint.setTextSize(Utils.convertDpToPixel(13f));
    mValuePaint.setColor(Color.WHITE);
    mValuePaint.setTextAlign(Align.CENTER);

    mValueLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mValueLinePaint.setStyle(Style.STROKE);
}
 
Example 16
Source Project: NetKnight   Source File: DataRenderer.java    License: Apache License 2.0 6 votes vote down vote up
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));
}
 
Example 17
Source Project: RxAndroidBootstrap   Source File: JustifiedTextView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {

    rowIndex=getPaddingTop();
    if (getAlignment()==Align.RIGHT)
        colIndex=getPaddingLeft()+getTextAreaWidth();
    else
        colIndex=getPaddingLeft();

    for (int i=0;i<lineList.size();i++){
        rowIndex+=getLineHeight()+getLineSpace();

        canvas.drawText(lineList.get(i), colIndex,rowIndex , getTextPaint());
    }

}
 
Example 18
Source Project: JNChartDemo   Source File: DataRenderer.java    License: Apache License 2.0 6 votes vote down vote up
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));
}
 
Example 19
private static Drawable getMoreSuggestionsHint(final Resources res, final float textSize,
        final int color) {
    final Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(textSize);
    paint.setColor(color);
    final Rect bounds = new Rect();
    paint.getTextBounds(MORE_SUGGESTIONS_HINT, 0, MORE_SUGGESTIONS_HINT.length(), bounds);
    final int width = Math.round(bounds.width() + 0.5f);
    final int height = Math.round(bounds.height() + 0.5f);
    final Bitmap buffer = Bitmap.createBitmap(width, (height * 3 / 2), Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(buffer);
    canvas.drawText(MORE_SUGGESTIONS_HINT, width / 2, height, paint);
    BitmapDrawable bitmapDrawable = new BitmapDrawable(res, buffer);
    bitmapDrawable.setTargetDensity(canvas);
    return bitmapDrawable;
}
 
Example 20
Source Project: BesselChart   Source File: HorizontalLegendView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    Log.d("HorizontalLegendView onDraw");
    if(titles.size()==0)
        return;
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(style.getHorizontalTitleTextSize());
    for (Title title : titles) {
        Log.d("title=" + title.text);
        paint.setColor(title.color);
        paint.setTextAlign(Align.CENTER);
        paint.setTextSize(style.getHorizontalTitleTextSize());
        if (title instanceof Marker) {
            Marker marker = (Marker) title;
            canvas.drawBitmap(marker.getBitmap(), null,
                    marker.updateRect(title.circleX, title.circleY, title.radius * 2, title.radius * 2), paint);
        } else {
            canvas.drawCircle(title.circleX, title.circleY, title.radius, paint);
        }
        paint.setAlpha(255);
        canvas.drawText(title.text, title.textX, title.textY, paint);
    }
}
 
Example 21
Source Project: material-components-android   Source File: ChipDrawable.java    License: Apache License 2.0 6 votes vote down vote up
/** Calculates the chip text's origin and alignment based on the ChipDrawable-absolute bounds. */
@NonNull
Align calculateTextOriginAndAlignment(@NonNull Rect bounds, @NonNull PointF pointF) {
  pointF.set(0, 0);
  Align align = Align.LEFT;

  if (text != null) {
    float offsetFromStart = chipStartPadding + calculateChipIconWidth() + textStartPadding;

    if (DrawableCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) {
      pointF.x = bounds.left + offsetFromStart;
      align = Align.LEFT;
    } else {
      pointF.x = bounds.right - offsetFromStart;
      align = Align.RIGHT;
    }

    pointF.y = bounds.centerY() - calculateTextCenterFromBaseline();
  }

  return align;
}
 
Example 22
Source Project: Notification-Analyser   Source File: PieChart.java    License: MIT License 6 votes vote down vote up
@Override
protected void init() {
    super.init();

    // // piechart has no offsets
    // mOffsetTop = 0;
    // mOffsetBottom = 0;
    // mOffsetLeft = 0;
    // mOffsetRight = 0;

    mHolePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mHolePaint.setColor(Color.WHITE);

    mCenterTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCenterTextPaint.setColor(Color.BLACK);
    mCenterTextPaint.setTextSize(Utils.convertDpToPixel(12f));
    mCenterTextPaint.setTextAlign(Align.CENTER);

    mValuePaint.setTextSize(Utils.convertDpToPixel(13f));
    mValuePaint.setColor(Color.WHITE);
    mValuePaint.setTextAlign(Align.CENTER);

    // for the piechart, drawing values is enabled
    mDrawYValues = true;
}
 
Example 23
Source Project: XCL-Charts   Source File: RangeBarChart.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void dataAxisDefaultSetting()
{		
	if(null == dataAxis) return;
		
	switch (mDirection) {
		case HORIZONTAL:					
				dataAxis.setHorizontalTickAlign(Align.CENTER);
				dataAxis.getTickLabelPaint().setTextAlign(Align.CENTER);
				dataAxis.setVerticalTickPosition(XEnum.VerticalAlign.BOTTOM);
				
				setDataAxisLocation(XEnum.AxisLocation.BOTTOM);
			break;
		case VERTICAL: 					
				dataAxis.setHorizontalTickAlign(Align.LEFT);
				dataAxis.getTickLabelPaint().setTextAlign(Align.RIGHT);	
				dataAxis.setVerticalTickPosition(XEnum.VerticalAlign.MIDDLE);
				
				setDataAxisLocation(XEnum.AxisLocation.LEFT);										
			break;
	}
}
 
Example 24
Source Project: BottomSheetPickers   Source File: MonthPickerView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets up the text and style properties for painting. Override this if you
 * want to use a different paint.
 */
protected void initView() {
    mMonthLabelPaint = new Paint();
    mMonthLabelPaint.setAntiAlias(true);
    mMonthLabelPaint.setTextSize(MONTH_LABEL_TEXT_SIZE);
    mMonthLabelPaint.setStyle(Style.FILL);
    mMonthLabelPaint.setTextAlign(Align.CENTER);
    mMonthLabelPaint.setFakeBoldText(false);

    mSelectedCirclePaint = new Paint();
    mSelectedCirclePaint.setFakeBoldText(true);
    mSelectedCirclePaint.setAntiAlias(true);
    mSelectedCirclePaint.setColor(mCurrentMonthTextColor);
    mSelectedCirclePaint.setTextAlign(Align.CENTER);
    mSelectedCirclePaint.setStyle(Style.FILL);
}
 
Example 25
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);
}
 
Example 26
Source Project: coolreader   Source File: BookPageFactory.java    License: MIT License 5 votes vote down vote up
public BookPageFactory(int w, int h) {
	mWidth = w;
	mHeight = h;
	mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mPaint.setTextAlign(Align.LEFT);
	mPaint.setTextSize(m_fontSize);
	mPaint.setColor(m_textColor);
	mVisibleWidth = mWidth - marginWidth * 2;
	mVisibleHeight = mHeight - marginHeight * 2;
	mLineCount = (int) (mVisibleHeight / m_fontSize); // 可显示的行数
}
 
Example 27
Source Project: GreatFit   Source File: FloorWidget.java    License: MIT License 5 votes vote down vote up
@Override
public void init(Service service) {
    // Font
    this.textPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
    this.textPaint.setColor(settings.floorsColor);
    this.textPaint.setTypeface(ResourceManager.getTypeFace(service.getResources(), settings.font));
    this.textPaint.setTextSize(settings.floorsFontSize);
    this.textPaint.setTextAlign( (settings.floorsAlignLeft) ? Paint.Align.LEFT : Paint.Align.CENTER );

    if(settings.floorsIcon){
        this.icon = Util.decodeImage(service.getResources(),"icons/"+settings.is_white_bg+"floors.png");
    }
}
 
Example 28
Source Project: vocefiscal-android   Source File: MapsActivity.java    License: Apache License 2.0 5 votes vote down vote up
private Bitmap writeTextOnDrawable(int drawableId, String text) 
{
	Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId).copy(Bitmap.Config.ARGB_8888, true);

	Typeface tf = Typeface.create("Helvetica", Typeface.BOLD);

	Paint paint = new Paint();
	paint.setStyle(Style.FILL);
	paint.setColor(Color.WHITE);
	paint.setTypeface(tf);
	paint.setTextAlign(Align.CENTER);
	paint.setTextSize(convertToPixels(getBaseContext(), 14));

	Rect textRect = new Rect();
	paint.getTextBounds(text, 0, text.length(), textRect);

	Canvas canvas = new Canvas(bm);

	//If the text is bigger than the canvas , reduce the font size
	if(textRect.width() >= (canvas.getWidth() - 4))     //the padding on either sides is considered as 4, so as to appropriately fit in the text
		paint.setTextSize(convertToPixels(getBaseContext(), 7));        //Scaling needs to be used for different dpi's

	//Calculate the positions
	int xPos = (canvas.getWidth() / 2) - 2;     //-2 is for regulating the x position offset

	//"- ((paint.descent() + paint.ascent()) / 2)" is the distance from the baseline to the center.
	int yPos = (int) ((canvas.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2) - 10) ;  

	canvas.drawText(text, xPos, yPos, paint);

	return  bm;
}
 
Example 29
Source Project: StockChart-MPAndroidChart   Source File: PieChartRenderer.java    License: MIT License 5 votes vote down vote up
public PieChartRenderer(PieChart chart, ChartAnimator animator,
                        ViewPortHandler viewPortHandler) {
    super(animator, viewPortHandler);
    mChart = chart;

    mHolePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mHolePaint.setColor(Color.WHITE);
    mHolePaint.setStyle(Style.FILL);

    mTransparentCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTransparentCirclePaint.setColor(Color.WHITE);
    mTransparentCirclePaint.setStyle(Style.FILL);
    mTransparentCirclePaint.setAlpha(105);

    mCenterTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mCenterTextPaint.setColor(Color.BLACK);
    mCenterTextPaint.setTextSize(Utils.convertDpToPixel(12f));

    mValuePaint.setTextSize(Utils.convertDpToPixel(13f));
    mValuePaint.setColor(Color.BLACK);
    mValuePaint.setTextAlign(Align.CENTER);

    mEntryLabelsPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mEntryLabelsPaint.setColor(Color.BLACK);
    mEntryLabelsPaint.setTextAlign(Align.CENTER);
    mEntryLabelsPaint.setTextSize(Utils.convertDpToPixel(13f));

    mValueLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mValueLinePaint.setStyle(Style.STROKE);
}
 
Example 30
Source Project: UltimateAndroid   Source File: TriangleView.java    License: Apache License 2.0 5 votes vote down vote up
public void init() {
	dp = getResources().getDimension(R.dimen.triangle_dp);
	paint = new Paint();

	paint_text = new Paint();
	paint_text.setAntiAlias(true);
	paint_text.setColor(0xffffffff);
	paint_text.setTextSize(dp * 1.5f);
	paint_text.setStrokeWidth(dp * 0.15f);
	paint_text.setTextAlign(Align.CENTER);
	paint_text.setStyle(Style.FILL);
	rectF = new RectF();

	widthCentre = getWidth() / 2;
	heightCentre = getHeight() / 3;

	if (gender == 0) {
		defaults = BitmapFactory.decodeResource(getResources(),
				R.drawable.triangle_woman_default);
		raiseYourhand = BitmapFactory.decodeResource(getResources(),
				R.drawable.triangle_woman_for);
		toLetGo = BitmapFactory.decodeResource(getResources(),
				R.drawable.triangle_woman_relinquish);
	} else {
		defaults = BitmapFactory.decodeResource(getResources(),
				R.drawable.triangle_man_default);
		raiseYourhand = BitmapFactory.decodeResource(getResources(),
				R.drawable.triangle_man_for);
		toLetGo = BitmapFactory.decodeResource(getResources(),
				R.drawable.triangle_man_relinquish);
	}
}