root / branches / v2_0_0_prep / extensions / extCenterViewToPoint / src / org / gvsig / centerviewpoint / CenterViewToPointExtension.java @ 38564
History | View | Annotate | Download (4.08 KB)
1 | 27475 | vcaballero | /*
|
---|---|---|---|
2 | * Created on 22-jun-2005
|
||
3 | *
|
||
4 | * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
5 | *
|
||
6 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
7 | *
|
||
8 | * This program is free software; you can redistribute it and/or
|
||
9 | * modify it under the terms of the GNU General Public License
|
||
10 | * as published by the Free Software Foundation; either version 2
|
||
11 | * of the License, or (at your option) any later version.
|
||
12 | *
|
||
13 | * This program is distributed in the hope that it will be useful,
|
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
16 | * GNU General Public License for more details.
|
||
17 | *
|
||
18 | * You should have received a copy of the GNU General Public License
|
||
19 | * along with this program; if not, write to the Free Software
|
||
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
21 | *
|
||
22 | * For more information, contact:
|
||
23 | *
|
||
24 | * Generalitat Valenciana
|
||
25 | * Conselleria d'Infraestructures i Transport
|
||
26 | * Av. Blasco Ib??ez, 50
|
||
27 | * 46010 VALENCIA
|
||
28 | * SPAIN
|
||
29 | *
|
||
30 | * +34 963862235
|
||
31 | * gvsig@gva.es
|
||
32 | * www.gvsig.gva.es
|
||
33 | *
|
||
34 | * or
|
||
35 | *
|
||
36 | * IVER T.I. S.A
|
||
37 | * Salamanca 50
|
||
38 | * 46005 Valencia
|
||
39 | * Spain
|
||
40 | *
|
||
41 | * +34 963163400
|
||
42 | * dac@iver.es
|
||
43 | */
|
||
44 | 29626 | jpiera | package org.gvsig.centerviewpoint; |
45 | 27475 | vcaballero | |
46 | import java.awt.Color; |
||
47 | |||
48 | 38564 | jjdelcerro | import org.gvsig.andami.IconThemeHelper; |
49 | 29626 | jpiera | import org.gvsig.andami.PluginServices; |
50 | import org.gvsig.andami.plugins.Extension; |
||
51 | 31496 | jjdelcerro | import org.gvsig.app.project.documents.view.ViewDocument; |
52 | import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
||
53 | 29626 | jpiera | import org.gvsig.centerviewpoint.gui.InputCoordinatesPanel; |
54 | 27475 | vcaballero | import org.gvsig.fmap.mapcontext.MapContext; |
55 | import org.gvsig.fmap.mapcontext.layers.FLayers; |
||
56 | |||
57 | |||
58 | /**
|
||
59 | * The CenterViewToPointExtension class allows to center the View over a
|
||
60 | * concrete point given by its coordinates.
|
||
61 | *
|
||
62 | * @author jmorell
|
||
63 | */
|
||
64 | public class CenterViewToPointExtension extends Extension { |
||
65 | 31496 | jjdelcerro | private DefaultViewPanel vista;
|
66 | 27475 | vcaballero | public static Color COLOR=Color.red; |
67 | 38564 | jjdelcerro | |
68 | public void initialize() { |
||
69 | IconThemeHelper.registerIcon("action", "view-navigation-center-view-to-point", this); |
||
70 | 27475 | vcaballero | } |
71 | |||
72 | /* (non-Javadoc)
|
||
73 | * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
|
||
74 | */
|
||
75 | public void execute(String actionCommand) { |
||
76 | 38564 | jjdelcerro | if( "view-navigation-center-view-to-point".equalsIgnoreCase(actionCommand)) { |
77 | vista = (DefaultViewPanel)PluginServices.getMDIManager().getActiveWindow(); |
||
78 | MapContext mapContext = vista.getModel().getMapContext(); |
||
79 | InputCoordinatesPanel dataSelectionPanel = new InputCoordinatesPanel(mapContext);
|
||
80 | //dataSelectionPanel.setColor(color);
|
||
81 | PluginServices.getMDIManager().addWindow(dataSelectionPanel); |
||
82 | } |
||
83 | 27475 | vcaballero | } |
84 | |||
85 | 31496 | jjdelcerro | public DefaultViewPanel getView(){
|
86 | 27475 | vcaballero | return vista;
|
87 | } |
||
88 | /* (non-Javadoc)
|
||
89 | * @see com.iver.andami.plugins.Extension#isEnabled()
|
||
90 | */
|
||
91 | public boolean isEnabled() { |
||
92 | 29626 | jpiera | org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
93 | 27475 | vcaballero | .getActiveWindow(); |
94 | if (f == null) { |
||
95 | return false; |
||
96 | } |
||
97 | 31496 | jjdelcerro | if (f.getClass() == DefaultViewPanel.class) {
|
98 | DefaultViewPanel vista = (DefaultViewPanel) f; |
||
99 | ViewDocument model = vista.getModel(); |
||
100 | 27475 | vcaballero | MapContext mapa = model.getMapContext(); |
101 | FLayers layers = mapa.getLayers(); |
||
102 | for (int i=0;i < layers.getLayersCount();i++) { |
||
103 | if (layers.getLayer(i).isAvailable()) return true; |
||
104 | } |
||
105 | } |
||
106 | return false; |
||
107 | |||
108 | } |
||
109 | |||
110 | /* (non-Javadoc)
|
||
111 | * @see com.iver.andami.plugins.Extension#isVisible()
|
||
112 | */
|
||
113 | public boolean isVisible() { |
||
114 | 29626 | jpiera | org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
115 | 27475 | vcaballero | .getActiveWindow(); |
116 | if (f == null) { |
||
117 | return false; |
||
118 | } |
||
119 | 31496 | jjdelcerro | if (f.getClass() == DefaultViewPanel.class) {
|
120 | DefaultViewPanel vista = (DefaultViewPanel) f; |
||
121 | ViewDocument model = vista.getModel(); |
||
122 | 27475 | vcaballero | MapContext mapa = model.getMapContext(); |
123 | if (mapa.getLayers().getLayersCount() > 0) { |
||
124 | return true; |
||
125 | } |
||
126 | return false; |
||
127 | } |
||
128 | return false; |
||
129 | } |
||
130 | |||
131 | } |