android.graphics.Paint.Align Java Examples

The following examples show how to use android.graphics.Paint.Align. 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 File: MonthPickerView.java    From BottomSheetPickers with 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 #2
Source File: AxesRenderer.java    From hellocharts-android with 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 #3
Source File: LetterTileDrawable.java    From tindroid with 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 #4
Source File: TiledImageView.java    From TurboLauncher with 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 #5
Source File: TiledImageView.java    From LB-Launcher with 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 #6
Source File: ArcLineChart01View.java    From XCL-Charts with 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 #7
Source File: PersonBarChartView.java    From loaned-android with 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 #8
Source File: JustifiedTextView.java    From MVPAndroidBootstrap with 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 File: DataRenderer.java    From StockChart-MPAndroidChart with 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 File: CircleDisplay.java    From itracing2 with 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 File: BesselChartView.java    From BesselChart with 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 File: BarChart08View.java    From XCL-Charts with 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 File: RSCBitmapSurfaceView.java    From Game with 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 #14
Source File: ItemLoanPieChartView.java    From loaned-android with 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 #15
Source File: RangeBarChart.java    From XCL-Charts with 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 #16
Source File: PieChart.java    From Notification-Analyser with 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 #17
Source File: ChipDrawable.java    From material-components-android with 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 #18
Source File: HorizontalLegendView.java    From BesselChart with 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 #19
Source File: SuggestionStripLayoutHelper.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
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 File: DataRenderer.java    From JNChartDemo with 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 #21
Source File: JustifiedTextView.java    From RxAndroidBootstrap with 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 #22
Source File: DataRenderer.java    From NetKnight with 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 #23
Source File: PieChartRenderer.java    From JNChartDemo with 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 #24
Source File: BarChart.java    From XCL-Charts with 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 #25
Source File: AmPmCirclesView.java    From Conquer with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #26
Source File: ChartValueSeries.java    From mytracks with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 * 
 * @param context the context
 * @param absoluteMin the absolute min value
 * @param absoluteMax the absolute max value
 * @param intervalValues the list of interval values
 * @param metricTitleId the metric title id
 * @param imperialTitleId the imperial title id
 * @param fillColor the fill color
 * @param strokeColor the stroke color
 */
public ChartValueSeries(Context context, int absoluteMin, int absoluteMax, int[] intervalValues,
    int metricTitleId, int imperialTitleId, int fillColor, int strokeColor) {
  this.absoluteMin = absoluteMin;
  this.absoluteMax = absoluteMax;
  this.intervalValues = intervalValues;
  this.metricTitleId = metricTitleId;
  this.imperialTitleId = imperialTitleId;

  fillPaint = new Paint();
  fillPaint.setStyle(Style.FILL);
  fillPaint.setColor(context.getResources().getColor(fillColor));
  fillPaint.setAntiAlias(true);

  strokePaint = new Paint();
  strokePaint.setStyle(Style.STROKE);
  strokePaint.setColor(context.getResources().getColor(strokeColor));
  strokePaint.setAntiAlias(true);

  float scale = context.getResources().getDisplayMetrics().density;
  
  // Make copies of the stroke paint with the default thickness
  titlePaint = new Paint(strokePaint);
  titlePaint.setTextSize(ChartView.MEDIUM_TEXT_SIZE * scale);
  titlePaint.setTextAlign(Align.CENTER);

  markerPaint = new Paint(strokePaint);
  markerPaint.setTextSize(ChartView.SMALL_TEXT_SIZE * scale);
  markerPaint.setTextAlign(Align.RIGHT);

  // Set stroke paint thickness
  strokePaint.setStrokeWidth(STROKE_WIDTH);

  extremityMonitor = new ExtremityMonitor();
  numberFormat = NumberFormat.getIntegerInstance();
  path = new Path();
}
 
Example #27
Source File: ColorPickerView.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
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);


	}
 
Example #28
Source File: BookPageFactory.java    From coolreader with 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 #29
Source File: LegendRenderer.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
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);
    mLegendFormPaint.setStrokeWidth(3f);
}
 
Example #30
Source File: PickerView.java    From YiZhi with Apache License 2.0 5 votes vote down vote up
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);
}