01: /*
02: * uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004,
03: * Refractions Research Inc. This library is free software; you can redistribute it and/or modify it
04: * under the terms of the GNU Lesser General Public License as published by the Free Software
05: * Foundation; version 2.1 of the License. This library is distributed in the hope that it will be
06: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
07: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
08: */
09: package net.refractions.udig.project.internal.command.navigation;
10:
11: import java.text.MessageFormat;
12:
13: import net.refractions.udig.project.command.MapCommand;
14: import net.refractions.udig.project.command.NavCommand;
15: import net.refractions.udig.project.internal.Messages;
16:
17: import org.eclipse.core.runtime.IProgressMonitor;
18:
19: /**
20: * Sets the width of the Viewport bounding box. Because the aspect ratio of the viewport bounding
21: * box is tied to the bounding box of the viewport, the height is also set to maintain the correct
22: * aspect ratio.
23: *
24: * @author jeichar
25: * @since 0.3
26: */
27: public class SetViewportWidth extends AbstractNavCommand implements
28: NavCommand {
29:
30: private double width;
31:
32: /**
33: * Creates a new instance of SetViewportWidth
34: *
35: * @param width the new viewport width
36: */
37: public SetViewportWidth(double width) {
38: this .width = width;
39: }
40:
41: /**
42: * @see net.refractions.udig.project.internal.command.navigation.AbstractNavCommand#runImpl()
43: */
44: protected void runImpl(IProgressMonitor monitor) throws Exception {
45: model.setWidth(width);
46: }
47:
48: /**
49: * @see net.refractions.udig.project.internal.command.MapCommand#copy()
50: */
51: public MapCommand copy() {
52: return new SetViewportWidth(width);
53: }
54:
55: /**
56: * @see net.refractions.udig.project.command.MapCommand#getName()
57: */
58: public String getName() {
59: return MessageFormat.format(
60: Messages.SetViewportWidth_setViewWidth,
61: new Object[] { width });
62: }
63:
64: }
|