From 02b1ea43844084dd8cd435a169ded172387ef617 Mon Sep 17 00:00:00 2001 From: yy1717 <fctom1215@outlook.com> Date: 星期五, 20 三月 2020 18:06:26 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java | 62 +++++++++++------------------- 1 files changed, 23 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java index 93bbeab..29b98bb 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java @@ -1,14 +1,11 @@ package safeluck.drive.evaluation.fragment; import android.content.Context; -import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.DashPathEffect; import android.graphics.Paint; import android.graphics.Path; -import android.graphics.PathEffect; -import android.graphics.RectF; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; @@ -34,14 +31,11 @@ import me.yokeyword.fragmentation.SupportFragment; import safeluck.drive.evaluation.Constant; -import safeluck.drive.evaluation.bean.ExamMap; import safeluck.drive.evaluation.bean.RealTimeCarPos; import safeluck.drive.evaluation.bean.RoadExamMap; import safeluck.drive.evaluation.cEventCenter.CEventCenter; import safeluck.drive.evaluation.cEventCenter.ICEventListener; import safeluck.drive.evaluation.util.FileUtil; - -import static android.view.View.LAYER_TYPE_SOFTWARE; public class RoadDriveMapFragment extends SupportFragment implements SurfaceHolder.Callback { @@ -356,6 +350,8 @@ min_y = car[i][1]; } } + //缁樺埗鑳屾櫙 娓呭睆 + mCanvas.drawColor(Color.WHITE); long scale_x = Math.round((mCanvas.getWidth() - base_x - 10) / (max_x - min_x)); long scale_y = Math.round((mCanvas.getHeight() - base_y - 10) / (max_y - min_y)); @@ -383,6 +379,21 @@ mPaint.setStyle(Paint.Style.STROKE); mPaint.setColor(Color.BLACK); + mPaint.reset(); + mPaint.setStyle(Paint.Style.STROKE); + mPaint.setStrokeWidth(1.5f); + mPaint.setAntiAlias(true); + mPaint.setColor(Color.BLACK); + mPath.moveTo((float) (base_x + (car[body.get(0)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(0)][1] - min_y) * scale_y)); + for (int k = 1; k < body.size(); k++){ + Log.i(TAG,String.format("car[%d][0]=%f,to X =%f,car[%d][1]=%f,to Y=%f",k,car[body.get(k)][0], + (float) (base_x + (car[body.get(k)][0] - min_x) * scale_x),k,car[body.get(k)][1],(float) (base_y + (car[body.get(k)][1] - min_y) * scale_y))); + mPath.lineTo((float) (base_x + (car[body.get(k)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(k)][1] - min_y) * scale_y)); + } + + mPath.close(); + + mCanvas.drawPath(mPath, mPaint); if (map.length > 9) { if (maps != null&& maps.size()>0){ @@ -396,18 +407,16 @@ mPaint.setStrokeWidth(1.5f); mPaint.setAntiAlias(true); mPaint.setColor(Color.RED); - Log.i(TAG,"redLinesSize"+redLines.size()); for (List<Integer> redline: redLines ) { for (int j = 0; j < redline.size(); j++) { - Log.i(TAG,"redLiSize"+redline.size()); int pos = redline.get(j); if (j == 0){ mPath.moveTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); } mPath.lineTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); - Log.i(TAG,String.format("map[%d][0]=%f,map[%d][1]=%f,line to (%f,%f)",pos,map[pos][0],pos,map[pos][1], - (float) (base_x + (map[pos][0] - min_x) * scale_x),(float) (base_y + (map[pos][1] - min_y) * scale_y))); +// Log.i(TAG,String.format("map[%d][0]=%f,map[%d][1]=%f,line to (%f,%f)",pos,map[pos][0],pos,map[pos][1], +// (float) (base_x + (map[pos][0] - min_x) * scale_x),(float) (base_y + (map[pos][1] - min_y) * scale_y))); } } @@ -428,8 +437,8 @@ mPath.moveTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); } mPath.lineTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); - Log.i(TAG,String.format("map[%d][0]=%f,map[%d][1]=%f,line to (%f,%f)",pos,map[pos][0],pos,map[pos][1], - (float) (base_x + (map[pos][0] - min_x) * scale_x),(float) (base_y + (map[pos][1] - min_y) * scale_y))); +// Log.i(TAG,String.format("map[%d][0]=%f,map[%d][1]=%f,line to (%f,%f)",pos,map[pos][0],pos,map[pos][1], +// (float) (base_x + (map[pos][0] - min_x) * scale_x),(float) (base_y + (map[pos][1] - min_y) * scale_y))); } } mCanvas.drawPath(mPath,mPaint); @@ -437,15 +446,6 @@ } } - mPath.moveTo((float) (base_x + (car[body.get(0)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(0)][1] - min_y) * scale_y)); - for (int k = 1; k < body.size(); k++){ - Log.d(TAG, "for 寰幆 DrawMap to X = " + (float) (base_x + (car[body.get(k)][0] - min_x) * scale_x)+ " Y = " + (float) (base_y + (car[body.get(k)][1] - min_y) * scale_y)); - mPath.lineTo((float) (base_x + (car[body.get(k)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(k)][1] - min_y) * scale_y)); - } - - mPath.close(); - - mCanvas.drawPath(mPath, mPaint); @@ -454,22 +454,6 @@ } -//mPaint.reset(); -// mPath = new Path(); -// mPaint.setStyle(Paint.Style.STROKE); -// mPaint.setStrokeWidth(1.5f); -// -// for (int i = 0; i < map.length; i++) { -// if (i<map.length-3){ -// mPath.moveTo((float) (base_x + (map[i][0] - min_x) * scale_x), (float) (base_y + (map[i][1] - min_y) * scale_y)); -// mPath.lineTo((float) (base_x + (map[i+3][0] - min_x) * scale_x), (float) (base_y + (map[i+3][1] - min_y) * scale_y)); -// }else{ -// break; -// } -// -// i++; -// } -// mCanvas.drawPath(mPath,mPaint); } /** @@ -479,8 +463,8 @@ try { //鑾峰緱canvas瀵硅薄 mCanvas = mSurfaceHolder.lockCanvas(); - //缁樺埗鑳屾櫙 - mCanvas.drawColor(Color.WHITE); +// //缁樺埗鑳屾櫙 +// mCanvas.drawColor(Color.WHITE); Log.i(TAG,"width="+mCanvas.getWidth()+"height:"+mCanvas.getHeight()); //缁樺埗璺緞 mCanvas.drawPath(mPath, mPaint); -- Gitblit v1.8.0