root / trunk / extensions / extAnnotations / src / com / iver / cit / gvsig / Annotation_Extension.java @ 11536
History | View | Annotate | Download (6.24 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 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 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig; |
42 |
|
43 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
44 |
|
45 |
import com.iver.andami.PluginServices; |
46 |
import com.iver.andami.plugins.Extension; |
47 |
import com.iver.andami.ui.mdiManager.IWindow; |
48 |
|
49 |
import com.iver.cit.gvsig.fmap.MapContext; |
50 |
import com.iver.cit.gvsig.fmap.layers.Annotation_Layer; |
51 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
52 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
53 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
54 |
import com.iver.cit.gvsig.gui.simpleWizard.SimpleWizard; |
55 |
import com.iver.cit.gvsig.project.documents.gui.Annotation_ConfigureLabel; |
56 |
import com.iver.cit.gvsig.project.documents.gui.Annotation_Create; |
57 |
import com.iver.cit.gvsig.project.documents.gui.Annotation_Open; |
58 |
import com.iver.cit.gvsig.project.documents.gui.Annotation_FieldSelect; |
59 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
60 |
|
61 |
import javax.swing.ImageIcon; |
62 |
|
63 |
|
64 |
/**
|
65 |
* Extension to create an annotation layer.
|
66 |
*
|
67 |
* @author Vicente Caballero Navarro
|
68 |
*/
|
69 |
public class Annotation_Extension extends Extension { |
70 |
private MapContext map = null; |
71 |
|
72 |
/**
|
73 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
74 |
*/
|
75 |
public void initialize() { |
76 |
System.out.println("A?ado WizardAnnotation."); |
77 |
AddLayer.addWizard(Annotation_Open.class); |
78 |
} |
79 |
/**
|
80 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
81 |
*/
|
82 |
public void execute(String actionCommand) { |
83 |
if ("ANNOTATIONLAYER".equals(actionCommand)) { |
84 |
ImageIcon Logo = new javax.swing.ImageIcon(this.getClass() |
85 |
.getClassLoader() |
86 |
.getResource("images/package_graphics.png"));
|
87 |
|
88 |
SimpleWizard wizard = new SimpleWizard(Logo);
|
89 |
|
90 |
FLyrVect lv = (FLyrVect) map.getLayers().getActives()[0];
|
91 |
Annotation_Layer la = new Annotation_Layer();
|
92 |
la.setSource(lv.getSource()); |
93 |
la.setProjection(lv.getProjection()); |
94 |
la.setName(lv.getName()); |
95 |
|
96 |
Annotation_FieldSelect panel1 = new Annotation_FieldSelect(wizard.getWizardComponents(),
|
97 |
la); |
98 |
Annotation_ConfigureLabel panel2 = new Annotation_ConfigureLabel(wizard.getWizardComponents(),
|
99 |
la); |
100 |
|
101 |
wizard.getWizardComponents().addWizardPanel(panel1); |
102 |
wizard.getWizardComponents().addWizardPanel(panel2); |
103 |
|
104 |
wizard.getWizardComponents().setFinishAction(new Annotation_Create(
|
105 |
wizard.getWizardComponents(), map, la)); |
106 |
|
107 |
wizard.getWindowInfo().setWidth(540);
|
108 |
wizard.getWindowInfo().setHeight(380);
|
109 |
wizard.getWindowInfo().setTitle(PluginServices.getText(this,
|
110 |
"to_annotation"));
|
111 |
|
112 |
PluginServices.getMDIManager().addWindow(wizard); |
113 |
|
114 |
/*
|
115 |
FLyrVect lv=(FLyrVect)map.getLayers().getActives()[0];
|
116 |
FLyrAnnotation la=new FLyrAnnotation();
|
117 |
la.setSource(lv.getSource());
|
118 |
|
119 |
MappingFieldsToAnotation mfta=new MappingFieldsToAnotation(la);
|
120 |
PluginServices.getMDIManager().addView(mfta);
|
121 |
|
122 |
if (mfta.isOk()){
|
123 |
map.getLayers().addLayer(la);
|
124 |
map.getLayers().removeLayer(lv);
|
125 |
}
|
126 |
*/
|
127 |
} |
128 |
} |
129 |
|
130 |
/**
|
131 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
132 |
*/
|
133 |
public boolean isEnabled() { |
134 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
135 |
|
136 |
if ((v != null) && |
137 |
v instanceof com.iver.cit.gvsig.project.documents.view.gui.View) {
|
138 |
com.iver.cit.gvsig.project.documents.view.gui.View vista = (com.iver.cit.gvsig.project.documents.view.gui.View) v; |
139 |
IProjectView model = vista.getModel(); |
140 |
map = model.getMapContext(); |
141 |
|
142 |
FLayer[] layers = map.getLayers().getActives();
|
143 |
|
144 |
if (layers.length == 1) { |
145 |
if (layers[0].isAvailable() && layers[0] instanceof FLyrVect) { |
146 |
FLyrVect lv = (FLyrVect) layers[0];
|
147 |
|
148 |
// ReadableVectorial src = lv.getSource();
|
149 |
try {
|
150 |
// if (src == null || src.getShapeType()==FShape.POLYGON || src.getShapeType()==FShape.LINE)
|
151 |
// return false;
|
152 |
SelectableDataSource sds = lv.getSource().getRecordset(); |
153 |
|
154 |
if (sds.getFieldCount() > 0) { |
155 |
return true; |
156 |
} |
157 |
} catch (DriverException e) {
|
158 |
return false; |
159 |
} |
160 |
} |
161 |
} |
162 |
} |
163 |
|
164 |
return false; |
165 |
} |
166 |
|
167 |
/**
|
168 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
169 |
*/
|
170 |
public boolean isVisible() { |
171 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
172 |
|
173 |
if (v == null) { |
174 |
return false; |
175 |
} else if (v instanceof com.iver.cit.gvsig.project.documents.view.gui.View) { |
176 |
return true; |
177 |
} else {
|
178 |
return false; |
179 |
} |
180 |
} |
181 |
} |