From d2f93c0726e93ae4f191cc252a76a3add8149eea Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期五, 03 四月 2020 11:39:23 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/endian11/DriveJudge
---
app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java | 133 +++++++++++++++++++++++++++++---------------
1 files changed, 87 insertions(+), 46 deletions(-)
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java b/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java
index 4847c6c..47f828a 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java
@@ -16,6 +16,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -45,41 +46,13 @@
import safeluck.drive.evaluation.util.CThreadPoolExecutor;
import safeluck.drive.evaluation.util.FileUtil;
-public class RoadDriveMapFragmentaa extends SupportFragment {
+public class RoadDriveMapFragmentaa extends SupportFragment implements View.OnClickListener {
private static final int ALL_MAP = 100;
+ private int pixels = 80;
private boolean isDrawing = false;
private StringBuffer buffer = null;//瀛樻斁鍦板浘鐨刡uffer
- private ICEventListener rtcmicEventListener = new ICEventListener() {
- @Override
- public void onCEvent(String topic, int msgCode, int resultCode, final Object obj) {
- if (msgCode == Constant.DEBUG_RTCM){
-
- CThreadPoolExecutor.runOnMainThread(new Runnable() {
- @Override
- public void run() {
- Log.i(TAG, "title="+(String)obj);
- toolbar.setTitle((String)obj);
- }
- });
- }
- }
- };
- private ICEventListener debugTxticEventListener = new ICEventListener() {
- @Override
- public void onCEvent(String topic, int msgCode, int resultCode, final Object obj) {
- if (msgCode == Constant.DEBUG_TXT){
- CThreadPoolExecutor.runOnMainThread(new Runnable() {
- @Override
- public void run() {
- Log.i(TAG, "subtitle="+(String)obj);
- toolbar.setSubtitle((String)obj);
- }
- });
-
- }
- }
- };
+
private ICEventListener speedListener = new ICEventListener() {
@Override
public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
@@ -137,20 +110,13 @@
}
private int avaliableHeight,avalibleWidth;
private void initView(View view) {
- toolbar = view.findViewById(R.id.toolbar);
- toolbar.setTitle("绠�鍗曞湴鍥�");
- toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
- toolbar.setNavigationOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- _mActivity.onBackPressed();
- }
- });
+
avaliableHeight= getResources().getDisplayMetrics().heightPixels;
avalibleWidth = getResources().getDisplayMetrics().widthPixels;
Log.i(TAG, "initView: aliwidht="+avalibleWidth+" height="+avaliableHeight);
mSurfaceView = view.findViewById(R.id.surfaceview);
-
+ view.findViewById(R.id.btn_reduce).setOnClickListener(this);
+ view.findViewById(R.id.btn_amplify).setOnClickListener(this);
holder = mSurfaceView.getHolder();
holder.addCallback(new SurfaceHolder.Callback() {
@@ -268,7 +234,7 @@
car[i][1] = -car[i][1];
}
- scale_x = Math.round(Math.abs(80 / Math.sqrt(Math.pow(car[0][0], 2) + Math.pow(car[0][1], 2)) ));
+ scale_x = Math.round(Math.abs(pixels / Math.sqrt(Math.pow(car[0][0], 2) + Math.pow(car[0][1], 2)) ));
scale_y = scale_x;
base_x = bmp.getWidth() / 2;
@@ -680,8 +646,6 @@
public void onAttach(Context context) {
super.onAttach(context);
CEventCenter.onBindEvent(true, icEventListener, Constant.REAL_TIME_POS_CAR_TOPIC);
- CEventCenter.onBindEvent(true, rtcmicEventListener, Constant.BIND_RTCM_TOPIC);
- CEventCenter.onBindEvent(true, debugTxticEventListener, Constant.BIND_DEBUG_TXT);
CEventCenter.onBindEvent(true, speedListener, Constant.BIND_RTK_SPEED_TOPIC);
}
@@ -692,9 +656,86 @@
producer.shutdown();
consumer.shutdown();
CEventCenter.onBindEvent(false, icEventListener, Constant.REAL_TIME_POS_CAR_TOPIC);
- CEventCenter.onBindEvent(false, icEventListener, Constant.BIND_RTCM_TOPIC);
- CEventCenter.onBindEvent(false, icEventListener, Constant.BIND_DEBUG_TXT);
CEventCenter.onBindEvent(false, speedListener, Constant.BIND_RTK_SPEED_TOPIC);
}
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()){
+ case R.id.btn_reduce:
+
+ if (pixels < 5){
+ pixels = 5;
+ Toast.makeText(_mActivity, "宸茬粡鏄渶灏忎簡锛屼笉鑳藉啀灏忎簡", Toast.LENGTH_SHORT).show();
+ }else{
+ pixels -= 5;
+ }
+ break;
+ case R.id.btn_amplify:
+ if (pixels >80){
+ Toast.makeText(_mActivity, "宸茬粡鏄渶澶т簡", Toast.LENGTH_SHORT).show();
+ pixels = 80;
+ }else{
+ pixels+=5;
+ }
+ break;
+ }
+ }
+
+
+
+ void DrawArrows(Canvas canvas, int color, float arrowSize, float x1,
+ float y1, float x2, float y2) {
+ paint.setAntiAlias(true);
+ paint.setStyle(Paint.Style.STROKE);
+ paint.setColor(color);
+
+ // 鐢荤洿绾�
+ canvas.drawLine(x1, y1, x2, y2, paint);
+
+ // 绠ご涓殑绗竴鏉$嚎鐨勮捣鐐�
+ int x3 = 0;
+ int y3 = 0;
+
+ // 绠ご涓殑绗簩鏉$嚎鐨勮捣鐐�
+ int x4 = 0;
+ int y4 = 0;
+
+ double awrad = Math.atan(3.5 / 8);
+ double[] arrXY_1 = rotateVec(x2 - x1, y2 - y1, awrad, arrowSize);
+ double[] arrXY_2 = rotateVec(x2 - x1, y2 - y1, -awrad, arrowSize);
+
+ // 绗竴绔偣
+ Double X3 = Double.valueOf(x2 - arrXY_1[0]);
+ x3 = X3.intValue();
+ Double Y3 = Double.valueOf(y2 - arrXY_1[1]);
+ y3 = Y3.intValue();
+
+ // 绗簩绔偣
+ Double X4 = Double.valueOf(x2 - arrXY_2[0]);
+ x4 = X4.intValue();
+ Double Y4 = Double.valueOf(y2 - arrXY_2[1]);
+ y4 = Y4.intValue();
+
+ Path arrowsPath = new Path();
+ arrowsPath.moveTo(x2, y2);
+ arrowsPath.lineTo(x3, y3);
+ arrowsPath.lineTo(x4, y4);
+ arrowsPath.close();
+ canvas.drawLine(x3, y3, x2, y2, paint);
+ canvas.drawLine(x4, y4, x2, y2, paint);
+ }
+
+ private double[] rotateVec(float px, float py, double ang, double arrowSize) {
+ double mathstr[] = new double[2];
+ double vx = px * Math.cos(ang) - py * Math.sin(ang);
+ double vy = px * Math.sin(ang) + py * Math.cos(ang);
+ double d = Math.sqrt(vx * vx + vy * vy);
+ vx = vx / d * arrowSize;
+ vy = vy / d * arrowSize;
+ mathstr[0] = vx;
+ mathstr[1] = vy;
+ return mathstr;
+ }
+
}
--
Gitblit v1.8.0