Statistics
| Revision:

svn-document-layout / trunk / org.gvsig.app.document.layout.app / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / extension / LayoutGraphicControls.java @ 5

History | View | Annotate | Download (5.57 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.app.extension;
23

    
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26

    
27
import org.gvsig.andami.PluginServices;
28
import org.gvsig.andami.plugins.Extension;
29
import org.gvsig.andami.ui.mdiManager.IWindow;
30
import org.gvsig.app.project.documents.layout.FLayoutGraphics;
31
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
32

    
33
/**
34
 * Extensi?n que actua sobre el Layout para controlas las diferentes
35
 * operaciones sobre los gr?ficos.
36
 * 
37
 * @author Vicente Caballero Navarro
38
 */
39
public class LayoutGraphicControls extends Extension {
40

    
41
    private static final Logger logger = LoggerFactory
42
        .getLogger(LayoutGraphicControls.class);
43
    private LayoutPanel layout = null;
44

    
45
    /**
46
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
47
     */
48
    public void execute(String s) {
49
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
50
        FLayoutGraphics lg = new FLayoutGraphics(layout);
51
        logger.debug("Comand : " + s);
52

    
53
        if (s.compareTo("AGRUPAR") == 0) {
54
            layout.getLayoutContext().getFrameCommandsRecord()
55
                .startComplex(PluginServices.getText(this, "group"));
56
            lg.grouping();
57
            layout.getLayoutContext().getFrameCommandsRecord().endComplex();
58
            layout.getDocument().setModified(true);
59
        } else
60
            if (s.compareTo("DESAGRUPAR") == 0) {
61
                lg.ungrouping();
62
                layout.getDocument().setModified(true);
63
            } else
64
                if (s.compareTo("PROPIEDADES") == 0) {
65
                    if (lg.openFFrameDialog()) {
66
                        layout.getDocument().setModified(true);
67
                    }
68
                } else
69
                    if (s.compareTo("ALINEAR") == 0) {
70
                        lg.aligning();
71
                        layout.getDocument().setModified(true);
72
                    } else
73
                        if (s.compareTo("DETRAS") == 0) {
74
                            lg.behind();
75
                            layout.getDocument().setModified(true);
76
                        } else
77
                            if (s.compareTo("DELANTE") == 0) {
78
                                lg.before();
79
                                layout.getDocument().setModified(true);
80
                            } else
81
                                if (s.compareTo("BORDEAR") == 0) {
82
                                    if (lg.border()) {
83
                                        layout.getDocument().setModified(true);
84
                                    }
85
                                } else
86
                                    if (s.compareTo("POSICIONAR") == 0) {
87
                                        lg.position();
88
                                        layout.getDocument().setModified(true);
89
                                    }
90
    }
91

    
92
    /**
93
     * @see com.iver.mdiApp.plugins.IExtension#isVisible()
94
     */
95
    public boolean isVisible() {
96
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
97

    
98
        if (f == null) {
99
            return false;
100
        }
101

    
102
        if (f instanceof LayoutPanel) {
103
            return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount()
104
                         // > 0;
105
        }
106
        return false;
107
    }
108

    
109
    /**
110
     * @see org.gvsig.andami.plugins.IExtension#initialize()
111
     */
112
    public void initialize() {
113
        registerIcons();
114
    }
115

    
116
    private void registerIcons() {
117
        PluginServices.getIconTheme().registerDefault("layout-group",
118
            this.getClass().getClassLoader().getResource("images/agrupar.png"));
119
        PluginServices.getIconTheme().registerDefault(
120
            "layout-ungroup",
121
            this.getClass().getClassLoader()
122
                .getResource("images/desagrupar.png"));
123
        PluginServices.getIconTheme().registerDefault("layout-bring-to-front",
124
            this.getClass().getClassLoader().getResource("images/delante.png"));
125
        PluginServices.getIconTheme().registerDefault("layout-send-to-back",
126
            this.getClass().getClassLoader().getResource("images/detras.png"));
127
        PluginServices.getIconTheme().registerDefault(
128
            "layout-set-size-position",
129
            this.getClass().getClassLoader()
130
                .getResource("images/posicionar.png"));
131
        PluginServices.getIconTheme().registerDefault("layout-add-border",
132
            this.getClass().getClassLoader().getResource("images/bordear.png"));
133
    }
134

    
135
    /**
136
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
137
     */
138
    public boolean isEnabled() {
139
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
140
        if (!layout.getLayoutContext().isEditable())
141
            return false;
142
        return true;
143
    }
144
}