项目:Rxjava2.0Demo
文件:FalsifyHeader.java
@Override
@SuppressLint("DrawAllocation")
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
int d = DensityUtil.dp2px(5);
Paint paint = new Paint();
paint.setStyle(Paint.Style.stroke);
paint.setColor(0x44ffffff);
paint.setstrokeWidth(DensityUtil.dp2px(1));
paint.setPathEffect(new DashPathEffect(new float[]{d,d,d},1));
canvas.drawRect(d,getWidth() - d,getBottom() - d,paint);
TextView textView = new TextView(getContext());
textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表下拉Header的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
textView.setTextColor(0x44ffffff);
textView.setGravity(Gravity.CENTER);
textView.measure(makeMeasureSpec(getWidth(),EXACTLY),makeMeasureSpec(getHeight(),EXACTLY));
textView.layout(0,getWidth(),getHeight());
textView.draw(canvas);
}
}
项目:Rxjava2.0Demo
文件:FalsifyFooter.java
@Override
@SuppressLint("DrawAllocation")
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
int d = DensityUtil.dp2px(5);
Paint paint = new Paint();
paint.setStyle(Paint.Style.stroke);
paint.setColor(0x44ffffff);
paint.setstrokeWidth(DensityUtil.dp2px(1));
paint.setPathEffect(new DashPathEffect(new float[]{d,paint);
TextView textView = new TextView(getContext());
textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表上拉Footer的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
textView.setTextColor(0x44ffffff);
textView.setGravity(Gravity.CENTER);
textView.measure(makeMeasureSpec(getWidth(),getHeight());
textView.draw(canvas);
}
}
项目:hypertrack-live-android
文件:DashedLine.java
public DashedLine(Context context,AttributeSet attrs) {
super(context,attrs);
int dashGap,dashLength,dashThickness;
int color;
TypedArray a = context.getTheme().obtainStyledAttributes(attrs,R.styleable.DashedLine,0);
try {
dashGap = a.getDimensionPixelSize(R.styleable.DashedLine_dashGap,5);
dashLength = a.getDimensionPixelSize(R.styleable.DashedLine_dashLength,5);
dashThickness = a.getDimensionPixelSize(R.styleable.DashedLine_dashThickness,3);
color = a.getColor(R.styleable.DashedLine_color,0xff000000);
orientation = a.getInt(R.styleable.DashedLine_orientation,ORIENTATION_HORIZONTAL);
} finally {
a.recycle();
}
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setColor(color);
mPaint.setStyle(Paint.Style.stroke);
mPaint.setstrokeWidth(dashThickness);
mPaint.setPathEffect(new DashPathEffect(new float[]{dashLength,dashGap,},0));
}
项目:weex-svg
文件:WXSvgPath.java
/**
* Sets up paint according to the props set on a shadow view. Returns {@code true}
* if the stroke should be drawn,{@code false} if not.
*/
protected boolean setupstrokePaint(Paint paint,float opacity,@Nullable RectF Box) {
paint.reset();
if (TextUtils.isEmpty(mstrokeColor)) {
return false;
}
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.stroke);
paint.setstrokeCap(mstrokeLinecap);
paint.setstrokeJoin(mstrokeLinejoin);
paint.setstrokeMiter(mstrokeMiterlimit * mScale);
paint.setstrokeWidth(mstrokeWidth * mScale);
setupPaint(paint,opacity,mstrokeColor,Box);
if (mstrokeDasharray != null && mstrokeDasharray.length > 0) {
paint.setPathEffect(new DashPathEffect(mstrokeDasharray,mstrokeDashoffset));
}
return true;
}
项目:Virtualview-Android
文件:NativeLineImp.java
public void setPaintParam(int color,int paintWidth,int style) {
mPaint.setstrokeWidth(paintWidth);
mPaint.setColor(color);
mPaint.setAntiAlias(true);
switch (style) {
case STYLE_DASH:
mPaint.setStyle(Paint.Style.stroke);
mPaint.setPathEffect(new DashPathEffect(mBase.mDashEffect,1));
this.setLayerType(View.LAYER_TYPE_SOFTWARE,null);
break;
case STYLE_SOLID:
mPaint.setStyle(Paint.Style.FILL);
break;
}
}
private void applyDashPatternIfNeeded() {
if (dashPatternAnimations.isEmpty()) {
return;
}
float scale = lottieDrawable.getScale();
for (int i = 0; i < dashPatternAnimations.size(); i++) {
dashPatternValues[i] = dashPatternAnimations.get(i).getValue();
// If the value of the dash pattern or gap is too small,the number of individual sections
// approaches infinity as the value approaches 0.
// To mitigate this,we essentially put a minimum value on the dash pattern size of 1px
// and a minimum gap size of 0.01.
if (i % 2 == 0) {
if (dashPatternValues[i] < 1f) {
dashPatternValues[i] = 1f;
}
} else {
if (dashPatternValues[i] < 0.1f) {
dashPatternValues[i] = 0.1f;
}
}
dashPatternValues[i] *= scale;
}
float offset = dashPatternOffsetAnimation == null ? 0f : dashPatternOffsetAnimation.getValue();
paint.setPathEffect(new DashPathEffect(dashPatternValues,offset));
}
项目:android-study
文件:PathEffectView.java
@Override protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//无效果
mEffects[0] = null;
//拐角处变得圆滑
mEffects[1] = new CornerPathEffect(30);
//线段上就会产生许多杂点
mEffects[2] = new discretePathEffect(3.0F,5.0F);
//绘制虚线
mEffects[3] = new DashPathEffect(new float[] { 20,10,5,10 },0);
Path path = new Path();
path.addRect(0,8,Path.Direction.ccw);
//设置点的图形,即方形点的虚线,圆形点的虚线
mEffects[4] = new PathDashPathEffect(path,12,PathDashPathEffect.Style.ROTATE);
//组合PathEffect
mEffects[5] = new ComposePathEffect(mEffects[3],mEffects[1]);
for (int i = 0; i < mEffects.length; i++) {
mPaint.setPathEffect(mEffects[i]);
canvas.drawPath(mPath,mPaint);
canvas.translate(0,200);
}
}
private Line getTargetLine() {
if (!needDrawTargetLine()) {
return null;
}
PointValue lastRecordPoint = (PointValue) this.mPointValues.get(this.mPointValues.size()
- 1);
PointValue targetPoint = new PointValue(((AxisValue) this.mAxisValues.get(this
.mAxisValues.size() - 1)).getValue(),this.mTargetWeight);
List<PointValue> points = new ArrayList();
points.add(lastRecordPoint);
points.add(targetPoint);
Line line = new Line(points);
line.setColor(this.resources.getColor(R.color.da));
line.setPathEffect(new DashPathEffect(new float[]{15.0f,15.0f,15.0f},0.0f));
line.setHasLabels(false);
if (this.mTypeMode > 0) {
line.setHasPoints(false);
return line;
}
line.setHasPoints(true);
return line;
}
private void init(Context context) {
setLayerType(1,null);
this.mContext = context;
this.mBackgroundPaint = new Paint();
this.mBackgroundPaint.setstrokeWidth(2.0f);
this.mBackgroundPaint.setAntiAlias(true);
this.mBackgroundPaint.setColor(-5056771);
this.mBackgroundPaint.setStyle(Style.stroke);
this.mColumnPaint = new Paint();
this.mColumnPaint.setAntiAlias(true);
this.mColumnPaint.setStyle(Style.FILL);
this.mColumnPaint.setColor(-12477447);
this.mLinePaint = new Paint();
this.mLinePaint.setAntiAlias(true);
this.mLinePaint.setStyle(Style.stroke);
this.mLinePaint.setColor(-5056771);
this.mLinePaint.setstrokeWidth(1.0f);
this.mLinePaint.setPathEffect(new DashPathEffect(new float[]{aj.hA,aj.hA},0.0f));
this.mBackgroundRect = new RectF();
}
public WidgetTextFrame(Context context,@Nullable AttributeSet attrs) {
super(context,attrs);
setClipChildren(false);
setClipToPadding(false);
mContext = context.getApplicationContext();
mPaddingSpace = context.getResources().getDimensionPixelSize(R.dimen.edit_text_space);
mRoundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
PathEffect effect = new DashPathEffect(new float[]{20,20},1);
mRoundPaint.setAntiAlias(true);
mRoundPaint.setColor(getResources().getColor(R.color.edit_text_background_color));
mRoundPaint.setPathEffect(effect);
mRoundPaint.setStyle(Paint.Style.stroke);
mRoundPaint.setstrokeWidth(3);
mDeletePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mDeletePaint.setAntiAlias(true);
mDeletePaint.setFilterBitmap(true);
mDeletePaint.setDither(true);
setwillNotDraw(false);
}
项目:HeadlineNews
文件:UILine.java
private void initPaint() {
mPaint = new Paint();
mPaint.setColor(mColor);
mPaint.setStyle(Paint.Style.stroke);
/** 边界实际的位置是在边框的中间,所以都要减去边框宽度的一半,所以需要乘以2,才能得到想要的尺寸*/
mPaint.setstrokeWidth(mThickness * 2);
if (mLineMode == LINE_MODE_DottED) {
/** 定义 虚线的一些尺寸属性 从0开始,偶数项代表 单个虚线的长度,第二个代表虚线间隔的大小,后面会依次循环*/
float[] intervals = new float[]{mDottedSize,mDottedSpacingSize};
/** 第二个参数是 偏移量,填0就够用了*/
DashPathEffect dashPathEffect = new DashPathEffect(intervals,0);
mPaint.setPathEffect(dashPathEffect);
}
mPath = new Path();
}
项目:SmartRefreshLayout
文件:FalsifyHeader.java
@Override
@SuppressLint({"DrawAllocation","SetTextI18n"})
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
int d = DensityUtil.dp2px(5);
Paint paint = new Paint();
paint.setStyle(Paint.Style.stroke);
paint.setColor(0x44ffffff);
paint.setstrokeWidth(DensityUtil.dp2px(1));
paint.setPathEffect(new DashPathEffect(new float[]{d,getHeight());
textView.draw(canvas);
}
}
项目:SmartRefreshLayout
文件:FalsifyFooter.java
@Override
@SuppressLint({"DrawAllocation",getHeight());
textView.draw(canvas);
}
}
项目:ticket-view
文件:TicketView.java
private void init(AttributeSet attrs) {
eraser.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
dashPaint.setARGB(255,200,200);
dashPaint.setStyle(Style.stroke);
dashPaint.setstrokeWidth(4);
dashPaint.setPathEffect(new DashPathEffect(new float[] { 4,8 },0));
borderPaint.setARGB(255,200);
borderPaint.setStyle(Style.stroke);
borderPaint.setstrokeWidth(4);
setLayerType(LAYER_TYPE_HARDWARE,null);
TypedArray a = getContext().obtainStyledAttributes(attrs,R.styleable.TicketView);
try {
orientation = a.getInt(R.styleable.TicketView_tv_orientation,Orientation.VERTICAL);
holeRadius = a.getFloat(R.styleable.TicketView_tv_holeRadius,DEFAULT_RADIUS);
anchorViewId = a.getResourceId(R.styleable.TicketView_tv_anchor,NO_VALUE);
} finally {
a.recycle();
}
}
项目:JZAndroidChart
文件:BarChartRenderer.java
@Override
public void renderHighlighted(Canvas canvas,@NonNull Highlight[] highlights) {
mRenderPaint.setColor(getHighlightColor());
mRenderPaint.setstrokeWidth(2);
mRenderPaint.setStyle(Paint.Style.stroke);
if (mDashedHighlightPhase > 0) {
mRenderPaint.setPathEffect(new DashPathEffect(mDashedHighlightIntervals,mDashedHighlightPhase));
}
for (Highlight highlight : highlights) {
canvas.drawLine(
highlight.getX(),highlight.getX(),mContentRect.bottom,mRenderPaint);
}
mRenderPaint.setPathEffect(null);
}
项目:RNLearn_Project1
文件:DrawBorder.java
@Override
protected @Nullable DashPathEffect getPathEffectForBorderStyle() {
if (isFlagSet(BORDER_PATH_EFFECT_DIRTY)) {
switch (mBorderStyle) {
case BORDER_STYLE_DottED:
mPathEffectForBorderStyle = createDashPathEffect(getBorderWidth());
break;
case BORDER_STYLE_DASHED:
mPathEffectForBorderStyle = createDashPathEffect(getBorderWidth() * 3);
break;
default:
mPathEffectForBorderStyle = null;
break;
}
resetFlag(BORDER_PATH_EFFECT_DIRTY);
}
return mPathEffectForBorderStyle;
}
项目:RNLearn_Project1
文件:ReactViewBackgroundDrawable.java
public @Nullable PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[] {borderWidth*3,borderWidth*3,borderWidth*3},0);
case DottED:
return new DashPathEffect(
new float[] {borderWidth,borderWidth,borderWidth},0);
default:
return null;
}
}
项目:Coding-Android
文件:DashLine.java
public DashLine(Context paramContext,AttributeSet paramAttributeSet) {
super(paramContext,paramAttributeSet);
//通过R.styleable.dashedline获得我们在attrs.xml中定义的
//<declare-styleable name="dashedline"> TypedArray
// TypedArray a = paramContext.obtainStyledAttributes(paramAttributeSet,R.styleable.dashedline);
//我们在attrs.xml中<declare-styleable name="dashedline">节点下
//添加了<attr name="lineColor" format="color" />
//表示这个属性名为lineColor类型为color。当用户在布局文件中对它有设定值时
//可通过TypedArray获得它的值当用户无设置值是采用默认值0XFF00000
// int lineColor = a.getColor(R.styleable.dashedline_lineColor,0XFF000000);
// a.recycle();
int lineColor = 0xffc1c1c1;
this.paint = new Paint();
this.path = new Path();
this.paint.setStyle(Paint.Style.stroke);
this.paint.setColor(lineColor);
this.paint.setAntiAlias(true);
this.paint.setstrokeWidth(Global.dpToPx(2));
float[] arrayOfFloat = new float[4];
arrayOfFloat[0] = Global.dpToPx(3);
arrayOfFloat[1] = Global.dpToPx(2);
arrayOfFloat[2] = Global.dpToPx(3);
arrayOfFloat[3] = Global.dpToPx(2);
this.pe = new DashPathEffect(arrayOfFloat,0);
}
项目:react-native-ibeacon-android
文件:ReactViewBackgroundDrawable.java
public @Nullable PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[] {borderWidth*3,0);
default:
return null;
}
}
项目:weex
文件:WXBackgroundDrawable.java
public
@Nullable
PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[]{borderWidth * 3,borderWidth * 3,borderWidth * 3},0);
case DottED:
return new DashPathEffect(
new float[]{borderWidth,0);
default:
return null;
}
}
private void init() {
mShapePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mShapePaint.setstrokeWidth(ViewUtils.dp2px(getContext(),1));
mShapePaint.setDither(true);
mShapePaint.setColor(COLOR_TEXT);
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setDither(true);
mTextPaint.setTextSize(ViewUtils.sp2px(getContext(),12));
mTextPaint.setColor(COLOR_TEXT);
mTextPaint.setTypeface(Typeface.DEFAULT);
Paint.FontMetrics metrics = mTextPaint.getFontMetrics();
mTextOffsetY = -(metrics.descent+metrics.ascent)/2.0f;
mTextOffsetX = (metrics.descent-metrics.ascent)/2.0f;
mCachedTextBounds = new Rect();
mViewMinWidth = DEFAULT_VIEW_WIDTH;
mViewMinHeight = DEFAULT_VIEW_HEIGHT;
mPathEffect = new DashPathEffect(new float[]{5,5},1);
}
public @Nullable PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[] {borderWidth*3,0);
default:
return null;
}
}
项目:AndroidAPS
文件:GraphData.java
public void addNowLine(GraphView graph,long Now) {
LineGraphSeries<DataPoint> seriesNow;
DataPoint[] NowPoints = new DataPoint[]{
new DataPoint(Now,0),new DataPoint(Now,maxY)
};
seriesNow = new LineGraphSeries<>(NowPoints);
seriesNow.setDrawDataPoints(false);
// custom paint to make a dotted line
Paint paint = new Paint();
paint.setStyle(Paint.Style.stroke);
paint.setstrokeWidth(2);
paint.setPathEffect(new DashPathEffect(new float[]{10,0));
paint.setColor(Color.WHITE);
seriesNow.setCustomPaint(paint);
addSeriesWithoutInvalidate(graph,seriesNow);
}
项目:Ironman
文件:ReactViewBackgroundDrawable.java
public @Nullable PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[] {borderWidth*3,0);
default:
return null;
}
}
项目:GitHub
文件:LegendEntry.java
/**
*
* @param label The legend entry text. A `null` label will start a group.
* @param form The form to draw for this entry.
* @param formSize Set to NaN to use the legend's default.
* @param formlinewidth Set to NaN to use the legend's default.
* @param formlineDashEffect Set to nil to use the legend's default.
* @param formColor The color for drawing the form.
*/
public LegendEntry(String label,Legend.LegendForm form,float formSize,float formlinewidth,DashPathEffect formlineDashEffect,int formColor)
{
this.label = label;
this.form = form;
this.formSize = formSize;
this.formlinewidth = formlinewidth;
this.formlineDashEffect = formlineDashEffect;
this.formColor = formColor;
}
项目:GitHub
文件:FishLoadingRenderer.java
项目:GitHub
文件:ComplexAdapter.java
@Override
public Paint dividerPaint(int position,RecyclerView parent) {
Paint paint = new Paint();
switch (position % 10) {
case 0:
paint.setColor(Color.RED);
paint.setstrokeWidth(30);
break;
case 1:
paint.setColor(Color.magenta);
paint.setstrokeWidth(10);
break;
default:
if (position % 2 == 0) {
paint.setColor(Color.BLUE);
paint.setAntiAlias(true);
paint.setPathEffect(new DashPathEffect(new float[]{25.0f,25.0f},0));
} else {
paint.setColor(Color.GREEN);
}
paint.setstrokeWidth(2 + position);
break;
}
return paint;
}
项目:GitHub
文件:PaintActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_recyclerview);
// Workaround for dash path effect
// https://code.google.com/p/android/issues/detail?id=29944
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
recyclerView.setLayerType(View.LAYER_TYPE_SOFTWARE,null);
}
SimpleAdapter adapter = new SimpleAdapter(this);
linearlayoutmanager manager = new linearlayoutmanager(this);
manager.setorientation(OrientationHelper.VERTICAL);
recyclerView.setLayoutManager(manager);
recyclerView.setAdapter(adapter);
Paint paint = new Paint();
paint.setstrokeWidth(5);
paint.setColor(Color.BLUE);
paint.setAntiAlias(true);
paint.setPathEffect(new DashPathEffect(new float[]{25.0f,0));
recyclerView.addItemdecoration(new HorizontalDividerItemdecoration.Builder(this)
.paint(paint)
.showLastDivider()
.build());
}
项目:GitHub
文件:WoWoPathView.java
private void initPaint() {
paint = new Paint();
paint.setColor(pathColor);
paint.setStyle(Paint.Style.stroke);
paint.setstrokeWidth(pathWidth);
paint.setAntiAlias(true);
setPath(new Path());
if (dashPath) {
pathEffect = new DashPathEffect(new float[]{dashSegmentLength,dashPaddingLength},dynamicalPathPhase);
paint.setPathEffect(pathEffect);
}
}
DashPathEffect get(float dash,float gap,float phase) {
if (this.dash != dash || this.gap != gap || this.phase != phase) {
this.dash = dash;
this.gap = gap;
this.phase = phase;
this.effect = new DashPathEffect(new float[] {dash,gap},phase);
}
return this.effect;
}
项目:RunHDU
文件:GradeProgressView.java
private void setup() {
mRectF = new RectF();
mOuterRectF = new RectF();
mOuterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mOuterPaint.setstrokeWidth(outlinewidth);
mOuterPaint.setColor(mBackgroundColor);
mOuterPaint.setStyle(Paint.Style.stroke);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setstrokeWidth(linewidth);
mPaint.setColor(mBackgroundColor);
mPaint.setStyle(Paint.Style.stroke);
mPaint.setPathEffect(new DashPathEffect(new float[]{dashWith,dashSpace},dashSpace));
mProgresspaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mProgresspaint.setstrokeWidth(linewidth);
mProgresspaint.setColor(mProgressColor);
mProgresspaint.setStyle(Paint.Style.stroke);
mProgresspaint.setPathEffect(new DashPathEffect(new float[]{dashWith,dashSpace));
mPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPointerPaint.setstrokeWidth(pointlinewidth / 2);
mPointerPaint.setColor(mProgressColor);
mPointerPaint.setStyle(Paint.Style.FILL_AND_stroke);
mPointerPaint.setstrokeCap(Paint.Cap.ROUND);
mPointerPaint.setShadowLayer(4,3,0x20000000);
mInnerCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mInnerCirclePaint.setstrokeWidth(pointlinewidth);
mInnerCirclePaint.setColor(mProgressColor);
mInnerCirclePaint.setStyle(Paint.Style.stroke);
mInnerCirclePaint.setShadowLayer(4,0x20000000);
}
项目:Weather-Android
文件:GraphActivity.java
private void temperatureGraph() {
LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_temperature);
// Data
Lineset dataset = new Lineset();
for (int i = 0; i < weatherList.size(); i++) {
float temperature = UnitConvertor.convertTemperature(Float.parseFloat(weatherList.get(i).getTemperature()),sp);
if (temperature < minTemp) {
minTemp = temperature;
}
if (temperature > maxTemp) {
maxTemp = temperature;
}
dataset.addPoint(getDateLabel(weatherList.get(i),i),(float) ((Math.ceil(temperature / 2)) * 2));
}
dataset.setSmooth(false);
dataset.setColor(Color.parseColor("#FF5722"));
dataset.setThickness(4);
lineChartView.addData(dataset);
// Grid
Paint paint = new Paint();
paint.setStyle(Paint.Style.stroke);
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#333333"));
paint.setPathEffect(new DashPathEffect(new float[]{10,10},0));
paint.setstrokeWidth(1);
lineChartView.setGrid(ChartView.GridType.HORIZONTAL,paint);
lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
lineChartView.setAxisBorderValues((int) minTemp - 2,(int) maxTemp + 2);
lineChartView.setStep(2);
lineChartView.setXAxis(false);
lineChartView.setYAxis(false);
lineChartView.show();
}
项目:Weather-Android
文件:GraphActivity.java
private void rainGraph() {
LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_rain);
// Data
Lineset dataset = new Lineset();
for (int i = 0; i < weatherList.size(); i++) {
float rain = Float.parseFloat(weatherList.get(i).getRain());
if (rain < minRain) {
minRain = rain;
}
if (rain > maxRain) {
maxRain = rain;
}
dataset.addPoint(getDateLabel(weatherList.get(i),rain);
}
dataset.setSmooth(false);
dataset.setColor(Color.parseColor("#2196F3"));
dataset.setThickness(4);
lineChartView.addData(dataset);
// Grid
Paint paint = new Paint();
paint.setStyle(Paint.Style.stroke);
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#333333"));
paint.setPathEffect(new DashPathEffect(new float[]{10,paint);
lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
lineChartView.setAxisBorderValues((int) minRain - 1,(int) maxRain + 2);
lineChartView.setStep(1);
lineChartView.setXAxis(false);
lineChartView.setYAxis(false);
lineChartView.show();
}
项目:Weather-Android
文件:GraphActivity.java
private void pressureGraph() {
LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_pressure);
// Data
Lineset dataset = new Lineset();
for (int i = 0; i < weatherList.size(); i++) {
float pressure = UnitConvertor.convertPressure(Float.parseFloat(weatherList.get(i).getPressure()),sp);
if (pressure < minPressure) {
minPressure = pressure;
}
if (pressure > maxPressure) {
maxPressure = pressure;
}
dataset.addPoint(getDateLabel(weatherList.get(i),pressure);
}
dataset.setSmooth(true);
dataset.setColor(Color.parseColor("#4CAF50"));
dataset.setThickness(4);
lineChartView.addData(dataset);
// Grid
Paint paint = new Paint();
paint.setStyle(Paint.Style.stroke);
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#333333"));
paint.setPathEffect(new DashPathEffect(new float[]{10,paint);
lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
lineChartView.setAxisBorderValues((int) minPressure - 1,(int) maxPressure + 1);
lineChartView.setStep(2);
lineChartView.setXAxis(false);
lineChartView.setYAxis(false);
lineChartView.show();
}
项目:YiZhi
文件:HistoryChartView.java
/**
* 开启动画
*/
private void startAnimation() {
if (mValueAnimator != null) {
mValueAnimator.cancel();
}
final float targetTempLength = mTargetTempPathMeasure.getLength();
final float roomTempLength = mRoomTempPathMeasure.getLength();
mValueAnimator = ValueAnimator.ofFloat(1,0);
mValueAnimator.setDuration(ANIM_DURATION);
// 减速插值器
mValueAnimator.setInterpolator(new DecelerateInterpolator());
mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float fraction = (Float) animation.getAnimatedValue();
// 更新mtargetTempEffect
mtargetTempEffect = new DashPathEffect(new float[]{
targetTempLength,targetTempLength},fraction
* targetTempLength);
targetTempPaint.setPathEffect(mtargetTempEffect);
// 更新mRoomTempEffect
mRoomTempEffect = new DashPathEffect(new float[]{
roomTempLength,roomTempLength},fraction
* roomTempLength);
roomTempPaint.setPathEffect(mRoomTempEffect);
// 更新rect绘制fraction进度
mRectFration = 1 - fraction;// fraction是1->0 我们需要的柱形图绘制比例是0->1
postInvalidate();
}
});
mValueAnimator.start();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。