首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Draw2d 连线1

2012-11-08 
Draw2d 连线一关键字:Draw2d 连线 PolylineConnection?public class HelloWorld2 {public static void mai

Draw2d 连线一

关键字:Draw2d 连线 PolylineConnection

?

public class HelloWorld2 {public static void main(String args[]) {Shell shell = new Shell();shell.setText("Draw2d Hello World");shell.setSize(400, 400);shell.open();// create content 4 shell.createContent4Shell(shell);while (!shell.isDisposed ()) {if (!Display.getDefault().readAndDispatch ())Display.getDefault().sleep ();}}private static void createContent4Shell(Shell shell) {Panel rootFigure = new Panel();rootFigure.setLayoutManager(new XYLayout());IFigure figure1 = new Ellipse();IFigure figure2 = new Ellipse();//IFigure figure2 = new Triangle();// --------------------// add connectionPolylineConnection connection = new PolylineConnection();connection.setSourceAnchor(new ChopboxAnchor(figure1));connection.setTargetAnchor(new ChopboxAnchor(figure2));// add connection// --------------------rootFigure.add(figure1,new Rectangle(10,10,60,30));rootFigure.add(figure2,new Rectangle(80,90,60,30));rootFigure.add(connection);LightweightSystem lws = new LightweightSystem(shell);lws.setContents(rootFigure);}}

?

连线也是一个Figure也要加到父Figure中去,要指定连线的两个端点就行了。


Draw2d 连线1
?

?

热点排行