svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / extension / ZoomNext.java @ 42173
History | View | Annotate | Download (2.7 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
9 |
* version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
14 |
* details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License along with
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.app.extension; |
24 |
|
25 |
import org.gvsig.andami.IconThemeHelper; |
26 |
import org.gvsig.andami.plugins.Extension; |
27 |
import org.gvsig.app.ApplicationLocator; |
28 |
import org.gvsig.app.ApplicationManager; |
29 |
import org.gvsig.app.project.documents.view.ViewDocument; |
30 |
import org.gvsig.app.project.documents.view.gui.IView; |
31 |
import org.gvsig.fmap.mapcontext.ViewPort; |
32 |
|
33 |
/**
|
34 |
* Extensi?n que cambia el extent de la vista al extent siguiente.
|
35 |
*/
|
36 |
public class ZoomNext extends Extension { |
37 |
|
38 |
public void initialize() { |
39 |
IconThemeHelper.registerIcon("action", "view-navigation-zoom-next", this); |
40 |
} |
41 |
|
42 |
public boolean isEnabled() { |
43 |
ApplicationManager application = ApplicationLocator.getManager(); |
44 |
|
45 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
46 |
if (view == null) { |
47 |
return false; |
48 |
} |
49 |
|
50 |
ViewDocument document = view.getViewDocument(); |
51 |
ViewPort vp = document.getMapContext().getViewPort(); |
52 |
return vp.getEnvelopes().hasNext();
|
53 |
} |
54 |
|
55 |
public boolean isVisible() { |
56 |
ApplicationManager application = ApplicationLocator.getManager(); |
57 |
|
58 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
59 |
if (view == null) { |
60 |
return false; |
61 |
} |
62 |
ViewDocument document = view.getViewDocument(); |
63 |
return document.getMapContext().getLayers().getLayersCount() > 0; |
64 |
} |
65 |
|
66 |
public void execute(String actionCommand) { |
67 |
ApplicationManager application = ApplicationLocator.getManager(); |
68 |
|
69 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
70 |
if (view == null) { |
71 |
return;
|
72 |
} |
73 |
ViewDocument document = view.getViewDocument(); |
74 |
ViewPort vp = document.getMapContext().getViewPort(); |
75 |
|
76 |
vp.setNextEnvelope(); |
77 |
document.setModified(true);
|
78 |
|
79 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
80 |
} |
81 |
} |