【Android】3.13 路径规划功能
分类:C#、Android、VS2015、百度地图应用; 创建日期:2016-02-04
一、简介
线路规划支持以下功能:
- 公交信息查询:可对公交详细信息进行查询;
- 公交换乘查询:根据起、终点,查询策略,进行线路规划方案;
- 驾车线路规划:提供不同策略,规划驾车路线;(支持设置途经点)
- 步行路径检索:支持步行路径的规划。
其中驾车线路规划自v3.4.0版本起支持多线路检索结果的能力。
二、运行截图
简介:介绍公交、驾车和步行三种线路规划方法和自设路线方法。
详述:
(1)驾车查询新增路径点查询功能,具体使用方法详见开发者指南路径规划部分,只需重载接口;
(2)自设路线功能演示开发者如何自己设定一条路线,包括如何设定起点、终点、途径站点和路段;
(3)自设路线功能同时也介绍如何在两个Activity之间切换的时候管理Mapview的生命周期;
(4)可自定义路线的起终点图标;
本示例运行截图如下:
三、设计步骤
1、添加自定义类【代码太多,就不再粘贴在这里了】
本示例用到的文件很多,主要涉及的是自定义覆盖物的相关类,这些文件都在SrcOverlayUtil文件夹下,除了上一节列出的OverlayManager.cs文件和PoiOverlay.cs外,还包括下面的文件。
(1)BikingRouteOverlay.cs文件
用于显示骑行路线的Overlay,自3.4.0版本起可实例化多个添加在地图中显示。
(2)BusLineOverlay.cs文件
用于显示一条公交详情结果的Overlay。
(3)DrivingRouteOverlay.cs文件
用于显示一条驾车路线的overlay,自3.4.0版本起可实例化多个添加在地图中显示,当数据中包含路况数据时,则默认使用路况纹理分段绘制。
(4)TransitRouteOverlay.cs文件
用于显示换乘路线的Overlay,自3.4.0版本起可实例化多个添加在地图中显示。
(5)WalkingRouteOverlay.cs文件
用于显示步行路线的overlay,自3.4.0版本起可实例化多个添加在地图中显示。
2、添加demo13_routeplan.xml文件
在layout文件夹下添加该文件,然后将代码改为下面的内容:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="起点:" />
<EditText
android:id="@+id/start"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="龙泽" >
<requestFocus />
</EditText>
</LinearLayout> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="终点:" />
<EditText
android:id="@+id/end"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="西单" >
<requestFocus />
</EditText>
</LinearLayout> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:orientation="horizontal" >
<Button
android:id="@+id/drive"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:layout_weight="1.0"
android:background="@drawable/button_style"
android:text="驾车搜索" />
<Button
android:id="@+id/transit"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:layout_weight="1.0"
android:background="@drawable/button_style"
android:text="公交搜索" />
<Button
android:id="@+id/walk"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:layout_weight="1.0"
android:background="@drawable/button_style"
android:text="步行搜索" />
<Button
android:id="@+id/bike"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:layout_weight="1.0"
android:background="@drawable/button_style"
android:text="骑行搜索" />
</LinearLayout> <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <com.baidu.mapapi.map.TextureMapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true" /> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="false"
android:layout_marginRight="10dp"
android:layout_marginTop="10dip"
android:orientation="vertical" >
<Button
android:id="@+id/customicon"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dip"
android:layout_weight="1.0"
android:background="@drawable/button_style"
android:text="自定义起终点图标" />
</LinearLayout> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignWithParentIfMissing="false"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginBottom="10dip" > <Button
android:id="@+id/pre"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:layout_weight="1.0"
android:background="@drawable/pre_" /> <Button
android:id="@+id/next"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:layout_weight="1.0"
android:background="@drawable/next_" />
</LinearLayout>
</RelativeLayout> </LinearLayout>
3、添加Demo13RoutePlan.cs文件
在SrcSdkDemos文件夹下添加该文件,然后将代码改为下面的内容:
using Android.App;
using Android.Content.PM;
using Android.OS;
using Android.Views;
using Android.Widget;
using Com.Baidu.Mapapi.Map;
using Com.Baidu.Mapapi.Model;
using Com.Baidu.Mapapi.Search.Core;
using Com.Baidu.Mapapi.Search.Route;
using BdMapV371Demos.SrcOverlayUtil; namespace BdMapV371Demos.SrcSdkDemos
{
/// <summary>
///此demo用来展示如何进行驾车、步行、公交路线搜索并在地图使用RouteOverlay、TransitOverlay绘制,
///同时展示如何进行节点浏览并弹出泡泡。
/// </summary>
[Activity(Label = "@string/demo_name_route",
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.KeyboardHidden,
ScreenOrientation = ScreenOrientation.Sensor)]
public class Demo13RoutePlan : Activity
{
//浏览路线节点相关
Button btnPre = null;//上一个节点
Button btnNext = null;//下一个节点
int nodeIndex = -;//节点索引,供浏览节点时使用
RouteLine route = null;
OverlayManager routeOverlay = null;
bool useDefaultIcon = false;
private TextView popupText = null;//泡泡view //地图相关,使用MyRouteMapView目的是重写touch事件实现泡泡处理。
//如果不处理touch事件,则无需继承,直接使用TextureMapView即可。
TextureMapView mMapView = null; // 地图View
BaiduMap mBaidumap = null;
//搜索相关
RoutePlanSearch mSearch = null; // 搜索模块,也可去掉地图模块独立使用 protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.demo13_routeplan); //初始化地图
mMapView = FindViewById<TextureMapView>(Resource.Id.map);
mBaidumap = mMapView.Map; btnPre = FindViewById<Button>(Resource.Id.pre);
btnNext = FindViewById<Button>(Resource.Id.next);
btnPre.Visibility = ViewStates.Invisible;
btnNext.Visibility = ViewStates.Invisible; //处理地图点击事件
mBaidumap.MapClick += (s, e) =>
{
//LatLng point = e.P0;
//Toast.MakeText(this, point.ToString(), ToastLength.Long).Show();
mBaidumap.HideInfoWindow();
}; //--begin--初始化搜索模块,注册处理事件
mSearch = RoutePlanSearch.NewInstance();
//处理驾车搜索结果
mSearch.GetDrivingRouteResult += (s, e) =>
{
var result = e.P0;
if (result == null || result.Error != SearchResult.ERRORNO.NoError)
{
Toast.MakeText(this, "抱歉,未找到结果", ToastLength.Short).Show();
}
if (result.Error == SearchResult.ERRORNO.AmbiguousRoureAddr)
{
//起终点或途经点地址有岐义,通过result.SuggestAddrInfo属性获取建议查询信息
//......
return;
}
if (result.Error == SearchResult.ERRORNO.NoError)
{
nodeIndex = -;
btnPre.Visibility = ViewStates.Visible;
btnNext.Visibility = ViewStates.Visible;
route = result.RouteLines[];
DrivingRouteOverlay overlay = new MyDrivingRouteOverlay(this, mBaidumap);
routeOverlay = overlay;
mBaidumap.MarkerClick += (sender, args) =>
{
//......
};
overlay.SetData(result.RouteLines[]);
overlay.AddToMap();
overlay.ZoomToSpan();
}
};
//处理公交搜索结果
mSearch.GetTransitRouteResult += (s,e) =>
{
var result = e.P0;
if (result == null || result.Error != SearchResult.ERRORNO.NoError)
{
Toast.MakeText(this, "抱歉,未找到结果", ToastLength.Short).Show();
}
if (result.Error == SearchResult.ERRORNO.AmbiguousRoureAddr)
{
//起终点或途经点地址有岐义,通过以下接口获取建议查询信息
//result.getSuggestAddrInfo()
return;
}
if (result.Error == SearchResult.ERRORNO.NoError)
{
nodeIndex = -;
btnPre.Visibility = ViewStates.Visible;
btnNext.Visibility = ViewStates.Visible;
route = result.RouteLines[];
TransitRouteOverlay overlay = new MyTransitRouteOverlay(this, mBaidumap);
mBaidumap.MarkerClick += (sender, args) =>
{
//......
};
routeOverlay = overlay;
overlay.SetData(result.RouteLines[]);
overlay.AddToMap();
overlay.ZoomToSpan();
}
};
//处理步行搜索结果
mSearch.GetWalkingRouteResult += (s, e) =>
{
var result = e.P0;
if (result == null || result.Error != SearchResult.ERRORNO.NoError)
{
Toast.MakeText(this, "抱歉,未找到结果", ToastLength.Short).Show();
}
if (result.Error == SearchResult.ERRORNO.AmbiguousRoureAddr)
{
//起终点或途经点地址有岐义,通过以下接口获取建议查询信息
//result.getSuggestAddrInfo()
return;
}
if (result.Error == SearchResult.ERRORNO.NoError)
{
nodeIndex = -;
btnPre.Visibility = ViewStates.Visible;
btnNext.Visibility = ViewStates.Visible;
route = result.RouteLines[];
WalkingRouteOverlay overlay = new MyWalkingRouteOverlay(this, mBaidumap);
mBaidumap.MarkerClick += (sender, args) =>
{
//......
};
routeOverlay = overlay;
overlay.SetData(result.RouteLines[]);
overlay.AddToMap();
overlay.ZoomToSpan();
}
};
//处理骑行搜索结果
mSearch.GetBikingRouteResult += (s, e) =>
{
var result = e.P0;
if (result == null || result.Error != SearchResult.ERRORNO.NoError)
{
Toast.MakeText(this, "抱歉,未找到结果", ToastLength.Short).Show();
}
if (result.Error == SearchResult.ERRORNO.AmbiguousRoureAddr)
{
// 如果起终点或途经点地址有岐义,可通过result.SuggestAddrInfo属性获取建议查询信息
//......
return;
}
if (result.Error == SearchResult.ERRORNO.NoError)
{
nodeIndex = -;
btnPre.Visibility = ViewStates.Visible;
btnNext.Visibility = ViewStates.Visible;
route = result.RouteLines[];
BikingRouteOverlay overlay = new MyBikingRouteOverlay(this, mBaidumap);
routeOverlay = overlay;
mBaidumap.MarkerClick += (sender, args) =>
{
//......
};
overlay.SetData(result.RouteLines[]);
overlay.AddToMap();
overlay.ZoomToSpan();
}
};
//--end--初始化搜索模块,注册监听事件 //处理【驾车搜素】按钮点击事件
var btnDrive = FindViewById<Button>(Resource.Id.drive);
btnDrive.Click += delegate
{
SearchButtonProcess(Resource.Id.drive);
}; //处理【公交搜素】按钮点击事件
var btnTransit = FindViewById<Button>(Resource.Id.transit);
btnTransit.Click += delegate
{
SearchButtonProcess(Resource.Id.transit);
}; //处理【步行搜素】按钮点击事件
var btnWalk = FindViewById<Button>(Resource.Id.walk);
btnWalk.Click += delegate
{
SearchButtonProcess(Resource.Id.walk);
}; //处理【骑行搜素】按钮点击事件
var btnBike = FindViewById<Button>(Resource.Id.bike);
btnBike.Click += delegate
{
SearchButtonProcess(Resource.Id.bike);
}; //处理【自定义起终点图标】按钮点击事件
var btnCustomicon = FindViewById<Button>(Resource.Id.customicon);
btnCustomicon.Click += delegate
{
//切换路线图标,刷新地图使其生效。注意:起终点图标使用中心对齐。
if (routeOverlay == null) return;
if (useDefaultIcon)
{
btnCustomicon.Text = "自定义起终点图标";
Toast.MakeText(this,"将使用系统起终点图标", ToastLength.Short).Show();
}
else
{
btnCustomicon.Text = "系统起终点图标";
Toast.MakeText(this, "将使用自定义起终点图标", ToastLength.Short).Show();
}
useDefaultIcon = !useDefaultIcon;
routeOverlay.RemoveFromMap();
routeOverlay.AddToMap();
}; //处理节点浏览相关的按钮事件
btnPre.Click += delegate
{
NodeClick(Resource.Id.pre);
};
btnNext.Click += delegate
{
NodeClick(Resource.Id.next);
};
} /// <summary>
/// 发起路线规划搜索
/// </summary>
/// <param name="id">按钮的id</param>
public void SearchButtonProcess(int id)
{
//重置浏览节点的路线数据
route = null;
btnPre.Visibility = ViewStates.Invisible;
btnNext.Visibility = ViewStates.Invisible;
mBaidumap.Clear();
// 处理搜索按钮响应示例
EditText editSt = FindViewById<EditText>(Resource.Id.start);
EditText editEn = FindViewById<EditText>(Resource.Id.end);
//设置起终点信息,对于tranist search 来说,城市名无意义
PlanNode stNode = PlanNode.WithCityNameAndPlaceName("北京", editSt.Text);
PlanNode enNode = PlanNode.WithCityNameAndPlaceName("北京", editEn.Text); // 实际使用中请对起点终点城市进行正确的设定
if (id == Resource.Id.drive)
{
mSearch.DrivingSearch(new DrivingRoutePlanOption()
.From(stNode).To(enNode));
}
else if (id == Resource.Id.transit)
{
mSearch.TransitSearch(new TransitRoutePlanOption()
.From(stNode).City("北京").To(enNode));
}
else if (id == Resource.Id.walk)
{
mSearch.WalkingSearch(new WalkingRoutePlanOption()
.From(stNode).To(enNode));
}
else if (id == Resource.Id.bike)
{
mSearch.BikingSearch(new BikingRoutePlanOption()
.From(stNode).To(enNode));
}
} /// <summary>
/// 节点浏览示例
/// </summary>
/// <param name="id">按钮的id</param>
public void NodeClick(int id)
{
if (nodeIndex < - || route == null ||
route.AllStep == null || nodeIndex > route.AllStep.Count)
{
return;
}
//设置节点索引
if (id == Resource.Id.next && nodeIndex < route.AllStep.Count - )
{
nodeIndex++;
}
else if (id == Resource.Id.pre && nodeIndex > )
{
nodeIndex--;
}
if (nodeIndex < || nodeIndex >= route.AllStep.Count)
{
return;
} //获取节结果信息
LatLng nodeLocation = null;
string nodeTitle = null;
var step = route.AllStep[nodeIndex];
if (step is DrivingRouteLine.DrivingStep)
{
nodeLocation = ((DrivingRouteLine.DrivingStep)step).Entrance.Location;
nodeTitle = ((DrivingRouteLine.DrivingStep)step).Instructions;
}
else if (step is WalkingRouteLine.WalkingStep)
{
nodeLocation = ((WalkingRouteLine.WalkingStep)step).Entrance.Location;
nodeTitle = ((WalkingRouteLine.WalkingStep)step).Instructions;
}
else if (step is TransitRouteLine.TransitStep)
{
nodeLocation = ((TransitRouteLine.TransitStep)step).Entrance.Location;
nodeTitle = ((TransitRouteLine.TransitStep)step).Instructions;
} if (nodeLocation == null || nodeTitle == null)
{
return;
}
//移动节点至中心
mBaidumap.SetMapStatus(MapStatusUpdateFactory.NewLatLng(nodeLocation));
// Show popup
popupText= new TextView(this);
popupText.SetBackgroundResource(Resource.Drawable.popup);
popupText.SetTextColor(Android.Graphics.Color.Black);
popupText.Text = nodeTitle;
mBaidumap.ShowInfoWindow(new InfoWindow(popupText, nodeLocation, ));
} protected override void OnRestoreInstanceState(Bundle savedInstanceState)
{
base.OnRestoreInstanceState(savedInstanceState);
} //定制RouteOverly
private class MyDrivingRouteOverlay : DrivingRouteOverlay
{
Demo13RoutePlan routePlanDemo; public MyDrivingRouteOverlay(Demo13RoutePlan routePlanDemo, BaiduMap baiduMap) :
base(baiduMap)
{
this.routePlanDemo = routePlanDemo;
} public override BitmapDescriptor GetStartMarker()
{
if (routePlanDemo.useDefaultIcon)
{
return BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_st);
}
return null;
} public override BitmapDescriptor GetTerminalMarker()
{
if (routePlanDemo.useDefaultIcon)
{
return BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_en);
}
return null;
}
} private class MyWalkingRouteOverlay : WalkingRouteOverlay
{
Demo13RoutePlan routePlanDemo;
public MyWalkingRouteOverlay(Demo13RoutePlan routePlanDemo, BaiduMap baiduMap) :
base(baiduMap)
{
this.routePlanDemo = routePlanDemo;
} public new BitmapDescriptor GetStartMarker()
{
if (routePlanDemo.useDefaultIcon)
{
return BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_st);
}
return null;
} public new BitmapDescriptor GetTerminalMarker()
{
if (routePlanDemo.useDefaultIcon)
{
return BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_en);
}
return null;
}
} private class MyTransitRouteOverlay : TransitRouteOverlay
{
Demo13RoutePlan routePlanDemo; public MyTransitRouteOverlay(Demo13RoutePlan routePlanDemo, BaiduMap baiduMap) :
base(baiduMap)
{
this.routePlanDemo = routePlanDemo;
} public override BitmapDescriptor GetStartMarker()
{
if (routePlanDemo.useDefaultIcon)
{
return BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_st);
}
return null;
} public override BitmapDescriptor GetTerminalMarker()
{
if (routePlanDemo.useDefaultIcon)
{
return BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_en);
}
return null;
}
} private class MyBikingRouteOverlay : BikingRouteOverlay
{
Demo13RoutePlan routePlanDemo;
public MyBikingRouteOverlay(Demo13RoutePlan routePlanDemo, BaiduMap baiduMap) : base(baiduMap)
{
this.routePlanDemo = routePlanDemo;
} public new BitmapDescriptor GetStartMarker()
{
if (routePlanDemo.useDefaultIcon)
{
return BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_st);
}
return null;
} public new BitmapDescriptor GetTerminalMarker()
{
if (routePlanDemo.useDefaultIcon)
{
return BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_en);
}
return null;
}
} protected override void OnPause()
{
mMapView.OnPause();
base.OnPause();
} protected override void OnResume()
{
mMapView.OnResume();
base.OnResume();
} protected override void OnDestroy()
{
mSearch.Destroy();
mMapView.OnDestroy();
base.OnDestroy();
}
}
}
4、修改MainActivity.cs
在MainActivity.cs文件的demos字段定义中,去掉【示例13】下面的注释。
运行观察结果。
【Android】3.13 路径规划功能的更多相关文章
- 如何用HMS Core位置和地图服务实现附近地点路径规划功能
日常出行中,路径规划是很重要的部分.用户想要去往某个地点,获取到该地点的所有路径,再根据预估出行时间自行选择合适的路线,极大方便出行.平时生活中也存在大量使用场景,在出行类App中,根据乘客的目的地可 ...
- 【BZOJ-3627】路径规划 分层图 + Dijkstra + spfa
3627: [JLOI2014]路径规划 Time Limit: 30 Sec Memory Limit: 128 MBSubmit: 186 Solved: 70[Submit][Status] ...
- 机器人自主移动的秘密:SLAM与路径规划有什么关系?(三)
博客转载自:https://www.leiphone.com/news/201612/lvDXqY82OGNqEiyl.html 雷锋网(公众号:雷锋网)按:本文作者SLAMTEC(思岚科技公号sla ...
- BZOJ3627: [JLOI2014]路径规划
BZOJ3627: [JLOI2014]路径规划 Description 相信大家都用过地图上的路径规划功能,只要输入起点终点就能找出一条最优路线.现在告诉你一张地图的信息,请你找出最优路径(即最短路 ...
- 【路径规划】 Optimal Trajectory Generation for Dynamic Street Scenarios in a Frenet Frame (附python代码实例)
参考与前言 2010年,论文 Optimal Trajectory Generation for Dynamic Street Scenarios in a Frenet Frame 地址:https ...
- 基础路径规划算法(Dijikstra、A*、D*)总结
引言 在一张固定地图上选择一条路径,当存在多条可选的路径之时,需要选择代价最小的那条路径.我们称这类问题为最短路径的选择问题.解决这个问题最经典的算法为Dijikstra算法,其通过贪心选择的步骤从源 ...
- Unity路径规划
Unity路径规划 转自:http://www.cnblogs.com/zsb517/p/4090629.html 背景 酷跑游戏中涉及到弯道.不规则道路. 找来一些酷跑游戏的案例来看,很多都是只有 ...
- ROS探索总结(十四)——move_base(路径规划)
在上一篇的博客中,我们一起学习了ROS定位于导航的总体框架,这一篇我们主要研究其中最重要的move_base包. 在总体框架图中可以看到,move_base提供了ROS导航的配置.运行.交互接口,它主 ...
- 全局路径规划算法Dijkstra(迪杰斯特拉算法)- matlab
参考博客链接:https://www.cnblogs.com/kex1n/p/4178782.html Dijkstra是常用的全局路径规划算法,其本质上是一个最短路径寻优算法.算法的详细介绍参考上述 ...
随机推荐
- Appium Python 二:理论概念理解
简介 Appium 是一个开源的自动化测试工具,支持 iOS 平台和 Android 平台上的原生应用,web 应用和混合应用. “移动原生应用”是指那些用 iOS 或者 Android SDK 写的 ...
- HTML5 坦克大战
代码 点击打开链接
- 策略模式(Strategy)简介
一.策略模式(Strategy)简介 策略模式是行为模式. 行为模式:规定了各个对象应该具备的职责以及对象间的通信模式,它很好的规范了对象间调用和数据传递方式 策略模式适合于算法经常变化的情况 算法的 ...
- 虚拟机stack全分析
通过jps -lv 获取到本地的一个JVM实例进程.再通过jstack pid > thread.txt ,把stack trace输出到thread.txt文件中. 2012-08-28 2 ...
- 转:StdRegProv类所属方法的使用
在root\default命名空间中的StdRegProv类(标准注册表提供程序)提供了下面16种方法,我们将陆续介绍这些方法的使用规则,并给出分别用WBscript和Powershell编写的例子. ...
- JS获取浏览器高宽度,屏幕分辨率和一些定位空隙等
IE中: document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 document.d ...
- 微信小程序裁剪图片成圆形
代码地址如下:http://www.demodashi.com/demo/14453.html 前言 最近在开发小程序,产品经理提了一个需求,要求微信小程序换头像,用户剪裁图片必须是圆形,也在gith ...
- 社区类 App 如何引导用户发帖和产生内容?
作者:Pmer在路上链接:http://www.zhihu.com/question/25502904/answer/31342246来源:知乎著作权归作者所有,转载请联系作者获得授权. ugc的产出 ...
- 如何在Win8中设置虚拟热点共享上网(转)
摘自:http://www.enet.com.cn/article/2013/0408/A20130408273749.shtml 在Windows 7中,我们可以通过网络与共享中心的“设置新的连接和 ...
- HDUOJ----1114(多重背包)悼念512汶川大地震遇难同胞——珍惜现在,感恩生活
悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...