首页 文章 精选 留言 我的

精选列表

搜索[自动化研究],共10000篇文章
优秀的个人博客,低调大师

JPDA 架构研究21 - JDI的Debugger的UI部分

引入: 前面揭示了JDI的Debugger如何建立连接,发送和处理请求,这里我们专注于人机交互部分,Debugger的UI,它主要负责如何把人发出的操作转为请求,以及把请求操作反映在调试器的界面上。 分析: 这个插件主要都定义在org.eclipse.jdt.debug.ui_<Version>.jar中的plugin.xml中,它提供了各种人机交互的插件功能。打的比方,我们看编辑器功能: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 < extension point = "org.eclipse.ui.editorActions" > < editorContribution targetID = "org.eclipse.jdt.ui.CompilationUnitEditor" id = "org.eclipse.jdt.debug.CompilationUnitEditor.BreakpointRulerActions" > < action label = "%AddBreakpoint.label" class = "org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate" actionID = "RulerDoubleClick" id = "org.eclipse.jdt.debug.ui.actions.ManageBreakpointRulerAction" > </ action > </ editorContribution > < editorContribution targetID = "org.eclipse.jdt.ui.ClassFileEditor" id = "org.eclipse.jdt.debug.ClassFileEditor.BreakpointRulerActions" > < action label = "%AddBreakpoint.label" class = "org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate" actionID = "RulerDoubleClick" id = "org.eclipse.jdt.debug.ui.actions.ManageBreakpointRulerAction" > </ action > </ editorContribution > < editorContribution targetID = "org.eclipse.jdt.debug.ui.SnippetEditor" id = "org.eclipse.jdt.debug.ui.JavaSnippetToolbarActions" > < action toolbarPath = "evaluationGroup" id = "org.eclipse.jdt.debug.ui.SnippetExecute" hoverIcon = "$nl$/icons/full/etool16/run_sbook.gif" class = "org.eclipse.jdt.internal.debug.ui.actions.ExecuteAction" disabledIcon = "$nl$/icons/full/dtool16/run_sbook.gif" enablesFor = "+" icon = "$nl$/icons/full/etool16/run_sbook.gif" helpContextId = "execute_action_context" label = "%Execute.label" tooltip = "%Execute.tooltip" > < selection class = "org.eclipse.jface.text.ITextSelection" > </ selection > </ action > < action toolbarPath = "evaluationGroup" id = "org.eclipse.jdt.debug.ui.SnippetDisplay" hoverIcon = "$nl$/icons/full/etool16/disp_sbook.gif" class = "org.eclipse.jdt.internal.debug.ui.actions.PopupDisplayAction" disabledIcon = "$nl$/icons/full/dtool16/disp_sbook.gif" enablesFor = "+" icon = "$nl$/icons/full/etool16/disp_sbook.gif" helpContextId = "display_action_context" label = "%Display.label" tooltip = "%Display.tooltip" > < selection class = "org.eclipse.jface.text.ITextSelection" > </ selection > </ action > < action toolbarPath = "evaluationGroup" id = "org.eclipse.jdt.debug.ui.SnippetInspect" hoverIcon = "$nl$/icons/full/etool16/insp_sbook.gif" class = "org.eclipse.jdt.internal.debug.ui.actions.PopupInspectAction" disabledIcon = "$nl$/icons/full/dtool16/insp_sbook.gif" enablesFor = "+" icon = "$nl$/icons/full/etool16/insp_sbook.gif" helpContextId = "inspect_action_context" label = "%Inspect.label" tooltip = "%Inspect.tooltip" > < selection class = "org.eclipse.jface.text.ITextSelection" > </ selection > </ action > </ editorContribution > </ extension > 从这里看出,它支持好几个操作:如CompilationUnitEditor的打断点 ,ClassFileEditor的打断点等。 每个操作都有用到的图标,用到的action响应类等,有兴趣的可以看下。 本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/1588681,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android Shape渲染的使用(经典,学习研究不后悔)

感觉好久都没有写博文了,感觉自己变懒了,真对不起…-_-… 也有部分原因是因为我想写的东 西网上已经有了,再加上还有很多方面小马我也正在学习,所以….这段时间一直暂停更新我的博客文 章,看到博客的访问量一天天的增加,很开心 。。。O_O。。。这一阵子也看了各种各样的书籍,技 术类的、非技术类的,也找到了自身很多的不足之处,我会用更多的心思来弥补不足,希望大家一起 努力、加油! 以上是对自己讲的一点废话,现在开始今天的主题,控件渲染Shade(也可以叫着色器,但坏小 马不喜欢这么叫,着色器….怪怪的!)的使用,一直都有在关注这方面的东西,网上也有部分文章写 得不错,但是还是觉得不过瘾,往往都是写一点点自己在工作中使用过的,今天小马就用点心总结下 这方面的东西,希望对这块知识有兴趣的帅果、美驴们有所帮助或提高,果断先看效果再一步步看代 码!希望大家仔细看看我在XML及.java中添加的注释,相信你不会后悔花时间在这文章上的,今天的 DEMO效果图如下: 好了,效果看完了,下一步开始看代码吧,亲…….静下心….一步步来!!! PS:模拟器与eclipse效果中预览的以下部分有点不一样,可能是eclipse与模拟器二者之前存在Bug吧…吼吼…. 工程目录如下: 首先,先做个小小的铺垫: Android提供的Shader类主要是渲染图像以及一些几何图形。 Shader有几个直接子类: BitmapShader :主要用来渲染图像 LinearGradient :用来进行线性渲染 RadialGradient :用来进行环形渲染 SweepGradient :扫描渐变---围绕一个中心点扫描渐变就像电影里那种雷达扫描,用来梯度渲染。 ComposeShader :组合渲染,可以和其他几个子类组合起来使用。 小记:Android控件渲染Shade的实现方式有两种,(一、JAVA代码实现;二、XML配置来实现), 小马自己比较偏向XML实现,原因很简单: 1.你代码实现写得再经典,不跑起来效果看不到! 2.跑一遍Android模拟器,思路可以断一大节!(我很笨,经常这样 T_T)! 3.JAVA代码的每个函数参数你也得一个个去啃(老板管效率,不管怎么实现,等你啃完参数时,XML已经看到效果了 O_o ……走起…..)! 4,这是最主要的一点,Eclipse或者I/O大会刚推出的Android Studio,实时显示,我就特别 喜欢立竿见影 ^_^ ! 5.二者各有利弊,JAVA代码实现可以动态且灵活滴,XML配置的统一但不杂乱 @_@!! Now…….. Ladies and乡亲们,看举一种JAVA代码excmple,其余类型的与之类似,亲们自己“度娘 、谷哥 ”: LinearGradient是线性渐变,用法如下: Gradient是基于Shader类,所以我们通过Paint的setShader方法来设置这个渐变,代码如下: Paint p=new Paint(); LinearGradient lg=newLinearGradien(0,0,100,100,Color.RED,Color.BLUE,Shader.TileMode.MIRROR); Gradient是基于Shader类,所以我们通过Paint的setShader方法来设置这个渐变,代码如下: p.setShader(lg); canvas.drawCicle(0,0,200,p); //参数3为画圆的半径,类型为float型。 先不说效果了,PS:看着上面的代码,有没有想哭的冲动啊 ? ? ?感觉乱乱的,不知道是什么,然后单词gradient不懂,一查如下(晕),看着挺牛,还是只是个渲染!不管了,继续往下看… 再看XML配置代码,如下: 一:主布局文件代码如下(为了方便,布局是直接拖的,大家不用太关注): 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 < RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android" xmlns:tools = "http://schemas.android.com/tools" android:layout_width = "match_parent" android:layout_height = "match_parent" android:background = "@drawable/background" android:paddingBottom = "@dimen/activity_vertical_margin" android:paddingLeft = "@dimen/activity_horizontal_margin" android:paddingRight = "@dimen/activity_horizontal_margin" android:paddingTop = "@dimen/activity_vertical_margin" tools:context = ".MainActivity" > < com.xiaoma.shadedemo.TextViewBorder android:id = "@+id/textView1" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_alignParentLeft = "true" android:layout_alignParentTop = "true" android:layout_marginLeft = "22dp" android:layout_marginTop = "20dp" android:text = " JAVA实现带四条边框" android:textColor = "@android:color/white" android:textSize = "25sp" /> < com.xiaoma.shadedemo.TextViewBorderLeftRight android:id = "@+id/TextViewBorder01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:textColor = "@android:color/white" android:layout_alignLeft = "@+id/textView1" android:layout_below = "@+id/textView1" android:layout_marginTop = "20dp" android:text = "JAVA实现带左右边框" android:textSize = "25sp" /> < com.xiaoma.shadedemo.TextViewBorderUnder android:id = "@+id/TextViewBorder02" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_alignLeft = "@+id/TextViewBorder01" android:textColor = "@android:color/white" android:layout_below = "@+id/TextViewBorder01" android:layout_marginTop = "33dp" android:text = "JAVA代码实现下边框" android:textSize = "25sp" /> < TextView android:id = "@+id/TextViewBorderUnder01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_alignLeft = "@+id/button1" android:layout_below = "@+id/TextViewBorder02" android:layout_marginTop = "20dp" android:text = "Shape XML实现边框" android:background = "@drawable/shape_test" android:textColor = "@android:color/white" android:textSize = "25sp" /> < Button android:id = "@+id/button1" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_alignLeft = "@+id/TextViewBorder02" android:layout_below = "@+id/TextViewBorderUnder01" android:layout_marginTop = "29dp" android:background = "@drawable/shape_selector" android:text = "Selector与Shape混用按钮" android:textColor = "@android:color/black" /> </ RelativeLayout > 二:上面布局中使用的自定义控件代码及Shape渲染代码分别如下: 2.1:JAVA实现带四条边框(自定义TextView JAVA代码一) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 package com.xiaoma.shadedemo; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.AttributeSet; import android.widget.TextView; public class TextViewBorder extends TextView { /** * 下面两个方法在构造时需注意: 一:如果是XML文件加载的方式使用自定义控件到布局中是用以下方式, 二:如果是用纯代码的方式加载自定义的控制到而已中时用第二种方式 */ // 方式一: public TextViewBorder(Context context, AttributeSet attrs) { super (context, attrs); } // 方式二: /* * public TextViewBorder(Context context) { // TODO Auto-generated constructor stub super(context); } */ /** * 1. Rect对象 一个区域对象Rect(left, top, right, bottom) , 是一个左闭右开的区域, 即是说使用 Rect.contains(left, top)为true, * Rect.contains(right, bottom)为false 2. drawLine方法 drawLine(float startX, float startY, float stopX, float stopY, * Paint paint) 也是一个左闭右开的区间,只会绘制到stopX-1,stopY-1 3. drawRect(Rect r, Paint paint) 当绘制空心矩形时,绘制的是一个左闭右闭的区域 * 验证方法:下面就是可以验证左闭右开的区间方法,现在知道为什么要-1 了 */ @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.GREEN); canvas.drawLine(0, 0, this.getWidth() - 1, 0, paint);// 绘制上边框 canvas.drawLine(0, 0, 0, this.getHeight() - 1, paint); // 绘制左边框 canvas.drawLine(this.getWidth() - 1, 0, this.getWidth() - 1, this.getHeight() - 1, paint); // 绘制右边框 canvas.drawLine(0, this.getHeight() - 1, this.getWidth() - 1, this.getHeight() - 1, paint);// 绘制下边框 } /* * 1. Rect对象 * * 一个区域对象Rect(left, top, right, bottom) , 是一个左闭右开的区域,即是说使用 Rect.contains(left, top)为true, Rect.contains(right, * bottom)为false * * 2.drawLine方法 * * drawLine(float startX, float startY, float stopX, float stopY, Paint paint) 也是一个左闭右开的区间,只会绘制到stopX-1,stopY-1 * * 验证方法: * * Canvas c = canvas; paint.setColor(Color.RED); c.drawLine(x, y, x+c.getWidth()-1, y, paint); c.drawLine(x, * y+height-1, x+c.getWidth(), y+height-1, paint); paint.setColor(Color.BLUE); c.drawPoint(x+c.getWidth()-1, y, * paint); 说明drawLine是没有绘制到右边最后一个点的 * * 3.drawRect(Rect r, Paint paint) * * 当绘制空心矩形时,绘制的是一个左闭右闭的区域 * * 验证方法: * * rect.set(x, y, x+width, y+height); paint.setStyle(Style.STROKE); paint.setColor(Color.BLUE); c.drawRect(rect, * paint); paint.setColor(Color.RED); c.drawLine(x, y, x+width, y, paint); c.drawLine(x, y+height, x+width, * y+height, paint); c.drawLine(x, y, x, y+height, paint); c.drawLine(x+width, y, x+width, y+height, paint); * 当绘制实心矩形时,绘制的是一个左闭右开的区域 * * 验证方法: * * rect.set(x, y, x+width, y+height); paint.setColor(Color.RED); c.drawLine(x, y, x+width, y, paint); c.drawLine(x, * y+height, x+width, y+height, paint); c.drawLine(x, y, x, y+height, paint); c.drawLine(x+width, y, x+width, * y+height, paint); paint.setStyle(Style.FILL); paint.setColor(Color.BLUE); c.drawRect(rect, paint); * 这个规则跟j2me也是一样的,在j2me里,drawRect长宽会多画出1px。SDK的说明是: * * The resulting rectangle will cover an area (width + 1) pixels wide by (height + 1) pixels tall. If either width * or height is less than zero, nothing is drawn. * * 例如drawRect(10,10,100,1)绘制,结果是一个2px高的矩形,用fillRect(10,10,100,1),结果是一个1px高的矩形 * * 以上就是对Android绘图的具体介绍。 */ } /** * 在布局文件中引用 这样引用就行了..吼吼 <com.xiaoma.shadedemo.TextViewBorder android:id="@+id/a02_txtKSSJ" android:textColor="#000000" * android:layout_marginLeft="10dip" android:layout_width="100dip" android:layout_height="wrap_content" /> */ 2.2:JAVA实现带左右边框(自定义TextView JAVA代码二) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 package com.xiaoma.shadedemo; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.AttributeSet; import android.widget.TextView; public class TextViewBorderLeftRight extends TextView { /** * 下面两个方法在构造时需注意: 一:如果是XML文件加载的方式使用自定义控件到布局中是用以下方式, 二:如果是用纯代码的方式加载自定义的控制到而已中时用第二种方式 */ // 方式一: public TextViewBorderLeftRight(Context context, AttributeSet attrs) { super (context, attrs); } // 方式二: /* * public TextViewBorder(Context context) { // TODO Auto-generated constructor stub super(context); } */ /** * 1. Rect对象 一个区域对象Rect(left, top, right, bottom) , 是一个左闭右开的区域, 即是说使用 Rect.contains(left, top)为true, * Rect.contains(right, bottom)为false 2. drawLine方法 drawLine(float startX, float startY, float stopX, float stopY, * Paint paint) 也是一个左闭右开的区间,只会绘制到stopX-1,stopY-1 3. drawRect(Rect r, Paint paint) 当绘制空心矩形时,绘制的是一个左闭右闭的区域 * 验证方法:下面就是可以验证左闭右开的区间方法,现在知道为什么要-1 了 */ @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.GREEN); canvas.drawLine(0, 0, 0, getHeight(), paint); // canvas.drawLine(getWidth(), 0, getWidth() - 1, getHeight() - 1, paint); canvas.drawLine(this.getWidth() - 1, 0, this.getWidth() - 1, this.getHeight() - 1, paint); // canvas.drawLine(0, 0, 0, this.getHeight() - 1, paint); // canvas.drawLine(this.getWidth() - 1, 0, this.getWidth() - 1, this.getHeight() - 1, paint); // canvas.drawLine(0, this.getHeight() - 1, this.getWidth() - 1, this.getHeight() - 1, paint); } /* * 1. Rect对象 * * 一个区域对象Rect(left, top, right, bottom) , 是一个左闭右开的区域,即是说使用 Rect.contains(left, top)为true, Rect.contains(right, * bottom)为false * * 2.drawLine方法 * * drawLine(float startX, float startY, float stopX, float stopY, Paint paint) 也是一个左闭右开的区间,只会绘制到stopX-1,stopY-1 * * 验证方法: * * Canvas c = canvas; paint.setColor(Color.RED); c.drawLine(x, y, x+c.getWidth()-1, y, paint); c.drawLine(x, * y+height-1, x+c.getWidth(), y+height-1, paint); paint.setColor(Color.BLUE); c.drawPoint(x+c.getWidth()-1, y, * paint); 说明drawLine是没有绘制到右边最后一个点的 * * 3.drawRect(Rect r, Paint paint) * * 当绘制空心矩形时,绘制的是一个左闭右闭的区域 * * 验证方法: * * rect.set(x, y, x+width, y+height); paint.setStyle(Style.STROKE); paint.setColor(Color.BLUE); c.drawRect(rect, * paint); paint.setColor(Color.RED); c.drawLine(x, y, x+width, y, paint); c.drawLine(x, y+height, x+width, * y+height, paint); c.drawLine(x, y, x, y+height, paint); c.drawLine(x+width, y, x+width, y+height, paint); * 当绘制实心矩形时,绘制的是一个左闭右开的区域 * * 验证方法: * * rect.set(x, y, x+width, y+height); paint.setColor(Color.RED); c.drawLine(x, y, x+width, y, paint); c.drawLine(x, * y+height, x+width, y+height, paint); c.drawLine(x, y, x, y+height, paint); c.drawLine(x+width, y, x+width, * y+height, paint); paint.setStyle(Style.FILL); paint.setColor(Color.BLUE); c.drawRect(rect, paint); * 这个规则跟j2me也是一样的,在j2me里,drawRect长宽会多画出1px。SDK的说明是: * * The resulting rectangle will cover an area (width + 1) pixels wide by (height + 1) pixels tall. If either width * or height is less than zero, nothing is drawn. * * 例如drawRect(10,10,100,1)绘制,结果是一个2px高的矩形,用fillRect(10,10,100,1),结果是一个1px高的矩形 * * 以上就是对Android绘图的具体介绍。 */ } /** * 在布局文件中引用 这样引用就行了..吼吼 <com.xiaoma.shadedemo.TextViewBorder android:id="@+id/a02_txtKSSJ" android:textColor="#000000" * android:layout_marginLeft="10dip" android:layout_width="100dip" android:layout_height="wrap_content" /> */ 2.3:JAVA代码实现下边框(自定义TextView JAVA代码三) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 package com.xiaoma.shadedemo; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.AttributeSet; import android.widget.TextView; public class TextViewBorderUnder extends TextView { /** * 下面两个方法在构造时需注意: 一:如果是XML文件加载的方式使用自定义控件到布局中是用以下方式, 二:如果是用纯代码的方式加载自定义的控制到而已中时用第二种方式 */ // 方式一: public TextViewBorderUnder(Context context, AttributeSet attrs) { super (context, attrs); } // 方式二: /* * public TextViewBorder(Context context) { // TODO Auto-generated constructor stub super(context); } */ /** * 1. Rect对象 一个区域对象Rect(left, top, right, bottom) , 是一个左闭右开的区域, 即是说使用 Rect.contains(left, top)为true, * Rect.contains(right, bottom)为false 2. drawLine方法 drawLine(float startX, float startY, float stopX, float stopY, * Paint paint) 也是一个左闭右开的区间,只会绘制到stopX-1,stopY-1 3. drawRect(Rect r, Paint paint) 当绘制空心矩形时,绘制的是一个左闭右闭的区域 * 验证方法:下面就是可以验证左闭右开的区间方法,现在知道为什么要-1 了 */ @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.GREEN); // canvas.drawLine(0, 0, this.getWidth() - 1, 0, paint); // canvas.drawLine(0, getHeight(), getWidth() - 1, getHeight(), paint); // canvas.drawLine(this.getWidth() - 1, 0, this.getWidth() - 1, this.getHeight() - 1, paint); canvas.drawLine(0, getHeight() - 1, getWidth() - 1, getHeight() - 1, paint); } /* * 1. Rect对象 * * 一个区域对象Rect(left, top, right, bottom) , 是一个左闭右开的区域,即是说使用 Rect.contains(left, top)为true, Rect.contains(right, * bottom)为false * * 2.drawLine方法 * * drawLine(float startX, float startY, float stopX, float stopY, Paint paint) 也是一个左闭右开的区间,只会绘制到stopX-1,stopY-1 * * 验证方法: * * Canvas c = canvas; paint.setColor(Color.RED); c.drawLine(x, y, x+c.getWidth()-1, y, paint); c.drawLine(x, * y+height-1, x+c.getWidth(), y+height-1, paint); paint.setColor(Color.BLUE); c.drawPoint(x+c.getWidth()-1, y, * paint); 说明drawLine是没有绘制到右边最后一个点的 * * 3.drawRect(Rect r, Paint paint) * * 当绘制空心矩形时,绘制的是一个左闭右闭的区域 * * 验证方法: * * rect.set(x, y, x+width, y+height); paint.setStyle(Style.STROKE); paint.setColor(Color.BLUE); c.drawRect(rect, * paint); paint.setColor(Color.RED); c.drawLine(x, y, x+width, y, paint); c.drawLine(x, y+height, x+width, * y+height, paint); c.drawLine(x, y, x, y+height, paint); c.drawLine(x+width, y, x+width, y+height, paint); * 当绘制实心矩形时,绘制的是一个左闭右开的区域 * * 验证方法: * * rect.set(x, y, x+width, y+height); paint.setColor(Color.RED); c.drawLine(x, y, x+width, y, paint); c.drawLine(x, * y+height, x+width, y+height, paint); c.drawLine(x, y, x, y+height, paint); c.drawLine(x+width, y, x+width, * y+height, paint); paint.setStyle(Style.FILL); paint.setColor(Color.BLUE); c.drawRect(rect, paint); * 这个规则跟j2me也是一样的,在j2me里,drawRect长宽会多画出1px。SDK的说明是: * * The resulting rectangle will cover an area (width + 1) pixels wide by (height + 1) pixels tall. If either width * or height is less than zero, nothing is drawn. * * 例如drawRect(10,10,100,1)绘制,结果是一个2px高的矩形,用fillRect(10,10,100,1),结果是一个1px高的矩形 * * 以上就是对Android绘图的具体介绍。 */ } /** * 在布局文件中引用 这样引用就行了..吼吼 <com.xiaoma.shadedemo.TextViewBorder android:id="@+id/a02_txtKSSJ" android:textColor="#000000" * android:layout_marginLeft="10dip" android:layout_width="100dip" android:layout_height="wrap_content" /> */ 2.4:Shape XML实现边框(XML代码) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 <? xml version = "1.0" encoding = "utf-8" ?> < shape xmlns:android = "http://schemas.android.com/apk/res/android" > <!-- <solid android:color="#cceeff"/> 直接写这个的话,可以给控制添加一个整体的背景哦 --> < stroke android:width = "0.5dp" android:color = "#22ccff" /> < padding android:left = "5dp" android:top = "5dp" android:right = "5dp" android:bottom = "5dp" /> < size android:height = "0.5dp" android:width = "5dp" /> <!-- 目前没有什么用,可删除,留在这个地方防止乱猜 --> < corners android:radius = "10dp" /> <!-- 这个radius里面的值需要个整型,单位用dp,用其它单位亦无影响 --> </ shape > 2.5:Selector与Shape混用控件效果实现 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 <? xml version = "1.0" encoding = "utf-8" ?> < selector xmlns:android = "http://schemas.android.com/apk/res/android" > <!-- 今天主要讲的是shape渲染,shape主要类型分四种,效果如下,我们常用rectangle,也就是矩形渲染,其它的都太丑了!! --> < item android:state_pressed = "true" > <!--按钮按下时的渲染效果 --> < shape android:shape = "oval" > < corners android:radius = "10dp" /> <!-- 四个角的角度 --> <!--gradient就是梯度渲染,简单说就是颜色渐变,type为渐变方式,总共三种 linear sweep ridial,常用linear--> < gradient android:endColor = "#eebbbb" android:startColor = "#9900ee" android:type = "linear" /> <!-- padding属性是指定内容与控件边距,这个地方小马专门将距左边距设置较大,方便观察 --> < padding android:bottom = "5dp" android:left = "20dp" android:right = "5dp" android:top = "5dp" /> <!-- solid填充整个区域,颜色为FFDDFF,如果使用整个区域填充的话,上面的gradient梯度会失效,即:覆盖 --> <!-- <solid android:color="#FFDDFF"/> --> <!-- stroke为需要填充的边框,指定颜色及边框宽度 --> < stroke android:width = "3dp" android:color = "#000000" /> </ shape > <!-- <clip android:clipOrientation="vertical" android:gravity="right" android:drawable="@drawable/ic_launcher" /> --> <!-- 试了下没用 --> <!-- <color android:color="#223344"/> --> <!-- <scale android:scaleWidth="15dp" android:scaleHeight=" 5dp" android:scaleGravity="center" /> --> </ item > < item > <!-- 默认 --> < shape android:shape = "rectangle" > < corners android:radius = "10dp" /> <!-- 四个角的角度 --> <!--gradient就是梯度渲染,简单说就是颜色渐变,type为渐变方式,总共三种 linear sweep ridial,常用linear--> <!-- 这个地方一定注意,在使用gradient标签中使用android:type的前提是必须android:gradientRadius="20dp"已经设置,否则会报错 --> < gradient android:endColor = "#acefda" android:startColor = "#0099ff" android:type = "linear" /> <!-- padding属性是指定内容与控件边距,这个地方小马专门将距左边距设置较大,方便观察 --> < padding android:bottom = "5dp" android:left = "20dp" android:right = "5dp" android:top = "5dp" /> <!-- solid填充整个区域,颜色为FFDDFF,如果使用整个区域填充的话,上面的gradient梯度会失效,即:覆盖 --> <!-- <solid android:color="#FFDDFF"/> --> <!-- stroke为需要填充的边框,指定颜色及边框宽度 --> < stroke android:width = "3dp" android:color = "#000000" /> </ shape > </ item > </ selector > 怎么样?看着JAVA自定义TextView代码是不是觉得特别的繁琐?今天的主题就是来解决这个问题的....…^_^.........下面着重来讲一下Selector与Shape混用控件效果Selector实现的细节,(请仔细看下XML里面的注释 O_O) 每个Item过是由Shape来进行渲染生成最终的效果,首先来看根Shape节点的常用属性<shape android:shape="rectangle">: 这个shape属性总共分三种 rectangle(矩形)、oval(椭圆) 、line(删除线)、ring(铃,这个存在不知道有什么意义),其效果分别如下: 1.rectangle 2.oval 3.line 4.ring 其中,gradient标签中的type为渐变方式,总共三种 linear sweep ridial,常用linear,其效果分别为(注意:ridial试了无任何效果 T_T) 1.linear效果 2.sweep效果 好了,代码及整体效果已经分解完毕了,如果认真从头到尾的看一边的话,肯定有所收获的,对了,以上的Shape渲染写好了,可以在任意控件上使用…不限于TextView,上面的例子只是拿TextView来开刀用的…大家别误会,呵呵….^_^…. ,最后,小马希望在文章中有什么不清楚或不明白或有错误的地方,请大家直接指出…有错必改的….这个源码小马已经上传到附件中,有兴趣或有用的朋友可以直接下载来跑跑改改看,有批评才有进步,希望有什么不好的,直接指出….在此先谢谢大家啦…. 官网参考链接如下(只是没效果图,所以大家也懒得去看这个东西) http://developer.android.com/guide/topics/resources/drawable-resource.html 这段时间也有在关注各种各样的东西,老听人说学这学那的人越来越多什么的,也希望大家不要随便听人家讲,我敢说….安卓虽然在很多人眼里看来简单、烂,但我觉得如果要深入的话,水还是很深的,如果用心,一定可以做的越来越好的,一步一步来,大家一起努力!做安卓的人越来越多,越有竞争!越有动力!!!这样才会进步!哈哈….加油加油加油! O_O 附件:http://down.51cto.com/data/2362968 本文转自华华世界 51CTO博客,原文链接:http://blog.51cto.com/mzh3344258/1215749,如需转载请自行联系原作者

优秀的个人博客,低调大师

JPDA 架构研究3 - JDWP层的数据包

引入: 现在我们把目光转到JDWP层(它的全称是Java Debug Wire Protocol。从"Wire"这词就可以看出,它主要是起到"连线”的作用)。首先我们从JDWP层的数据包讲起。源码在JDK中很容易找到,它定义$JAVA_HOME/include/jdwpTransport.h头文件中。 分析: Part 1: 握手过程 (handshake ) 握手包发生在Debugger(JDI端)和Target VM(JVMTI端)的传输层连接建立,并且在发送任何实际数据报之前完成的。它过程如下: a. Debugger会发送14个字节的握手请求到Target VM,这个包的内容是14字节的ASCII字符串 “JDWP-Handshake” b. Target VM会返回14个字节的握手响应到Debugger,其内容也是14字节的ASCII字符串,和刚才一样,“JDWP-Handshake" 这样的主要作用是为了确保 Debugger和Target VM之间通信正常。 Part2:发送具体调试请求和获得响应阶段:命令包(Command Packet)和响应包(Reply Packet) 从许多文档中, 我概括了JDWP层包的一些特点: (1)包是无状态的 (2)命令包可以通过Debugger或者Target VM来发送。 对于从Debugger发送的命令包来说,它主要可以发送请求消息或者控制程序执行。 对于从Target VM发送的命令包来说,它可通知Debugger一些Target VM中的事件比如断点或者异常。 (3)响应包 响应包用于对于某命令包的响应,它总用于返回命令的成功或失败,并且可以携带命令包中包含的数据。 对于从Debugger发送的命令包,一般总会有响应包。 对于从Target VM发送的命令包,无需要响应包。 (4)JDWP平台对于数据包的发送是异步的,各个命令/响应包之间无顺序概念。命令包和对应的响应包通过ID来配对识别。 命令包的定义如下: 1 2 3 4 5 6 7 8 9 10 11 typedef struct { jintlen; //命令包的长度:4字节,它是整个包的长度 jintid; //命令包的ID:4字节,用于表示命令包和对应响应包的配对,正因为此机制才可以让包是异步传输的。 jbyteflags; //命令包的标志位:1字节,用于定义该命令如何进队列/处理或者被打标记 jbytecmdSet; //命令包的命令集:1字节,用于分组该命令 //(0-63:表示Debugger往TargetVM发送的命令) //(64-127:表示TargetVM往Debugger发送的命令) //(128-256:Vendor自定义命令) jbytecmd; //命令包中的命令:1字节 jbyte*data; //命令包中携带的数据 }jdwpCmdPacket; 响应包的定义如下: 1 2 3 4 5 6 7 typedef struct { jintlen; //响应包的长度:4字节 jintid; //响应包的ID:4字节,用于表示命令包和对应响应包的配对,正因为此机制才可以让包是异步传输的。 jbyteflags; //响应包的标志位:1字节,用于定义该命令如何进队列/处理或者被打标记 jshorterrorCode; //响应包中的错误码:2字节,其中0表示成功,非0表示某种错误码,一般错误码会映射到JVMTI的返回码。 jbyte*data; //响应包中携带的数据 }jdwpReplyPacket; 补充说明: (1)如果接收端接受到的命令包,其中携带的命令集或者命令是规范中未定义的,那么响应包的errorCode会被定义为NOT_IMPLEMENTED. (2)ErrorCode定义如下: 1 2 3 4 5 6 7 8 9 10 typedef enum { JDWPTRANSPORT_ERROR_NONE=0, JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT=103, JDWPTRANSPORT_ERROR_OUT_OF_MEMORY=110, JDWPTRANSPORT_ERROR_INTERNAL=113, JDWPTRANSPORT_ERROR_ILLEGAL_STATE=201, JDWPTRANSPORT_ERROR_IO_ERROR=202, JDWPTRANSPORT_ERROR_TIMEOUT=203, JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE=204 }jdwpTransportError; 本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/1587595,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册