Revision 39028

View differences:

tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
0 9

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.annotation">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
0 38

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/test/java/org/gvsig/annotation/impl/DefaultAnnotationCreationServiceTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.annotation.impl;
23

  
24
import org.gvsig.annotation.AnnotationCreationService;
25
import org.gvsig.annotation.AnnotationCreationServiceTest;
26
import org.gvsig.fmap.geom.Geometry;
27
import org.gvsig.fmap.geom.GeometryLocator;
28
import org.gvsig.fmap.geom.GeometryManager;
29
import org.gvsig.fmap.geom.exception.CreateGeometryException;
30

  
31
/**
32
 * {@link AnnotationCreationService} API compatibility tests for the
33
 * {@link DefaultAnnotationCreationService} implementation.
34
 * 
35
 * @author gvSIG Team
36
 * @version $Id$
37
 */
38
public class DefaultAnnotationCreationServiceTest extends AnnotationCreationServiceTest {
39
		
40
	public DefaultAnnotationCreationServiceTest() {
41
		super();		
42
	}
43

  
44
	@Override
45
	public TextPointPairList getResult() throws CreateGeometryException {
46
		GeometryManager geometryManager = GeometryLocator.getGeometryManager();
47
		TextPointPairList textPointPairList = new TextPointPairList();
48
		textPointPairList.addPoint("Sevilla", geometryManager.createPoint(262760.53, 4146732.91, Geometry.SUBTYPES.GEOM2D));
49
		return textPointPairList;
50
	}
51
}
0 52

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/DefaultAnnotationCreationService.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.annotation.impl;
23

  
24
import java.io.File;
25
import java.io.FileOutputStream;
26
import java.io.IOException;
27
import java.io.InputStream;
28
import java.io.OutputStream;
29

  
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32

  
33
import org.gvsig.annotation.AnnotationCreationException;
34
import org.gvsig.annotation.AnnotationCreationFinishAction;
35
import org.gvsig.annotation.AnnotationCreationService;
36
import org.gvsig.annotation.AnnotationDataTypes;
37
import org.gvsig.annotation.AnnotationManager;
38
import org.gvsig.annotation.calculator.AnnotationPositionCalculationException;
39
import org.gvsig.annotation.calculator.AnnotationPositionCalculator;
40
import org.gvsig.annotation.calculator.AnnotationPositionCalculatorCreationException;
41
import org.gvsig.fmap.dal.DALLocator;
42
import org.gvsig.fmap.dal.DataManager;
43
import org.gvsig.fmap.dal.DataTypes;
44
import org.gvsig.fmap.dal.exception.DataException;
45
import org.gvsig.fmap.dal.exception.InitializeException;
46
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
47
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
48
import org.gvsig.fmap.dal.feature.EditableFeature;
49
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
50
import org.gvsig.fmap.dal.feature.EditableFeatureType;
51
import org.gvsig.fmap.dal.feature.Feature;
52
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
53
import org.gvsig.fmap.dal.feature.FeatureSet;
54
import org.gvsig.fmap.dal.feature.FeatureStore;
55
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
56
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
57
import org.gvsig.fmap.geom.Geometry;
58
import org.gvsig.tools.dispose.DisposableIterator;
59
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
60
import org.gvsig.tools.task.AbstractMonitorableTask;
61

  
62

  
63
/**
64
 * Default {@link AnnotationCreationService} implementation.
65
 * 
66
 * @author gvSIG Team
67
 * @version $Id$
68
 */
