gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / filter / FilterTocMenuEntry.java @ 2123
History | View | Annotate | Download (3.41 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.filter; |
23 |
|
24 |
import javax.swing.Icon; |
25 |
|
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.layers.FLayer; |
29 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
30 |
import org.gvsig.raster.fmap.layers.ILayerState; |
31 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
32 |
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem; |
33 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
34 |
import org.gvsig.raster.tools.app.basic.tool.filter.ui.FilterDialog; |
35 |
|
36 |
/**
|
37 |
* Punto de entrada del menu para los filtros
|
38 |
*
|
39 |
* @version 02/05/2007
|
40 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
41 |
*/
|
42 |
public class FilterTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
43 |
static private FilterTocMenuEntry singleton = null; |
44 |
|
45 |
/**
|
46 |
* Nadie puede crear una instancia a esta clase ?nica, hay que usar el
|
47 |
* getSingleton()
|
48 |
*/
|
49 |
private FilterTocMenuEntry() {}
|
50 |
|
51 |
/**
|
52 |
* Devuelve un objeto unico a dicha clase
|
53 |
* @return
|
54 |
*/
|
55 |
static public FilterTocMenuEntry getSingleton() { |
56 |
if (singleton == null) |
57 |
singleton = new FilterTocMenuEntry();
|
58 |
return singleton;
|
59 |
} |
60 |
|
61 |
public String getGroup() { |
62 |
return "RasterProcess"; |
63 |
} |
64 |
|
65 |
public int getGroupOrder() { |
66 |
return 55; |
67 |
} |
68 |
|
69 |
public int getOrder() { |
70 |
return 0; |
71 |
} |
72 |
|
73 |
public String getText() { |
74 |
return RasterToolsUtil.getText(this, "filtros"); |
75 |
} |
76 |
|
77 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
78 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
79 |
return false; |
80 |
|
81 |
if (!(selectedItems[0] instanceof ILayerState)) |
82 |
return false; |
83 |
|
84 |
if (!((ILayerState) selectedItems[0]).isOpen()) |
85 |
return false; |
86 |
|
87 |
return true; |
88 |
} |
89 |
|
90 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
91 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
92 |
return false; |
93 |
|
94 |
if (!(selectedItems[0] instanceof IRasterLayerActions)) |
95 |
return false; |
96 |
|
97 |
return ((IRasterLayerActions) selectedItems[0]).isActionEnabled(IRasterLayerActions.FILTER); |
98 |
} |
99 |
|
100 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
101 |
if ((selectedItems == null) || (selectedItems.length != 1) || (!(selectedItems[0] instanceof FLyrRaster))) |
102 |
return;
|
103 |
|
104 |
FilterDialog rasterFilterDialog = new FilterDialog((FLyrRaster) selectedItems[0], 740, 400); |
105 |
RasterToolsUtil.addWindow(rasterFilterDialog); |
106 |
} |
107 |
|
108 |
public Icon getIcon() { |
109 |
return RasterToolsUtil.getIcon("layer-filter-raster"); |
110 |
} |
111 |
|
112 |
public boolean isEnableEvents() { |
113 |
return true; |
114 |
} |
115 |
} |