This page last changed on Apr 13, 2005 by jgarnett.
PanCommand.java
/**
 * A command that pans the viewport. The command can be defined in terms of pixels on the screen or
 * in terms of world units.
 * 
 * @author jeichar
 * @since 0.3
 */
public class PanCommand extends AbstractNavCommand implements NavCommand {

	double worldx, worldy;

	int pixelx, pixely;

	boolean inPixel;

	/**
	 * Creates a new instance of PanCommand
	 * 
	 * @param pixelx The amount to pan in the x direction
	 * @param pixely The amount to pan in the y direction
	 */
	public PanCommand(int pixelx, int pixely) {
		this.pixelx = pixelx;
		this.pixely = pixely;
		inPixel = true;
	}

	/**
	 * Creates a new instance of PanCommand
	 * 
	 * @param worldx The amount to pan in the x direction
	 * @param worldy The amount to pan in the y direction
	 */
	public PanCommand(double worldx, double worldy) {
		this.worldx = worldx;
		this.worldy = worldy;
		inPixel = false;
	}

	/**
	 * @see net.refractions.udig.project.internal.command.navigation.AbstractNavCommand#runImpl()
	 */
	protected void runImpl() throws Exception {
		if (inPixel)
			model.panUsingScreenCoords(pixelx, pixely);
		else
			model.panUsingWorldCoords(worldx, worldy);
	}

	/**
	 * @see net.refractions.udig.project.internal.command.Command#copy()
	 */
	public Command copy() {
		if (inPixel)
			return new PanCommand(pixelx, pixely);

		return new PanCommand(worldx, worldy);
	}

	/**
	 * @see net.refractions.udig.project.command.Command#getName()
	 */
	public String getName() {
		return Policy.bind("PanCommand.pan"); //$NON-NLS-1$
	}

}
Document generated by Confluence on Nov 19, 2005 20:03