Statistics
| Revision:

svn-gvsig-desktop / branches / gvSIG_CAD_Layout_version / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / Popupmenu.java @ 1822

History | View | Annotate | Download (5.09 KB)

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

    
47
import java.awt.Font;
48
import java.awt.Point;
49
import java.awt.event.ActionEvent;
50
import java.awt.event.ActionListener;
51
import java.io.IOException;
52

    
53
import javax.swing.JMenuItem;
54
import javax.swing.JPopupMenu;
55

    
56
import com.iver.andami.PluginServices;
57
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
58

    
59

    
60
/**
61
 * Popupmenu de bot?n derecho que se abre sobre el Layout.
62
 *
63
 * @author Vicente Caballero Navarro
64
 */
65
public class Popupmenu extends JPopupMenu {
66
    private final static Font theFont = new Font("SansSerif", Font.PLAIN, 10);
67
    private JMenuItem m_properties=null;
68
    private JMenuItem m_selecAll = null;
69
    private JMenuItem m_behind = null;
70
    private JMenuItem m_before = null;
71
        private JMenuItem m_position = null;
72
    private JMenuItem m_simplify = null;
73
    private JMenuItem m_refresh = null;
74
    private FLayoutGraphics m_flg = null;
75
    private Layout m_layout = null;
76
    private Point m_p = null;
77

    
78
    /**
79
     * Crea un nuevo Popupmenu.
80
     *
81
     * @param layout Layout sobre el que se abre el Popupmenu.
82
     * @param p punto donde se abre el popupmenu.
83
     */
84
    public Popupmenu(Layout layout, Point p) {
85
        m_layout = layout;
86
        m_flg = new FLayoutGraphics(m_layout);
87
        m_p = p;
88
        initialize();
89
    }
90

    
91
    /**
92
     * Inicializa los componentes del Popupmenu.
93
     */
94
    private void initialize() {
95
            m_properties=new JMenuItem(PluginServices.getText(this,"propiedades"));
96
        m_selecAll = new JMenuItem(PluginServices.getText(this,"seleccionar_todos"));
97
        m_behind = new JMenuItem(PluginServices.getText(this,"colocar_detras"));
98
        m_before = new JMenuItem(PluginServices.getText(this,"colocar_delante"));
99
        m_position = new JMenuItem(PluginServices.getText(this,"tama?o_posicion"));
100
        m_simplify = new JMenuItem(PluginServices.getText(this,"simplificar"));
101
        m_refresh = new JMenuItem(PluginServices.getText(this,"refrescar"));
102
        add(m_properties);
103
        addSeparator();
104
        add(m_selecAll);
105
        addSeparator();
106
        add(m_behind);
107
        add(m_before);
108
        add(m_position);
109
                addSeparator();
110
        add(m_simplify);
111
        addSeparator();
112
        add(m_refresh);
113
                m_properties.addActionListener(new ActionListener() {
114
                                public void actionPerformed(ActionEvent e) {
115
                                        m_flg.openFFrameDialog();
116
                                }
117
                        });
118
        m_selecAll.addActionListener(new ActionListener() {
119
                public void actionPerformed(ActionEvent e) {
120
                    m_flg.selecAll();
121
                }
122
            });
123
        m_behind.addActionListener(new ActionListener() {
124
                public void actionPerformed(ActionEvent e) {
125
                    try {
126
                                                m_flg.behind();
127
                                        } catch (DriverIOException e1) {
128
                                                e1.printStackTrace();
129
                                        } catch (IOException e1) {
130
                                                e1.printStackTrace();
131
                                        }
132
                }
133
            });
134
        m_before.addActionListener(new ActionListener() {
135
                public void actionPerformed(ActionEvent e) {
136
                    try {
137
                                                m_flg.before();
138
                                        } catch (DriverIOException e1) {
139
                                                e1.printStackTrace();
140
                                        } catch (IOException e1) {
141
                                                e1.printStackTrace();
142
                                        }
143
                }
144
            });
145
                m_position.addActionListener(new ActionListener() {
146
                                public void actionPerformed(ActionEvent e) {
147
                                        m_flg.position();
148
                                }
149
                        });
150
        m_simplify.addActionListener(new ActionListener() {
151
                public void actionPerformed(ActionEvent e) {
152
                    try {
153
                                                m_flg.simplify();
154
                                        } catch (DriverIOException e1) {
155
                                                e1.printStackTrace();
156
                                        } catch (IOException e1) {
157
                                                e1.printStackTrace();
158
                                        }
159
                }
160
            });
161
        m_refresh.addActionListener(new ActionListener() {
162
                public void actionPerformed(ActionEvent e) {
163
                    m_layout.refresh();
164
                }
165
            });
166
        this.show(m_layout, m_p.x, m_p.y);
167
    }
168
}