首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

draw2d胪陈(IFigure)

2012-06-29 
draw2d详述(IFigure)?1.IFigureIFigure接口是所有Figure的基础接口,里面有很多方法,这里只列出部分自己觉

draw2d详述(IFigure)

?

1.IFigure

IFigure接口是所有Figure的基础接口,里面有很多方法,这里只列出部分自己觉得有用的方法:

?

(1)add(IFigure figure, Object constraint, int index):添加一个子,并且指定其约束和位置:

?

?

public void layout(IFigure parent) {Iterator children = parent.getChildren().iterator();Point offset = getOrigin(parent);IFigure f;while (children.hasNext()) {f = (IFigure) children.next();Rectangle bounds = (Rectangle) getConstraint(f);if (bounds == null)continue;if (bounds.width == -1 || bounds.height == -1) {Dimension preferredSize = f.getPreferredSize(bounds.width,bounds.height);bounds = bounds.getCopy();if (bounds.width == -1)bounds.width = preferredSize.width;if (bounds.height == -1)bounds.height = preferredSize.height;}bounds = bounds.getTranslated(offset);f.setBounds(bounds);}}
?

计算布局:最终会把计算到的值,赋值给IFigure:f.setBounds(bounds);

?

?

(2)其他的以后再分析,其实就是按照某种规则算,算大小什么的,其它的都是浮云。

?

热点排行