Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / LayoutEditableToolsExtension.java @ 3573

History | View | Annotate | Download (4.13 KB)

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

    
43
import com.iver.andami.PluginServices;
44
import com.iver.andami.plugins.Extension;
45
import com.iver.andami.ui.mdiManager.View;
46

    
47
import com.iver.cit.gvsig.gui.layout.Layout;
48

    
49
import org.apache.log4j.Logger;
50

    
51

    
52
/**
53
 * Extensi?n que contiene todas las herramientas de edici?n.
54
 *
55
 * @author Vicente Caballero Navarro
56
 */
57
public class LayoutEditableToolsExtension implements Extension {
58
    private static Logger logger = Logger.getLogger(LayoutEditableToolsExtension.class.getName());
59
    private Layout layout = null;
60

    
61
    /**
62
     * DOCUMENT ME!
63
     */
64
    public void inicializar() {
65
        // TODO Auto-generated method stub
66
    }
67

    
68
    /**
69
     * DOCUMENT ME!
70
     *
71
     * @param s DOCUMENT ME!
72
     */
73
    public void execute(String s) {
74
        layout = (Layout) PluginServices.getMDIManager().getActiveView();
75

    
76
        logger.debug("Comand : " + s);
77

    
78
        if (s.equals("SELECT")) {
79
            layout.setTool(Layout.SELECT);
80
        } else if (s.equals("RECTANGLEVIEW")) {
81
                    layout.setTool(Layout.RECTANGLEVIEW);
82
            } else if (s.equals("RECTANGLEPICTURE")) {
83
                    layout.setTool(Layout.RECTANGLEPICTURE);
84
            } else if (s.equals("RECTANGLESCALEBAR")) {
85
                    layout.setTool(Layout.RECTANGLESCALEBAR);
86
            } else if (s.equals("RECTANGLELEGEND")) {
87
                    layout.setTool(Layout.RECTANGLELEGEND);
88
            } else if (s.equals("RECTANGLETEXT")) {
89
                    layout.setTool(Layout.RECTANGLETEXT);
90
            } else if (s.equals("RECTANGLENORTH")) {
91
                    layout.setTool(Layout.RECTANGLENORTH);
92
            } else if (s.equals("POINT")) {
93
                    layout.setTool(Layout.POINT);
94
            } else if (s.equals("LINE")) {
95
                    layout.setTool(Layout.LINE);
96
            } else if (s.equals("POLYLINE")) {
97
                    layout.setTool(Layout.POLYLINE);
98
            } else if (s.equals("CIRCLE")) {
99
                    layout.setTool(Layout.CIRCLE);
100
            } else if (s.equals("RECTANGLESIMPLE")) {
101
                    layout.setTool(Layout.RECTANGLESIMPLE);
102
            } else if (s.equals("POLYGON")) {
103
                    layout.setTool(Layout.POLYGON);
104
            } else if (s.equals("REMOVE")){
105
                    layout.delFFrameSelected();
106
                    layout.refresh();
107
            }else if (s.compareTo("VERTEX")==0){
108
                        layout.setTool(Layout.EDIT);
109
                }
110
    }
111

    
112
    /**
113
     * DOCUMENT ME!
114
     *
115
     * @return DOCUMENT ME!
116
     */
117
    public boolean isEnabled() {
118
        View f = PluginServices.getMDIManager().getActiveView();
119

    
120
        if (f == null) {
121
            return false;
122
        }
123

    
124
        if (f instanceof Layout) {
125
            return ((Layout) f).isEditable();
126
        }
127

    
128
        return false;
129
    }
130

    
131
    /**
132
     * DOCUMENT ME!
133
     *
134
     * @return DOCUMENT ME!
135
     */
136
    public boolean isVisible() {
137
        View f = PluginServices.getMDIManager().getActiveView();
138

    
139
        if (f == null) {
140
            return false;
141
        }
142

    
143
        if (f.getClass() == Layout.class) {
144
            //        Layout layout = (Layout) f;
145
            return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0;
146
        } else {
147
            return false;
148
        }
149
    }
150
}