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 net.refractions.udig.project.IMap;
12: import net.refractions.udig.project.command.NavCommand;
13: import net.refractions.udig.project.internal.Map;
14: import net.refractions.udig.project.internal.render.ViewportModel;
15:
16: import org.eclipse.core.runtime.IProgressMonitor;
17:
18: import com.vividsolutions.jts.geom.Envelope;
19:
20: /**
21: * TODO Purpose of net.refractions.udig.project.internal.command.navigation
22: * <p>
23: * </p>
24: *
25: * @author Jesse
26: * @since 1.0.0
27: */
28: public abstract class AbstractNavCommand implements NavCommand {
29:
30: private Envelope oldbbox = null;
31:
32: protected ViewportModel model = null;
33:
34: private Map map;
35:
36: /**
37: * @see net.refractions.udig.project.internal.command.UndoableCommand#rollback()
38: */
39: public void rollback(IProgressMonitor monitor) throws Exception {
40: model.zoomToBox(oldbbox);
41: }
42:
43: /**
44: * @see net.refractions.udig.project.internal.command.MapCommand#run()
45: */
46: public void run(IProgressMonitor monitor) throws Exception {
47: oldbbox = model.getBounds();
48: runImpl(monitor);
49: }
50:
51: /**
52: * This where the actual implementation of subclasses should go.
53: *
54: * @throws Exception
55: */
56: protected abstract void runImpl(IProgressMonitor monitor)
57: throws Exception;
58:
59: /**
60: * @see net.refractions.udig.project.internal.command.navigation.NavCommand#setViewportModel(net.refractions.udig.project.ViewportModelControl)
61: */
62: public void setViewportModel(ViewportModel model) {
63: this .model = model;
64: }
65:
66: /**
67: * @see net.refractions.udig.project.command.MapCommand#setMap(IMap)
68: * @uml.property name="map"
69: */
70: public void setMap(IMap map) {
71: this .map = (Map) map;
72: }
73:
74: /**
75: * @see net.refractions.udig.project.command.MapCommand#getMap()
76: * @uml.property name="map"
77: */
78: public Map getMap() {
79: return map;
80: }
81:
82: }
|