Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / legend / edition / gui / PanelEditInterval.java @ 40596

History | View | Annotate | Download (5.55 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

    
25
package org.gvsig.app.project.documents.view.legend.edition.gui;
26

    
27

    
28
import javax.swing.JButton;
29
import javax.swing.JLabel;
30
import javax.swing.JOptionPane;
31
import javax.swing.JPanel;
32
import javax.swing.JTextField;
33

    
34
import org.gvsig.andami.PluginServices;
35
import org.gvsig.andami.ui.mdiManager.IWindow;
36
import org.gvsig.andami.ui.mdiManager.WindowInfo;
37
import org.gvsig.fmap.mapcontext.rendering.legend.IInterval;
38
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.FInterval;
39

    
40

    
41

    
42
/**
43
 * DOCUMENT ME!
44
 *
45
 * @author fjp To change the template for this generated type comment go to
46
 *         Window>Preferences>Java>Code Generation>Code and
47
 *         Comments
48
*/
49
public class PanelEditInterval extends JPanel implements IWindow  {
50
        private JButton jButton = null;
51
        //private FIntervalCellEditor intervaleditor;
52
        private JPanel jPanel = null;
53
        private JPanel jPanel1 = null;
54
        private JLabel jLabel = null;
55
        private JTextField m_txtMin1 = null;
56
        private JPanel jPanel2 = null;
57
        private JLabel jLabel1 = null;
58
        private JTextField m_txtMax1 = null;
59
        private boolean ok=false;
60
        /**
61
     * This is the default constructor
62
     */
63
    public PanelEditInterval() {
64
        super();
65
        initialize();
66
                //intervaleditor=ice;
67
    }
68

    
69
    /**
70
     * DOCUMENT ME!
71
     *
72
     * @param i DOCUMENT ME!
73
     */
74
    public void setFInterval(IInterval i) {
75
            ok=false;
76
                if (i instanceof FInterval){
77

    
78
                        m_txtMin1.setText(String.valueOf(((FInterval)i).getMin()));
79
                        m_txtMax1.setText(String.valueOf(((FInterval)i).getMax()));
80
                }
81
        }
82

    
83
    /**
84
     * DOCUMENT ME!
85
     *
86
     * @return DOCUMENT ME!
87
     */
88
    public FInterval getFInterval() {
89
                double from=0;
90
                double to=0;
91
                try{
92
        from = Double.parseDouble(m_txtMin1.getText());
93
        to =Double.parseDouble(m_txtMax1.getText());
94

    
95
                }catch (NumberFormatException e) {
96
                        JOptionPane.showMessageDialog(null, PluginServices.getText(this,"Formato_de_numero_erroneo")+".");
97
                }
98
                FInterval i = new FInterval(from, to);
99
        return i;
100
    }
101

    
102
    /**
103
     * This method initializes this
104
     */
105
    private void initialize() {
106
        this.setSize(316, 124);
107
                this.add(getJPanel1(), null);
108
                this.add(getJPanel2(), null);
109
                this.add(getJPanel(), null);
110

    
111

    
112
    }
113

    
114
        public WindowInfo getWindowInfo() {
115
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
116
                m_viewinfo.setTitle(PluginServices.getText(this, "Intervalo"));
117
                m_viewinfo.setWidth(this.getWidth());
118
                m_viewinfo.setHeight(this.getHeight());
119
                return m_viewinfo;
120
        }
121

    
122
        /**
123
         * This method initializes jButton
124
         *
125
         * @return javax.swing.JButton
126
         */
127
        private JButton getJButton() {
128
                if (jButton == null) {
129
                        jButton = new JButton();
130
                        jButton.setText("aceptar");
131
                        jButton.setPreferredSize(new java.awt.Dimension(90,26));
132
                        jButton.addActionListener(new java.awt.event.ActionListener() {
133
                                public void actionPerformed(java.awt.event.ActionEvent e) {
134
                                        //intervaleditor.setCurrentInterval(getFInterval());
135
                                        ok=true;
136
                                        PluginServices.getMDIManager().closeWindow(PanelEditInterval.this);
137
                                }
138
                        });
139
                }
140
                return jButton;
141
        }
142
        public boolean isOK(){
143
                return ok;
144
        }
145
        /**
146
         * This method initializes jPanel
147
         *
148
         * @return javax.swing.JPanel
149
         */
150
        private JPanel getJPanel() {
151
                if (jPanel == null) {
152
                        jPanel = new JPanel();
153
                        jPanel.setPreferredSize(new java.awt.Dimension(140,36));
154
                        jPanel.add(getJButton(), null);
155
                }
156
                return jPanel;
157
        }
158

    
159
        /**
160
         * This method initializes jPanel1
161
         *
162
         * @return javax.swing.JPanel
163
         */
164
        private JPanel getJPanel1() {
165
                if (jPanel1 == null) {
166
                        jLabel = new JLabel();
167
                        jLabel.setText("Valor minimo");
168
                        jPanel1 = new JPanel();
169
                        jPanel1.add(jLabel, null);
170
                        jPanel1.add(getM_txtMin1(), null);
171

    
172
                }
173
                return jPanel1;
174
        }
175

    
176
        /**
177
         * This method initializes jTextField
178
         *
179
         * @return javax.swing.JTextField
180
         */
181
        private JTextField getM_txtMin1() {
182
                if (m_txtMin1 == null) {
183
                        m_txtMin1 = new JTextField();
184
                        m_txtMin1.setPreferredSize(new java.awt.Dimension(100,20));
185
                }
186
                return m_txtMin1;
187
        }
188

    
189
        /**
190
         * This method initializes jPanel2
191
         *
192
         * @return javax.swing.JPanel
193
         */
194
        private JPanel getJPanel2() {
195
                if (jPanel2 == null) {
196
                        jLabel1 = new JLabel();
197
                        jLabel1.setText("Valor maximo");
198
                        jPanel2 = new JPanel();
199
                        jPanel2.add(jLabel1, null);
200
                        jPanel2.add(getM_txtMax1(), null);
201

    
202
                }
203
                return jPanel2;
204
        }
205

    
206
        /**
207
         * This method initializes jTextField
208
         *
209
         * @return javax.swing.JTextField
210
         */
211
        private JTextField getM_txtMax1() {
212
                if (m_txtMax1 == null) {
213
                        m_txtMax1 = new JTextField();
214
                        m_txtMax1.setPreferredSize(new java.awt.Dimension(100,20));
215
                }
216
                return m_txtMax1;
217
        }
218
        public Object getWindowProfile() {
219
                return WindowInfo.DIALOG_PROFILE;
220
        }
221

    
222
}  //  @jve:decl-index=0:visual-constraint="10,10"