rootshape.java
来自「mywork是rcp开发的很好的例子」· Java 代码 · 共 75 行
JAVA
75 行
package net.sf.freenote.mindmap.model;
import net.sf.freenote.FreeNoteConstants;
import net.sf.freenote.mindmap.NumberPropertyDescriptor;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
/**
* 中心主题
* @author levin
* @since 2008-2-11 下午08:35:12
*/
public class RootShape extends BranchShape {
private static final Image ROOT_ICON = createImage("icons/root.gif");
private int major = 20;
private int minor = 10;
public RootShape() {
super();
setSize(new Dimension(540,380));
}
public Image getIcon() {
return ROOT_ICON;
}
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
IPropertyDescriptor[] propertyDescriptors = super.getPropertyDescriptors();
IPropertyDescriptor[] ret=new IPropertyDescriptor[propertyDescriptors.length+2];
System.arraycopy(propertyDescriptors, 0, ret, 2, propertyDescriptors.length);
ret[0]=new NumberPropertyDescriptor(FreeNoteConstants.MAJOR_SPACING_PROP, FreeNoteConstants.MAJOR_SPACING_PROP,int.class);
ret[1]=new NumberPropertyDescriptor(FreeNoteConstants.MINOR_SPACING_PROP, FreeNoteConstants.MINOR_SPACING_PROP,int.class);
return ret;
}
@Override
public Object getPropertyValue(Object propertyId) {
if(propertyId.equals(FreeNoteConstants.MAJOR_SPACING_PROP))
return getMajor();
if(propertyId.equals(FreeNoteConstants.MINOR_SPACING_PROP))
return getMinor();
return super.getPropertyValue(propertyId);
}
@Override
public void setPropertyValue(Object propertyId, Object value) {
if(propertyId.equals(FreeNoteConstants.MAJOR_SPACING_PROP))
setMajor((Integer)value);
if(propertyId.equals(FreeNoteConstants.MINOR_SPACING_PROP))
setMinor((Integer)value);
super.setPropertyValue(propertyId, value);
}
public int getMajor() {
return major==0?major=20:major;
}
public void setMajor(int major) {
this.major = major;
firePropertyChange(FreeNoteConstants.MAJOR_SPACING_PROP, null, major);
}
public int getMinor() {
return minor==0?minor=10:minor;
}
public void setMinor(int minor) {
this.minor = minor;
firePropertyChange(FreeNoteConstants.MINOR_SPACING_PROP, null, minor);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?