use of android.graphics.DashPathEffect in project Anki-Android by Ramblurr.
the class XYChart method drawSeries.
/**
* Draws the series.
*
* @param series the series
* @param canvas the canvas
* @param paint the paint object
* @param pointsList the points to be rendered
* @param seriesRenderer the series renderer
* @param yAxisValue the y axis value in pixels
* @param seriesIndex the series index
* @param or the orientation
* @param startIndex the start index of the rendering points
*/
protected void drawSeries(XYSeries series, Canvas canvas, Paint paint, List<Float> pointsList, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, Orientation or, int startIndex, int range) {
BasicStroke stroke = seriesRenderer.getStroke();
Cap cap = paint.getStrokeCap();
Join join = paint.getStrokeJoin();
float miter = paint.getStrokeMiter();
PathEffect pathEffect = paint.getPathEffect();
Style style = paint.getStyle();
if (stroke != null) {
PathEffect effect = null;
if (stroke.getIntervals() != null) {
effect = new DashPathEffect(stroke.getIntervals(), stroke.getPhase());
}
setStroke(stroke.getCap(), stroke.getJoin(), stroke.getMiter(), Style.FILL_AND_STROKE, effect, paint);
}
float[] points = MathHelper.getFloats(pointsList);
drawSeries(canvas, paint, points, seriesRenderer, yAxisValue, seriesIndex, startIndex, range);
if (isRenderPoints(seriesRenderer)) {
ScatterChart pointsChart = getPointsChart();
if (pointsChart != null) {
pointsChart.drawSeries(canvas, paint, points, seriesRenderer, yAxisValue, seriesIndex, startIndex, range);
}
}
paint.setTextSize(seriesRenderer.getChartValuesTextSize());
if (or == Orientation.HORIZONTAL) {
paint.setTextAlign(Align.CENTER);
} else {
paint.setTextAlign(Align.LEFT);
}
if (seriesRenderer.isDisplayChartValues()) {
paint.setTextAlign(seriesRenderer.getChartValuesTextAlign());
drawChartValuesText(canvas, series, seriesRenderer, paint, points, seriesIndex, startIndex);
}
if (stroke != null) {
setStroke(cap, join, miter, style, pathEffect, paint);
}
}
use of android.graphics.DashPathEffect in project sensorreadout by onyxbits.
the class XYChart method drawSeries.
/**
* Draws the series.
*
* @param series the series
* @param canvas the canvas
* @param paint the paint object
* @param pointsList the points to be rendered
* @param seriesRenderer the series renderer
* @param yAxisValue the y axis value in pixels
* @param seriesIndex the series index
* @param or the orientation
* @param startIndex the start index of the rendering points
*/
protected void drawSeries(XYSeries series, Canvas canvas, Paint paint, List<Float> pointsList, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, Orientation or, int startIndex) {
BasicStroke stroke = seriesRenderer.getStroke();
Cap cap = paint.getStrokeCap();
Join join = paint.getStrokeJoin();
float miter = paint.getStrokeMiter();
PathEffect pathEffect = paint.getPathEffect();
Style style = paint.getStyle();
if (stroke != null) {
PathEffect effect = null;
if (stroke.getIntervals() != null) {
effect = new DashPathEffect(stroke.getIntervals(), stroke.getPhase());
}
setStroke(stroke.getCap(), stroke.getJoin(), stroke.getMiter(), Style.FILL_AND_STROKE, effect, paint);
}
// float[] points = MathHelper.getFloats(pointsList);
drawSeries(canvas, paint, pointsList, seriesRenderer, yAxisValue, seriesIndex, startIndex);
if (isRenderPoints(seriesRenderer)) {
ScatterChart pointsChart = getPointsChart();
if (pointsChart != null) {
pointsChart.drawSeries(canvas, paint, pointsList, seriesRenderer, yAxisValue, seriesIndex, startIndex);
}
}
paint.setTextSize(seriesRenderer.getChartValuesTextSize());
if (or == Orientation.HORIZONTAL) {
paint.setTextAlign(Align.CENTER);
} else {
paint.setTextAlign(Align.LEFT);
}
if (seriesRenderer.isDisplayChartValues()) {
paint.setTextAlign(seriesRenderer.getChartValuesTextAlign());
drawChartValuesText(canvas, series, seriesRenderer, paint, pointsList, seriesIndex, startIndex);
}
if (stroke != null) {
setStroke(cap, join, miter, style, pathEffect, paint);
}
}
use of android.graphics.DashPathEffect in project fitscales by paulburton.
the class ScaleView method init.
private void init() {
regions = new ScaleRegion[4];
regions[0] = new ScaleRegion("underweight", 0.0f, 18.5f, 0xffff4020);
regions[1] = new ScaleRegion("normal", 18.5f, 25.0f, 0xff00ff00);
regions[2] = new ScaleRegion("overweight", 25.0f, 30.0f, 0xffffff00);
regions[3] = new ScaleRegion("obese", 30.0f, Float.MAX_VALUE, 0xffff4020);
paintLine = new Paint();
paintLine.setColor(0xff33b5e5);
paintLine.setStrokeWidth(2);
if (DRAW_REGION_SEPARATORS) {
paintSeparator = new Paint();
paintSeparator.setColor(0xff606060);
paintSeparator.setStyle(Style.STROKE);
paintSeparator.setStrokeWidth(1);
paintSeparator.setPathEffect(new DashPathEffect(new float[] { 20, 10 }, 0));
}
paintOverlay = new Paint();
paintOverlay.setColor(0);
paintOverlay.setStyle(Style.FILL);
paintCurrBmi = new Paint();
paintCurrBmi.setColor(0xff33b5e5);
paintCurrBmi.setStrokeWidth(3);
paintCurrBmiTriangle = new Paint(Paint.ANTI_ALIAS_FLAG);
paintCurrBmiTriangle.setColor(0xff33b5e5);
paintCurrBmiTriangle.setStyle(Style.FILL);
paintCurrWeight = new Paint(Paint.ANTI_ALIAS_FLAG);
paintCurrWeight.setColor(0xff202020);
paintCurrWeight.setTypeface(Typeface.DEFAULT);
paintPrevBmi = new Paint();
paintPrevBmi.setColor(0xff808080);
paintPrevBmi.setStrokeWidth(3);
paintPrevBmiTriangle = new Paint(Paint.ANTI_ALIAS_FLAG);
paintPrevBmiTriangle.setColor(0xff808080);
}
use of android.graphics.DashPathEffect in project muzei by romannurik.
the class AnimatedMuzeiLoadingSpinnerView method onDraw.
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mStartTime < 0 || mGlyphData == null) {
return;
}
long t = (System.currentTimeMillis() - mStartTime) % (TRACE_TIME * 2);
int sc = canvas.save();
canvas.translate(-VIEWPORT.left * mWidth / VIEWPORT.width(), -VIEWPORT.top * mHeight / VIEWPORT.height());
// Draw outlines (starts as traced)
float phase = MathUtil.constrain(0, 1, (t % TRACE_TIME) * 1f / TRACE_TIME);
float distance = INTERPOLATOR.getInterpolation(phase) * mGlyphData.length;
mGlyphData.paint.setColor(TRACE_RESIDUE_COLOR);
if (t < TRACE_TIME) {
mGlyphData.paint.setPathEffect(new DashPathEffect(new float[] { distance, mGlyphData.length }, 0));
} else {
mGlyphData.paint.setPathEffect(new DashPathEffect(new float[] { 0, distance, mGlyphData.length, 0 }, 0));
}
canvas.drawPath(mGlyphData.path, mGlyphData.paint);
mGlyphData.paint.setColor(TRACE_COLOR);
mGlyphData.paint.setPathEffect(new DashPathEffect(new float[] { 0, distance, phase > 0 ? mMarkerLength : 0, mGlyphData.length }, 0));
canvas.drawPath(mGlyphData.path, mGlyphData.paint);
canvas.restoreToCount(sc);
postInvalidateOnAnimation();
}
use of android.graphics.DashPathEffect in project platform_frameworks_base by android.
the class GradientDrawable method updateLocalState.
private void updateLocalState(Resources res) {
final GradientState state = mGradientState;
if (state.mSolidColors != null) {
final int[] currentState = getState();
final int stateColor = state.mSolidColors.getColorForState(currentState, 0);
mFillPaint.setColor(stateColor);
} else if (state.mGradientColors == null) {
// If we don't have a solid color and we don't have a gradient,
// the app is stroking the shape, set the color to the default
// value of state.mSolidColor
mFillPaint.setColor(0);
} else {
// Otherwise, make sure the fill alpha is maxed out.
mFillPaint.setColor(Color.BLACK);
}
mPadding = state.mPadding;
if (state.mStrokeWidth >= 0) {
mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mStrokePaint.setStyle(Paint.Style.STROKE);
mStrokePaint.setStrokeWidth(state.mStrokeWidth);
if (state.mStrokeColors != null) {
final int[] currentState = getState();
final int strokeStateColor = state.mStrokeColors.getColorForState(currentState, 0);
mStrokePaint.setColor(strokeStateColor);
}
if (state.mStrokeDashWidth != 0.0f) {
final DashPathEffect e = new DashPathEffect(new float[] { state.mStrokeDashWidth, state.mStrokeDashGap }, 0);
mStrokePaint.setPathEffect(e);
}
}
mTintFilter = updateTintFilter(mTintFilter, state.mTint, state.mTintMode);
mGradientIsDirty = true;
state.computeOpacity();
}
Aggregations