movenodecommand.java

来自「eclipse开发笔记」· Java 代码 · 共 44 行

JAVA
44
字号
package com.example.commands;

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

import com.example.model.FNode;

/**
 * TODO 
 * @2007-1-26
 * @author xuli
 */
public class MoveNodeCommand extends Command {
	private FNode node;

	private Point oldPos;

	private Point newPos;

	public void setLocation(Point p) {
		this.newPos = p;
	}

	public void setNode(FNode node) {
		this.node = node;
	}

	public void execute() {
		oldPos = this.node.getLocation();
		node.setLocation(newPos);
	}

	public String getLabel() {
		return "";
	}

	public void redo() {
		this.node.setLocation(newPos);
	}

	public void undo() {
		this.node.setLocation(oldPos);
	}
}

⌨️ 快捷键说明

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