Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / gui / dialogs / FFrameBoxDialog.java @ 10626

History | View | Annotate | Download (9.06 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: FFrameBoxDialog.java 10626 2007-03-06 16:55:54Z caballero $
44
 * $Log$
45
 * Revision 1.6  2007-03-06 16:36:19  caballero
46
 * Exceptions
47
 *
48
 * Revision 1.5  2007/01/23 13:10:25  caballero
49
 * valor no num?rico
50
 *
51
 * Revision 1.4  2006/12/20 14:42:15  caballero
52
 * Remodelado Layout
53
 *
54
 * Revision 1.3  2006/12/11 17:40:35  caballero
55
 * ajustar a grid en el Layout
56
 *
57
 * Revision 1.2.2.2  2006/12/11 11:14:10  caballero
58
 * no clonar el fframe hasta darle aceptar
59
 *
60
 * Revision 1.2.2.1  2006/11/15 04:10:43  jjdelcerro
61
 * *** empty log message ***
62
 *
63
 * Revision 1.2  2006/10/03 12:09:31  jmvivo
64
 * * Ajustado tama?os
65
 * * cambiados botones aceptar/cancelar por AcceptCancelPanel
66
 *
67
 * Revision 1.5.4.1  2006/10/03 12:07:12  jmvivo
68
 * * Ajustado el dialog
69
 * * Sustituido los botones aceptar y cancelar por panel AcceptCancelPanel
70
 *
71
 * Revision 1.5  2006/08/29 07:56:27  cesar
72
 * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
73
 *
74
 * Revision 1.4  2006/06/08 07:57:37  caballero
75
 * zoom a un raster sobre el Layout
76
 *
77
 * Revision 1.3  2006/04/10 06:38:06  caballero
78
 * FFrameTable
79
 *
80
 * Revision 1.2  2006/01/18 15:15:08  caballero
81
 * eliminar c?digo no usado
82
 *
83
 * Revision 1.1  2006/01/12 12:32:12  caballero
84
 * box
85
 *
86
 *
87
 */
88

    
89
package com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs;
90

    
91
import java.awt.Graphics;
92
import java.awt.Graphics2D;
93
import java.awt.geom.Rectangle2D;
94

    
95
import javax.swing.JLabel;
96
import javax.swing.JPanel;
97

    
98
import org.gvsig.gui.beans.AcceptCancelPanel;
99

    
100
import com.iver.andami.PluginServices;
101
import com.iver.andami.ui.mdiManager.WindowInfo;
102
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameTable;
103
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
104
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.JPRotation;
105
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
106

    
107
import de.ios.framework.swing.NumberField;
108

    
109
public class FFrameBoxDialog extends JPanel implements IFFrameDialog{
110

    
111
        private JPanel jPanel = null;
112
        private JLabel jLabel = null;
113
        private JLabel jLabel1 = null;
114
        private NumberField txtNumColumns = null;
115
        private NumberField txtNumRows = null;
116
        private Rectangle2D rect = new Rectangle2D.Double();
117
        private FFrameTable fframebox;
118
        private Layout m_layout;
119
        private boolean isAcepted = false;
120
        private JPanel pBox = null;
121
        private FFrameTable thefframebox;
122
        private JPRotation pRotation;
123
        private AcceptCancelPanel acceptCancel = null;
124
        private FFrameTable newFFrameBox;
125

    
126
        /**
127
         * This is the default constructor
128
         *
129
         * @param layout Referencia al Layout.
130
         * @param fframe Referencia al fframe del cajet?n.
131
         */
132
        public FFrameBoxDialog(Layout layout, FFrameTable fframe) {
133
                super();
134
                fframebox = fframe;
135
                thefframebox=(FFrameTable)fframebox.cloneFFrame(layout);
136
                m_layout = layout;
137
                initialize();
138
        }
139

    
140
        /**
141
         * This method initializes this
142
         *
143
         * @return void
144
         */
145
        private void initialize() {
146
                this.setLayout(null);
147
                this.setSize(380, 185);
148
                this.add(getJPanel(), null);
149
                this.add(getPRotation(),null);
150
                this.add(getAcceptCancel());
151
                getPRotation().setRotation(fframebox.getRotation());
152
        }
153

    
154
        private AcceptCancelPanel getAcceptCancel(){
155
                if (this.acceptCancel == null){
156
                        this.acceptCancel = new AcceptCancelPanel(
157
                                        new java.awt.event.ActionListener() {
158

    
159
                                                public void actionPerformed(java.awt.event.ActionEvent e) {
160
                                                        newFFrameBox=(FFrameTable)fframebox.cloneFFrame(m_layout);
161
                                                        if (getTxtNumColumns().getText().equals(""))
162
                                                                getTxtNumColumns().setText("0");
163
                                                        if (getTxtNumRows().getText().equals(""))
164
                                                                getTxtNumRows().setText("0");
165
                                                        newFFrameBox.setNumColumns(Integer.parseInt(getTxtNumColumns().getText()));
166
                                                        newFFrameBox.setNumRows(Integer.parseInt(getTxtNumRows().getText()));
167
                                                        newFFrameBox.setRotation(getPRotation().getRotation());
168
                                                        Rectangle2D r=fframebox.getBoundBox();
169
                                                        newFFrameBox.calculateTable(r);
170
                                                        PluginServices.getMDIManager().closeWindow(FFrameBoxDialog.this);
171
                                                        //m_layout.refresh();
172
                                                        isAcepted = true;
173
                                                }
174
                                        }
175
                                        ,
176

    
177
                                        new java.awt.event.ActionListener() {
178
                                                public void actionPerformed(java.awt.event.ActionEvent e) {
179
                                                        newFFrameBox=null;
180
                                                        PluginServices.getMDIManager().closeWindow(FFrameBoxDialog.this);
181
                                                }
182
                                        }
183
                        );
184
                        this.acceptCancel.setBounds(5,150,this.getWidth()-10,30);
185

    
186
                }
187
                return this.acceptCancel;
188
        }
189

    
190

    
191
        /**
192
         * This method initializes jPanel
193
         *
194
         * @return javax.swing.JPanel
195
         */
196
        private JPanel getJPanel() {
197
                if (jPanel == null) {
198
                        jLabel1 = new JLabel();
199
                        jLabel1.setBounds(new java.awt.Rectangle(5,32,165,19));
200
                        jLabel1.setText(PluginServices.getText(this,"num_filas"));
201
                        jLabel = new JLabel();
202
                        jLabel.setBounds(new java.awt.Rectangle(5,8,165,19));
203
                        jLabel.setText(PluginServices.getText(this,"num_columnas"));
204
                        jPanel = new JPanel();
205
                        jPanel.setLayout(null);
206
                        jPanel.setBounds(new java.awt.Rectangle(12,9,220,140));
207
                        jPanel.add(jLabel, null);
208
                        jPanel.add(jLabel1, null);
209
                        jPanel.add(getTxtNumColumns(), null);
210
                        jPanel.add(getTxtNumRows(), null);
211
                        jPanel.add(getPBox(), null);
212

    
213
                }
214
                return jPanel;
215
        }
216

    
217
        /**
218
         * This method initializes txtNumColumns
219
         *
220
         * @return javax.swing.JTextField
221
         */
222
        private NumberField getTxtNumColumns() {
223
                if (txtNumColumns == null) {
224
                        txtNumColumns = new NumberField();
225
                        txtNumColumns.setText(String.valueOf(fframebox.getNumColumns()));
226
                        txtNumColumns.setBounds(new java.awt.Rectangle(175,8,35,19));
227
                        txtNumColumns.addKeyListener(new java.awt.event.KeyAdapter() {
228
                                public void keyReleased(java.awt.event.KeyEvent e) {
229
                                        if (txtNumColumns.getIntegerValue()== null || getTxtNumColumns().getText().equals("") || getTxtNumColumns().getText().equals("0"))return;
230
                                        thefframebox.setNumColumns(txtNumColumns.getIntegerValue().intValue());
231
                                        getPBox().repaint();
232
                                }
233
                        });
234
                }
235
                return txtNumColumns;
236
        }
237

    
238
        /**
239
         * This method initializes txtNumRows
240
         *
241
         * @return javax.swing.JTextField
242
         */
243
        private NumberField getTxtNumRows() {
244
                if (txtNumRows == null) {
245
                        txtNumRows = new NumberField();
246
                        txtNumRows.setText(String.valueOf(fframebox.getNumRows()));
247
                        txtNumRows.setBounds(new java.awt.Rectangle(175,32,35,19));
248
                        txtNumRows.addKeyListener(new java.awt.event.KeyAdapter() {
249
                                public void keyReleased(java.awt.event.KeyEvent e) {
250
                                        if (txtNumRows.getIntegerValue() == null || getTxtNumRows().getText().equals("") || getTxtNumRows().getText().equals("0"))return;
251
                                                thefframebox.setNumRows(txtNumRows.getIntegerValue().intValue());
252
                                        getPBox().repaint();
253
                                }
254
                        });
255
                }
256
                return txtNumRows;
257
        }
258

    
259
        public void setRectangle(Rectangle2D r) {
260
                rect.setRect(r);
261
        }
262

    
263
        public WindowInfo getWindowInfo() {
264
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
265
                m_viewinfo.setTitle(PluginServices.getText(this,
266
                                "propiedades_cajetin"));
267

    
268
                return m_viewinfo;
269
        }
270

    
271
        public boolean getIsAcepted() {
272
                return isAcepted;
273
        }
274

    
275
        /**
276
         * This method initializes jPanel1
277
         *
278
         * @return javax.swing.JPanel
279
         */
280
        private JPanel getPBox() {
281
                if (pBox == null) {
282
                        pBox = new PanelBox();
283
                        pBox.setBackground(java.awt.Color.white);
284
                        pBox.setSize(new java.awt.Dimension(202,75));
285
                        pBox.setLocation(new java.awt.Point(5,55));
286
                        pBox.addMouseListener(new java.awt.event.MouseAdapter() {
287
                                public void mouseReleased(java.awt.event.MouseEvent e) {
288
                                        ///Rectangle2D r = new Rectangle2D.Double(5, 5, 155, 65);
289
                                }
290
                        });
291
                }
292
                return pBox;
293
        }
294
        /**
295
         * This method initializes pRotation
296
         *
297
         * @return javax.swing.JPanel
298
         */
299
        private JPRotation getPRotation() {
300
                if (pRotation == null) {
301
                        pRotation = new JPRotation();
302
                        pRotation.setBounds(240, 14, 120, 120);
303
                }
304
                return pRotation;
305
        }
306
        class PanelBox extends JPanel{
307
                protected void paintComponent(Graphics g) {
308
                        super.paintComponent(g);
309
                        Rectangle2D r=new Rectangle2D.Double(5,5,this.getWidth()-10,this.getHeight()-10);
310
                        thefframebox.drawBox(r,(Graphics2D)g);
311
                }
312

    
313
        }
314
        public IFFrame getFFrame() {
315
                return newFFrameBox;
316
        }
317
}  //  @jve:decl-index=0:visual-constraint="10,10"