From dae6a3f73b39597ebbf55401aa4449c6ae5f7cd3 Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期五, 03 四月 2020 11:27:14 +0800
Subject: [PATCH]  修改科目二显示,左右边距

---
 app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java |   92 +++++++++++++++++++++++++++++-----------------
 1 files changed, 58 insertions(+), 34 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 c1277da..47f828a 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java
@@ -52,36 +52,7 @@
     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) {
@@ -675,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);
     }
 
@@ -687,8 +656,6 @@
         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
@@ -714,4 +681,61 @@
         }
     }
 
+
+
+    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