root / branches / v2_0_0_prep / libraries / org.gvsig.annotation / org.gvsig.annotation.main / src / main / java / org / gvsig / annotation / main / Main.java @ 33272
History | View | Annotate | Download (3.55 KB)
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.main; |
23 |
|
24 |
import org.gvsig.annotation.AnnotationCreationService; |
25 |
import org.gvsig.annotation.AnnotationLocator; |
26 |
import org.gvsig.annotation.AnnotationManager; |
27 |
import org.gvsig.annotation.swing.AnnotationSwingLocator; |
28 |
import org.gvsig.annotation.swing.AnnotationSwingManager; |
29 |
import org.gvsig.annotation.swing.AnnotationWindowManager; |
30 |
import org.gvsig.annotation.swing.JAnnotationCreationServicePanel; |
31 |
import org.gvsig.fmap.crs.CRSFactory; |
32 |
import org.gvsig.fmap.dal.DALLocator; |
33 |
import org.gvsig.fmap.dal.DataManager; |
34 |
import org.gvsig.fmap.dal.DataStoreParameters; |
35 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
36 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
37 |
import org.slf4j.Logger; |
38 |
import org.slf4j.LoggerFactory; |
39 |
|
40 |
/**
|
41 |
* Main executable class for testing the Annotation library.
|
42 |
*
|
43 |
* @author gvSIG Team
|
44 |
* @version $Id$
|
45 |
*/
|
46 |
public class Main { |
47 |
|
48 |
private static final Logger LOG = LoggerFactory.getLogger(Main.class); |
49 |
|
50 |
private AnnotationManager annotationManager;
|
51 |
private AnnotationSwingManager annotationSwingManager;
|
52 |
private DataManager dataManager;
|
53 |
|
54 |
public static void main(String args[]) throws Exception { |
55 |
new DefaultLibrariesInitializer().fullInitialize();
|
56 |
Main main = new Main();
|
57 |
main.show(); |
58 |
} |
59 |
|
60 |
|
61 |
|
62 |
@SuppressWarnings("serial") |
63 |
public void show() throws Exception { |
64 |
annotationManager = AnnotationLocator.getManager(); |
65 |
annotationSwingManager = AnnotationSwingLocator.getSwingManager(); |
66 |
dataManager = DALLocator.getDataManager(); |
67 |
|
68 |
|
69 |
JAnnotationCreationServicePanel annotationCreationService = annotationSwingManager.createAnnotation(createService()); |
70 |
annotationSwingManager.getWindowManager().showWindow(annotationCreationService, "Annotation App. example", AnnotationWindowManager.MODE_DIALOG);
|
71 |
} |
72 |
|
73 |
/**
|
74 |
* Returns an instance of the {@link AnnotationCreationService}.
|
75 |
*
|
76 |
* @return a {@link AnnotationCreationService} instance
|
77 |
* @throws Exception
|
78 |
* if there is any error creating the instance
|
79 |
*/
|
80 |
protected AnnotationCreationService createService() throws Exception { |
81 |
String sourceFileName = getClass().getClassLoader().getResource("org/gvsig/annotation/data/andalucia.shp").getFile(); |
82 |
DataStoreParameters sourceParameters = dataManager.createStoreParameters("Shape");
|
83 |
sourceParameters.setDynValue("shpfile", sourceFileName);
|
84 |
sourceParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030")); |
85 |
FeatureStore sourceStore = (FeatureStore) dataManager.openStore("Shape", sourceParameters);
|
86 |
return annotationManager.getAnnotationCreationService(sourceStore);
|
87 |
} |
88 |
|
89 |
} |