Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / LayoutGraphicControls.java @ 24962

History | View | Annotate | Download (4.88 KB)

1
/*
2
 * Created on 15-jul-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package com.iver.cit.gvsig;
48

    
49
import org.apache.log4j.Logger;
50

    
51
import com.iver.andami.PluginServices;
52
import com.iver.andami.plugins.Extension;
53
import com.iver.andami.ui.mdiManager.IWindow;
54
import com.iver.cit.gvsig.project.documents.layout.FLayoutGraphics;
55
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
56

    
57

    
58
/**
59
 * Extensi?n que actua sobre el Layout para controlas las diferentes
60
 * operaciones sobre los gr?ficos.
61
 *
62
 * @author Vicente Caballero Navarro
63
 */
64
public class LayoutGraphicControls extends Extension {
65
        private static Logger logger = Logger.getLogger(LayoutGraphicControls.class.getName());
66
        private Layout layout =null;
67
        /**
68
         * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
69
         */
70
        public void execute(String s) {
71
                layout = (Layout) PluginServices.getMDIManager().getActiveWindow();
72
                FLayoutGraphics lg = new FLayoutGraphics(layout);
73
                logger.debug("Comand : " + s);
74

    
75
                if (s.compareTo("AGRUPAR") == 0) {
76
                        layout.getLayoutContext().getFrameCommandsRecord().startComplex(PluginServices.getText(this,"group"));
77
                        lg.grouping();
78
                        layout.getLayoutContext().getFrameCommandsRecord().endComplex();
79
                        layout.getModel().setModified(true);
80
                } else if (s.compareTo("DESAGRUPAR") == 0) {
81
                        lg.ungrouping();
82
                        layout.getModel().setModified(true);
83
                } else if (s.compareTo("PROPIEDADES") == 0) {
84
                        if (lg.openFFrameDialog()) {
85
                                layout.getModel().setModified(true);
86
                        }
87
                } else if (s.compareTo("ALINEAR") == 0) {
88
                        lg.aligning();
89
                        layout.getModel().setModified(true);
90
                } else if (s.compareTo("DETRAS") == 0) {
91
                        lg.behind();
92
                        layout.getModel().setModified(true);
93
                } else if (s.compareTo("DELANTE") == 0) {
94
                        lg.before();
95
                        layout.getModel().setModified(true);
96
                } else if (s.compareTo("BORDEAR") == 0) {
97
                        if (lg.border()) {
98
                                layout.getModel().setModified(true);
99
                        }
100
                } else if (s.compareTo("POSICIONAR") == 0) {
101
                        lg.position();
102
                        layout.getModel().setModified(true);
103
                }
104
        }
105

    
106
        /**
107
         * @see com.iver.mdiApp.plugins.IExtension#isVisible()
108
         */
109
        public boolean isVisible() {
110
                IWindow f = PluginServices.getMDIManager().getActiveWindow();
111

    
112
                if (f == null) {
113
                        return false;
114
                }
115

    
116
                if (f instanceof Layout) {
117
                        return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0;
118
                }
119
                return false;
120
        }
121

    
122
        /**
123
         * @see com.iver.andami.plugins.IExtension#initialize()
124
         */
125
        public void initialize() {
126
                registerIcons();
127
        }
128

    
129
        private void registerIcons(){
130
                PluginServices.getIconTheme().registerDefault(
131
                                "layout-group",
132
                                this.getClass().getClassLoader().getResource("images/agrupar.png")
133
                        );
134
                PluginServices.getIconTheme().registerDefault(
135
                                "layout-ungroup",
136
                                this.getClass().getClassLoader().getResource("images/desagrupar.png")
137
                        );
138
                PluginServices.getIconTheme().registerDefault(
139
                                "layout-bring-to-front",
140
                                this.getClass().getClassLoader().getResource("images/delante.png")
141
                        );
142
                PluginServices.getIconTheme().registerDefault(
143
                                "layout-send-to-back",
144
                                this.getClass().getClassLoader().getResource("images/detras.png")
145
                        );
146
                PluginServices.getIconTheme().registerDefault(
147
                                "layout-set-size-position",
148
                                this.getClass().getClassLoader().getResource("images/posicionar.png")
149
                        );
150
                PluginServices.getIconTheme().registerDefault(
151
                                "layout-add-border",
152
                                this.getClass().getClassLoader().getResource("images/bordear.png")
153
                        );
154
        }
155

    
156
        /**
157
         * @see com.iver.andami.plugins.IExtension#isEnabled()
158
         */
159
        public boolean isEnabled() {
160
                layout = (Layout) PluginServices.getMDIManager().getActiveWindow();
161
                if (!layout.getLayoutContext().isEditable())
162
                        return false;
163
                return true;
164
        }
165
}