Revision 31486
branches/v2_0_0_prep/extensions/org.gvsig.annotation/src/main/resources/locale/text_ca.properties | ||
---|---|---|
69 | 69 |
tipo_de_leyenda=Tipus de llegenda |
70 | 70 |
to_annotation=Transformar a capa d'anotacions |
71 | 71 |
units_of_annotations=Unitats de les anotacions |
72 |
activate_annotation_layer=Activar capa d'anotacions |
branches/v2_0_0_prep/extensions/org.gvsig.annotation/src/main/resources/locale/text.properties | ||
---|---|---|
70 | 70 |
tipo_de_leyenda=Tipo de leyenda |
71 | 71 |
to_annotation=Transformar a capa de anotaciones |
72 | 72 |
units_of_annotations=Unidades de las anotationes |
73 |
activate_annotation_layer=Activar capa de anotaciones |
|
73 | 74 |
www.gvsig\#Translations=for language [es] |
branches/v2_0_0_prep/extensions/org.gvsig.annotation/src/main/resources/config/config.xml | ||
---|---|---|
19 | 19 |
position="1050" |
20 | 20 |
priority="999"/> |
21 | 21 |
</extension> |
22 |
<!-- <extension class-name="org.gvsig.annotation.Annotation_ToolExtension"
|
|
23 |
description="Annotation tool extension"
|
|
22 |
<extension class-name="org.gvsig.annotation.AnnotationCreateExtension"
|
|
23 |
description="Create Annotation Extension"
|
|
24 | 24 |
active="true" |
25 |
priority="1"> |
|
26 |
|
|
27 |
<menu text="Capa/activate_annotation_layer" action-command="ACTIVATEANNOTATIONLAYER" |
|
28 |
icon="images/ActivateAnnotation.png" |
|
29 |
tooltip="activate_annotation_layer" |
|
30 |
position="5000" |
|
31 |
priority="2"/> |
|
32 |
<tool-bar name="annotation_tools" position="5"> |
|
33 |
<selectable-tool icon="images/ActivateAnnotation.png" action-command="ACTIVATEANNOTATIONLAYER" tooltip="activate_annotation_layer" position="3"/> |
|
34 |
</tool-bar> |
|
35 |
</extension> |
|
36 |
<extension class-name="org.gvsig.annotation.AnnotationEditionExtension" |
|
37 |
description="Annotation text edition button tool extension" |
|
38 |
active="true" |
|
25 | 39 |
priority="2"> |
26 | 40 |
|
27 |
<menu text="Capa/modify_annotation" action-command="MODIFYANNOTATION" icon="images/Annotation.png" |
|
41 |
<menu text="Capa/modify_annotation" action-command="MODIFYANNOTATION" |
|
42 |
icon="images/ActivateAnnotation.png" |
|
28 | 43 |
tooltip="modify_annotation" |
29 | 44 |
position="5000" |
30 | 45 |
priority="2"/> |
31 | 46 |
<tool-bar name="annotation_tools" position="5"> |
32 |
<selectable-tool icon="images/Annotation.png" action-command="MODIFYANNOTATION" tooltip="modify_annotation" position="3"/> |
|
47 |
<selectable-tool icon="images/ActivateAnnotation.png" action-command="MODIFYANNOTATION" tooltip="modify_annotation" position="3"/>
|
|
33 | 48 |
</tool-bar> |
34 |
</extension> -->
|
|
49 |
</extension> |
|
35 | 50 |
</extensions> |
36 | 51 |
</plugin-config> |
branches/v2_0_0_prep/extensions/org.gvsig.annotation/src/main/java/org/gvsig/annotation/impl/DefaultAnnotationManager.java | ||
---|---|---|
281 | 281 |
/** |
282 | 282 |
* OPEN ANNOTATION: Opens an store to generate new Labeling Strategy. |
283 | 283 |
*/ |
284 |
public ILabelingStrategy open(FeatureStore annotationStore) throws DataException { |
|
284 |
public ILabelingStrategy open(FeatureStore annotationStore,int cartographicSupport) throws DataException {
|
|
285 | 285 |
//Creating a new Strategy. |
286 | 286 |
AttrInTableLabelingStrategy strategy = new AttrInTableLabelingStrategy(); |
287 | 287 |
|
... | ... | |
291 | 291 |
fieldsNames = type.getAttributeDescriptors(); |
292 | 292 |
if (it.hasNext()){ |
293 | 293 |
Feature feature = (Feature) it.next(); |
294 |
int size = feature.getInt("HEIGHT"); |
|
294 |
int fontsize=0; |
|
295 |
try{ |
|
296 |
fontsize=new Double(feature.getDouble("HEIGHT")).intValue(); |
|
297 |
}catch (ClassCastException e){ |
|
298 |
//In order to maintain the compatibility with 1.1.2 annotations. |
|
299 |
fontsize=feature.getInt("HEIGHT"); |
|
300 |
} |
|
295 | 301 |
int style = feature.getInt("STYLEFONT"); |
296 |
Font font = new Font(feature.getString("TYPEFONT"),size,style);
|
|
302 |
Font font = new Font(feature.getString("TYPEFONT"),style,fontsize);
|
|
297 | 303 |
|
298 | 304 |
strategy.setTextField("TEXT"); |
299 | 305 |
strategy.setColorField("COLOR"); |
300 | 306 |
strategy.setHeightField("HEIGHT"); |
301 |
strategy.setRotationField("ROTATION");
|
|
307 |
strategy.setRotationField("ROTATE");
|
|
302 | 308 |
strategy.setFont(font); |
309 |
strategy.setReferenceSystem(cartographicSupport); |
|
310 |
//TODO set data unit |
|
303 | 311 |
} |
304 | 312 |
return strategy; |
305 | 313 |
} |
314 |
|
|
315 |
public ILabelingStrategy activate(FeatureStore annotationStore,int cartographicSupport) throws DataException { |
|
316 |
int fieldsIncluded=0; |
|
317 |
boolean rightType=false; |
|
318 |
//Checking that the store has the right fields |
|
319 |
FeatureSet annotationFeatures = annotationStore.getFeatureSet(); |
|
320 |
FeatureType type = annotationFeatures.getDefaultFeatureType(); |
|
321 |
fieldsNames = type.getAttributeDescriptors(); |
|
322 |
for(int i=0;i<fieldsNames.length;i++){ |
|
323 |
if(fieldsNames[i].getName().compareToIgnoreCase("TEXT")==0){ |
|
324 |
if(fieldsNames[i].getDataType()==DataTypes.STRING) |
|
325 |
rightType=true; |
|
326 |
else |
|
327 |
rightType=false; |
|
328 |
fieldsIncluded++; |
|
329 |
}else if(fieldsNames[i].getName().compareToIgnoreCase("TYPEFONT")==0){ |
|
330 |
if(fieldsNames[i].getDataType()==DataTypes.STRING) |
|
331 |
rightType=true; |
|
332 |
else |
|
333 |
rightType=false; |
|
334 |
fieldsIncluded++; |
|
335 |
}else if(fieldsNames[i].getName().compareToIgnoreCase("STYLEFONT")==0){ |
|
336 |
if(fieldsNames[i].getDataType()==DataTypes.INT) |
|
337 |
rightType=true; |
|
338 |
else |
|
339 |
rightType=false; |
|
340 |
fieldsIncluded++; |
|
341 |
}else if(fieldsNames[i].getName().compareToIgnoreCase("COLOR")==0){ |
|
342 |
if(fieldsNames[i].getDataType()==DataTypes.INT) |
|
343 |
rightType=true; |
|
344 |
else |
|
345 |
rightType=false; |
|
346 |
fieldsIncluded++; |
|
347 |
}else if(fieldsNames[i].getName().compareToIgnoreCase("ROTATE")==0){ |
|
348 |
if(fieldsNames[i].getDataType()==DataTypes.DOUBLE) |
|
349 |
rightType=true; |
|
350 |
else |
|
351 |
rightType=false; |
|
352 |
fieldsIncluded++; |
|
353 |
}else if(fieldsNames[i].getName().compareToIgnoreCase("HEIGHT")==0){ |
|
354 |
if((fieldsNames[i].getDataType()==DataTypes.DOUBLE)||(fieldsNames[i].getDataType()==DataTypes.INT)) |
|
355 |
rightType=true; |
|
356 |
else |
|
357 |
rightType=false; |
|
358 |
fieldsIncluded++; |
|
359 |
} |
|
360 |
} |
|
361 |
if ((fieldsIncluded==6)&&(rightType==true)){ |
|
362 |
//Open AnnotationLayer |
|
363 |
return open(annotationStore,cartographicSupport); |
|
364 |
} |
|
365 |
return null; |
|
366 |
} |
|
306 | 367 |
} |
branches/v2_0_0_prep/extensions/org.gvsig.annotation/src/main/java/org/gvsig/annotation/open/AnnotationOpenWizard.java | ||
---|---|---|
47 | 47 |
import java.awt.GridBagLayout; |
48 | 48 |
import java.awt.event.ActionEvent; |
49 | 49 |
import java.io.File; |
50 |
|
|
51 | 50 |
import javax.swing.JButton; |
52 | 51 |
import javax.swing.JDialog; |
53 | 52 |
import javax.swing.JFileChooser; |
... | ... | |
91 | 90 |
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer; |
92 | 91 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
93 | 92 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy; |
93 |
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport; |
|
94 | 94 |
import org.gvsig.fmap.mapcontrol.MapControl; |
95 | 95 |
import org.gvsig.utils.swing.JComboBox; |
96 | 96 |
|
... | ... | |
444 | 444 |
layerName = file.getName(); |
445 | 445 |
try { |
446 | 446 |
FeatureStore annotationStore = openStore(file, projection); |
447 |
ILabelingStrategy strategy = annotationManager.open(annotationStore); |
|
447 |
ILabelingStrategy strategy = annotationManager.open(annotationStore, CartographicSupport.WORLD);
|
|
448 | 448 |
layer = layerFactory.createLayer(layerName,annotationStore); |
449 | 449 |
((FLyrVect)layer).setLabelingStrategy(strategy); |
450 |
((FLyrVect) layer).setIsLabeled(true); |
|
450 | 451 |
layer = appGvSigMan.prepareOpenLayer(layer,null); |
451 | 452 |
} catch (ValidateDataParametersException e) { |
452 | 453 |
NotificationManager.addError(e); |
... | ... | |
472 | 473 |
} |
473 | 474 |
mapContext.getLayers().addLayer(layer); |
474 | 475 |
mapContext.callLegendChanged(); |
476 |
mapContext.getViewPort().refreshExtent(); |
|
475 | 477 |
mapContext.endAtomicEvent(); |
476 | 478 |
return true; |
477 | 479 |
} |
branches/v2_0_0_prep/extensions/org.gvsig.annotation/src/main/java/org/gvsig/annotation/AnnotationEditionExtension.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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 |
|
|
42 |
package org.gvsig.annotation; |
|
43 |
|
|
44 |
import org.gvsig.andami.PluginServices; |
|
45 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
46 |
import org.gvsig.app.extension.InfoToolExtension; |
|
47 |
import org.gvsig.app.project.documents.view.gui.View; |
|
48 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
|
49 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
50 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
51 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
52 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
|
53 |
|
|
54 |
/** |
|
55 |
* Class that extends of the tool InfoToolExtension and |
|
56 |
* override the methods that interests us to change its behavior. |
|
57 |
* |
|
58 |
* @author Vicente Caballero Navarro |
|
59 |
*/ |
|
60 |
public class AnnotationEditionExtension extends InfoToolExtension { |
|
61 |
|
|
62 |
/* (non-Javadoc) |
|
63 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
64 |
*/ |
|
65 |
public void execute(String s) { |
|
66 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
67 |
|
|
68 |
if (window instanceof View) { |
|
69 |
MapControl mapCtrl = ((View) window).getMapControl(); |
|
70 |
|
|
71 |
if (s.compareTo("MODIFYANNOTATION") == 0) { |
|
72 |
if (mapCtrl.getMapTool("centerviewtopoint") == null) { |
|
73 |
StatusBarListener sbl = new StatusBarListener(mapCtrl); |
|
74 |
// Annotation_ModifyListener chl = new Annotation_ModifyListener(mapCtrl); |
|
75 |
// mapCtrl.addMapTool("modifyannotation",new Behavior[] { |
|
76 |
// new PointBehavior(chl), |
|
77 |
// new MouseMovementBehavior(sbl) |
|
78 |
// }); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
if (s.compareTo("MODIFYANNOTATION") == 0) { |
|
83 |
mapCtrl.setTool("modifyannotation"); |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
/* (non-Javadoc) |
|
89 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
90 |
*/ |
|
91 |
public void initialize() { |
|
92 |
super.initialize(); |
|
93 |
} |
|
94 |
|
|
95 |
/* (non-Javadoc) |
|
96 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
97 |
*/ |
|
98 |
public boolean isEnabled() { |
|
99 |
return super.isEnabled(); |
|
100 |
} |
|
101 |
|
|
102 |
/* (non-Javadoc) |
|
103 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
104 |
*/ |
|
105 |
public boolean isVisible() { |
|
106 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
107 |
|
|
108 |
if (window instanceof View) { |
|
109 |
MapContext mapContext = ((View) window).getMapControl() |
|
110 |
.getMapContext(); |
|
111 |
FLayer[] layers=mapContext.getLayers().getActives(); |
|
112 |
for (int i=0;i<layers.length;i++){ |
|
113 |
//if (layers[i] instanceof Annotation_Layer){ |
|
114 |
if (layers[i].isEditing()) |
|
115 |
return true; |
|
116 |
} |
|
117 |
} |
|
118 |
//} |
|
119 |
|
|
120 |
return false; |
|
121 |
} |
|
122 |
} |
branches/v2_0_0_prep/extensions/org.gvsig.annotation/src/main/java/org/gvsig/annotation/AnnotationManager.java | ||
---|---|---|
12 | 12 |
|
13 | 13 |
public interface AnnotationManager { |
14 | 14 |
public void create (FeatureStore origStore, DataServerExplorer explorer, NewFeatureStoreParameters parameters, String duplicate) throws DataException, ValidateDataParametersException, CreateGeometryException, IOException; |
15 |
public ILabelingStrategy open(FeatureStore annotationStore) throws DataException; |
|
15 |
public ILabelingStrategy activate(FeatureStore annotationStore, int cartographicSupport) throws DataException; |
|
16 |
public ILabelingStrategy open(FeatureStore annotationStore, int cartographicSupport) throws DataException; |
|
17 |
|
|
16 | 18 |
} |
branches/v2_0_0_prep/extensions/org.gvsig.annotation/src/main/java/org/gvsig/annotation/AnnotationCreateExtension.java | ||
---|---|---|
41 | 41 |
|
42 | 42 |
package org.gvsig.annotation; |
43 | 43 |
|
44 |
import java.awt.Component; |
|
44 | 45 |
import java.io.File; |
45 | 46 |
|
46 | 47 |
import javax.swing.ImageIcon; |
48 |
import javax.swing.JOptionPane; |
|
47 | 49 |
|
48 | 50 |
import org.gvsig.andami.PluginServices; |
51 |
import org.gvsig.andami.messages.NotificationManager; |
|
49 | 52 |
import org.gvsig.andami.plugins.Extension; |
50 | 53 |
import org.gvsig.andami.preferences.IPreference; |
51 | 54 |
import org.gvsig.andami.preferences.IPreferenceExtension; |
... | ... | |
54 | 57 |
import org.gvsig.annotation.create.AnnotationCreateAction; |
55 | 58 |
import org.gvsig.annotation.create.AnnotationFieldSelectPanel; |
56 | 59 |
import org.gvsig.annotation.open.AnnotationOpenWizard; |
60 |
import org.gvsig.app.extension.AddLayer; |
|
57 | 61 |
import org.gvsig.app.gui.simpleWizard.SimpleWizard; |
58 | 62 |
import org.gvsig.app.project.documents.view.IProjectView; |
59 | 63 |
import org.gvsig.fmap.dal.exception.DataException; |
60 | 64 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
61 | 65 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
62 | 66 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
67 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy; |
|
68 |
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport; |
|
63 | 69 |
import org.gvsig.tools.ToolsLocator; |
64 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
65 | 70 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
66 |
import org.gvsig.app.project.documents.view.legend.gui.ThemeManagerWindow; |
|
67 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
|
68 |
import org.gvsig.app.extension.AddLayer; |
|
69 | 71 |
|
70 | 72 |
/** |
71 | 73 |
* Extension to export one vector layer to a new annotation layer. |
... | ... | |
102 | 104 |
|
103 | 105 |
//Register Icons |
104 | 106 |
registerIcons(); |
105 |
|
|
106 | 107 |
} |
107 | 108 |
|
108 | 109 |
/** |
... | ... | |
111 | 112 |
public void registerIcons(){ |
112 | 113 |
PluginServices.getIconTheme().registerDefault( |
113 | 114 |
"annotation", |
114 |
this.getClass().getClassLoader().getResource("images/Annotation.png") |
|
115 |
this.getClass().getClassLoader().getResource("images/ActivateAnnotation.png")
|
|
115 | 116 |
); |
116 | 117 |
PluginServices.getIconTheme().registerDefault( |
117 | 118 |
"annotation-properties", |
... | ... | |
159 | 160 |
|
160 | 161 |
PluginServices.getMDIManager().addWindow(wizard); |
161 | 162 |
} |
163 |
if ("ACTIVATEANNOTATIONLAYER".equals(actionCommand)) { |
|
164 |
activateAnnotation(); |
|
165 |
} |
|
162 | 166 |
} |
163 | 167 |
|
168 |
private void activateAnnotation() { |
|
169 |
map.beginAtomicEvent(); |
|
170 |
AnnotationManager annotationManager = AnnotationLocator.getAnnotationManager(); |
|
171 |
//Only checks the first layer if it is an annotation layer to activate it |
|
172 |
FLyrVect layer = (FLyrVect) map.getLayers().getActives()[0]; |
|
173 |
FeatureStore store = (FeatureStore) layer.getDataStore(); |
|
174 |
try { |
|
175 |
ILabelingStrategy strategy = annotationManager.activate(store,CartographicSupport.WORLD); |
|
176 |
if(strategy!=null){ |
|
177 |
((FLyrVect)layer).setLabelingStrategy(strategy); |
|
178 |
((FLyrVect) layer).setIsLabeled(true); |
|
179 |
}else{ |
|
180 |
JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this,"incorrect_annotation_format")); |
|
181 |
} |
|
182 |
} catch (DataException e) { |
|
183 |
NotificationManager.addError(e); |
|
184 |
} |
|
185 |
map.callLegendChanged(); |
|
186 |
map.endAtomicEvent(); |
|
187 |
map.getViewPort().refreshExtent(); |
|
188 |
} |
|
189 |
|
|
164 | 190 |
/** |
165 | 191 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
166 | 192 |
*/ |
Also available in: Unified diff