Statistics
| Revision:

svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.library / org.gvsig.annotation / org.gvsig.annotation.main / src / main / java / org / gvsig / annotation / main / PreferencesMain.java @ 43830

History | View | Annotate | Download (3.73 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.annotation.main;
25

    
26
import org.slf4j.Logger;
27
import org.slf4j.LoggerFactory;
28

    
29
import org.gvsig.annotation.AnnotationCreationService;
30
import org.gvsig.annotation.AnnotationLocator;
31
import org.gvsig.annotation.AnnotationManager;
32
import org.gvsig.annotation.swing.AnnotationSwingLocator;
33
import org.gvsig.annotation.swing.AnnotationSwingManager;
34
import org.gvsig.annotation.swing.JAnnotationPreferencesPanel;
35
import org.gvsig.fmap.crs.CRSFactory;
36
import org.gvsig.fmap.dal.DALLocator;
37
import org.gvsig.fmap.dal.DataManager;
38
import org.gvsig.fmap.dal.DataStoreParameters;
39
import org.gvsig.fmap.dal.feature.FeatureStore;
40
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
41
import org.gvsig.tools.swing.api.ToolsSwingLocator;
42
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
43

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

    
52
    private static final Logger LOG = LoggerFactory.getLogger(PreferencesMain.class);
53

    
54
    private AnnotationManager annotationManager;
55
    private AnnotationSwingManager annotationSwingManager;
56
    private DataManager dataManager;
57

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

    
92
}