01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.project.internal.commands;
16:
17: import net.refractions.udig.project.command.AbstractCommand;
18: import net.refractions.udig.project.command.UndoableCommand;
19: import net.refractions.udig.project.internal.Messages;
20:
21: import org.eclipse.core.runtime.IProgressMonitor;
22:
23: /**
24: * Sets the scale denominator of the map.
25: *
26: * @author Jesse
27: * @since 1.1.0
28: */
29: public class SetScaleCommand extends AbstractCommand implements
30: UndoableCommand {
31:
32: private double oldScale;
33: private double newScale;
34:
35: public SetScaleCommand(double newScale) {
36: this .newScale = newScale;
37: }
38:
39: public void rollback(IProgressMonitor monitor) throws Exception {
40: getMap().getViewportModelInternal().setScale(oldScale);
41: }
42:
43: public String getName() {
44: return Messages.SetScaleCommand_name;
45: }
46:
47: public void run(IProgressMonitor monitor) throws Exception {
48: this.oldScale = getMap().getViewportModel()
49: .getScaleDenominator();
50: getMap().getViewportModelInternal().setScale(newScale);
51: }
52:
53: }
|