Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / gui / dialogs / FFrameBoxDialog.java @ 9392

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

    
83
package com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs;
84

    
85
import java.awt.Graphics;
86
import java.awt.Graphics2D;
87
import java.awt.geom.Rectangle2D;
88

    
89
import javax.swing.JLabel;
90
import javax.swing.JPanel;
91
import javax.swing.JTextField;
92

    
93
import org.gvsig.gui.beans.AcceptCancelPanel;
94

    
95
import com.iver.andami.PluginServices;
96
import com.iver.andami.ui.mdiManager.WindowInfo;
97
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameTable;
98
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
99
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.JPRotation;
100
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
101

    
102
public class FFrameBoxDialog extends JPanel implements IFFrameDialog{
103

    
104
        private JPanel jPanel = null;
105
        private JLabel jLabel = null;
106
        private JLabel jLabel1 = null;
107
        private JTextField txtNumColumns = null;
108
        private JTextField txtNumRows = null;
109
        private Rectangle2D rect = new Rectangle2D.Double();
110
        private FFrameTable fframebox;
111
        private Layout m_layout;
112
        private boolean isAcepted = false;
113
        private JPanel pBox = null;
114
        private FFrameTable thefframebox;
115
        private JPRotation pRotation;
116
        private AcceptCancelPanel acceptCancel = null;
117
        private FFrameTable newFFrameBox;
118

    
119
        /**
120
         * This is the default constructor
121
         *
122
         * @param layout Referencia al Layout.
123
         * @param fframe Referencia al fframe del cajet?n.
124
         */
125
        public FFrameBoxDialog(Layout layout, FFrameTable fframe) {
126
                super();
127
                fframebox = fframe;
128
                thefframebox=(FFrameTable)fframebox.cloneFFrame(layout);
129
                m_layout = layout;
130
                initialize();
131
        }
132

    
133
        /**
134
         * This method initializes this
135
         *
136
         * @return void
137
         */
138
        private void initialize() {
139
                this.setLayout(null);
140
                this.setSize(380, 185);
141
                this.add(getJPanel(), null);
142
                this.add(getPRotation(),null);
143
                this.add(getAcceptCancel());
144
                getPRotation().setRotation(fframebox.getRotation());
145
        }
146

    
147
        private AcceptCancelPanel getAcceptCancel(){
148
                if (this.acceptCancel == null){
149
                        this.acceptCancel = new AcceptCancelPanel(
150
                                        new java.awt.event.ActionListener() {
151

    
152
                                                public void actionPerformed(java.awt.event.ActionEvent e) {
153
                                                        newFFrameBox=(FFrameTable)fframebox.cloneFFrame(m_layout);
154
                                                        newFFrameBox.setNumColumns(Integer.parseInt(getTxtNumColumns().getText()));
155
                                                        newFFrameBox.setNumRows(Integer.parseInt(getTxtNumRows().getText()));
156
                                                        newFFrameBox.setRotation(getPRotation().getRotation());
157
                                                        Rectangle2D r=fframebox.getBoundBox();
158
                                                        newFFrameBox.calculateTable(r);
159
                                                        PluginServices.getMDIManager().closeWindow(FFrameBoxDialog.this);
160
                                                        //m_layout.refresh();
161
                                                        isAcepted = true;
162
                                                }
163
                                        }
164
                                        ,
165

    
166
                                        new java.awt.event.ActionListener() {
167
                                                public void actionPerformed(java.awt.event.ActionEvent e) {
168
                                                        newFFrameBox=null;
169
                                                        PluginServices.getMDIManager().closeWindow(FFrameBoxDialog.this);
170
                                                }
171
                                        }
172
                        );
173
                        this.acceptCancel.setBounds(5,150,this.getWidth()-10,30);
174

    
175
                }
176
                return this.acceptCancel;
177
        }
178

    
179

    
180
        /**
181
         * This method initializes jPanel
182
         *
183
         * @return javax.swing.JPanel
184
         */
185
        private JPanel getJPanel() {
186
                if (jPanel == null) {
187
                        jLabel1 = new JLabel();
188
                        jLabel1.setBounds(new java.awt.Rectangle(5,32,165,19));
189
                        jLabel1.setText(PluginServices.getText(this,"num_filas"));
190
                        jLabel = new JLabel();
191
                        jLabel.setBounds(new java.awt.Rectangle(5,8,165,19));
192
                        jLabel.setText(PluginServices.getText(this,"num_columnas"));
193
                        jPanel = new JPanel();
194
                        jPanel.setLayout(null);
195
                        jPanel.setBounds(new java.awt.Rectangle(12,9,220,140));
196
                        jPanel.add(jLabel, null);
197
                        jPanel.add(jLabel1, null);
198
                        jPanel.add(getTxtNumColumns(), null);
199
                        jPanel.add(getTxtNumRows(), null);
200
                        jPanel.add(getPBox(), null);
201

    
202
                }
203
                return jPanel;
204
        }
205

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

    
227
        /**
228
         * This method initializes txtNumRows
229
         *
230
         * @return javax.swing.JTextField
231
         */
232
        private JTextField getTxtNumRows() {
233
                if (txtNumRows == null) {
234
                        txtNumRows = new JTextField();
235
                        txtNumRows.setText(String.valueOf(fframebox.getNumRows()));
236
                        txtNumRows.setBounds(new java.awt.Rectangle(175,32,35,19));
237
                        txtNumRows.addKeyListener(new java.awt.event.KeyAdapter() {
238
                                public void keyReleased(java.awt.event.KeyEvent e) {
239
                                        if (getTxtNumRows().getText().equals("") || getTxtNumRows().getText().equals("0"))return;
240
                                        thefframebox.setNumRows(Integer.parseInt(getTxtNumRows().getText()));
241
                                        getPBox().repaint();
242
                                }
243
                        });
244
                }
245
                return txtNumRows;
246
        }
247

    
248
        public void setRectangle(Rectangle2D r) {
249
                rect.setRect(r);
250
        }
251

    
252
        public WindowInfo getWindowInfo() {
253
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
254
                m_viewinfo.setTitle(PluginServices.getText(this,
255
                                "propiedades_cajetin"));
256

    
257
                return m_viewinfo;
258
        }
259

    
260
        public boolean getIsAcepted() {
261
                return isAcepted;
262
        }
263

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

    
302
        }
303
        public IFFrame getFFrame() {
304
                return newFFrameBox;
305
        }
306
}  //  @jve:decl-index=0:visual-constraint="10,10"