Statistics
| Revision:

svn-gvsig-desktop / tags / v10_RC2c / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / dialogs / FFrameBoxDialog.java @ 8745

History | View | Annotate | Download (7.83 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
/* CVS MESSAGES:
42
 *
43
 * $Id$
44
 * $Log$
45
 * Revision 1.5.4.1  2006-10-03 12:07:12  jmvivo
46
 * * Ajustado el dialog
47
 * * Sustituido los botones aceptar y cancelar por panel AcceptCancelPanel
48
 *
49
 * Revision 1.5  2006/08/29 07:56:27  cesar
50
 * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
51
 *
52
 * Revision 1.4  2006/06/08 07:57:37  caballero
53
 * zoom a un raster sobre el Layout
54
 *
55
 * Revision 1.3  2006/04/10 06:38:06  caballero
56
 * FFrameTable
57
 *
58
 * Revision 1.2  2006/01/18 15:15:08  caballero
59
 * eliminar c?digo no usado
60
 *
61
 * Revision 1.1  2006/01/12 12:32:12  caballero
62
 * box
63
 *
64
 *
65
 */
66

    
67
package com.iver.cit.gvsig.gui.layout.fframes.dialogs;
68

    
69
import java.awt.Graphics;
70
import java.awt.Graphics2D;
71
import java.awt.geom.Rectangle2D;
72

    
73
import javax.swing.JLabel;
74
import javax.swing.JPanel;
75
import javax.swing.JTextField;
76

    
77
import org.gvsig.gui.beans.AcceptCancelPanel;
78

    
79
import com.iver.andami.PluginServices;
80
import com.iver.andami.ui.mdiManager.WindowInfo;
81
import com.iver.cit.gvsig.gui.layout.Layout;
82
import com.iver.cit.gvsig.gui.layout.fframes.FFrameTable;
83

    
84
public class FFrameBoxDialog extends JPanel implements IFFrameDialog{
85

    
86
        private JPanel jPanel = null;
87
        private JLabel jLabel = null;
88
        private JLabel jLabel1 = null;
89
        private JTextField txtNumColumns = null;
90
        private JTextField txtNumRows = null;
91
        private Rectangle2D rect = new Rectangle2D.Double();
92
        private FFrameTable fframebox;
93
        private Layout m_layout;
94
        private boolean isAcepted = false;
95
        private JPanel pBox = null;
96
        private FFrameTable thefframebox;
97
        private JPRotation pRotation;
98
        private AcceptCancelPanel acceptCancel = null;
99
        /**
100
         * This is the default constructor
101
         *
102
         * @param layout Referencia al Layout.
103
         * @param fframe Referencia al fframe del cajet?n.
104
         */
105
        public FFrameBoxDialog(Layout layout, FFrameTable fframe) {
106
                super();
107
                fframebox = fframe;
108
                thefframebox=(FFrameTable)fframebox.cloneFFrame(layout);
109
                m_layout = layout;
110
                initialize();
111
        }
112

    
113
        /**
114
         * This method initializes this
115
         *
116
         * @return void
117
         */
118
        private void initialize() {
119
                this.setLayout(null);
120
                this.setSize(380, 185);
121
                this.add(getJPanel(), null);
122
                this.add(getPRotation(),null);
123
                this.add(getAcceptCancel());
124
                getPRotation().setRotation(fframebox.getRotation());
125
        }
126
        
127
        private AcceptCancelPanel getAcceptCancel(){
128
                if (this.acceptCancel == null){
129
                        this.acceptCancel = new AcceptCancelPanel(
130
                                        new java.awt.event.ActionListener() {
131
                                                public void actionPerformed(java.awt.event.ActionEvent e) {
132
                                                        fframebox.setNumColumns(Integer.parseInt(getTxtNumColumns().getText()));
133
                                                        fframebox.setNumRows(Integer.parseInt(getTxtNumRows().getText()));
134
                                                        fframebox.setRotation(getPRotation().getRotation());
135
                                                        Rectangle2D r=fframebox.getBoundBox();
136
                                                        fframebox.calculateTable(r);
137
                                                        PluginServices.getMDIManager().closeWindow(FFrameBoxDialog.this);
138
                                                        m_layout.refresh();
139
                                                        isAcepted = true;
140
                                                }
141
                                        }
142
                                        ,
143
                                        
144
                                        new java.awt.event.ActionListener() {
145
                                                public void actionPerformed(java.awt.event.ActionEvent e) {
146
                                                        PluginServices.getMDIManager().closeWindow(FFrameBoxDialog.this);
147
                                                }
148
                                        }
149
                        );
150
                        this.acceptCancel.setBounds(5,150,this.getWidth()-10,30);
151
                        
152
                }
153
                return this.acceptCancel;
154
        }
155

    
156

    
157
        /**
158
         * This method initializes jPanel
159
         *
160
         * @return javax.swing.JPanel
161
         */
162
        private JPanel getJPanel() {
163
                if (jPanel == null) {
164
                        jLabel1 = new JLabel();
165
                        jLabel1.setBounds(new java.awt.Rectangle(5,32,165,19));
166
                        jLabel1.setText(PluginServices.getText(this,"num_filas"));
167
                        jLabel = new JLabel();
168
                        jLabel.setBounds(new java.awt.Rectangle(5,8,165,19));
169
                        jLabel.setText(PluginServices.getText(this,"num_columnas"));
170
                        jPanel = new JPanel();
171
                        jPanel.setLayout(null);                        
172
                        jPanel.setBounds(new java.awt.Rectangle(12,9,220,140));
173
                        jPanel.add(jLabel, null);
174
                        jPanel.add(jLabel1, null);
175
                        jPanel.add(getTxtNumColumns(), null);
176
                        jPanel.add(getTxtNumRows(), null);
177
                        jPanel.add(getPBox(), null);
178

    
179
                }
180
                return jPanel;
181
        }
182

    
183
        /**
184
         * This method initializes txtNumColumns
185
         *
186
         * @return javax.swing.JTextField
187
         */
188
        private JTextField getTxtNumColumns() {
189
                if (txtNumColumns == null) {
190
                        txtNumColumns = new JTextField();
191
                        txtNumColumns.setText(String.valueOf(fframebox.getNumColumns()));
192
                        txtNumColumns.setBounds(new java.awt.Rectangle(175,8,35,19));
193
                        txtNumColumns.addKeyListener(new java.awt.event.KeyAdapter() {
194
                                public void keyReleased(java.awt.event.KeyEvent e) {
195
                                        if (getTxtNumColumns().getText().equals("") || getTxtNumColumns().getText().equals("0"))return;
196
                                        thefframebox.setNumColumns(Integer.parseInt(getTxtNumColumns().getText()));
197
                                        getPBox().repaint();
198
                                }
199
                        });
200
                }
201
                return txtNumColumns;
202
        }
203

    
204
        /**
205
         * This method initializes txtNumRows
206
         *
207
         * @return javax.swing.JTextField
208
         */
209
        private JTextField getTxtNumRows() {
210
                if (txtNumRows == null) {
211
                        txtNumRows = new JTextField();
212
                        txtNumRows.setText(String.valueOf(fframebox.getNumRows()));
213
                        txtNumRows.setBounds(new java.awt.Rectangle(175,32,35,19));
214
                        txtNumRows.addKeyListener(new java.awt.event.KeyAdapter() {
215
                                public void keyReleased(java.awt.event.KeyEvent e) {
216
                                        if (getTxtNumRows().getText().equals("") || getTxtNumRows().getText().equals("0"))return;
217
                                        thefframebox.setNumRows(Integer.parseInt(getTxtNumRows().getText()));
218
                                        getPBox().repaint();
219
                                }
220
                        });
221
                }
222
                return txtNumRows;
223
        }
224

    
225
        public void setRectangle(Rectangle2D r) {
226
                rect.setRect(r);
227
        }
228

    
229
        public WindowInfo getWindowInfo() {
230
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
231
                m_viewinfo.setTitle(PluginServices.getText(this,
232
                                "propiedades_cajetin"));
233

    
234
                return m_viewinfo;
235
        }
236

    
237
        public boolean getIsAcepted() {
238
                return isAcepted;
239
        }
240

    
241
        /**
242
         * This method initializes jPanel1
243
         *
244
         * @return javax.swing.JPanel
245
         */
246
        private JPanel getPBox() {
247
                if (pBox == null) {
248
                        pBox = new PanelBox();
249
                        pBox.setBackground(java.awt.Color.white);
250
                        pBox.setSize(new java.awt.Dimension(202,75));
251
                        pBox.setLocation(new java.awt.Point(5,55));
252
                        pBox.addMouseListener(new java.awt.event.MouseAdapter() {
253
                                public void mouseReleased(java.awt.event.MouseEvent e) {
254
                                        ///Rectangle2D r = new Rectangle2D.Double(5, 5, 155, 65);
255
                                }
256
                        });
257
                }
258
                return pBox;
259
        }
260
        /**
261
         * This method initializes pRotation
262
         *
263
         * @return javax.swing.JPanel
264
         */
265
        private JPRotation getPRotation() {
266
                if (pRotation == null) {
267
                        pRotation = new JPRotation();
268
                        pRotation.setBounds(240, 14, 120, 120);
269
                }
270
                return pRotation;
271
        }
272
        class PanelBox extends JPanel{
273
                protected void paintComponent(Graphics g) {
274
                        super.paintComponent(g);
275
                        Rectangle2D r=new Rectangle2D.Double(5,5,this.getWidth()-10,this.getHeight()-10);
276
                        thefframebox.drawBox(r,(Graphics2D)g);
277
                }
278

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