本文整理匯總了Java中android.graphics.Paint.getColor方法的典型用法代碼示例。如果您正苦於以下問題:Java Paint.getColor方法的具體用法?Java Paint.getColor怎麽用?Java Paint.getColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.getColor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: draw
import android.graphics.Paint; //導入方法依賴的package包/類
@Override
public void draw(@NonNull final Canvas canvas, final CharSequence text,
@IntRange(from = 0) final int start,
@IntRange(from = 0) final int end,
final float x, final int top, final int y, final int bottom,
@NonNull final Paint paint) {
Paint.Style style = paint.getStyle();
int color = paint.getColor();
paint.setStyle(Paint.Style.FILL);
paint.setColor(this.color);
canvas.drawRect(x, top, x + width, bottom, paint);
paint.setStyle(style);
paint.setColor(color);
}
示例2: drawPressPoint
import android.graphics.Paint; //導入方法依賴的package包/類
/**
* 繪製按下狀態的點
*
* @param point 單位點
* @param canvas 畫布
* @param pressPaint 按下狀態畫筆
*/
@Override
public void drawPressPoint(Point point, Canvas canvas, Paint pressPaint) {
int originColor = pressPaint.getColor();
// 1.繪製白色底圓
pressPaint.setStyle(Paint.Style.FILL);
pressPaint.setColor(Color.WHITE);
canvas.drawCircle(point.x, point.y, point.radius, pressPaint);
// 2.繪製實心點
pressPaint.setColor(originColor);
canvas.drawCircle(point.x, point.y, point.radius / 3.0F, pressPaint);
// 3.繪製外部邊界圓
pressPaint.setStyle(Paint.Style.STROKE);
pressPaint.setStrokeWidth(point.radius / 20.0F);
canvas.drawCircle(point.x, point.y, point.radius, pressPaint);
}
示例3: draw1LineTextAnchorMid
import android.graphics.Paint; //導入方法依賴的package包/類
/**
* Draw a single line text, x, y is in the middle of the line.
*/
public void draw1LineTextAnchorMid(Canvas canvas, String text, double x, double y,
Paint paint, com.cyzapps.VisualMFP.Color color, double dTextSize, double dRotateDegree) {
float fRotateDegree = (float)dRotateDegree, fX = (float)x, fY = (float)y;
if (dRotateDegree != 0) {
canvas.rotate(fRotateDegree, fX, fY);
}
int nPaintOriginalColor = paint.getColor();
float fPaintOriginalTxtSize = paint.getTextSize();
if (color != null) {
paint.setColor(color.getARGB());
} // otherwise, use paint's color.
paint.setTextSize((float)dTextSize);
float fWidth = paint.measureText(text);
canvas.drawText(text, fX - fWidth/2, fY + (float)dTextSize/2 - paint.descent(), paint);
paint.setTextSize(fPaintOriginalTxtSize);
paint.setColor(nPaintOriginalColor);
if (dRotateDegree != 0) {
canvas.rotate(-fRotateDegree, fX, fY);
}
}
示例4: drawLeadingMargin
import android.graphics.Paint; //導入方法依賴的package包/類
public void drawLeadingMargin(Canvas c,
Paint p,
int x,
int dir,
int top,
int baseline,
int bottom,
CharSequence text,
int start,
int end,
boolean first,
Layout layout) {
Paint.Style prevStyle = p.getStyle();
int prevColor = p.getColor();
p.setStyle(Paint.Style.FILL);
p.setColor(lineColor);
c.drawRect(x, top, x + dir * lineWidth, bottom, p);
p.setStyle(prevStyle);
p.setColor(prevColor);
}
示例5: draw
import android.graphics.Paint; //導入方法依賴的package包/類
public void draw(Canvas g2, float x, float y) {
g2.save();
Paint st = AjLatexMath.getPaint();
int c = st.getColor();
Style s = st.getStyle();
float w = st.getStrokeWidth();
g2.translate(x + 0.25f * height / 2.15f, y - 1.75f / 2.15f * height);
st.setColor(gray);
st.setStrokeWidth(3.79999995f);
g2.scale(0.05f * height / 2.15f, 0.05f * height / 2.15f);
g2.rotate((float) Math.toDegrees((-26 * Math.PI / 180)), 20.5f, 17.5f);
g2.drawArc(new RectF(0f, 0f, 43f, 32f), 0f, 360f, false, st);
g2.rotate((float) Math.toDegrees((26 * Math.PI / 180)), 20.5f, 17.5f);
st.setStyle(Style.STROKE);
drawCircle(st, g2, 16f, -5f);
drawCircle(st, g2, -1f, 7f);
drawCircle(st, g2, 5f, 28f);
drawCircle(st, g2, 27f, 24f);
drawCircle(st, g2, 36f, 3f);
st.setColor(c);
st.setStyle(s);
st.setStrokeWidth(w);
g2.restore();
}
示例6: drawBackground
import android.graphics.Paint; //導入方法依賴的package包/類
/**
* Draws the chart background.
*/
public void drawBackground(Canvas canvas, double x, double y, double width, double height,
Paint paint, com.cyzapps.VisualMFP.Color newColor) {
int nPaintOriginalColor = paint.getColor();
Style stylePaintOriginalStyle = paint.getStyle();
if (newColor != null) { // a valid color
paint.setColor(newColor.getARGB());
} else if (mcolorBkGrnd != null) {
paint.setColor(mcolorBkGrnd.getARGB());
}
paint.setStyle(Style.FILL);
float fLeft = (float)x, fTop = (float)y, fRight = (float)(x + width), fBottom = (float)(y + height);
canvas.drawRect(fLeft, fTop, fRight, fBottom, paint);
// restore paint attribute.
paint.setStyle(stylePaintOriginalStyle);
paint.setColor(nPaintOriginalColor);
}
示例7: drawLeadingMargin
import android.graphics.Paint; //導入方法依賴的package包/類
public void drawLeadingMargin(final Canvas c, final Paint p, final int x, final int dir,
final int top, final int baseline, final int bottom,
final CharSequence text, final int start, final int end,
final boolean first, final Layout layout) {
Paint.Style style = p.getStyle();
int color = p.getColor();
p.setStyle(Paint.Style.FILL);
p.setColor(this.color);
c.drawRect(x, top, x + dir * stripeWidth, bottom, p);
p.setStyle(style);
p.setColor(color);
}
示例8: drawBackground
import android.graphics.Paint; //導入方法依賴的package包/類
@Override
public void drawBackground(Canvas c, Paint p, int left, int right, int top, int baseline, int bottom, CharSequence text, int start, int end, int lnum) {
final int paintColorBak = p.getColor();
boolean isFirstLineOfParagraph = _previousParagraphBeginIndex != start;
drawBackground(c, p, left, right, top, baseline, bottom, text, start, end, lnum, isFirstLineOfParagraph);
_previousParagraphBeginIndex = end;
p.setColor(paintColorBak);
}
示例9: drawBackground
import android.graphics.Paint; //導入方法依賴的package包/類
@Override
public void drawBackground(
Canvas canvas, Paint paint,
int left, int right, int top, int baseline, int bottom,
CharSequence charSequence,
int start, int end, int lineNum
) {
int oldColor = paint.getColor();
if (color != 0) {
paint.setColor(color);
}
canvas.drawCircle((left + right) / 2, bottom + radius, radius, paint);
paint.setColor(oldColor);
}
示例10: applyListItemStyle
import android.graphics.Paint; //導入方法依賴的package包/類
public void applyListItemStyle(@NonNull Paint paint) {
final int color;
if (listItemColor != 0) {
color = listItemColor;
} else {
color = paint.getColor();
}
paint.setColor(color);
if (bulletListItemStrokeWidth != 0) {
paint.setStrokeWidth(bulletListItemStrokeWidth);
}
}
示例11: draw
import android.graphics.Paint; //導入方法依賴的package包/類
@Override public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end, float x, int top,
int y, int bottom, @NonNull Paint paint) {
final int currentColor = paint.getColor();
paint.setColor(color);
paint.setStyle(Paint.Style.FILL);
int height = 10;
canvas.drawRect(new Rect(0, bottom - height, (int) x + width, bottom), paint);
paint.setColor(currentColor);
}
示例12: drawBackground
import android.graphics.Paint; //導入方法依賴的package包/類
@Override public void drawBackground(Canvas c, Paint p, int left, int right, int top, int baseline, int bottom,
CharSequence text, int start, int end, int lnum) {
Paint.Style style = p.getStyle();
int color = p.getColor();
p.setStyle(Paint.Style.FILL);
p.setColor(this.color);
rect.set(left, top, right, bottom);
c.drawRect(rect, p);
p.setColor(color);
p.setStyle(style);
}
示例13: draw
import android.graphics.Paint; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas, double x, double y, double width, double height, Paint paint) {
Log.e(LOG_TAG, "in XYChart.draw");
//calcCoordArea(x, y, width, height);
//update();
int nPaintOriginalColor = paint.getColor();
// draw background
paint.setColor(mcolorBkGrnd.getARGB());
drawBackground(canvas, x, y, width, height, paint, null);
paint.setColor(mcolorForeGrnd.getARGB());
// draw title
draw1LineTextAnchorMid(canvas, mstrChartTitle, width / 2, y + mdSmallSize/2, paint, null, mdSmallSize, 0);
// draw x-axis
drawAxis(canvas, mcaXAxis, mp3CoordLeftBottomInTO.getX(), mp3CoordLeftBottomInTO.getY(),
mp3CoordLeftBottomInTO.getX() + mdCoordWidth, mp3CoordLeftBottomInTO.getY(),
paint, mcolorForeGrnd, false);
// draw y-axis
drawAxis(canvas, mcaYAxis, mp3CoordLeftBottomInTO.getX(), mp3CoordLeftBottomInTO.getY(),
mp3CoordLeftBottomInTO.getX(), mp3CoordLeftBottomInTO.getY() - mdCoordHeight,
paint, mcolorForeGrnd, true);
paint.setColor(mcolorHint.getARGB());
// draw a rectangle for drawing area
float fCoordLeft = (float)mp3CoordLeftBottomInTO.getX(),
fCoordTop = (float)(mp3CoordLeftBottomInTO.getY() - mdCoordHeight),
fCoordRight = (float)(mp3CoordLeftBottomInTO.getX() + mdCoordWidth),
fCoordBottom = (float)mp3CoordLeftBottomInTO.getY();
canvas.drawLine(fCoordLeft, fCoordTop, fCoordRight, fCoordTop, paint);
canvas.drawLine(fCoordRight, fCoordTop, fCoordRight, fCoordBottom, paint);
if (mbShowGrid) {
drawGrid(canvas, paint);
}
Rect rectClip = canvas.getClipBounds();
canvas.clipRect(fCoordLeft, fCoordTop, fCoordRight, fCoordBottom, Op.REPLACE);
drawDataCurves(canvas, mmapperP2P, mDataSet, mp3CoordLeftBottomInTO.getX(), mp3CoordLeftBottomInTO.getY() - mdCoordHeight,
mdCoordWidth, mdCoordHeight, paint);
canvas.clipRect(rectClip, Op.REPLACE);
drawLegends(canvas, mdCoordWidth <= mdCoordHeight, paint);
drawButtons(canvas, x, y, width, height, paint);
paint.setColor(nPaintOriginalColor);
Log.e(LOG_TAG, "out of XYChart.draw");
}
示例14: draw
import android.graphics.Paint; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas, double x, double y, double width, double height, Paint paint) {
Log.e(LOG_TAG, "in PolarChart.draw");
//calcCoordArea(x, y, width, height);
//update();
int nPaintOriginalColor = paint.getColor();
// draw background
paint.setColor(mcolorBkGrnd.getARGB());
drawBackground(canvas, x, y, width, height, paint, null);
paint.setColor(mcolorForeGrnd.getARGB());
// draw title
draw1LineTextAnchorMid(canvas, mstrChartTitle, width / 2, y + mdSmallSize/2, paint, null, mdSmallSize, 0);
// draw r-axis only if it is visible.
if (mp3CoordOriginInTO.getX() <= mp3CoordLeftBottomInTO.getX() + mdCoordWidth) {
drawAxis(canvas, mcaXAxis, mp3CoordOriginInTO.getX(), mp3CoordOriginInTO.getY(),
mp3CoordLeftBottomInTO.getX() + mdCoordWidth, mp3CoordOriginInTO.getY(),
paint, mcolorForeGrnd, false);
}
// draw a rectangle for drawing area
float fCoordLeft = (float)mp3CoordLeftBottomInTO.getX(),
fCoordTop = (float)(mp3CoordLeftBottomInTO.getY() - mdCoordHeight),
fCoordRight = (float)(mp3CoordLeftBottomInTO.getX() + mdCoordWidth),
fCoordBottom = (float)mp3CoordLeftBottomInTO.getY();
Rect rectClip = canvas.getClipBounds();
canvas.clipRect(fCoordLeft, fCoordTop, fCoordRight, fCoordBottom, Op.REPLACE);
if (mbShowGrid) {
drawGrid(canvas, paint);
}
drawDataCurves(canvas, mmapperPolarXY, mDataSet, fCoordLeft, fCoordTop, mdCoordWidth, mdCoordHeight, paint);
canvas.clipRect(rectClip, Op.REPLACE);
drawLegends(canvas, mdCoordWidth <= mdCoordHeight, paint);
drawButtons(canvas, x, y, width, height, paint);
paint.setColor(nPaintOriginalColor);
Log.e(LOG_TAG, "out of PolarChart.draw");
}
示例15: blendAlpha
import android.graphics.Paint; //導入方法依賴的package包/類
private static void blendAlpha(@NonNull final Paint paint, final int alpha) {
final int color = paint.getColor();
paint.setARGB((paint.getAlpha() * alpha) / Constants.Color.ALPHA_OPAQUE,
Color.red(color), Color.green(color), Color.blue(color));
}