systemshape.java

来自「mywork是rcp开发的很好的例子」· Java 代码 · 共 55 行

JAVA
55
字号
package net.sf.freenote.uml.model;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.swt.graphics.Image;

import net.sf.freenote.FreeNoteConstants;
import net.sf.freenote.model.Shape;
import net.sf.freenote.model.ShapesContainer;

/**
 * 用例图中边界图形,同时是个容器
 * @author levin
 * @since 2008-2-3 下午09:47:22
 */
public class SystemShape extends UmlShape implements ShapesContainer{
	private static final Image SYSTEM_ICON = createImage("icons/system.gif");
	private List<Shape> children ;
	
	public SystemShape() {
		setSize(new Dimension(320,240));
	}

	public boolean addChild(Shape s) {
		if (s != null && getChildren().add(s)) {
			firePropertyChange(FreeNoteConstants.CHILD_ADDED_PROP, null, s);
			return true;
		}
		return false;
	}

	public List<Shape> getChildren() {
		return children ==null ? children =new ArrayList<Shape>():children;
	}
	public boolean removeChild(Shape s) {
		if (s != null && getChildren().remove(s)) {
			firePropertyChange(FreeNoteConstants.CHILD_REMOVED_PROP, null, s);
			return true;
		}
		return false;
	}

	@Override
	public Image getIcon() {
		return SYSTEM_ICON;
	}

	public void setChildren(List<Shape> children) {
		this.children = children;
	}	

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?