69
public class DefaultAnnotationCreationService extends AbstractMonitorableTask implements AnnotationCreationService {
70
	private static final Logger LOG = LoggerFactory.getLogger(DefaultAnnotationCreationService.class);
71
	private static final String TEMPLATE_NAME = "template.gvslab";
72
	private static DataManager dataManager = DALLocator.getDataManager();
73

  
74
	private AnnotationManager manager;
75
	private FeatureStore sourceStore;
76

  
77
	private int sourceFontTypeAttribute = -1;
78
	private int sourceFontStyleAttribute = -1;
79
	private int sourceFontColorAttribute = -1;
80
	private int sourceRotationAttribute = -1;
81
	private int sourceHeigthAttribute = -1;
82
	private AnnotationPositionCalculator annotationPositionCalculator = null;
83

  
84
	private String destinationGeometryAttributeName = null;
85

  
86
	private AnnotationCreationFinishAction annotationCreationFinishAction = null; 
87

  
88
	/**
89
	 * {@link DefaultAnnotationCreationService} constructor with a
90
	 * {@link AnnotationManager}.
91
	 * 
92
	 * @param manager
93
	 *            to use in the service
94
	 * @throws DataException 
95
	 */
96
	public DefaultAnnotationCreationService(FeatureStore featureStore, AnnotationManager manager) throws DataException {
97
		super("annotation");
98
	    this.sourceStore = featureStore; 
99
		this.manager = manager;
100
		destinationGeometryAttributeName = featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName();
101
	}
102

  
103
	public AnnotationManager getManager() {
104
		return this.manager;
105
	}
106

  
107
	public FeatureStore createAnnotationStore(String destinationShapeFile, int textValueAttribute)
108
	throws AnnotationCreationException {		
109
		try {
110
			if (destinationShapeFile == null){
111
				throw new AnnotationCreationException("File can not be null");
112
			}	
113

  
114
			String destinationShapeFileWithoutExtension = destinationShapeFile.toLowerCase().replaceAll("\\.shp", "");
115
			if (destinationShapeFileWithoutExtension.length() == destinationShapeFile.length()-4){
116
				destinationShapeFileWithoutExtension =  destinationShapeFile.substring(0, destinationShapeFile.length()-4);
117
			}else{
118
				destinationShapeFileWithoutExtension = destinationShapeFile;
119
			}			
120

  
121
			NewFeatureStoreParameters newFeatureStoreParameters = (NewFeatureStoreParameters)dataManager.createNewStoreParameters("FilesystemExplorer", "Shape");
122
			newFeatureStoreParameters.setDynValue("shpfile", destinationShapeFileWithoutExtension + ".shp");
123
			newFeatureStoreParameters.setDynValue("dbffile", destinationShapeFileWithoutExtension + ".dbf");
124
			newFeatureStoreParameters.setDynValue("shxfile", destinationShapeFileWithoutExtension + ".shx");
125
			newFeatureStoreParameters.setDynValue("crs", sourceStore.getDefaultFeatureType().getDefaultSRS());
126

  
127
			EditableFeatureType editableFeatureType = sourceStore.getDefaultFeatureType().getEditable();//newFeatureStoreParameters.getDefaultFeatureType().getEditable();
128
			FeatureAttributeDescriptor[] featureAttributeDescriptors = editableFeatureType.getAttributeDescriptors();
129
			for (int i=featureAttributeDescriptors.length-1  ; i>=0 ; i--){
130
				editableFeatureType.remove(i);
131
			}
132
			initializeFeatureType(editableFeatureType);
133
			newFeatureStoreParameters.setDefaultFeatureType(editableFeatureType);
134

  
135
			dataManager.newStore("FilesystemExplorer", "Shape", newFeatureStoreParameters, true);
136

  
137
			//If there is not an annotationPositionCalculator it gets the default 
138
			if (annotationPositionCalculator == null){
139
				annotationPositionCalculator = manager.getDefaultAnnotationPositionCalculator();
140
			}	
141

  
142
			FeatureStore destinationStore = (FeatureStore) dataManager.openStore("Shape", newFeatureStoreParameters);
143

  
144
			copyFeatureStore(sourceStore, 
145
					destinationStore,
146
					textValueAttribute);	
147

  
148
			try {
149
				copyLegend(destinationStore);
150
			} catch (IOException e) {
151
				LOG.error("Error copying the legend");
152
			}
153

  
154
			if (annotationCreationFinishAction != null){
155
				annotationCreationFinishAction.finished(destinationStore);
156
			}
157

  
158
			return destinationStore;
159
		} catch (InitializeException e) {
160
			throw new AnnotationCreationException(e);
161
		} catch (ProviderNotRegisteredException e) {
162
			throw new AnnotationCreationException(e);
163
		} catch (ValidateDataParametersException e) {
164
			throw new AnnotationCreationException(e);
165
		} catch (DynFieldNotFoundException e) {
166
			throw new AnnotationCreationException(e);
167
		} catch (DataException e) {
168
			throw new AnnotationCreationException(e);
169
		} catch (AnnotationPositionCalculatorCreationException e) {
170
			throw new AnnotationCreationException(e);
171
		} 			
172
	}	
173

  
174
	public FeatureStore createAnnotationStore(String destinationShapeFile,
175
			String textValueAttributeName) throws AnnotationCreationException {
176
		try {
177
			return createAnnotationStore(destinationShapeFile, getIndex(textValueAttributeName));
178
		} catch (DataException e) {
179
			throw new AnnotationCreationException(e);
180
		}			
181
	}
182

  
183
	private void initializeFeatureType(EditableFeatureType editableFeatureType) throws DataException
184
	{		
185
		EditableFeatureAttributeDescriptor geometryType = editableFeatureType.add(destinationGeometryAttributeName, DataTypes.GEOMETRY);
186
		geometryType.setAllowNull(false);		
187
		geometryType.setGeometryType(Geometry.TYPES.POINT).setGeometrySubType(Geometry.SUBTYPES.GEOM2D);
188
		geometryType.setSRS(sourceStore.getDefaultFeatureType().getDefaultSRS());
189
		geometryType.setObjectClass(Geometry.class);
190
		editableFeatureType.setDefaultGeometryAttributeName(destinationGeometryAttributeName);
191

  
192
		editableFeatureType.add(AnnotationManager.TEXTVALUE_ATTRIBUTE_NAME, AnnotationDataTypes.TEXT, 256).setAllowNull(true);
193
		editableFeatureType.add(AnnotationManager.FONTTYPE_ATTRIBUTE_NAME, AnnotationDataTypes.FONTTYPE, 30).setAllowNull(true);
194
		editableFeatureType.add(AnnotationManager.FONTSTYLE_ATTRIBUTE_NAME, AnnotationDataTypes.FONTSTYLE, 30).setAllowNull(true);
195
		editableFeatureType.add(AnnotationManager.FONTCOLOR_ATTRIBUTE_NAME, AnnotationDataTypes.FONTCOLOR, 20).setAllowNull(true);
196
		editableFeatureType.add(AnnotationManager.FONTROTATION_ATTRIBUTE_NAME, AnnotationDataTypes.FONTROTATION, 5).setAllowNull(true);
197
		editableFeatureType.add(AnnotationManager.FONTHEGTH_ATTRIBUTE_NAME, AnnotationDataTypes.FONTHEIGHT, 5).setAllowNull(true);
198
	}
199

  
200
	private AttributeInserter createInserter(int attributePosition, Object defaultValue)
201
	{
202
		if (attributePosition > -1){
203
			return new StoreAttributeInserter(attributePosition);
204
		}else{
205
			return new DefaultAttributeInserter(defaultValue);
206
		}
207
	}
208

  
209
	private void copyFeatureStore(FeatureStore sourceStore,
210
			FeatureStore destinationStore, int textAttribute)
211
	throws AnnotationCreationException, DataException {		
212

  
213
		//Start the edition
214
		destinationStore.edit();
215

  
216
		//Copy data
217
		FeatureSet featureSet = sourceStore.getFeatureSet();
218
		DisposableIterator iterator = featureSet.iterator();
219
		
220
		taskStatus.setRangeOfValues(0, featureSet.getSize());
221

  
222
		//Create the attribute inserter's
223
		AttributeInserter fontTypeAttributeInserter = createInserter(sourceFontTypeAttribute, manager.getDefaultFontType());		
224
		AttributeInserter fontStyleAttributeInserter = createInserter(sourceFontStyleAttribute, manager.getDefaultFontStyle());		
225
		AttributeInserter fontColorAttributeInserter = createInserter(sourceFontColorAttribute, manager.getDefaultFontColor());		
226
		AttributeInserter fontRotationAttributeInserter = createInserter(sourceRotationAttribute, manager.getDefaultFontRotation());		
227
		AttributeInserter fontHeigthAttributeInserter = createInserter(sourceHeigthAttribute, manager.getDefaultFontHeight());		
228

  
229
		Feature sourceFeature;
230
		long featureCount = 0;
231
		while (iterator.hasNext()) {			
232
			sourceFeature = (Feature) iterator.next();
233

  
234
			EditableFeature destinationFeature = destinationStore.createNewFeature().getEditable();
235
			try {
236
				destinationFeature.set(destinationGeometryAttributeName, annotationPositionCalculator.getAnnotationPosition(sourceFeature));
237
			} catch (AnnotationPositionCalculationException e) {
238
				LOG.error("Not possible to get the point for the geometry", e);				
239
			}
240
			destinationFeature.set(AnnotationManager.TEXTVALUE_ATTRIBUTE_NAME, sourceFeature.get(textAttribute));
241
			destinationFeature.set(AnnotationManager.FONTTYPE_ATTRIBUTE_NAME, fontTypeAttributeInserter.getValue(sourceFeature));
242
			destinationFeature.set(AnnotationManager.FONTSTYLE_ATTRIBUTE_NAME, fontStyleAttributeInserter.getValue(sourceFeature));
243
			destinationFeature.set(AnnotationManager.FONTCOLOR_ATTRIBUTE_NAME, fontColorAttributeInserter.getValue(sourceFeature));
244
			destinationFeature.set(AnnotationManager.FONTROTATION_ATTRIBUTE_NAME, fontRotationAttributeInserter.getValue(sourceFeature));
245
			destinationFeature.set(AnnotationManager.FONTHEGTH_ATTRIBUTE_NAME, fontHeigthAttributeInserter.getValue(sourceFeature));
246

  
247
			destinationStore.insert(destinationFeature);
248
    		featureCount++;  
249
    		this.taskStatus.setCurValue(featureCount);
250
    
251
            if (this.taskStatus.isCancellationRequested()) {
252
                return;
253
            }
254
		}
255

  
256
		//Finish the edition
257
		destinationStore.finishEditing();
258

  
259
		//Dispose resources
260
		iterator.dispose();		
261
		featureSet.dispose();
262
		
263
		this.taskStatus.terminate();
264
        this.taskStatus.remove();		
265
	}
266

  
267
	private void copyLegend(FeatureStore destinationStore) throws ValidateDataParametersException, DataException, IOException {
268
		FilesystemServerExplorer filesystemServerExplorer = (FilesystemServerExplorer)destinationStore.getExplorer();
269
		File target = filesystemServerExplorer.getResourcePath(destinationStore, "gvslab");
270

  
271
		//Copy the template
272
		InputStream in = getClass().getClassLoader().getResourceAsStream(TEMPLATE_NAME);
273
		OutputStream out = null;
274

  
275
		out = new FileOutputStream(target);
276

  
277
		byte[] buf = new byte[1024];
278
		int len;
279
		while ((len = in.read(buf)) > 0) { 
280
			out.write(buf, 0, len); 
281
		} 
282
		in.close();
283
		out.close(); 		
284
	}
285

  
286
	private void checkAttribute(int index, int type) throws DataException{
287
		if (index >= sourceStore.getDefaultFeatureType().size()){
288
			throw new IllegalArgumentException("Attribute not found");
289
		}
290
		if (sourceStore.getDefaultFeatureType().getAttributeDescriptor(index).getDataType().getType() != type){
291
			throw new IllegalArgumentException("The Attribute has not have the fine type");
292
		}
293
	}
294

  
295

  
296
	public void setFontTypetAttribute(int index) throws DataException {
297
		checkAttribute(index, AnnotationDataTypes.FONTTYPE);
298
		this.sourceFontTypeAttribute = index;		
299
	}
300

  
301
	public void setFontStyleAttribute(int index) throws DataException {
302
		checkAttribute(index, AnnotationDataTypes.FONTSTYLE);
303
		this.sourceFontStyleAttribute = index;		
304
	}
305

  
306
	public void setFontColorAttribute(int index) throws DataException {
307
		checkAttribute(index, AnnotationDataTypes.FONTCOLOR);
308
		this.sourceFontColorAttribute = index;		
309
	}
310

  
311
	public void setFontHeigthAttribute(int index) throws DataException {
312
		checkAttribute(index, AnnotationDataTypes.FONTHEIGHT);
313
		this.sourceHeigthAttribute = index;		
314
	}
315

  
316
	public void setFontRotationAttribute(int index) throws DataException {
317
		checkAttribute(index, AnnotationDataTypes.FONTROTATION);
318
		this.sourceRotationAttribute = index;		
319
	}
320

  
321
	public void setAnnotationPositionCalculator(
322
			AnnotationPositionCalculator annotationPositionCalculator) {		
323
		this.annotationPositionCalculator = annotationPositionCalculator;		
324
	}
325

  
326
	public int getIndex(String attributeName) throws DataException{
327
		FeatureAttributeDescriptor featureAttributeDescriptor = sourceStore.getDefaultFeatureType().getAttributeDescriptor(attributeName);
328
		if (featureAttributeDescriptor != null){
329
			return featureAttributeDescriptor.getIndex();
330
		}
331
		return -1;
332
	}
333

  
334
	public void setFontColorAttribute(String attributeName) throws DataException {
335
		setFontColorAttribute(getIndex(attributeName));		
336
	}
337

  
338
	public void setFontHeigthAttribute(String attributeName) throws DataException {
339
		setFontHeigthAttribute(getIndex(attributeName));				
340
	}
341

  
342
	public void setFontRotationAttribute(String attributeName) throws DataException {
343
		setFontRotationAttribute(getIndex(attributeName));				
344
	}
345

  
346
	public void setFontStyleAttribute(String attributeName) throws DataException {
347
		setFontStyleAttribute(getIndex(attributeName));				
348
	}
349

  
350
	public void setFontTypetAttribute(String attributeName) throws DataException {
351
		setFontTypetAttribute(getIndex(attributeName));				
352
	}
353

  
354

  
355
	public FeatureStore getFeatureStore() {
356
		return sourceStore;
357
	}
358

  
359
	private interface AttributeInserter{
360
		public Object getValue(Feature feature);
361
	}
362

  
363

  
364
	private class StoreAttributeInserter implements AttributeInserter{
365
		private int attributePosition = -1;
366

  
367
		public StoreAttributeInserter(int attributePosition) {
368
			super();
369
			this.attributePosition = attributePosition;			
370
		}
371

  
372
		public Object getValue(Feature feature){
373
			return feature.get(attributePosition);
374
		}
375
	}
376

  
377
	private class DefaultAttributeInserter implements AttributeInserter{
378
		private Object defaultValue = null;
379

  
380
		public DefaultAttributeInserter(Object defaultValue) {
381
			super();	
382
			this.defaultValue = defaultValue;
383
		}
384

  
385
		public Object getValue(Feature feature){
386
			return defaultValue;
387
		}
388
	}
389

  
390
	public AnnotationCreationFinishAction getAnnotationCreationFinishAction() {
391
		return annotationCreationFinishAction;
392
	}
393

  
394

  
395
	public void setAnnotationCreationFinishAction(
396
			AnnotationCreationFinishAction annotationCreationFinishAction) {
397
		this.annotationCreationFinishAction = annotationCreationFinishAction;	
398
	}
399
}
0 400

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/AnnotationDefaultImplLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.annotation.impl;
23

  
24
import java.awt.Color;
25

  
26
import org.gvsig.annotation.AnnotationLibrary;
27
import org.gvsig.annotation.AnnotationLocator;
28
import org.gvsig.annotation.AnnotationManager;
29
import org.gvsig.annotation.impl.calculator.CentroidPositionCalculatior;
30
import org.gvsig.tools.library.AbstractLibrary;
31
import org.gvsig.tools.library.LibraryException;
32
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
33

  
34
/**
35
 * Library for default implementation initialization and configuration.
36
 * 
37
 * @author gvSIG team
38
 * @version $Id$
39
 */
