svn-gvsig-desktop / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / coordDataInput / CoordDataInputContainer.java @ 10885
History | View | Annotate | Download (8.81 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 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 |
package org.gvsig.gui.beans.coordDataInput; |
20 |
|
21 |
import java.awt.FlowLayout; |
22 |
import java.awt.GridBagConstraints; |
23 |
import java.awt.GridBagLayout; |
24 |
|
25 |
import javax.swing.JLabel; |
26 |
import javax.swing.JPanel; |
27 |
|
28 |
import org.gvsig.gui.beans.BaseComponent; |
29 |
import org.gvsig.gui.beans.dataInput.DataInputContainer; |
30 |
|
31 |
public class CoordDataInputContainer extends BaseComponent{ |
32 |
private static final long serialVersionUID = 3336324382874763427L; |
33 |
private int MARGIN = 12; |
34 |
private int wComp = 350, hComp = 80; |
35 |
private int hPanel = 24; |
36 |
private int wLabels = 60, hLabels = 22; |
37 |
private int wData = 152, hData = 24; |
38 |
|
39 |
private JPanel pCoord = null; |
40 |
private JPanel pData1 = null; |
41 |
private JPanel pData2 = null; |
42 |
private JLabel lTitulo1 = null; |
43 |
private JLabel lTitulo2 = null; |
44 |
private DataInputContainer pDataInput11 = null; |
45 |
private DataInputContainer pDataInput12 = null; |
46 |
private DataInputContainer pDataInput21 = null; |
47 |
private DataInputContainer pDataInput22 = null; |
48 |
|
49 |
private String tituloPanel = "Title"; |
50 |
|
51 |
/**
|
52 |
* This is the default constructor
|
53 |
*/
|
54 |
public CoordDataInputContainer(int w, int h) { |
55 |
super();
|
56 |
this.wComp = w;
|
57 |
setComponentSize(wComp, hComp); |
58 |
initialize(); |
59 |
} |
60 |
|
61 |
/**
|
62 |
* This method initializes this
|
63 |
*
|
64 |
* @return void
|
65 |
*/
|
66 |
private void initialize() { |
67 |
FlowLayout flowLayout = new FlowLayout(); |
68 |
flowLayout.setHgap(0);
|
69 |
flowLayout.setVgap(0);
|
70 |
this.setLayout(flowLayout);
|
71 |
this.setPreferredSize(new java.awt.Dimension(wComp, hComp)); |
72 |
this.add(getPCoord(), null); |
73 |
} |
74 |
|
75 |
/**
|
76 |
* This method initializes jPanel
|
77 |
*
|
78 |
* @return javax.swing.JPanel
|
79 |
*/
|
80 |
private JPanel getPCoord() { |
81 |
if (pCoord == null) { |
82 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
83 |
gridBagConstraints2.gridx = 0;
|
84 |
gridBagConstraints2.gridy = 1;
|
85 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
86 |
gridBagConstraints.gridx = 0;
|
87 |
gridBagConstraints.gridy = 0;
|
88 |
pCoord = new JPanel(); |
89 |
pCoord.setLayout(new GridBagLayout()); |
90 |
pCoord.setBorder(javax.swing.BorderFactory.createTitledBorder(null, tituloPanel, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10), null)); |
91 |
pCoord.add(getPData1(), gridBagConstraints); |
92 |
pCoord.add(getPData2(), gridBagConstraints2); |
93 |
} |
94 |
return pCoord;
|
95 |
} |
96 |
|
97 |
/**
|
98 |
* This method initializes jPanel
|
99 |
*
|
100 |
* @return javax.swing.JPanel
|
101 |
*/
|
102 |
private JPanel getPData1() { |
103 |
if (pData1 == null) { |
104 |
FlowLayout flowLayout1 = new FlowLayout(); |
105 |
flowLayout1.setHgap(0);
|
106 |
flowLayout1.setAlignment(java.awt.FlowLayout.LEFT); |
107 |
flowLayout1.setVgap(0);
|
108 |
pData1 = new JPanel(); |
109 |
pData1.setLayout(flowLayout1); |
110 |
pData1.add(getLTitulo1(), null);
|
111 |
pData1.add(getPDataInput11(), null);
|
112 |
pData1.add(getPDataInput12(), null);
|
113 |
//pData1.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
|
114 |
} |
115 |
return pData1;
|
116 |
} |
117 |
|
118 |
private JLabel getLTitulo1(){ |
119 |
if (lTitulo1 == null){ |
120 |
lTitulo1 = new JLabel(); |
121 |
lTitulo1.setText("JLabel");
|
122 |
} |
123 |
return lTitulo1;
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* This method initializes jPanel1
|
128 |
*
|
129 |
* @return javax.swing.JPanel
|
130 |
*/
|
131 |
private JPanel getPData2() { |
132 |
if (pData2 == null) { |
133 |
FlowLayout flowLayout2 = new FlowLayout(); |
134 |
flowLayout2.setHgap(0);
|
135 |
flowLayout2.setAlignment(java.awt.FlowLayout.LEFT); |
136 |
flowLayout2.setVgap(0);
|
137 |
pData2 = new JPanel(); |
138 |
pData2.setLayout(flowLayout2); |
139 |
pData2.add(getLTitulo2(), null);
|
140 |
pData2.add(getPDataInput21(), null);
|
141 |
pData2.add(getPDataInput22(), null);
|
142 |
//pData2.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
|
143 |
} |
144 |
return pData2;
|
145 |
} |
146 |
|
147 |
private JLabel getLTitulo2(){ |
148 |
if (lTitulo2 == null){ |
149 |
lTitulo2 = new JLabel(); |
150 |
lTitulo2.setText("JLabel");
|
151 |
} |
152 |
return lTitulo2;
|
153 |
} |
154 |
|
155 |
/**
|
156 |
* This method initializes jPanel
|
157 |
*
|
158 |
* @return javax.swing.JPanel
|
159 |
*/
|
160 |
public DataInputContainer getPDataInput11() {
|
161 |
if (pDataInput11 == null) { |
162 |
pDataInput11 = new DataInputContainer(0); |
163 |
} |
164 |
return pDataInput11;
|
165 |
} |
166 |
|
167 |
/**
|
168 |
* This method initializes jPanel1
|
169 |
*
|
170 |
* @return javax.swing.JPanel
|
171 |
*/
|
172 |
public DataInputContainer getPDataInput12() {
|
173 |
if (pDataInput12 == null) { |
174 |
pDataInput12 = new DataInputContainer(0); |
175 |
} |
176 |
return pDataInput12;
|
177 |
} |
178 |
|
179 |
/**
|
180 |
* This method initializes jPanel2
|
181 |
*
|
182 |
* @return javax.swing.JPanel
|
183 |
*/
|
184 |
public DataInputContainer getPDataInput21() {
|
185 |
if (pDataInput21 == null) { |
186 |
pDataInput21 = new DataInputContainer(0); |
187 |
} |
188 |
return pDataInput21;
|
189 |
} |
190 |
|
191 |
/**
|
192 |
* This method initializes jPanel3
|
193 |
*
|
194 |
* @return javax.swing.JPanel
|
195 |
*/
|
196 |
public DataInputContainer getPDataInput22() {
|
197 |
if (pDataInput22 == null) { |
198 |
pDataInput22 = new DataInputContainer(0); |
199 |
} |
200 |
return pDataInput22;
|
201 |
} |
202 |
|
203 |
/**
|
204 |
* M?todo para introducir los campos del componente. Por orden de
|
205 |
* arriba a abajo se introducen las cadenas que tienen que ir en el panel.
|
206 |
* @param tPanel
|
207 |
* @param titulo1
|
208 |
* @param celda11
|
209 |
* @param celda12
|
210 |
* @param titulo2
|
211 |
* @param celda21
|
212 |
* @param celda22
|
213 |
*/
|
214 |
public void setParameters(String tPanel, String titulo1, String celda11, String celda12, String titulo2, String celda21, String celda22){ |
215 |
this.tituloPanel = tPanel;
|
216 |
this.lTitulo1.setText(titulo1);
|
217 |
this.pDataInput11.setLabelText(celda11);
|
218 |
this.pDataInput12.setLabelText(celda12);
|
219 |
this.lTitulo2.setText(titulo2);
|
220 |
this.pDataInput21.setLabelText(celda21);
|
221 |
this.pDataInput22.setLabelText(celda22);
|
222 |
pCoord.setBorder(javax.swing.BorderFactory.createTitledBorder(null, tituloPanel, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10), null)); |
223 |
|
224 |
} |
225 |
|
226 |
/**
|
227 |
* Modifica el tama?o del componente.
|
228 |
* @param w
|
229 |
* @param h
|
230 |
*/
|
231 |
public void setComponentSize(int w, int h){ |
232 |
wComp = w; |
233 |
this.getPCoord().setPreferredSize(new java.awt.Dimension(wComp, hComp)); |
234 |
this.getLTitulo1().setPreferredSize(new java.awt.Dimension(wLabels,hLabels)); |
235 |
this.getLTitulo2().setPreferredSize(new java.awt.Dimension(wLabels,hLabels)); |
236 |
this.getPData1().setPreferredSize(new java.awt.Dimension(wComp - MARGIN, hPanel)); |
237 |
this.getPData2().setPreferredSize(new java.awt.Dimension(wComp - MARGIN, hPanel)); |
238 |
|
239 |
wData = (int)Math.floor((wComp - wLabels - 10) >> 1); |
240 |
int MARG = 2; |
241 |
this.getPDataInput11().setPreferredSize(new java.awt.Dimension(wData,hData)); |
242 |
this.pDataInput11.setComponentSize(wData - MARG, hData - MARG);
|
243 |
this.getPDataInput12().setPreferredSize(new java.awt.Dimension(wData,hData)); |
244 |
this.pDataInput12.setComponentSize(wData - MARG, hData - MARG);
|
245 |
this.getPDataInput21().setPreferredSize(new java.awt.Dimension(wData,hData)); |
246 |
this.pDataInput21.setComponentSize(wData - MARG, hData - MARG);
|
247 |
this.getPDataInput22().setPreferredSize(new java.awt.Dimension(wData,hData)); |
248 |
this.pDataInput22.setComponentSize(wData - MARG, hData - MARG);
|
249 |
} |
250 |
|
251 |
/**
|
252 |
* Indica si los campos de texto admiten valores
|
253 |
* decimales o no.
|
254 |
* @param dec
|
255 |
*/
|
256 |
public void setDecimalValues(boolean dec){ |
257 |
this.pDataInput11.setDecimal(dec);
|
258 |
this.pDataInput12.setDecimal(dec);
|
259 |
this.pDataInput21.setDecimal(dec);
|
260 |
this.pDataInput22.setDecimal(dec);
|
261 |
} |
262 |
|
263 |
|
264 |
/**
|
265 |
* Indica si los campos de texto admiten cadenas de
|
266 |
* de caracteres.
|
267 |
* @param car
|
268 |
*/
|
269 |
public void setCaracterValues(boolean car){ |
270 |
this.pDataInput11.setCaracter(car);
|
271 |
this.pDataInput12.setCaracter(car);
|
272 |
this.pDataInput21.setCaracter(car);
|
273 |
this.pDataInput22.setCaracter(car);
|
274 |
} |
275 |
|
276 |
|
277 |
/**
|
278 |
* Devuelve los valores del panel por orden de izquierda a derecha
|
279 |
* y de arriba a bajo.
|
280 |
* @return
|
281 |
*/
|
282 |
public String[] getValues(){ |
283 |
String[] values = {this.pDataInput11.getValue(), |
284 |
this.pDataInput12.getValue(),
|
285 |
this.pDataInput21.getValue(),
|
286 |
this.pDataInput22.getValue()
|
287 |
}; |
288 |
return values;
|
289 |
} |
290 |
|
291 |
/**
|
292 |
* Asigna los valores del panel por orden de izquierda a derecha
|
293 |
* y de arriba a bajo.
|
294 |
* @return
|
295 |
*/
|
296 |
public void setValues(String[] values){ |
297 |
this.pDataInput11.setValue(values[0]); |
298 |
this.pDataInput12.setValue(values[1]); |
299 |
this.pDataInput21.setValue(values[2]); |
300 |
this.pDataInput22.setValue(values[3]); |
301 |
} |
302 |
} |