⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diagramlayouteditpolicy.java

📁 GEF基础源码
💻 JAVA
字号:
package com.jixy.study.gef.util;

import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
import org.eclipse.gef.requests.CreateRequest;

import com.jixy.study.gef.model.Ellipse;

// XYLayoutEditPolicy is a policy that constrains figures by a location and size
// This extends it with the capability to change the location 
public class DiagramLayoutEditPolicy extends XYLayoutEditPolicy {
	// Abstract methods from ConstrainedLayoutEditPolicy
	protected Command createAddCommand(EditPart child, Object constraint) {
		return null;
		// no support for adding
	}

	protected Command createChangeConstraintCommand(EditPart child,
			Object constraint) {
		// return a command to move the part to the location given by the
		// constraint
		MoveCommand locationCommand = new MoveCommand();
		locationCommand.setNode((Ellipse) child.getModel());
		locationCommand.setLocation(((Rectangle) constraint).getLocation());
		return locationCommand;
	}

	protected Command getCreateCommand(CreateRequest request) {
		return null;
		// no support for creating
	}

	protected Command getDeleteDependantCommand(Request request) {
		return null;
	}
}

⌨️ 快捷键说明

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