root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / colortable / ColorTableTocMenuEntry.java @ 20948
History | View | Annotate | Download (4.51 KB)
1 | 12344 | bsanchez | /* 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.rastertools.colortable; |
||
20 | |||
21 | 18826 | bsanchez | import javax.swing.Icon; |
22 | |||
23 | 12425 | nacho | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
24 | 13703 | nacho | import org.gvsig.fmap.raster.layers.ILayerState; |
25 | 13300 | nacho | import org.gvsig.fmap.raster.layers.IRasterLayerActions; |
26 | 18826 | bsanchez | import org.gvsig.raster.gui.IGenericToolBarMenuItem; |
27 | 20646 | nbrodin | import org.gvsig.raster.util.RasterToolsUtil; |
28 | 12344 | bsanchez | import org.gvsig.rastertools.colortable.ui.ColorTableDialog; |
29 | |||
30 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
31 | import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
||
32 | import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
||
33 | /**
|
||
34 | * <code>ColorTableTocMenuEntry</code> es el punto de entrada del menu de la
|
||
35 | * tabla de color
|
||
36 | 13693 | bsanchez | *
|
37 | 12344 | bsanchez | * @version 26/06/2007
|
38 | 12369 | bsanchez | * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
39 | 12344 | bsanchez | */
|
40 | 18826 | bsanchez | public class ColorTableTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
41 | static private ColorTableTocMenuEntry singleton = null; |
||
42 | |||
43 | /**
|
||
44 | * Nadie puede crear una instancia a esta clase ?nica, hay que usar el
|
||
45 | * getSingleton()
|
||
46 | */
|
||
47 | private ColorTableTocMenuEntry() {}
|
||
48 | |||
49 | /**
|
||
50 | * Devuelve un objeto unico a dicha clase
|
||
51 | * @return
|
||
52 | */
|
||
53 | static public ColorTableTocMenuEntry getSingleton() { |
||
54 | if (singleton == null) |
||
55 | singleton = new ColorTableTocMenuEntry();
|
||
56 | return singleton;
|
||
57 | } |
||
58 | |||
59 | 12344 | bsanchez | /*
|
60 | * (non-Javadoc)
|
||
61 | * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroup()
|
||
62 | */
|
||
63 | public String getGroup() { |
||
64 | 18826 | bsanchez | return "RasterLayer"; |
65 | 12344 | bsanchez | } |
66 | |||
67 | /*
|
||
68 | * (non-Javadoc)
|
||
69 | * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroupOrder()
|
||
70 | */
|
||
71 | public int getGroupOrder() { |
||
72 | 12592 | bsanchez | return 55; |
73 | 12344 | bsanchez | } |
74 | |||
75 | /*
|
||
76 | * (non-Javadoc)
|
||
77 | * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getOrder()
|
||
78 | */
|
||
79 | public int getOrder() { |
||
80 | 12592 | bsanchez | return 3; |
81 | 12344 | bsanchez | } |
82 | |||
83 | /*
|
||
84 | * (non-Javadoc)
|
||
85 | * @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getText()
|
||
86 | */
|
||
87 | public String getText() { |
||
88 | 20646 | nbrodin | return RasterToolsUtil.getText(this, "tablas_color"); |
89 | 12344 | bsanchez | } |
90 | |||
91 | /*
|
||
92 | * (non-Javadoc)
|
||
93 | * @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[])
|
||
94 | */
|
||
95 | public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
||
96 | 18826 | bsanchez | if ((selectedItems == null) || (selectedItems.length != 1)) |
97 | 13693 | bsanchez | return false; |
98 | |||
99 | if (!(selectedItems[0] instanceof FLyrRasterSE)) |
||
100 | return false; |
||
101 | |||
102 | 18826 | bsanchez | if (!((ILayerState) selectedItems[0]).isOpen()) |
103 | return false; |
||
104 | |||
105 | 13693 | bsanchez | return true; |
106 | 12344 | bsanchez | } |
107 | |||
108 | /*
|
||
109 | * (non-Javadoc)
|
||
110 | * @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[])
|
||
111 | */
|
||
112 | public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
||
113 | 18826 | bsanchez | if ((selectedItems == null) || (selectedItems.length != 1)) |
114 | return false; |
||
115 | |||
116 | if (!(selectedItems[0] instanceof FLyrRasterSE)) |
||
117 | return false; |
||
118 | |||
119 | if ((((FLyrRasterSE) selectedItems[0]).getBandCount() == 1) && |
||
120 | (((FLyrRasterSE) selectedItems[0]).isActionEnabled(IRasterLayerActions.COLOR_TABLE)))
|
||
121 | 12592 | bsanchez | return true; |
122 | 12344 | bsanchez | return false; |
123 | } |
||
124 | |||
125 | /*
|
||
126 | * (non-Javadoc)
|
||
127 | * @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[])
|
||
128 | */
|
||
129 | public void execute(ITocItem item, FLayer[] selectedItems) { |
||
130 | 19292 | bsanchez | ColorTableDialog colorTableDialog = new ColorTableDialog(selectedItems[0], 660, 465); |
131 | 20646 | nbrodin | RasterToolsUtil.addWindow(colorTableDialog); |
132 | 12344 | bsanchez | } |
133 | 18826 | bsanchez | |
134 | /*
|
||
135 | * (non-Javadoc)
|
||
136 | * @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getIcon()
|
||
137 | */
|
||
138 | public Icon getIcon() { |
||
139 | 20646 | nbrodin | return RasterToolsUtil.getIcon("colortable-icon"); |
140 | 18826 | bsanchez | } |
141 | 12344 | bsanchez | } |