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 / ZoomPrev.java @ 42589
History | View | Annotate | Download (2.73 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40558 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
6 | 41248 | jjdelcerro | * 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 | 40435 | jjdelcerro | *
|
11 | 41248 | jjdelcerro | * 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 | 40435 | jjdelcerro | *
|
16 | 41248 | jjdelcerro | * 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 | 40435 | jjdelcerro | *
|
20 | 41248 | jjdelcerro | * For any additional information, do not hesitate to contact us at info AT
|
21 | * gvsig.com, or visit our website www.gvsig.com.
|
||
22 | 40435 | jjdelcerro | */
|
23 | package org.gvsig.app.extension; |
||
24 | |||
25 | import org.gvsig.andami.IconThemeHelper; |
||
26 | import org.gvsig.andami.plugins.Extension; |
||
27 | 41248 | jjdelcerro | import org.gvsig.app.ApplicationLocator; |
28 | import org.gvsig.app.ApplicationManager; |
||
29 | import org.gvsig.app.project.documents.view.ViewDocument; |
||
30 | 41264 | jjdelcerro | import org.gvsig.app.project.documents.view.gui.IView; |
31 | 40435 | jjdelcerro | import org.gvsig.fmap.mapcontext.ViewPort; |
32 | |||
33 | /**
|
||
34 | * Extensi?n que cambia el extent de la vista al extent anterior.
|
||
35 | */
|
||
36 | public class ZoomPrev extends Extension { |
||
37 | |||
38 | 42173 | mcompany | public void postInitialize() {} |
39 | 40435 | jjdelcerro | |
40 | 42173 | mcompany | public void initialize() { |
41 | IconThemeHelper.registerIcon("action", "view-navigation-zoom-back", this); |
||
42 | } |
||
43 | 40435 | jjdelcerro | |
44 | 42173 | mcompany | public boolean isEnabled() { |
45 | ApplicationManager application = ApplicationLocator.getManager(); |
||
46 | 40435 | jjdelcerro | |
47 | 42173 | mcompany | IView view = (IView) application.getActiveComponent(ViewDocument.class); |
48 | if (view == null) { |
||
49 | return false; |
||
50 | 41248 | jjdelcerro | } |
51 | 42173 | mcompany | ViewDocument document = view.getViewDocument(); |
52 | ViewPort vp = document.getMapContext().getViewPort(); |
||
53 | return vp.getEnvelopes().hasPrevious();
|
||
54 | } |
||
55 | 40435 | jjdelcerro | |
56 | 42173 | mcompany | public boolean isVisible() { |
57 | ApplicationManager application = ApplicationLocator.getManager(); |
||
58 | 40435 | jjdelcerro | |
59 | 42173 | mcompany | IView view = (IView) application.getActiveComponent(ViewDocument.class); |
60 | if (view == null) { |
||
61 | return false; |
||
62 | 41248 | jjdelcerro | } |
63 | 42173 | mcompany | ViewDocument document = view.getViewDocument(); |
64 | return document.getMapContext().getLayers().getLayersCount() > 0; |
||
65 | } |
||
66 | 40435 | jjdelcerro | |
67 | 42173 | mcompany | public void execute(String arg0) { |
68 | ApplicationManager application = ApplicationLocator.getManager(); |
||
69 | 41248 | jjdelcerro | |
70 | 42173 | mcompany | IView view = (IView) application.getActiveComponent(ViewDocument.class); |
71 | if (view == null) { |
||
72 | return;
|
||
73 | 41248 | jjdelcerro | } |
74 | 42173 | mcompany | ViewDocument document = view.getViewDocument(); |
75 | ViewPort vp = document.getMapContext().getViewPort(); |
||
76 | 41248 | jjdelcerro | |
77 | 42173 | mcompany | vp.setPreviousEnvelope(); |
78 | document.setModified(true);
|
||
79 | |||
80 | ApplicationLocator.getManager().refreshMenusAndToolBars(); |
||
81 | } |
||
82 | |||
83 | 40435 | jjdelcerro | } |