40
public class AnnotationDefaultImplLibrary extends AbstractLibrary {
41
	  	
42
    @Override
43
    public void doRegistration() {
44
        registerAsImplementationOf(AnnotationLibrary.class);
45
    }
46

  
47
	@Override
48
    protected void doInitialize() throws LibraryException {
49
		AnnotationLocator.registerManager(DefaultAnnotationManager.class);           
50
    }
51

  
52
    @Override
53
    protected void doPostInitialize() throws LibraryException {
54
        AnnotationManager annotationManager = AnnotationLocator.getManager();
55
                
56
        if (annotationManager == null) {
57
            throw new ReferenceNotRegisteredException(
58
                AnnotationLocator.MANAGER_NAME, AnnotationLocator
59
                    .getInstance());
60
        }
61
        
62
        annotationManager.registerDefaultAnnotationPositionCalculator(CentroidPositionCalculatior.class);
63
       
64
        //Adding font types
65
        annotationManager.addFontType("Arial");
66
        annotationManager.addFontType("Dialog");
67
        annotationManager.addFontType("DialogInput");
68
        annotationManager.addFontType("Serif");
69
        annotationManager.addFontType("SansSerif");
70
        annotationManager.addFontType("Monospaced");
71
        annotationManager.addFontType("Courier");
72
        annotationManager.addFontType("TimesRoman");
73
        annotationManager.addFontType("Helvetica");
74
        
75
           //Adding font styles
76
        annotationManager.addFontStyle("Plain");
77
        annotationManager.addFontStyle("Italic");
78
        annotationManager.addFontStyle("Bold");
79
        
80
        //Setting the default values if there are not registered
81
        if (annotationManager.getDefaultTextValue() == null){
82
        	annotationManager.setDefaultTextValue("Text");
83
        }
84
        
85
        if (annotationManager.getDefaultFontColor() == -1){
86
        	annotationManager.setDefaultFontColor(Color.BLACK);
87
        }
88
        
89
        if (annotationManager.getDefaultFontHeight() == -1){
90
        	annotationManager.setDefaultFontHeight(10);
91
        }
92
        
93
        if (annotationManager.getDefaultFontRotation() == -1){
94
        	annotationManager.setDefaultFontRotation(0);
95
        }
96
        
97
        if (annotationManager.getDefaultFontStyle() == null){
98
        	annotationManager.setDefaultFontStyle("Plain");
99
        }
100
        
101
        if (annotationManager.getDefaultFontType() == null){
102
        	annotationManager.setDefaultFontType("Arial");
103
        }        
104
    }
105

  
106
}
0 107

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/calculator/CentroidPositionCalculatior.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Prodevelop}   {Task}
26
*/
27
 
28
package org.gvsig.annotation.impl.calculator;
29

  
30
import org.gvsig.annotation.calculator.AnnotationPositionCalculationException;
31
import org.gvsig.annotation.calculator.AnnotationPositionCalculator;
32
import org.gvsig.fmap.dal.feature.Feature;
33
import org.gvsig.fmap.geom.operation.GeometryOperationException;
34
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
35
import org.gvsig.fmap.geom.primitive.Point;
36
import org.gvsig.i18n.Messages;
37

  
38
/**
39
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
40
 */
41
public class CentroidPositionCalculatior implements AnnotationPositionCalculator{
42

  
43
	public Point getAnnotationPosition(Feature feature) throws AnnotationPositionCalculationException {
44
		try {
45
			return feature.getDefaultGeometry().centroid();
46
		} catch (GeometryOperationNotSupportedException e) {
47
			throw new AnnotationPositionCalculationException(e);
48
		} catch (GeometryOperationException e) {
49
			throw new AnnotationPositionCalculationException(e);
50
		}
51
	}
52

  
53
	public String getName() {
54
		return Messages.getText("centroid");
55
	}
56
}
57

  
0 58

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/DefaultAnnotationManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.annotation.impl;
23

  
24
import java.awt.Color;
25
import java.util.ArrayList;
26
import java.util.Collections;
27
import java.util.List;
28

  
29
import org.gvsig.annotation.AnnotationCreationService;
30
import org.gvsig.annotation.AnnotationCreationServiceException;
31
import org.gvsig.annotation.AnnotationManager;
32
import org.gvsig.annotation.calculator.AnnotationPositionCalculator;
33
import org.gvsig.annotation.calculator.AnnotationPositionCalculatorCreationException;
34
import org.gvsig.fmap.dal.exception.DataException;
35
import org.gvsig.fmap.dal.feature.FeatureStore;
36
import org.gvsig.tools.ToolsLocator;
37
import org.gvsig.tools.extensionpoint.ExtensionPoint;
38
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
39
import org.gvsig.tools.service.ServiceException;
40

  
41
/**
42
 * Default {@link AnnotationManager} implementation.
43
 * 
44
 * @author gvSIG Team
45
 * @version $Id$
46
 */
