root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / toc / actions / ChangeSymbolTocMenuEntry.java @ 13730
History | View | Annotate | Download (5.13 KB)
1 |
package com.iver.cit.gvsig.project.documents.view.toc.actions; |
---|---|
2 |
|
3 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
4 |
import com.iver.andami.PluginServices; |
5 |
import com.iver.andami.messages.NotificationManager; |
6 |
import com.iver.cit.gvsig.ProjectExtension; |
7 |
import com.iver.cit.gvsig.fmap.MapContext; |
8 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
9 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
10 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
11 |
import com.iver.cit.gvsig.fmap.rendering.IClassifiedVectorialLegend; |
12 |
import com.iver.cit.gvsig.fmap.rendering.ILegend; |
13 |
import com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend; |
14 |
import com.iver.cit.gvsig.gui.styling.SymbolSelector; |
15 |
import com.iver.cit.gvsig.project.Project; |
16 |
import com.iver.cit.gvsig.project.documents.view.legend.gui.ISymbolSelector; |
17 |
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
18 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
19 |
import com.iver.cit.gvsig.project.documents.view.toc.TocItemLeaf; |
20 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
21 |
*
|
22 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
23 |
*
|
24 |
* This program is free software; you can redistribute it and/or
|
25 |
* modify it under the terms of the GNU General Public License
|
26 |
* as published by the Free Software Foundation; either version 2
|
27 |
* of the License, or (at your option) any later version.
|
28 |
*
|
29 |
* This program is distributed in the hope that it will be useful,
|
30 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
31 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
32 |
* GNU General Public License for more details.
|
33 |
*
|
34 |
* You should have received a copy of the GNU General Public License
|
35 |
* along with this program; if not, write to the Free Software
|
36 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
37 |
*
|
38 |
* For more information, contact:
|
39 |
*
|
40 |
* Generalitat Valenciana
|
41 |
* Conselleria d'Infraestructures i Transport
|
42 |
* Av. Blasco Ib??ez, 50
|
43 |
* 46010 VALENCIA
|
44 |
* SPAIN
|
45 |
*
|
46 |
* +34 963862235
|
47 |
* gvsig@gva.es
|
48 |
* www.gvsig.gva.es
|
49 |
*
|
50 |
* or
|
51 |
*
|
52 |
* IVER T.I. S.A
|
53 |
* Salamanca 50
|
54 |
* 46005 Valencia
|
55 |
* Spain
|
56 |
*
|
57 |
* +34 963163400
|
58 |
* dac@iver.es
|
59 |
*/
|
60 |
/* CVS MESSAGES:
|
61 |
*
|
62 |
* $Id: ChangeSymbolTocMenuEntry.java 13730 2007-09-17 09:22:21Z jaume $
|
63 |
* $Log$
|
64 |
* Revision 1.2 2007-09-17 09:22:21 jaume
|
65 |
* view draw frame rate now customizable
|
66 |
*
|
67 |
* Revision 1.1 2007/09/10 15:34:39 jaume
|
68 |
* improvements on usability (double-clicks on TOC and some minor shorcuts)
|
69 |
*
|
70 |
* Revision 1.5 2007/01/04 07:24:31 caballero
|
71 |
* isModified
|
72 |
*
|
73 |
* Revision 1.4 2006/10/02 13:52:34 jaume
|
74 |
* organize impots
|
75 |
*
|
76 |
* Revision 1.3 2006/09/29 07:07:41 caballero
|
77 |
* llamada a listener
|
78 |
*
|
79 |
* Revision 1.2 2006/09/28 15:00:45 fjp
|
80 |
* Usar siempre que se pueda ISymbol en lugar de FSymbol
|
81 |
*
|
82 |
* Revision 1.1 2006/09/15 10:41:30 caballero
|
83 |
* extensibilidad de documentos
|
84 |
*
|
85 |
* Revision 1.1 2006/09/12 15:58:14 jorpiell
|
86 |
* "Sacadas" las opcines del men? de FPopupMenu
|
87 |
*
|
88 |
*
|
89 |
*/
|
90 |
/**
|
91 |
* Realiza el cambio de color si se pulsa OK
|
92 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
93 |
*/
|
94 |
public class ChangeSymbolTocMenuEntry extends AbstractTocContextMenuAction { |
95 |
public String getGroup() { |
96 |
return "group1"; //FIXME |
97 |
} |
98 |
|
99 |
public int getGroupOrder() { |
100 |
return 10; |
101 |
} |
102 |
|
103 |
public int getOrder() { |
104 |
return 0; |
105 |
} |
106 |
|
107 |
public String getText() { |
108 |
return PluginServices.getText(this, "change_symbol"); |
109 |
} |
110 |
|
111 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
112 |
return true; |
113 |
} |
114 |
|
115 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
116 |
return isTocItemLeaf(item);
|
117 |
} |
118 |
|
119 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
120 |
|
121 |
boolean showDialog = isTocItemLeaf(item);
|
122 |
|
123 |
if (!showDialog) return; |
124 |
|
125 |
try {
|
126 |
FLyrVect layer = (FLyrVect) selectedItems[0];
|
127 |
ISymbol oldSymbol = ((TocItemLeaf) item).getSymbol(); |
128 |
|
129 |
|
130 |
int shapeType = layer.getShapeType();
|
131 |
ISymbolSelector symSel = SymbolSelector.createSymbolSelector(oldSymbol, shapeType); |
132 |
PluginServices.getMDIManager().addWindow(symSel); |
133 |
ISymbol newSymbol = (ISymbol) symSel.getSelectedObject(); |
134 |
|
135 |
if (newSymbol == null) |
136 |
return;
|
137 |
|
138 |
newSymbol.setDescription(oldSymbol.getDescription()); |
139 |
|
140 |
for (int i = 0; i < selectedItems.length; i++) { |
141 |
FLyrVect theLayer = ((FLyrVect) selectedItems[i]); |
142 |
|
143 |
try {
|
144 |
ILegend legend = theLayer.getLegend(); |
145 |
if (legend instanceof IClassifiedVectorialLegend) { |
146 |
IClassifiedVectorialLegend cv = (IClassifiedVectorialLegend) legend; |
147 |
cv.replace(oldSymbol, newSymbol); |
148 |
} else if (legend instanceof SingleSymbolLegend) { |
149 |
SingleSymbolLegend ss = (SingleSymbolLegend) legend; |
150 |
ss.setDefaultSymbol(newSymbol); |
151 |
} |
152 |
} catch (Exception e) { |
153 |
NotificationManager.addWarning(PluginServices.getText(this, "skipped_symbol_changed_for_layer")+": "+theLayer.getName(), e); |
154 |
} |
155 |
|
156 |
} |
157 |
// refresh view treak
|
158 |
MapContext mc = layer.getMapContext(); |
159 |
mc.invalidate(); |
160 |
Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject(); |
161 |
project.setModified(true);
|
162 |
mc.callLegendChanged(); |
163 |
|
164 |
} catch (ReadDriverException e) {
|
165 |
NotificationManager.addError(PluginServices.getText(this, "getting_shape_type"), e); |
166 |
} |
167 |
} |
168 |
} |
169 |
|