| | |
| | | } |
| | | |
| | | /** |
| | | * 创建随机位置 |
| | | * 创建一个随机位置 坐标限制在 x 和 y内 |
| | | * @param maxX |
| | | * @param maxY |
| | | * @return |
| | | */ |
| | | public Point random(int maxX,int maxY){ |
| | | //设计边框距离,已避免部分地点名称出界 |
| | | int marginX = (int) (getResources().getDisplayMetrics() .density*15)*2; |
| | | Point point = new Point(); |
| | | |
| | |
| | | } |
| | | |
| | | int index = 0 ; |
| | | ArrayList<ArrayList<PathPlan.Place>> customLists; |
| | | ArrayList<ArrayList<PathPlan.Place>> customLists = new ArrayList<>(); |
| | | /** |
| | | * 自定义算法画线 |
| | | * @param view |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 自定义算法画线 |
| | | */ |
| | | public void drawLineCustome(){ |
| | | if(customLists.size()>1){ |
| | | Toast.makeText(MainActivity.this,"当前有"+customLists.size()+"路线规划",Toast.LENGTH_SHORT).show(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 刷新 重新加载地点 |
| | | * @param view |
| | | */ |
| | | public void refresh(View view) { |
| | | planPathView.clear(); |
| | | customLists.clear(); |
| | | int width = planPathView.getWidth(); |
| | | int height = planPathView.getHeight(); |
| | | ArrayList<PathPlan.Place> places = new ArrayList<>(); |
| | | places.add(new PathPlan.Place("A",random(width,height),0)); |
| | | places.add(new PathPlan.Place("B",random(width,height),0)); |
| | | places.add(new PathPlan.Place("C",random(width,height),0)); |
| | | places.add(new PathPlan.Place("D",random(width,height),0)); |
| | | places.add(new PathPlan.Place("E",random(width,height),0)); |
| | | places.add(new PathPlan.Place("F",random(width,height),0)); |
| | | places.add(new PathPlan.Place("G",random(width,height),0)); |
| | | places.add(new PathPlan.Place("H",random(width,height),0)); |
| | | animD = false; |
| | | animC = false; |
| | | planPathView.setAnimPoints(randomList(width,height),listener); |