gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / infobypoint / InfoByRasterPointTocMenuEntry.java @ 1169
History | View | Annotate | Download (4.61 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.raster.tools.app.basic.tool.infobypoint; |
20 |
|
21 |
import javax.swing.Icon; |
22 |
|
23 |
import org.gvsig.andami.PluginServices; |
24 |
import org.gvsig.app.project.documents.view.ViewDocument; |
25 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
26 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
27 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
28 |
import org.gvsig.fmap.mapcontext.MapContext; |
29 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
30 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
31 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
32 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
33 |
import org.gvsig.raster.tools.app.basic.raster.gui.IGenericToolBarMenuItem; |
34 |
|
35 |
/**
|
36 |
* Entry point to the InfoByRasterPoint tool
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
38 |
*/
|
39 |
public class InfoByRasterPointTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
40 |
static private InfoByRasterPointTocMenuEntry singleton = null; |
41 |
private InfoByRasterPointExtension extension = null; |
42 |
|
43 |
/**
|
44 |
* Nadie puede crear una instancia a esta clase ?nica, hay que usar el
|
45 |
* getSingleton()
|
46 |
*/
|
47 |
private InfoByRasterPointTocMenuEntry() {
|
48 |
extension = new InfoByRasterPointExtension();
|
49 |
extension.initialize(); |
50 |
} |
51 |
|
52 |
/**
|
53 |
* Devuelve un objeto unico a dicha clase
|
54 |
* @return
|
55 |
*/
|
56 |
static public InfoByRasterPointTocMenuEntry getSingleton() { |
57 |
if (singleton == null) |
58 |
singleton = new InfoByRasterPointTocMenuEntry();
|
59 |
return singleton;
|
60 |
} |
61 |
/*
|
62 |
* (non-Javadoc)
|
63 |
* @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroup()
|
64 |
*/
|
65 |
public String getGroup() { |
66 |
return "RasterLayer"; |
67 |
} |
68 |
|
69 |
/*
|
70 |
* (non-Javadoc)
|
71 |
* @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroupOrder()
|
72 |
*/
|
73 |
public int getGroupOrder() { |
74 |
return 55; |
75 |
} |
76 |
|
77 |
/*
|
78 |
* (non-Javadoc)
|
79 |
* @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getOrder()
|
80 |
*/
|
81 |
public int getOrder() { |
82 |
return 1; |
83 |
} |
84 |
|
85 |
/*
|
86 |
* (non-Javadoc)
|
87 |
* @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getText()
|
88 |
*/
|
89 |
public String getText() { |
90 |
return RasterToolsUtil.getText(this, "infobypoint"); |
91 |
} |
92 |
|
93 |
/*
|
94 |
* (non-Javadoc)
|
95 |
* @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
96 |
*/
|
97 |
@SuppressWarnings("deprecation") |
98 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
99 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
100 |
if (f == null) |
101 |
return false; |
102 |
if (f instanceof AbstractViewPanel) { |
103 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
104 |
ViewDocument model = vista.getModel(); |
105 |
MapContext mapa = model.getMapContext(); |
106 |
FLayers layers = mapa.getLayers(); |
107 |
for (int i = 0; i < layers.getLayersCount(); i++) |
108 |
if (layers.getLayer(i) instanceof FLyrRaster && layers.getLayer(i).isActive()) |
109 |
return true; |
110 |
} |
111 |
return false; |
112 |
} |
113 |
|
114 |
/*
|
115 |
* (non-Javadoc)
|
116 |
* @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
117 |
*/
|
118 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
119 |
return true; |
120 |
} |
121 |
|
122 |
/*
|
123 |
* (non-Javadoc)
|
124 |
* @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
125 |
*/
|
126 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
127 |
extension.execute("INFO_BY_PIXEL");
|
128 |
} |
129 |
|
130 |
/*
|
131 |
* (non-Javadoc)
|
132 |
* @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getIcon()
|
133 |
*/
|
134 |
public Icon getIcon() { |
135 |
return RasterToolsUtil.getIcon("info-by-pixel"); |
136 |
} |
137 |
} |