Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / org.gvsig.annotation / org.gvsig.annotation.main / src / main / java / org / gvsig / annotation / main / PreferencesMain.java @ 36679

History | View | Annotate | Download (3.6 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.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26

    
27
import org.gvsig.annotation.AnnotationCreationService;
28
import org.gvsig.annotation.AnnotationLocator;
29
import org.gvsig.annotation.AnnotationManager;
30
import org.gvsig.annotation.swing.AnnotationSwingLocator;
31
import org.gvsig.annotation.swing.AnnotationSwingManager;
32
import org.gvsig.annotation.swing.AnnotationWindowManager;
33
import org.gvsig.annotation.swing.JAnnotationPreferencesPanel;
34
import org.gvsig.fmap.crs.CRSFactory;
35
import org.gvsig.fmap.dal.DALLocator;
36
import org.gvsig.fmap.dal.DataManager;
37
import org.gvsig.fmap.dal.DataStoreParameters;
38
import org.gvsig.fmap.dal.feature.FeatureStore;
39
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
40

    
41
/**
42
 * Main executable class for testing the Annotation library.
43
 * 
44
 * @author gvSIG Team
45
 * @version $Id$
46
 */
47
public class PreferencesMain {
48

    
49
    private static final Logger LOG = LoggerFactory.getLogger(PreferencesMain.class);
50

    
51
    private AnnotationManager annotationManager;
52
    private AnnotationSwingManager annotationSwingManager;
53
    private DataManager dataManager;
54

    
55
    public static void main(String args[]) throws Exception {
56
        new DefaultLibrariesInitializer().fullInitialize();
57
        PreferencesMain main = new PreferencesMain();
58
        main.show();
59
    }    
60
    
61
    @SuppressWarnings("serial")
62
    public void show() throws Exception {
63
        annotationManager = AnnotationLocator.getManager();
64
        annotationSwingManager = AnnotationSwingLocator.getSwingManager();
65
        dataManager = DALLocator.getDataManager();
66
        
67
        
68
        JAnnotationPreferencesPanel annotationPreferencesPanel = annotationSwingManager.createAnnotationPreferences();
69
        annotationSwingManager.getWindowManager().showPreferencesWindow(annotationPreferencesPanel, "Annotation Preferences. example", AnnotationWindowManager.MODE_DIALOG);
70
    }   
71
    
72
    /**
73
     * Returns an instance of the {@link AnnotationCreationService}.
74
     * 
75
     * @return a {@link AnnotationCreationService} instance
76
     * @throws Exception
77
     *             if there is any error creating the instance
78
     */
79
    protected AnnotationCreationService createService() throws Exception {
80
            String sourceFileName = getClass().getClassLoader().getResource("org/gvsig/annotation/data/andalucia.shp").getFile();
81
            DataStoreParameters sourceParameters = dataManager.createStoreParameters("Shape");
82
             sourceParameters.setDynValue("shpfile", sourceFileName);
83
             sourceParameters.setDynValue("crs", CRSFactory.getCRS("EPSG:23030"));
84
             FeatureStore sourceStore = (FeatureStore) dataManager.openStore("Shape", sourceParameters);
85
            return annotationManager.getAnnotationCreationService(sourceStore);
86
    }
87

    
88
}