| | |
| | | private int pixels = 80; |
| | | private boolean isDrawing = false; |
| | | private StringBuffer buffer = null;//存放地图的buffer |
| | | 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) { |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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 |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |