17如何使用SurfaceView计时绘点或线.doc17如何使用SurfaceView计时绘点或线.doc

收藏 分享

资源预览需要最新版本的Flash Player支持。
您尚未安装或版本过低,建议您

17如何使用SURFACEVIEW计时绘点或线大家常撰写VIEW的子类别,然后在其ONDRAW函数里绘出各式各样的图形,例如画出点或是直线。不过,基本上ONDRAW函数是在CANVAS画完所有线条等图形后,才一块儿将CANVAS显示出来。然而,当我们想再画出一些线条之后,停个几秒钟之后,才继续绘出后续的图形,这种有停顿的计时性绘图,又该如何呢例如,先绘出一条绿色线段停顿5秒钟之后,才画出一条黄色线段这时,使用SURFACEVIEW会是一个好方法。如下之范例程序代码/AC01JAVA/PACKAGECOMMISOOPPVV;IMPORTANDROIDAPPACTIVITY;IMPORTANDROIDOSBUNDLE;IMPORTANDROIDWIDGETLINEARLAYOUT;PUBLICCLASSAC01EXTENDSACTIVITY{OVERRIDEPROTECTEDVOIDONCREATEBUNDLEICICLE{SUPERONCREATEICICLE;MYSURFACEVIEWMVNULL;TRY{MVNEWMYSURFACEVIEWTHIS;}CATCHINTERRUPTEDEXCEPTIONE{EPRINTSTACKTRACE;}//LINEARLAYOUTLAYOUTNEWLINEARLAYOUTTHIS;LAYOUTSETORIENTATIONLINEARLAYOUTVERTICAL;LINEARLAYOUTLAYOUTPARAMSPARAMNEWLINEARLAYOUTLAYOUTPARAMS200,150;PARAMTOPMARGIN5;LAYOUTADDVIEWMV,PARAM;//SETCONTENTVIEWLAYOUT;}}/MYSURFACEVIEWJAVA/PACKAGECOMMISOOPPVV;IMPORTANDROIDCONTENTCONTEXT;IMPORTANDROIDGRAPHICSCOLOR;IMPORTANDROIDVIEWSURFACEHOLDER;IMPORTANDROIDVIEWSURFACEVIEW;CLASSMYSURFACEVIEWEXTENDSSURFACEVIEWIMPLEMENTSSURFACEHOLDERCALLBACK{SURFACEHOLDERMHOLDER;PRIVATEDRAWTHREADMTHREAD;PRIVATEDWLISTDWL;MYSURFACEVIEWCONTEXTCONTEXTTHROWSINTERRUPTEDEXCEPTION{SUPERCONTEXT;GETHOLDERADDCALLBACKTHIS;DWLNEWDWLIST;DWLBEGIN_RECORD;DWLRECORD30,30,0,0;DWLRECORD100,100,1,COLORGREEN;THREADSLEEP50;DWLRECORD100,30,1,COLORYELLOW;THREADSLEEP60;DWLRECORD30,30,1,COLORBLUE;THREADSLEEP40;DWLRECORD30,100,1,COLORRED;}PUBLICVOIDSURFACECREATEDSURFACEHOLDERHOLDER{MHOLDERHOLDER;MTHREADNEWDRAWTHREAD;MTHREADSTART;}PUBLICVOIDSURFACEDESTROYEDSURFACEHOLDERHOLDER{MTHREADNULL;}PUBLICVOIDSURFACECHANGEDSURFACEHOLDERHOLDER,INTFORMAT,INTW,INTH{}//CLASSDRAWTHREADEXTENDSTHREAD{DRAWTHREAD{SUPER;}OVERRIDEPUBLICVOIDRUN{DWLDRAWMHOLDER;}}}/DWLISTJAVA/PACKAGECOMMISOOPPVV;IMPORTJAVAUTILARRAYLIST;IMPORTJAVAUTILITERATOR;IMPORTANDROIDGRAPHICSCANVAS;IMPORTANDROIDGRAPHICSPAINT;IMPORTANDROIDVIEWSURFACEHOLDER;PUBLICCLASSDWLIST{PRIVATEPAINTPAINTNULL;PRIVATELONGDRAW_TIME;PRIVATEARRAYLISTDWPOINTPOLIST;PUBLICVOIDBEGIN_RECORD{DWPOINTINITIAL_TIMESYSTEMCURRENTTIMEMILLIS;POLISTCLEAR;}PUBLICVOIDRECORDINTX,INTY,INTTY,INTCOLOR{DWPOINTPONEWDWPOINTX,Y,TY,COLOR;POLISTADDPO;}PUBLICDWLIST{PAINTNEWPAINT;POLISTNEWARRAYLISTDWPOINT;}PUBLICVOIDDRAWSURFACEHOLDERHOLDER{DWPOINTPO;LONGCURR_TIME;LONGBASE_TIME0;INTNNN0;ITERATORDWPOINTITPOLISTITERATOR;WHILEITHASNEXT{POITNEXT;DRAW_TIMEPOM_TIMESPAN100;IFNNN0BASE_TIMESYSTEMCURRENTTIMEMILLIS;NNN;//WAITINGDO{CURR_TIMESYSTEMCURRENTTIMEMILLISBASE_TIME;}WHILECURR_TIMEDRAW_TIME;//PAINTHOLDER,NNN;}}PUBLICVOIDPAINTSURFACEHOLDERHOLDER,INTK{CANVASCANVASHOLDERLOCKCANVAS;DWPOINTPO;INTLASTX0;INTLASTY0;ITERATORDWPOINTITPOLISTITERATOR;FORINTI0;IK;I{POITNEXT;IFPOM_TYPE0{LASTXPOM_X;LASTYPOM_Y;}ELSE{PAINTSETCOLORPOM_COLOR;PAINTSETSTROKEWIDTH3;CANVASDRAWLINELASTX,LASTY,POM_X,POM_Y,PAINT;LASTXPOM_X;LASTYPOM_Y;}}HOLDERUNLOCKCANVASANDPOSTCANVAS;}}/DWPOINTJAVA/PACKAGECOMMISOOPPVV;PUBLICCLASSDWPOINT{PUBLICSTATICLONGINITIAL_TIME;PUBLICINTM_X,M_Y,M_TYPE;PUBLICLONGM_TIMESPAN;PUBLICINTM_COLOR;PUBLICDWPOINT{}PUBLICDWPOINTINTX,INTY,INTTY,INTCC{M_XX;M_YY;M_TYPETY;M_COLORCC;M_TIMESPANLONGSYSTEMCURRENTTIMEMILLISINITIAL_TIME;}}
编号:201312142342347820    类型:共享资源    大小:64.00KB    格式:DOC    上传时间:2013-12-14
  
3
关 键 词:
IS 电气 高压 110kv 220kv 550kv 800kv
  人人文库网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:17如何使用SurfaceView计时绘点或线.doc
链接地址:http://www.renrendoc.com/p-217820.html

当前资源信息

4.0
 
(2人评价)
浏览:10次
baixue100上传于2013-12-14

官方联系方式

客服手机:17625900360   
2:不支持迅雷下载,请使用浏览器下载   
3:不支持QQ浏览器下载,请用其他浏览器   
4:下载后的文档和图纸-无水印   
5:文档经过压缩,下载后原文更清晰   

精品推荐

相关阅读

人人文库
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服客服 - 联系我们

网站客服QQ:2846424093    人人文库上传用户QQ群:460291265   

[email protected] 2016-2018  renrendoc.com 网站版权所有   南天在线技术支持

经营许可证编号:苏ICP备12009002号-5