movecommand.java

来自「GEF初学者可以用来对照的小例子」· Java 代码 · 共 41 行

JAVA
41
字号
package com.dss.moon.gef.commands;

import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.commands.Command;

import com.dss.moon.gef.model.Ellipse;

public class MoveCommand extends Command{

	private Ellipse node;
	//private Point oldloc;
	//private Point newloc;
	private Rectangle constraint,oldcon;
	
	public void setConstraint(Rectangle p){
		constraint = p;
	}
	
	public void setNode(Ellipse n){
		node = n;
	}
	
	public String getLabel(){
		return "move node";
	}
	
	public void execute(){
		oldcon = node.getConstraint();
		node.setConstraint(constraint);
	}
	
	public void redo(){
		execute();
	}
	
	public void undo(){
		node.setConstraint(oldcon);
	}
}

⌨️ 快捷键说明

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