47
public class DefaultAnnotationManager implements AnnotationManager {
48
	private static final String ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT = "AnnotationPositionCalculatorExtensionPoint";
49
	private ExtensionPointManager extensionPointManager = ToolsLocator.getExtensionPointManager();
50
	private static final String DEFAULT_ANNOTATION_POSITION_CALCULATOR = "DefaultAnnotationPositionCalculator";
51
	
52
	private String defaultTextValue = null;
53
	private int defaultFontColor = -1;
54
	private double defaultFontHeight = -1;
55
	private double defaultFontRotation = -1;
56
	private String defaultFontStyle = null;
57
	private String defaultFontType = null;
58
	
59
	private List<String> fontTypes = Collections.synchronizedList(new ArrayList<String>());
60
	private List<String> fontStyles = Collections.synchronizedList(new ArrayList<String>());
61
	
62
	
63
    public AnnotationCreationService getAnnotationCreationService(FeatureStore featureStore)
64
        throws ServiceException {
65
        AnnotationCreationService fc;
66
		try {
67
			fc = new DefaultAnnotationCreationService(featureStore, this);
68
		} catch (DataException e) {
69
			throw new AnnotationCreationServiceException("Impossible to create the annotation service", e);
70
		}
71
        return fc;
72
    }
73

  
74
	public AnnotationPositionCalculator getAnnotationPositionCalculator(
75
			String name) throws AnnotationPositionCalculatorCreationException {
76
		if (extensionPointManager.get(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT).has(name)){
77
			try {
78
				return (AnnotationPositionCalculator)extensionPointManager.get(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT).create(name);
79
			} catch (InstantiationException e) {
80
				throw new AnnotationPositionCalculatorCreationException(name, e);
81
			} catch (IllegalAccessException e) {
82
				throw new AnnotationPositionCalculatorCreationException(name, e);
83
			}
84
		}else{
85
			throw new IllegalArgumentException("There is not an annotation position calculator registered with this name"); 
86
		}		
87
	}
88

  
89
	public List<String> getAnnotationPositionCalculatorList() {
90
		return extensionPointManager.get(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT).getNames();
91
	}
92

  
93
	public AnnotationPositionCalculator getDefaultAnnotationPositionCalculator() throws AnnotationPositionCalculatorCreationException {
94
		return getAnnotationPositionCalculator(DEFAULT_ANNOTATION_POSITION_CALCULATOR);
95
	}
96

  
97
	public void registerAnnotationPositionCalculator(String name,
98
			Class annotationPositionCalculatorClass) {
99
		if (!AnnotationPositionCalculator.class.isAssignableFrom(annotationPositionCalculatorClass)) {
100
			throw new IllegalArgumentException(annotationPositionCalculatorClass.getName()
101
					+ " must implement the AnnotationPositionCalculator interface");
102
		}
103
		
104
		ExtensionPoint extensionPoint = extensionPointManager.add(ANNOTATION_POSITION_CALCULATOR_EXTENSION_POINT, "");
105
		extensionPoint.append(name, name, annotationPositionCalculatorClass);		
106
	}
107

  
108
	public void registerDefaultAnnotationPositionCalculator(Class annotationPositionCalculatorClass) {
109
		registerAnnotationPositionCalculator(DEFAULT_ANNOTATION_POSITION_CALCULATOR,
110
				annotationPositionCalculatorClass);
111
	}
112

  
113
	public void addFontStyle(String fontStyle) {
114
		fontStyles.add(fontStyle);		
115
	}
116

  
117
	public void addFontType(String fontType) {
118
		fontTypes.add(fontType);		
119
	}
120

  
121
	public int getDefaultFontColor() {
122
		return defaultFontColor;
123
	}
124

  
125
	public double getDefaultFontHeight() {
126
		return defaultFontHeight;
127
	}
128

  
129
	public double getDefaultFontRotation() {
130
		return defaultFontRotation;
131
	}
132

  
133
	public String getDefaultFontStyle() {
134
		return defaultFontStyle;
135
	}
136

  
137
	public String getDefaultFontType() {
138
		return defaultFontType;
139
	}
140

  
141
	public String getDefaultTextValue() {
142
		return defaultTextValue;
143
	}
144

  
145
	public List<String> getFontStyles() {
146
		return fontStyles;
147
	}
148

  
149
	public List<String> getFontTypes() {
150
		return fontTypes;
151
	}
152

  
153
	public void setDefaultFontColor(int fontColor) {
154
		this.defaultFontColor = fontColor;		
155
	}
156
	
157
	public void setDefaultFontColor(Color fontColor) {
158
		this.defaultFontColor = fontColor.getRGB();		
159
	}
160

  
161
	public void setDefaultFontHeight(double fontHeight) {
162
		this.defaultFontHeight = fontHeight;		
163
	}
164

  
165
	public void setDefaultFontRotation(double fontRotation) {
166
		this.defaultFontRotation = fontRotation;		
167
	}
168

  
169
	public void setDefaultFontStyle(String fontStyle) {
170
		this.defaultFontStyle = fontStyle;		
171
	}
172

  
173
	public void setDefaultFontType(String fontType) {
174
		this.defaultFontType = fontType;		
175
	}
176

  
177
	public void setDefaultTextValue(String textValue) {
178
		this.defaultTextValue = textValue;		
179
	}
180

  
181

  
182
}
0 183

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.annotation package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>Annotation library API default implementation.</p>
11

  
12
</body>
13
</html>
0 14

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/resources/locale/text.properties
1
# Resource bundle texts for the Spanish language locale (es)
2
centroid=Centroide
3

  
0 4

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/resources/locale/text_en.properties
1
# Resource bundle texts for the English language locale (en)
2
centroid=Centroid
3

  
0 4

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.annotation.impl.AnnotationDefaultImplLibrary
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.annotation.lib.impl</artifactId>
6
	<packaging>jar</packaging>
7
	<name>org.gvsig.annotation.lib.impl</name>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.annotation.lib</artifactId>
11
		<version>1.0.0-SNAPSHOT</version>
12
	</parent>
13
	<dependencies>
14
		<dependency>
15
			<groupId>org.gvsig</groupId>
16
			<artifactId>org.gvsig.annotation.lib.api</artifactId>
17
			<version>1.0.0-SNAPSHOT</version>
18
            <scope>compile</scope>
19
		</dependency>	
20
		<dependency>
21
			<groupId>org.gvsig</groupId>
22
			<artifactId>org.gvsig.fmap.dal</artifactId>			
23
            <scope>compile</scope>
24
		</dependency>
25
		<dependency>
26
			<groupId>org.gvsig</groupId>
27
			<artifactId>org.gvsig.i18n</artifactId>		
28
            <scope>compile</scope>
29
		</dependency>
30
			<dependency>
31
			<groupId>org.gvsig</groupId>
32
			<artifactId>org.gvsig.projection</artifactId>
33
            <scope>compile</scope>
34
		</dependency>
35
		<dependency>
36
			<groupId>org.gvsig</groupId>
37
			<artifactId>org.gvsig.fmap.geometry</artifactId>			
38
            <scope>compile</scope>
39
		</dependency>				
