root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / layout / fframes / gui / dialogs / FFrameBoxDialog.java @ 29596
History | View | Annotate | Download (9.16 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 29596 2009-06-29 16:02:00Z jpiera $
|
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 org.gvsig.app.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.andami.PluginServices; |
99 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
100 |
import org.gvsig.app.project.documents.layout.fframes.FFrameTable; |
101 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
102 |
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation; |
103 |
import org.gvsig.app.project.documents.layout.gui.Layout; |
104 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
105 |
|
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 |
} |
164 |
if (getTxtNumRows().getText().equals("")) { |
165 |
getTxtNumRows().setText("0");
|
166 |
} |
167 |
newFFrameBox.setNumColumns(Integer.parseInt(getTxtNumColumns().getText()));
|
168 |
newFFrameBox.setNumRows(Integer.parseInt(getTxtNumRows().getText()));
|
169 |
newFFrameBox.setRotation(getPRotation().getRotation()); |
170 |
Rectangle2D r=fframebox.getBoundBox();
|
171 |
newFFrameBox.calculateTable(r); |
172 |
PluginServices.getMDIManager().closeWindow(FFrameBoxDialog.this); |
173 |
//m_layout.refresh();
|
174 |
isAcepted = true;
|
175 |
} |
176 |
} |
177 |
, |
178 |
|
179 |
new java.awt.event.ActionListener() {
|
180 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
181 |
newFFrameBox=null;
|
182 |
PluginServices.getMDIManager().closeWindow(FFrameBoxDialog.this); |
183 |
} |
184 |
} |
185 |
); |
186 |
this.acceptCancel.setBounds(5,150,this.getWidth()-10,30); |
187 |
|
188 |
} |
189 |
return this.acceptCancel; |
190 |
} |
191 |
|
192 |
|
193 |
/**
|
194 |
* This method initializes jPanel
|
195 |
*
|
196 |
* @return javax.swing.JPanel
|
197 |
*/
|
198 |
private JPanel getJPanel() { |
199 |
if (jPanel == null) { |
200 |
jLabel1 = new JLabel(); |
201 |
jLabel1.setBounds(new java.awt.Rectangle(5,32,165,19)); |
202 |
jLabel1.setText(PluginServices.getText(this,"num_filas")); |
203 |
jLabel = new JLabel(); |
204 |
jLabel.setBounds(new java.awt.Rectangle(5,8,165,19)); |
205 |
jLabel.setText(PluginServices.getText(this,"num_columnas")); |
206 |
jPanel = new JPanel(); |
207 |
jPanel.setLayout(null);
|
208 |
jPanel.setBounds(new java.awt.Rectangle(12,9,220,140)); |
209 |
jPanel.add(jLabel, null);
|
210 |
jPanel.add(jLabel1, null);
|
211 |
jPanel.add(getTxtNumColumns(), null);
|
212 |
jPanel.add(getTxtNumRows(), null);
|
213 |
jPanel.add(getPBox(), null);
|
214 |
|
215 |
} |
216 |
return jPanel;
|
217 |
} |
218 |
|
219 |
/**
|
220 |
* This method initializes txtNumColumns
|
221 |
*
|
222 |
* @return javax.swing.JTextField
|
223 |
*/
|
224 |
private NumberField getTxtNumColumns() {
|
225 |
if (txtNumColumns == null) { |
226 |
txtNumColumns = new NumberField();
|
227 |
txtNumColumns.setText(String.valueOf(fframebox.getNumColumns()));
|
228 |
txtNumColumns.setBounds(new java.awt.Rectangle(175,8,35,19)); |
229 |
txtNumColumns.addKeyListener(new java.awt.event.KeyAdapter() {
|
230 |
public void keyReleased(java.awt.event.KeyEvent e) { |
231 |
if (txtNumColumns.getIntegerValue()== null || getTxtNumColumns().getText().equals("") || getTxtNumColumns().getText().equals("0")) { |
232 |
return;
|
233 |
} |
234 |
thefframebox.setNumColumns(txtNumColumns.getIntegerValue().intValue()); |
235 |
getPBox().repaint(); |
236 |
} |
237 |
}); |
238 |
} |
239 |
return txtNumColumns;
|
240 |
} |
241 |
|
242 |
/**
|
243 |
* This method initializes txtNumRows
|
244 |
*
|
245 |
* @return javax.swing.JTextField
|
246 |
*/
|
247 |
private NumberField getTxtNumRows() {
|
248 |
if (txtNumRows == null) { |
249 |
txtNumRows = new NumberField();
|
250 |
txtNumRows.setText(String.valueOf(fframebox.getNumRows()));
|
251 |
txtNumRows.setBounds(new java.awt.Rectangle(175,32,35,19)); |
252 |
txtNumRows.addKeyListener(new java.awt.event.KeyAdapter() {
|
253 |
public void keyReleased(java.awt.event.KeyEvent e) { |
254 |
if (txtNumRows.getIntegerValue() == null || getTxtNumRows().getText().equals("") || getTxtNumRows().getText().equals("0")) { |
255 |
return;
|
256 |
} |
257 |
thefframebox.setNumRows(txtNumRows.getIntegerValue().intValue()); |
258 |
getPBox().repaint(); |
259 |
} |
260 |
}); |
261 |
} |
262 |
return txtNumRows;
|
263 |
} |
264 |
|
265 |
public void setRectangle(Rectangle2D r) { |
266 |
rect.setRect(r); |
267 |
} |
268 |
|
269 |
public WindowInfo getWindowInfo() {
|
270 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
271 |
m_viewinfo.setTitle(PluginServices.getText(this,
|
272 |
"propiedades_cajetin"));
|
273 |
|
274 |
return m_viewinfo;
|
275 |
} |
276 |
|
277 |
public boolean getIsAcepted() { |
278 |
return isAcepted;
|
279 |
} |
280 |
|
281 |
/**
|
282 |
* This method initializes jPanel1
|
283 |
*
|
284 |
* @return javax.swing.JPanel
|
285 |
*/
|
286 |
private JPanel getPBox() { |
287 |
if (pBox == null) { |
288 |
pBox = new PanelBox();
|
289 |
pBox.setBackground(java.awt.Color.white); |
290 |
pBox.setSize(new java.awt.Dimension(202,75)); |
291 |
pBox.setLocation(new java.awt.Point(5,55)); |
292 |
pBox.addMouseListener(new java.awt.event.MouseAdapter() {
|
293 |
public void mouseReleased(java.awt.event.MouseEvent e) { |
294 |
///Rectangle2D r = new Rectangle2D.Double(5, 5, 155, 65);
|
295 |
} |
296 |
}); |
297 |
} |
298 |
return pBox;
|
299 |
} |
300 |
/**
|
301 |
* This method initializes pRotation
|
302 |
*
|
303 |
* @return javax.swing.JPanel
|
304 |
*/
|
305 |
private JPRotation getPRotation() {
|
306 |
if (pRotation == null) { |
307 |
pRotation = new JPRotation();
|
308 |
pRotation.setBounds(240, 14, 120, 120); |
309 |
} |
310 |
return pRotation;
|
311 |
} |
312 |
class PanelBox extends JPanel{ |
313 |
protected void paintComponent(Graphics g) { |
314 |
super.paintComponent(g);
|
315 |
Rectangle2D r=new Rectangle2D.Double(5,5,this.getWidth()-10,this.getHeight()-10); |
316 |
thefframebox.drawBox(r,(Graphics2D)g);
|
317 |
} |
318 |
|
319 |
} |
320 |
public IFFrame getFFrame() {
|
321 |
return newFFrameBox;
|
322 |
} |
323 |
|
324 |
public Object getWindowProfile() { |
325 |
return WindowInfo.DIALOG_PROFILE;
|
326 |
} |
327 |
} // @jve:decl-index=0:visual-constraint="10,10"
|