Draw2d 边界 边框 border

关键字:Draw2d 边界 边框 border

 

在Draw2d中还提供了许多的边界的选择:

分组框边界:(GroupBoxBorder)

标题栏边界:(TitleBarBorder)

复合式边界:(CompoundBorder)

框架边界:(FrameBorder)

焦点边界:(FocusBorder)

线条边界:(LineBorder)

预配置型边界:(SchemeBorder)

按钮边界:(ButtonBorder)

下沉式边界:(SimpleLoweredBorder)

上浮式边界:(SimpleRaisedBorder)

 

同时还可以定制边界,边界其实很简单。

public class HelloWorld2 {
	public static void main(String args[]) {
		Shell shell = new Shell();
		shell.setText("Draw2d Hello World");
		shell.setSize(40, 140);
		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());

		Figure f = new CompartmentFigure();
		f.add(new Label("columns1"));
		f.add(new Label("columns2"));
		rootFigure.add(f ,new Rectangle(10,10,80,90));

		LightweightSystem lws = new LightweightSystem(shell);
		lws.setContents(rootFigure);
	}
}

class CompartmentFigure extends Figure {
	public CompartmentFigure() {
		ToolbarLayout layout = new ToolbarLayout();
		layout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT);
		layout.setStretchMinorAxis(false);
		layout.setSpacing(10);
		setLayoutManager(layout);
		setBorder(new CompartmentFigureBorder());
	}
	public class CompartmentFigureBorder extends AbstractBorder {
		public Insets getInsets(IFigure figure) {
			return  new Insets(1,0,0,0);
		}
		public void paint(IFigure figure, Graphics graphics, Insets insets) {
					      graphics.drawLine(getPaintRectangle(figure, insets).getTopLeft(),
					                        tempRect.getTopRight());
		}
	}
}

 

 



 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值