40
		<dependency>
41
			<groupId>org.gvsig</groupId>
42
			<artifactId>org.gvsig.fmap.geometry</artifactId>
43
			<classifier>operation</classifier>		
44
            <scope>compile</scope>
45
		</dependency>	
46
        <dependency>
47
            <groupId>org.gvsig</groupId>
48
            <artifactId>org.gvsig.tools.lib</artifactId>            
49
            <scope>compile</scope>
50
        </dependency>               
51
        <dependency>
52
            <groupId>org.gvsig</groupId>
53
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>            
54
            <scope>compile</scope>
55
        </dependency>  
56
        <dependency>
57
            <groupId>org.gvsig</groupId>
58
            <artifactId>org.gvsig.timesupport.lib.api</artifactId>
59
            <scope>compile</scope>
60
        </dependency>             
61
		<dependency>
62
			<groupId>org.opengis</groupId>
63
		    <artifactId>geoapi</artifactId>
64
			<scope>runtime</scope>
65
		</dependency>
66
		<dependency>
67
			<groupId>org.geotools</groupId>
68
			<artifactId>gt2-main</artifactId>
69
			<scope>runtime</scope>
70
		</dependency>
71
		<dependency>
72
			<groupId>javax.media</groupId>
73
			<artifactId>jai_core</artifactId>
74
			<scope>runtime</scope>
75
		</dependency>
76
		<dependency>
77
			<groupId>javax.media</groupId>
78
			<artifactId>jai_codec</artifactId>
79
			<scope>runtime</scope>
80
		</dependency>		
81
		<dependency>
82
			<groupId>org.gvsig</groupId>
83
			<artifactId>org.gvsig.annotation.lib.api</artifactId>
84
			<version>1.0.0-SNAPSHOT</version>
85
			<type>test-jar</type>
86
			<scope>test</scope>
87
		</dependency>	
88
		<dependency>
89
			<groupId>org.gvsig</groupId>
90
			<artifactId>org.gvsig.fmap.dal</artifactId>
91
			<classifier>spi</classifier>
92
			<scope>runtime</scope>		
93
		</dependency>
94
		<dependency>
95
			<groupId>org.gvsig</groupId>
96
			<artifactId>org.gvsig.fmap.dal</artifactId>			
97
			<classifier>impl</classifier>
98
			<scope>runtime</scope>
99
		</dependency>	
100
		<dependency>
101
			<groupId>org.gvsig</groupId>
102
			<artifactId>org.gvsig.fmap.dal.file</artifactId>		
103
            <scope>compile</scope>
104
		</dependency>	
105
		<dependency>
106
			<groupId>org.gvsig</groupId>
107
			<artifactId>org.gvsig.fmap.dal.file</artifactId>
108
			<classifier>store.shp</classifier>
109
			<scope>test</scope>	
110
		</dependency>	
111
		<dependency>
112
			<groupId>org.gvsig</groupId>
113
			<artifactId>org.gvsig.fmap.dal.file</artifactId>
114
			<classifier>store.dbf</classifier>
115
			<scope>test</scope>	
116
		</dependency>
117
		<dependency>
118
            <groupId>org.gvsig</groupId>
119
            <artifactId>org.gvsig.projection</artifactId>  
120
            <classifier>cresques-impl</classifier>
121
            <scope>runtime</scope>		
122
		</dependency>	
123
		<dependency>
124
			<groupId>org.gvsig</groupId>
125
			<artifactId>org.gvsig.fmap.geometry</artifactId>			
126
			<classifier>impl</classifier>
127
			<scope>runtime</scope>		
128
		</dependency>
129
		<dependency>
130
			<groupId>org.gvsig</groupId>
131
			<artifactId>org.gvsig.compat</artifactId>			
132
			<scope>runtime</scope>		
133
		</dependency>
134
		<dependency>
135
			<groupId>org.gvsig</groupId>
136
			<artifactId>org.gvsig.compat</artifactId>			
137
			<classifier>se</classifier>		
138
			<scope>runtime</scope>		
139
		</dependency>	
140
		<dependency>
141
			<groupId>org.gvsig</groupId>
142
			<artifactId>org.gvsig.fmap.dal.index.spatial</artifactId>
143
			<classifier>jts</classifier>
144
			<scope>runtime</scope>
145
		</dependency>		
146
        <dependency>
147
            <groupId>org.gvsig</groupId>
148
            <artifactId>org.gvsig.i18n</artifactId>           
149
            <scope>compile</scope>      
150
        </dependency>   
151
	</dependencies>
152
</project>
0 153

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4
		 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5

  
6
	<modelVersion>4.0.0</modelVersion>
7
	<artifactId>org.gvsig.annotation.lib</artifactId>
8
	<packaging>pom</packaging>
