Java Code Examples for android.graphics.Paint.Align#LEFT

The following examples show how to use android.graphics.Paint.Align#LEFT . 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: 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 2
Source File: PXText.java    From pixate-freestyle-android with Apache License 2.0 6 votes vote down vote up
@Override
public void render(Canvas canvas) {
    canvas.save();
    if (align != null && align != Align.LEFT) {
        Rect clipBounds = canvas.getClipBounds();
        if (align == Align.CENTER) {
            canvas.translate(origin.x + clipBounds.exactCenterX(), origin.y + textSize);
        } else {
            canvas.translate(origin.x + clipBounds.width(), origin.y + textSize);
        }
    } else {
        canvas.translate(origin.x, origin.y + textSize);
    }
    super.render(canvas);
    canvas.restore();
}
 
Example 3
Source File: XYAxis.java    From XCL-Charts with Apache License 2.0 6 votes vote down vote up
private void renderHorizontalTickLabels(float chatLeft,float plotLeft,Canvas canvas,
							float labelStartX,float labelStartY,
							float markeStopX,
							String text   )
{
	float labelHeight = DrawHelper.getInstance().getPaintFontHeight(
			getTickLabelPaint());
	float textHeight  = labelHeight/4;
	if(Align.LEFT == getHorizontalTickAlign()) //处理多行标签
	{
		float width = 0.0f;
		if (isShowTickMarks()) {
			width = markeStopX - chatLeft;
		}else{				
			width = MathHelper.getInstance().sub(plotLeft ,chatLeft);					
		}
		renderLeftAxisTickMaskLabel(canvas,labelStartX, labelStartY + textHeight,text,width );				
	}else{		
		DrawHelper.getInstance().drawRotateText(
				getFormatterLabel(text), labelStartX,labelStartY + textHeight,
				getTickLabelRotateAngle(), canvas,getTickLabelPaint());	
	}
}