博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Eclipse REST 库使用
阅读量:4201 次
发布时间:2019-05-26

本文共 3041 字,大约阅读时间需要 10 分钟。

很高兴今天成为了CSDN的专家,所以再忙也要抽空写一篇博客。最近公司有个需求要在RCP应用中用树状结构显示层级关系。我找了半天的开源框架,最后发现Eclipse REST最符合现在的需求。REST是专门用来显示图状效果的,废话少说了上效果,上代码。

public class DeviceTreeViewSWT {    public static void main(String[] args) {        Display d = new Display();        Shell shell = new Shell(d);        Image image1 = Display.getDefault().getSystemImage(SWT.ICON_INFORMATION);        Image image2 = Display.getDefault().getSystemImage(SWT.ICON_WARNING);        Image image3 = Display.getDefault().getSystemImage(SWT.ICON_ERROR);        shell.setLayout(new FillLayout());        shell.setSize(800, 800);        Graph g = new Graph(shell, SWT.NONE);        g.addSelectionListener(new SelectionAdapter() {            public void widgetSelected(SelectionEvent e) {                System.out.println(((Graph) e.widget).getSelection());            }        });        g.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);        GraphNode n1 = new GraphNode(g, SWT.NONE, "Virtual");        n1.setBackgroundColor(new Color(d,255,0,0));        GraphNode n2 = new GraphNode(g, SWT.NONE, "Shanghai");        GraphNode n3 = new GraphNode(g, SWT.NONE, "Beijing");        GraphNode n4 = new GraphNode(g, SWT.NONE, "AGM001");        GraphNode n5 = new GraphNode(g, SWT.NONE, "AGM002");        GraphNode n6 = new GraphNode(g, SWT.NONE, "AGM003");        GraphNode n7 = new GraphNode(g, SWT.NONE, "AGM004");        GraphNode n8 = new GraphNode(g, SWT.NONE, "AGM005");        GraphNode n9 = new GraphNode(g, SWT.NONE, "AGM006");        GraphNode n10 = new GraphNode(g, SWT.NONE, "AGM007");        GraphNode n11 = new GraphNode(g, SWT.NONE, "AGM008");//        class PathFigure extends PolylineConnection {//            public PathFigure() {//                setTargetDecoration(new PolylineDecoration());//                setConnectionRouter(new ManhattanConnectionRouter());//            }//        }        new GraphConnection(g, SWT.NONE, n1, n2);        new GraphConnection(g, SWT.NONE, n1, n3);        new GraphConnection(g, SWT.NONE, n2, n4);        new GraphConnection(g, SWT.NONE, n2, n5);        new GraphConnection(g, SWT.NONE, n2, n6);        new GraphConnection(g, SWT.NONE, n3, n7);        new GraphConnection(g, SWT.NONE, n3, n8);        new GraphConnection(g, SWT.NONE, n5, n9);        new GraphConnection(g, SWT.NONE, n5, n10);        new GraphConnection(g, SWT.NONE, n4, n11);        //g.setLayoutAlgorithm(new TreeLayoutAlgorithm(LayoutStyles.ENFORCE_BOUNDS), true);        //g.setLayoutAlgorithm(new HorizontalTreeLayoutAlgorithm(LayoutStyles.ENFORCE_BOUNDS),true);        g.setLayoutAlgorithm(new RadialLayoutAlgorithm(LayoutStyles.ENFORCE_BOUNDS),true);        //g.setLayoutAlgorithm(new GridLayoutAlgorithm(LayoutStyles.ENFORCE_BOUNDS), true);        shell.open();        while (!shell.isDisposed()) {            while (!d.readAndDispatch()) {                d.sleep();            }        }        image1.dispose();        image2.dispose();        image3.dispose();    }}
改下LayoutAlgorithm可以看到更炫的辐射状图

效果不错吧,用来显示图,树等都非常的方便

如果你用Jface封装的GraphViewer,那MVC使用起来更是方便.

转载地址:http://vxbli.baihongyu.com/

你可能感兴趣的文章
建造者模式(Builder)-设计模式(三)
查看>>
初学Java必备基础知识,编程领域你需要掌握的关键点!
查看>>
阿里五年Java程序员的总结,献给还在迷茫中的你!
查看>>
程序员身上有异味,同事为什么都不会直接告诉他?
查看>>
Java、C、C+ +、PHP、Python分别用来开发什么?一篇文章告诉你!
查看>>
Linux-SHELL常用命令
查看>>
Linux-网络运维基础
查看>>
Verilog编程网站学习——门电路、组合电路、时序电路
查看>>
android——学生信息显示和添加
查看>>
Android——ImageSwitcher轮流显示动画
查看>>
Android——利用手机端的文件存储和SQLite实现一个拍照图片管理系统
查看>>
图像调优1:清晰度相关参数MTF,SFR,MTF50,MTF50P 以及TVL的概念以及换算说明
查看>>
罗永浩欲直播带货,京东说可以帮忙联系
查看>>
B站,正在变成下一个“公众号”?
查看>>
小米启动安心服务月 手机家电产品可免费清洁保养
查看>>
刘作虎:一加新品将全系支持 5G
查看>>
滴滴顺风车上线新功能,特殊时期便捷出行
查看>>
不会延期!iPhone 12S预计如期在9月发售:升级三星LTPO屏幕
查看>>
腾讯物联网操作系统TencentOS tiny线上移植大赛,王者机器人、QQ公仔、定制开发板等礼品等你来拿 !
查看>>
为云而生,腾讯云服务器操作系统TencentOS内核正式开源
查看>>