9
	<name>org.gvsig.annotation.lib</name>
10
	<parent>
11
		<groupId>org.gvsig</groupId>
12
		<artifactId>org.gvsig.annotation</artifactId>
13
		<version>1.0.0-SNAPSHOT</version>
14
	</parent>
15

  
16
	<modules>
17
		<module>org.gvsig.annotation.lib.api</module>
18
		<module>org.gvsig.annotation.lib.impl</module>
19
	</modules>
20
</project>
0 21

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/AnnotationCreationException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.annotation;
23

  
24
/**
25
 * Exception thrown when there is an error creating an Annotation layer.
26
 * 
27
 * @author gvSIG team
28
 * @version $Id$
29
 */
30
public class AnnotationCreationException extends AnnotationException {
31

  
32
    private static final long serialVersionUID = -4051458353306878010L;
33

  
34
    private static final String MESSAGE =
35
        "An error has been produced " + "creating the Annotation layer";
36

  
37
    private static final String KEY = "_AnnotationCreationException";
38

  
39
    /**
40
     * Creates a new {@link AnnotationCreationException}.
41
     * 
42
     * @param cause
43
     *            the original cause
44
     */
45
    public AnnotationCreationException(Throwable cause) {
46
        super(MESSAGE, cause, KEY, serialVersionUID);
47
    }
48
    
49
    public AnnotationCreationException(String message) {
50
        super(message, KEY, serialVersionUID);
51
    }
52
}
0 53

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/AnnotationCreationFinishAction.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Prodevelop}   {Task}
26
*/
27
 
28
package org.gvsig.annotation;
29

  
30
import org.gvsig.fmap.dal.feature.FeatureStore;
31

  
32
/**
33
 * Action that can be executed at the end of the annotation 
34
 * creation process. An example of action can be load the destination
35
 * {@link FeatureStore} like a layer in a view.
36
 * 
37
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
38
 */
39
public interface AnnotationCreationFinishAction {
40

  
41
	/**
42
	 * This method is called at the end of an annotation
43
	 * creation process.
44
	 * @param featureStore
45
	 * the destination store.
46
	 */
47
	public void finished(FeatureStore featureStore);
48
}
49

  
0 50

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/AnnotationLocator.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.annotation;
23

  
24
import org.gvsig.tools.locator.BaseLocator;
25
import org.gvsig.tools.locator.Locator;
26
import org.gvsig.tools.locator.LocatorException;
27

  
28
/**
29
 * This locator is the entry point for the Annotation library, providing
30
 * access to all Annotation services through the {@link AnnotationManager}
31
 * .
32
 * 
33
 * @author gvSIG team
34
 * @version $Id$
35
 */
36
public class AnnotationLocator extends BaseLocator {
37

  
38
    /**
39
     * Annotation manager name.
40
     */
41
    public static final String MANAGER_NAME = "Annotation.manager";
42

  
43
    /**
44
     * Annotation manager description.
45
     */
46
    public static final String MANAGER_DESCRIPTION = "Annotation Manager";
47

  
48
    private static final String LOCATOR_NAME = "Annotation.locator";
49

  
50
    /**
51
     * Unique instance.
52
     */
53
    private static final AnnotationLocator INSTANCE =
54
        new AnnotationLocator();
55

  
56
    /**
57
     * Return the singleton instance.
58
     * 
59
     * @return the singleton instance
60
     */
61
    public static AnnotationLocator getInstance() {
62
        return INSTANCE;
63
    }
64

  
65
    /**
66
     * Return the Locator's name.
67
     * 
68
     * @return a String with the Locator's name
69
     */
70
    public final String getLocatorName() {
71
        return LOCATOR_NAME;
72
    }
73

  
74
    /**
75
     * Return a reference to the AnnotationManager.
76
     * 
77
     * @return a reference to the AnnotationManager
78
     * @throws LocatorException
79
     *             if there is no access to the class or the class cannot be
80
     *             instantiated
81
     * @see Locator#get(String)
82
     */
83
    public static AnnotationManager getManager() throws LocatorException {
84
        return (AnnotationManager) getInstance().get(MANAGER_NAME);
85
    }
86

  
87
    /**
88
     * Registers the Class implementing the AnnotationManager interface.
89
     * 
90
     * @param clazz
91
     *            implementing the AnnotationManager interface
92
     */
93
    public static void registerManager(
94
        Class<? extends AnnotationManager> clazz) {
95
        getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
96
    }
97

  
98
}
0 99

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.annotation package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>Annotation library API.</p>
11
	
12
	<p>
13
	It allows to get new Annotation and get their text.
14
	</p>
15

  
16
</body>
17
</html>
0 18

  
tags/v2_0_0_Build_2056/libraries/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/AnnotationCreationServiceException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Prodevelop}   {Task}
26
*/
27
 
28
package org.gvsig.annotation;
29

  
30
import org.gvsig.tools.service.ServiceException;
31

  
32
/**
33
 * Exception thrown by the {@link AnnotationCreationService}.
34
 * 
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
36
 */
37
public class AnnotationCreationServiceException extends ServiceException {
38
	private static final long serialVersionUID = -4200816057552322619L;
39
	private final static String MESSAGE_KEY = "_AnnotationCreationServiceException";	
40

  
41

  
42
	public AnnotationCreationServiceException(String message, Throwable e) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff