ImageVerifierCode 换一换
格式:DOCX , 页数:29 ,大小:20.72KB ,
资源ID:9204257      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/9204257.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(画布图形实例.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

画布图形实例.docx

1、画布图形实例package ;importimportimportimportimportimportpublic class GCCreation Display display = new Display();Shell shell = new Shell(display);public GCCreation() Image image = new Image(display, C:/icons/);Image image2 = new Image(display, ();GC gc = new GC(image2););(10, 10, 90, 40);();CLabel label =

2、 new CLabel(shell, ;(image);(10, 10, 130, 130);CLabel label2 = new CLabel(shell, ;(image2);(150, 10, 130, 130);();();while (!() if (!() ();();public static void main(String args) new GCCreation();package ;import class GCCreation Display display = new Display();Shell shell = new Shell(display);public

3、 GCCreation() Image image = new Image(display, C:/icons/);Image image2 = new Image(display, ();GC gc = new GC(image2););(10, 10, 90, 40);();CLabel label = new CLabel(shell, ;(image);(10, 10, 130, 130);CLabel label2 = new CLabel(shell, ;(image2);(150, 10, 130, 130);();();while (!() if (!() ();();publ

4、ic static void main(String args) new GCCreation();接下来请参看以下示例:演示代码 1:view plaincopy to clipboardprint package ;import importimportimportimportimportpublic class CanvasExample Display display = new Display();Shell shell = new Shell(display);public CanvasExample() Canvas canvas = new Canvas(shell, ;(10

5、, 10, 200, 100);(new PaintListener() public void paintControl(PaintEvent e) 10, 180, 80, 10, 10););();();while (!() if (!() ();();package ;import class CanvasExample Display display = new Display();Shell shell = new Shell(display);public CanvasExample() Canvas canvas = new Canvas(shell, ;(10, 10, 20

6、0, 100);(new PaintListener() public void paintControl(PaintEvent e) 10, 180, 80, 10, 10););();();while (!() if (!() ();();演示代码 2:(三角 )view plaincopy to clipboardprintpackage ;importimportimportimportimportimportimportimportimportpublic class Clipping Display display = new Display();Shell shell = new

7、 Shell(display);public Clipping() (new FillLayout();final Canvas canvas = new Canvas(shell, ;final Image image = new Image(display, C:/icons/);(new PaintListener() Region region = new Region(); (new int60, 10, 10, 100, 110, 100);0, 0););(200, 140);();while (!() if (!() ();();public static void main(

8、String args) new Clipping();package ;import class Clipping Display display = new Display();Shell shell = new Shell(display);public Clipping() final Canvas canvas = new Canvas(shell, ;final Image image = new Image(display, C:/icons/);(new PaintListener() public void paintControl(PaintEvent e) Region

9、region = new Region();(new int60, 10, 10, 100, 110, 100);0, 0););(200, 140);();while (!() if (!() ();();public static void main(String args) new Clipping();演示代码 3:(动态画布)view plaincopy to clipboardprintpackage ;importimportimportimportimportimportimportimportimportimportimportpublic class DoubleBuffe

10、r Display display = new Display();Shell shell = new Shell(display);public DoubleBuffer() (new FillLayout();final Canvas canvas = new Canvas(shell, ;(new PaintListener() public void paintControl(PaintEvent e) Point size = ();int x1 = (int) () * ;int y1 = (int) () *int x2 = ().width - x1 - 10, 50); in

11、t y2 = ().height - y1 - 10, 50);y1, x2, y2, 5, 5);(100, new Runnable() public void run() ();););final Canvas doubleBufferedCanvas = new Canvas(shell, ;(new PaintListener() public void paintControl(PaintEvent e) Image image = (Image) (double-buffer-image);if (image = null| ().width != ().x| ().height

12、 != ().y) image =new Image(display,().x,().y);(double-buffer-image, image);GC imageGC = new GC(image);Rectangle imageSize = ();(0, 0, + 1, + 1);Point size = ();int x1 = (int) () * ;int y1 = (int) () * ;int x2 = ().width - x1 - 10, 50);int y2 = ().height - y1 - 10, 50);(x1, y1, x2, y2, 5, 5);0, 0);()

13、;(100, new Runnable() public void run() ();););(300, 200);();while (!() if (!() ();();public static void main(String args) new DoubleBuffer();package ;import class DoubleBuffer Display display = new Display(); Shell shell = new Shell(display); public DoubleBuffer() (new FillLayout();final Canvas can

14、vas = new Canvas(shell, ;(new PaintListener() public void paintControl(PaintEvent e) Point size = ();int x1 = (int) () * ;int y1 = (int) () * ;int x2 = ().width - x1 - 10, 50);int y2 = ().height - y1 - 10, 50);y1, x2, y2, 5, 5);(100, new Runnable() public void run() ();););final Canvas doubleBuffere

15、dCanvas = new Canvas(shell, ;(new PaintListener() public void paintControl(PaintEvent e) Image image = (Image) (double-buffer-image);if (image = null| ().width != ().x| ().height != ().y) image =new Image(display,().x,().y);(double-buffer-image, image);GC imageGC = new GC(image);RectangleimageSize =

16、 ();(0, 0, + 1, + 1);Point size = ();int x1 = (int) () * ;int y1 = (int) () * ;int x2 = ().width - x1 - 10, 50);int y2 = ().height - y1 - 10, 50);(x1, y1, x2, y2, 5, 5);0, 0);();(100, new Runnable() public void run() ();););(300, 200);();while (!() if (!() ();();public static void main(String args)

17、new DoubleBuffer();演示代码 4:(图片)view plaincopy to clipboardprintpackage ;importimportimportimportimportimportimportimportimportimportimportimportpublic class DrawImages Display display = new Display();Shell shell = new Shell(display);public DrawImages() (new FillLayout();Canvas canvas = new Canvas(she

18、ll, ;final Image image = new Image(display, C:/icons/);(new PaintListener() public void paintControl(PaintEvent e) 10, 10);0, 0, 100, 100, 200, 10, 200, 50););(430, 200);();captureControl(canvas, );while (!() if (!() ();();public static void captureControl(Control control, String file) GC gc = new G

19、C(control);Image image = new Image(), ().x, ().y);(image, 0, 0);ImageLoader loader = new ImageLoader();= new ImageData () ;(file, ;();public static void main(String args) new DrawImages();package ;Display display = new Display();Shell shell = new Shell(display);public DrawImages() (new FillLayout();

20、Canvas canvas = new Canvas(shell, ;final Image image = new Image(display, C:/icons/);(new PaintListener() public void paintControl(PaintEvent e) 10, 10);0, 0, 100, 100, 200, 10, 200, 50););(430, 200);();captureControl(canvas, );while (!() if (!() ();();public static void captureControl(Control contr

21、ol, String file) GC gc = new GC(control);Image image = new Image(), ().x, ().y);(image, 0, 0);ImageLoader loader = new ImageLoader(); = new ImageData () ;(file, ;();public static void main(String args) new DrawImages();演示代码 5:(画线)view plaincopy to clipboardprint package ;importimportimportimportimpo

22、rtimportimportpublic class Drawings Display display = new Display();Shell shell = new Shell(display);public Drawings() (new FillLayout();Canvas canvas = new Canvas(shell, ;);(new PaintListener() public void paintControl(PaintEvent e) (default), 10, 10);, 10, 30);, 10, 50);, 10, 70);, 10, 90);Line wi

23、dth = 1 (default), 10, 120);Line width = 3, 10, 140);int start = 150;15, start + 200, 15);35, start + 200, 35);55, start + 200, 55);75, start + 200, 75);95, start + 200, 95);125, start + 200, 125);145, start + 200, 145);int points = new int3 * 2;points0 = 10;points1 = 10;points2 = 10;points3 = 100;p

24、oints4 = 100;points5 = 100;10, 200, 100, 0, -90);60, 220, 60);0, 110, 120););();();while (!() if (!() ();();public static void main(String args) new Drawings();package ;import class Drawings Display display = new Display();Shell shell = new Shell(display); public Drawings() (new FillLayout();Canvas

25、canvas = new Canvas(shell, ;);(new PaintListener() public void paintControl(PaintEvent e) (default), 10, 10);, 10, 30);, 10, 50);, 10, 70);, 10, 90);Line width = 1 (default), 10, 120);Line width = 3, 10, 140);int start =150;15, start + 200, 15);35, start + 200, 35);55, start + 200, 55);75, start + 2

26、00, 75);95, start + 200, 95);125, start + 200, 125);145, start + 200, 145);int points= new int3 * 2;points0 =10;points1 =10;points2 =10;points3 =100;points4 =100;points5 =100;10, 200, 100, 0, -90);60, 220, 60);0, 110, 120););();while (!() if (!() ();();public static void main(String args) new Drawin

27、gs();演示代码 6:(文本效果) view plaincopy to clipboardprint package ;importimportimportimportimportimportimportimportimportimport importpublic class DrawText Display display = new Display();Shell shell = new Shell(display);public DrawText() (new FillLayout();final Canvas canvas = new Canvas(shell, ;final Im

28、age image = new Image(display, C:/icons/);(new PaintListener() public void paintControl(PaintEvent e) Rectangle size = ();0, 0, , , 0, 0, ().x, ().y);Font font = new Font(display, Tahoma, 18, ;String english = SWT rocks!;String chinese = u4e2du6587u6c49u5b57u6d4bu8bd5;10, 10);10, 80, true);String text = Text to be drawn in the center;Point textSize = ().x - /2, ().y - /2););(300, 150);();while (!() if (!() ()

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1