`

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());
		}
	}
}

 

 



 

  • 大小: 4.5 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics