package plug_in_test; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; import org.eclipse.swt.SWT; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.graphics.GC; public class TstDrawDisplay2 { /* * wave #1 * ********************************************** * /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ / * / \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ * ********************************************** */ private static int[] wave1_data = new int[]{-100, 0, 100, 0, }; /* * wave #2 * ********************************************** * _ _ _ _ _ _ _ _ * / \ / \ / \ / \ / \ / \ / \ / * / \_/ \_/ \_/ \_/ \_/ \_/ \_/ * ********************************************** */ private static int[] wave2_data = new int[]{-100, 0, 100, 100, 0, -100 }; /* * wave #3 * ********************************************** * _ _ _ _ _ _ * _/ \_ _/ \_ _/ \_ _/ \_ _/ \_ _/ \_ * / \_/ \_/ \_/ \_/ \_/ \ * ********************************************** */ private static int[] wave3_data = new int[]{-100, 0, 0, 100, 100, 0, 0, -100, -100, 0, 0, 100, 100, 0, 0, -100,}; /* * wave #4 * ********************************************** * /\ /\ /\ /\ * / \ /\ / \ /\ / \ /\ / \ * / \ / \/ \ / \/ \ / \/ \ / * / \/ \/ \/ \/ * ********************************************** */ private static int[] wave4_data = new int[]{-200, -100, 0, 100, 200, 100, 0, -100, -200, -100, 0, 100, 0, -100, 0, 100, 200, 100, 0, -100 }; private static int timerCounter = 0; public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); shell.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { GC gc = e.gc; int x = e.x, y = e.y, width = e.width, height = e.height; /* * draw x axis. */ gc.setLineWidth(3); gc.setForeground(display.getSystemColor(SWT.COLOR_YELLOW)); gc.drawLine(x, y + height/2, x + width, y + height/2); /* * draw x coordinate. */ gc.setLineWidth(1); gc.setLineStyle(SWT.LINE_DOT); gc.setForeground(display.getSystemColor(SWT.COLOR_DARK_YELLOW)); for (int i = 0 ; (y + height/2 - 40*i) > y ; i++) { gc.drawLine(x, y + height/2 - 40*i, x + width, y + height/2 - 40*i); gc.drawLine(x, y + height/2 + 40*i, x + width, y + height/2 + 40*i); } /* * draw y coordinate. */ int xSum=0; for (int i = 0; i*60 < width; i++) { gc.drawLine(x+60*i, y, x+60*i, y + height); xSum = i; } /* * draw y axis */ gc.setLineWidth(3); gc.setForeground(display.getSystemColor(SWT.COLOR_YELLOW)); gc.drawLine(x+60*(xSum/2+1), y, x+60*(xSum/2+1), y + height); /* * draw wave */ gc.setLineWidth(3); gc.setLineStyle(SWT.LINE_SOLID); gc.setForeground(display.getSystemColor(SWT.COLOR_GREEN)); gc.drawPolyline(getWave(xSum, x, y, height, wave1_data)); // gc.drawPolyline(getWave(xSum, x, y, height, wave2_data)); // gc.drawPolyline(getWave(xSum, x, y, height, wave3_data)); gc.drawPolyline(getWave(xSum, x, y, height, wave4_data)); } private int[] getWave(int xSum, int x, int y, int height, int[] wave_data) { List<Integer> list = new ArrayList<Integer>(); for(int i = 0; i <= xSum + 1; i++) { list.add(0); list.add(0); } for(int i = 0; i <= xSum + 1; i++) { list.set(2*i, x+60*i); } int wave_start_index = timerCounter % (wave_data.length); for(int i = 0; i <= xSum + 1; i++) { list.set(2*i+1, y + height/2 + wave_data[(wave_start_index+i) % wave_data.length]); } int[] points = new int[list.size()]; for(int i = 0 ; i < points.length; i++) points[i] = list.get(i); return points; } }); Timer timer = new Timer(true); timer.schedule(new TimerTask() { public void run() { timerCounter ++; display.syncExec(new Runnable() { public void run() { if ( null != shell && !shell.isDisposed() ) shell.redraw(); } }); } }, 200, 300); shell.setSize(600, 500); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
相关推荐
java swt 实现的隐藏和显示任务栏图标和托盘图标的(导入swt包即可) 资源名称是:java swt 隐藏和显示任务栏图标和托盘图标(2)
SWT 3.0 开始引入了 Tray,可以在系统栏放置你的程序图标了 本程序实现的功能有四: * 1. 点击窗口的最小化或关闭按钮都是隐藏窗口--任务栏里不显示,不退出程序 * 2. 窗口隐藏时,任务栏无图标,系统栏有图标;...
java swt 实现的隐藏和显示任务栏图标和托盘图标的(导入swt包即可)
SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置
64位windows操作系统使用的SWT库
Java socket编程使用SWT编写界面,远程升级程序.class文件,不是工程源码,工程里面还有其他的,不方便发。https://blog.csdn.net/L_e_c/article/details/110423909
org.eclipse.swt.SWT.class org.eclipse.swt.SWTError.class org.eclipse.swt.SWTException.class org.eclipse.swt.accessibility.ACC.class org.eclipse.swt.accessibility.Accessible.class org.eclipse.swt....
swt工具文档 swt工具文档 swt工具文档 swt工具文档 swt工具文档 swt工具文档
SWT examples,SWT官方例子:http://www.eclipse.org/swt/examples.php 该页面所要下载的例子 其中,swt的例子在\plugins\org.eclipse.swt.examples.source_3.7.0.v3740f.jar中
下载编译的SWT库,版本号4.911,包含多个版本: org.eclipse.swt.cocoa.macosx.x86_64 org.eclipse.swt.gtk.linux.aarch64 org.eclipse.swt.gtk.linux.arm org.eclipse.swt.gtk.linux.ppc64le org.eclipse.swt.gtk....
SWT-Internal-Video使用SWT技术对视频的常用显示功能进行了实现和封装,并提供了API。 它的接口之灵活性可以满足视频显示上的很多要求 与 情况。 SWT-Internal-Video解决的是程序与视频设备DVR/DVS之间的链接,并...
SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法
swt 基础教程 swt 基础教程 swt 基础教程swt 基础教程swt 基础教程
swt教程 有关SWT怎么应用
SWT官方api文档 开发基于swt的GUI程序必备手册
swt.jar swt.jar swt.jar swt.jar swt.jar
swt-api java swt GUI java界面编程,swt的开发DOC,谁用谁知道,一般人我不告诉他
swt table 实现换行
swt 画图小程序 自由画线 矩形。。import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseMoveListener; ...
swt框架 适用与window下java窗口开发~~~~