gvsig-raster / org.gvsig.raster.principalcomponents / branches / org.gvsig.raster.principalcomponents_dataaccess_refactoring / org.gvsig.raster.principalcomponents.app.principalcomponentsclient / src / main / java / org / gvsig / raster / principalcomponents / app / PrincipalComponentsTocMenuEntry.java @ 2367
History | View | Annotate | Download (2.26 KB)
1 |
package org.gvsig.raster.principalcomponents.app; |
---|---|
2 |
|
3 |
import javax.swing.Icon; |
4 |
|
5 |
import org.gvsig.andami.IconThemeHelper; |
6 |
import org.gvsig.andami.plugins.Extension; |
7 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
8 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
9 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
10 |
import org.gvsig.i18n.Messages; |
11 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
12 |
import org.gvsig.raster.fmap.layers.ILayerState; |
13 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
14 |
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem; |
15 |
|
16 |
public class PrincipalComponentsTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
17 |
static private PrincipalComponentsTocMenuEntry singleton = null; |
18 |
private static Extension extension = null; |
19 |
|
20 |
|
21 |
public static void setExtension(Extension ext) { |
22 |
extension = ext; |
23 |
} |
24 |
|
25 |
private PrincipalComponentsTocMenuEntry() {}
|
26 |
|
27 |
static public PrincipalComponentsTocMenuEntry getSingleton() { |
28 |
if (singleton == null) |
29 |
singleton = new PrincipalComponentsTocMenuEntry();
|
30 |
return singleton;
|
31 |
} |
32 |
|
33 |
public String getGroup() { |
34 |
return "Multispectral"; |
35 |
} |
36 |
|
37 |
public int getGroupOrder() { |
38 |
return 55; |
39 |
} |
40 |
|
41 |
public int getOrder() { |
42 |
return 0; |
43 |
} |
44 |
|
45 |
public String getText() { |
46 |
return Messages.getText("principalcomponents"); |
47 |
} |
48 |
|
49 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
50 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
51 |
return false; |
52 |
|
53 |
if (!(selectedItems[0] instanceof ILayerState)) |
54 |
return false; |
55 |
|
56 |
if (!((ILayerState) selectedItems[0]).isOpen()) |
57 |
return false; |
58 |
|
59 |
if(((FLyrRaster) selectedItems[0]).getRender().getFilterList().get("colortable") != null) |
60 |
return false; |
61 |
|
62 |
return true; |
63 |
} |
64 |
|
65 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
66 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
67 |
return false; |
68 |
|
69 |
if (!(selectedItems[0] instanceof IRasterLayerActions)) |
70 |
return false; |
71 |
|
72 |
return ((IRasterLayerActions) selectedItems[0]).isActionEnabled(IRasterLayerActions.ENHANCED); |
73 |
} |
74 |
|
75 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
76 |
extension.execute("PrincipalComponents");
|
77 |
} |
78 |
|
79 |
public Icon getIcon() { |
80 |
return IconThemeHelper.getImageIcon("principal-components"); |
81 |
} |
82 |
|
83 |
} |