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 / GenericToolBarModule.java @ 1426
History | View | Annotate | Download (9.46 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.tools.app.basic.tool; |
23 |
|
24 |
import java.awt.Dimension; |
25 |
|
26 |
import org.gvsig.andami.IconThemeHelper; |
27 |
import org.gvsig.andami.PluginServices; |
28 |
import org.gvsig.andami.plugins.Extension; |
29 |
import org.gvsig.andami.ui.mdiFrame.MDIFrame; |
30 |
import org.gvsig.app.project.documents.view.ViewDocument; |
31 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
32 |
import org.gvsig.fmap.mapcontext.MapContext; |
33 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
34 |
import org.gvsig.raster.tools.app.basic.tool.analysisview.ViewRasterAnalysisTocMenuEntry; |
35 |
import org.gvsig.raster.tools.app.basic.tool.clip.ClippingTocMenuEntry; |
36 |
import org.gvsig.raster.tools.app.basic.tool.colortable.ColorTableTocMenuEntry; |
37 |
import org.gvsig.raster.tools.app.basic.tool.enhanced.EnhancedTocMenuEntry; |
38 |
import org.gvsig.raster.tools.app.basic.tool.filter.FilterTocMenuEntry; |
39 |
import org.gvsig.raster.tools.app.basic.tool.generictoolbar.GenericToolBarMenuItem; |
40 |
import org.gvsig.raster.tools.app.basic.tool.generictoolbar.GenericToolBarPanel; |
41 |
import org.gvsig.raster.tools.app.basic.tool.geolocation.GeoLocationTocMenuEntry; |
42 |
import org.gvsig.raster.tools.app.basic.tool.histogram.HistogramTocMenuEntry; |
43 |
import org.gvsig.raster.tools.app.basic.tool.infobypoint.InfoByRasterPointTocMenuEntry; |
44 |
import org.gvsig.raster.tools.app.basic.tool.layerdatatype.LayerDatatypeTocMenuEntry; |
45 |
import org.gvsig.raster.tools.app.basic.tool.multiresolution.ZoomResolutionLevelTocMenuEntry; |
46 |
import org.gvsig.raster.tools.app.basic.tool.overview.OverviewsTocMenuEntry; |
47 |
import org.gvsig.raster.tools.app.basic.tool.properties.RasterPropertiesTocMenuEntry; |
48 |
import org.gvsig.raster.tools.app.basic.tool.roi.ROIManagerTocMenuEntry; |
49 |
import org.gvsig.raster.tools.app.basic.tool.saveas.SaveAsTocMenuEntry; |
50 |
import org.gvsig.raster.tools.app.basic.tool.saveraster.SaveRasterTocMenuEntry; |
51 |
import org.gvsig.raster.tools.app.basic.tool.selectrasterlayer.SelectLayerTocMenuEntry; |
52 |
import org.gvsig.raster.tools.app.basic.tool.viewexport.SaveViewToImageTocMenuEntry; |
53 |
import org.gvsig.tools.ToolsLocator; |
54 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
55 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
56 |
|
57 |
/**
|
58 |
* Extension para la barra de herramientas generica
|
59 |
*
|
60 |
* @version 13/02/2008
|
61 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
62 |
*/
|
63 |
public class GenericToolBarModule extends Extension { |
64 |
private GenericToolBarPanel toolBar = null; |
65 |
|
66 |
/**
|
67 |
* Crea y devuelve la barra de herramientas
|
68 |
* @return
|
69 |
*/
|
70 |
private GenericToolBarPanel getGenericToolBarPanel() {
|
71 |
if (toolBar == null) { |
72 |
MDIFrame f = (MDIFrame) PluginServices.getMainFrame(); |
73 |
if (f == null) |
74 |
return null; |
75 |
toolBar = new GenericToolBarPanel();
|
76 |
toolBar.setVisible(false);
|
77 |
f.addToolBarControl(getClass(), toolBar, "RasterToolBar");
|
78 |
} else {
|
79 |
toolBar.setPreferredSize(new Dimension(300, getToolbarHeight())); |
80 |
} |
81 |
|
82 |
return toolBar;
|
83 |
} |
84 |
|
85 |
/**
|
86 |
* Obtenemos el alto de cualquier toolbar que este visible en gvSIG y no sea
|
87 |
* nuestro para poder asignarselo al GenericToolBar como PreferredSize. En
|
88 |
* caso de no encontrar ninguno que cumpla las condiciones, se devolver? 24
|
89 |
* @return
|
90 |
*/
|
91 |
private int getToolbarHeight() { |
92 |
if ((PluginServices.getMainFrame() == null) || |
93 |
(PluginServices.getMainFrame().getToolbars() == null) ||
|
94 |
(PluginServices.getMainFrame().getToolbars().length <= 0))
|
95 |
return 24; |
96 |
|
97 |
for (int i = 0; i < PluginServices.getMainFrame().getToolbars().length; i++) { |
98 |
if ((PluginServices.getMainFrame().getToolbars()[i].getHeight() > 16) && |
99 |
((Object) PluginServices.getMainFrame().getToolbars()[i] != (Object) toolBar)) |
100 |
return PluginServices.getMainFrame().getToolbars()[i].getHeight();
|
101 |
} |
102 |
return 24; |
103 |
} |
104 |
|
105 |
/*
|
106 |
* (non-Javadoc)
|
107 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
108 |
*/
|
109 |
public void initialize() { |
110 |
registerIcons(); |
111 |
|
112 |
// Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades.
|
113 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
114 |
ExtensionPoint point = extensionPoints.add("GenericToolBarGroup");
|
115 |
point.setDescription("Punto de extension para los grupos de menus del GenericToolBarPanel");
|
116 |
|
117 |
point.append("RasterLayer", "", new GenericToolBarMenuItem(RasterToolsUtil.getText(this, "capa_raster"), IconThemeHelper.getImageIcon("menu-layer-icon"))); |
118 |
point.append("RasterProcess", "", new GenericToolBarMenuItem(RasterToolsUtil.getText(this, "process_raster"), IconThemeHelper.getImageIcon("menu-process-icon"))); |
119 |
point.append("GeoRaster", "", new GenericToolBarMenuItem(RasterToolsUtil.getText(this, "transformaciones_geograficas"), IconThemeHelper.getImageIcon("menu-transgeo-icon"))); |
120 |
point.append("RasterExport", "", new GenericToolBarMenuItem(RasterToolsUtil.getText(this, "raster_export"), IconThemeHelper.getImageIcon("menu-raster-export"))); |
121 |
|
122 |
point = extensionPoints.add("GenericToolBarMenu");
|
123 |
point.setDescription("Punto de extension para los submenus del GenericToolBarPanel");
|
124 |
point.append("RasterProperties", "", RasterPropertiesTocMenuEntry.getSingleton()); |
125 |
point.append("SelectLayer", "", SelectLayerTocMenuEntry.getSingleton()); |
126 |
point.append("HistogramPanel", "", HistogramTocMenuEntry.getSingleton()); |
127 |
point.append("ViewColorTable", "",ColorTableTocMenuEntry.getSingleton()); |
128 |
point.append("Overviews", "", OverviewsTocMenuEntry.getSingleton()); |
129 |
point.append("RoisManager", "", ROIManagerTocMenuEntry.getSingleton()); |
130 |
point.append("ViewRasterAnalysis", "", ViewRasterAnalysisTocMenuEntry.getSingleton()); |
131 |
point.append("ZoomResolutionLevel", "", ZoomResolutionLevelTocMenuEntry.getSingleton()); |
132 |
|
133 |
point.append("SaveAs", "", SaveAsTocMenuEntry.getSingleton()); |
134 |
point.append("ClippingPanel", "", ClippingTocMenuEntry.getSingleton()); |
135 |
point.append("SaveRaster", "", SaveRasterTocMenuEntry.getSingleton()); |
136 |
point.append("SaveViewToImageRaster", "", SaveViewToImageTocMenuEntry.getSingleton()); |
137 |
|
138 |
point.append("FilterPanel", "", FilterTocMenuEntry.getSingleton()); |
139 |
point.append("EnhancedPanel", "", EnhancedTocMenuEntry.getSingleton()); |
140 |
point.append("GeoLocation", "", GeoLocationTocMenuEntry.getSingleton()); |
141 |
point.append("InfoByPoint", "", InfoByRasterPointTocMenuEntry.getSingleton()); |
142 |
point.append("LayerDatatype", "", LayerDatatypeTocMenuEntry.getSingleton()); |
143 |
//point.append("Vectorization", "", VectorizationTocMenuEntry.getSingleton());
|
144 |
//point.append("Reproject", "", ReprojectTocMenuEntry.getSingleton());
|
145 |
|
146 |
} |
147 |
|
148 |
private void registerIcons() { |
149 |
//Actions
|
150 |
IconThemeHelper.registerIcon("action", "menu-layer-icon", this); |
151 |
IconThemeHelper.registerIcon("action", "menu-process-icon", this); |
152 |
IconThemeHelper.registerIcon("action", "menu-transgeo-icon", this); |
153 |
IconThemeHelper.registerIcon("action", "menu-raster-export", this); |
154 |
} |
155 |
|
156 |
@Override
|
157 |
public void postInitialize() { |
158 |
super.postInitialize();
|
159 |
if (getGenericToolBarPanel() != null) |
160 |
getGenericToolBarPanel().reloadMenuGroup(); |
161 |
} |
162 |
|
163 |
/*
|
164 |
* (non-Javadoc)
|
165 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
166 |
*/
|
167 |
public boolean isEnabled() { |
168 |
return false; |
169 |
} |
170 |
|
171 |
/**
|
172 |
* Establece si la barra de herramientas esta visible
|
173 |
* @param enabled
|
174 |
*/
|
175 |
private void setToolBarVisible(boolean enabled) { |
176 |
if (getGenericToolBarPanel() == null) |
177 |
return;
|
178 |
|
179 |
toolBar.setVisible(enabled); |
180 |
} |
181 |
|
182 |
/*
|
183 |
* (non-Javadoc)
|
184 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
185 |
*/
|
186 |
@SuppressWarnings("deprecation") |
187 |
public boolean isVisible() { |
188 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
189 |
if (f == null || !(f instanceof AbstractViewPanel)) { |
190 |
setToolBarVisible(false);
|
191 |
return false; |
192 |
} |
193 |
|
194 |
if (getGenericToolBarPanel() != null) |
195 |
getGenericToolBarPanel().setLayers(null);
|
196 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
197 |
ViewDocument model = vista.getModel(); |
198 |
MapContext mapa = model.getMapContext(); |
199 |
if (mapa.getLayers().getLayersCount() > 0) { |
200 |
if (getGenericToolBarPanel() != null) { |
201 |
getGenericToolBarPanel().setLayers(mapa.getLayers()); |
202 |
} |
203 |
} |
204 |
|
205 |
setToolBarVisible(true);
|
206 |
return true; |
207 |
|
208 |
/*if (f instanceof AbstractViewPanel) {
|
209 |
AbstractViewPanel vista = (AbstractViewPanel) f;
|
210 |
ViewDocument model = vista.getModel();
|
211 |
MapContext mapa = model.getMapContext();
|
212 |
if (mapa.getLayers().getLayersCount() > 0) {
|
213 |
setToolBarVisible(true);
|
214 |
if (getGenericToolBarPanel() != null) {
|
215 |
getGenericToolBarPanel().setLayers(mapa.getLayers());
|
216 |
}
|
217 |
return true;
|
218 |
}
|
219 |
}
|
220 |
|
221 |
setToolBarVisible(false);
|
222 |
return false;*/
|
223 |
} |
224 |
|
225 |
public void execute(String actionCommand) {} |
226 |
} |