root / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / coorddatainput / CoordDataInputContainer.java @ 12284
History | View | Annotate | Download (7.83 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.BorderLayout; |
22 |
import java.awt.GridBagConstraints; |
23 |
import java.awt.GridBagLayout; |
24 |
|
25 |
import javax.swing.ImageIcon; |
26 |
import javax.swing.JLabel; |
27 |
import javax.swing.JPanel; |
28 |
|
29 |
import org.gvsig.gui.beans.datainput.DataInputContainer; |
30 |
|
31 |
public class CoordDataInputContainer extends JPanel { |
32 |
private static final long serialVersionUID = 3336324382874763427L; |
33 |
private String pathToImages = "images/"; |
34 |
|
35 |
private JPanel pCoord = null; |
36 |
private JLabel lTitulo1 = null; |
37 |
private JLabel lTitulo2 = null; |
38 |
private DataInputContainer pDataInput11 = null; |
39 |
private DataInputContainer pDataInput12 = null; |
40 |
private DataInputContainer pDataInput21 = null; |
41 |
private DataInputContainer pDataInput22 = null; |
42 |
|
43 |
private String tituloPanel = "Title"; |
44 |
|
45 |
/**
|
46 |
* This is the default constructor
|
47 |
*/
|
48 |
public CoordDataInputContainer() {
|
49 |
initialize(); |
50 |
} |
51 |
|
52 |
/**
|
53 |
* This method initializes this
|
54 |
*
|
55 |
* @return void
|
56 |
*/
|
57 |
private void initialize() { |
58 |
setLayout(new BorderLayout()); |
59 |
add(getPCoord(), BorderLayout.CENTER);
|
60 |
} |
61 |
|
62 |
/**
|
63 |
* This method initializes jPanel
|
64 |
*
|
65 |
* @return javax.swing.JPanel
|
66 |
*/
|
67 |
private JPanel getPCoord() { |
68 |
if (pCoord == null) { |
69 |
|
70 |
GridBagConstraints gridBagConstraints0 = new GridBagConstraints(); |
71 |
gridBagConstraints0.gridx = 0;
|
72 |
gridBagConstraints0.gridy = 0;
|
73 |
gridBagConstraints0.insets = new java.awt.Insets(5, 5, 2, 2); |
74 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
75 |
gridBagConstraints1.gridx = 0;
|
76 |
gridBagConstraints1.gridy = 1;
|
77 |
gridBagConstraints1.insets = new java.awt.Insets(2, 5, 5, 2); |
78 |
|
79 |
GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
80 |
gridBagConstraints11.gridx = 1;
|
81 |
gridBagConstraints11.gridy = 0;
|
82 |
gridBagConstraints11.fill = java.awt.GridBagConstraints.HORIZONTAL; |
83 |
gridBagConstraints11.weightx = 1.0;
|
84 |
gridBagConstraints11.insets = new java.awt.Insets(5, 2, 2, 2); |
85 |
GridBagConstraints gridBagConstraints12 = new GridBagConstraints(); |
86 |
gridBagConstraints12.gridx = 2;
|
87 |
gridBagConstraints12.gridy = 0;
|
88 |
gridBagConstraints12.fill = java.awt.GridBagConstraints.HORIZONTAL; |
89 |
gridBagConstraints12.weightx = 1.0;
|
90 |
gridBagConstraints12.insets = new java.awt.Insets(5, 2, 2, 5); |
91 |
GridBagConstraints gridBagConstraints21 = new GridBagConstraints(); |
92 |
gridBagConstraints21.gridx = 1;
|
93 |
gridBagConstraints21.gridy = 1;
|
94 |
gridBagConstraints21.fill = java.awt.GridBagConstraints.HORIZONTAL; |
95 |
gridBagConstraints21.weightx = 1.0;
|
96 |
gridBagConstraints21.insets = new java.awt.Insets(2, 2, 5, 2); |
97 |
GridBagConstraints gridBagConstraints22 = new GridBagConstraints(); |
98 |
gridBagConstraints22.gridx = 2;
|
99 |
gridBagConstraints22.gridy = 1;
|
100 |
gridBagConstraints22.fill = java.awt.GridBagConstraints.HORIZONTAL; |
101 |
gridBagConstraints22.weightx = 1.0;
|
102 |
gridBagConstraints22.insets = new java.awt.Insets(2, 2, 5, 5); |
103 |
|
104 |
pCoord = new JPanel(); |
105 |
pCoord.setLayout(new GridBagLayout()); |
106 |
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)); |
107 |
|
108 |
pCoord.add(getLTitulo1(), gridBagConstraints0); |
109 |
pCoord.add(getLTitulo2(), gridBagConstraints1); |
110 |
pCoord.add(getPDataInput11(), gridBagConstraints11); |
111 |
pCoord.add(getPDataInput12(), gridBagConstraints12); |
112 |
pCoord.add(getPDataInput21(), gridBagConstraints21); |
113 |
pCoord.add(getPDataInput22(), gridBagConstraints22); |
114 |
} |
115 |
return pCoord;
|
116 |
} |
117 |
|
118 |
private JLabel getLTitulo1(){ |
119 |
if (lTitulo1 == null){ |
120 |
lTitulo1 = new JLabel(new ImageIcon(getClass().getResource(pathToImages + "upleft.png"))); |
121 |
} |
122 |
return lTitulo1;
|
123 |
} |
124 |
|
125 |
private JLabel getLTitulo2(){ |
126 |
if (lTitulo2 == null){ |
127 |
lTitulo2 = new JLabel(new ImageIcon(getClass().getResource(pathToImages + "downright.png"))); |
128 |
} |
129 |
return lTitulo2;
|
130 |
} |
131 |
|
132 |
/**
|
133 |
* This method initializes jPanel
|
134 |
*
|
135 |
* @return javax.swing.JPanel
|
136 |
*/
|
137 |
public DataInputContainer getPDataInput11() {
|
138 |
if (pDataInput11 == null) { |
139 |
pDataInput11 = new DataInputContainer();
|
140 |
pDataInput11.setLabelText("X:");
|
141 |
} |
142 |
return pDataInput11;
|
143 |
} |
144 |
|
145 |
/**
|
146 |
* This method initializes jPanel1
|
147 |
*
|
148 |
* @return javax.swing.JPanel
|
149 |
*/
|
150 |
public DataInputContainer getPDataInput12() {
|
151 |
if (pDataInput12 == null) { |
152 |
pDataInput12 = new DataInputContainer();
|
153 |
pDataInput12.setLabelText("Y:");
|
154 |
} |
155 |
return pDataInput12;
|
156 |
} |
157 |
|
158 |
/**
|
159 |
* This method initializes jPanel2
|
160 |
*
|
161 |
* @return javax.swing.JPanel
|
162 |
*/
|
163 |
public DataInputContainer getPDataInput21() {
|
164 |
if (pDataInput21 == null) { |
165 |
pDataInput21 = new DataInputContainer();
|
166 |
pDataInput21.setLabelText("X:");
|
167 |
} |
168 |
return pDataInput21;
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* This method initializes jPanel3
|
173 |
*
|
174 |
* @return javax.swing.JPanel
|
175 |
*/
|
176 |
public DataInputContainer getPDataInput22() {
|
177 |
if (pDataInput22 == null) { |
178 |
pDataInput22 = new DataInputContainer();
|
179 |
pDataInput22.setLabelText("Y:");
|
180 |
} |
181 |
return pDataInput22;
|
182 |
} |
183 |
|
184 |
/**
|
185 |
* M?todo para introducir los campos del componente. Por orden de
|
186 |
* arriba a abajo se introducen las cadenas que tienen que ir en el panel.
|
187 |
* @param tPanel
|
188 |
* @param titulo1
|
189 |
* @param celda11
|
190 |
* @param celda12
|
191 |
* @param titulo2
|
192 |
* @param celda21
|
193 |
* @param celda22
|
194 |
*/
|
195 |
public void setParameters(String tPanel, String titulo1, String celda11, String celda12, String titulo2, String celda21, String celda22){ |
196 |
this.tituloPanel = tPanel;
|
197 |
this.pDataInput11.setLabelText(celda11);
|
198 |
this.pDataInput12.setLabelText(celda12);
|
199 |
this.pDataInput21.setLabelText(celda21);
|
200 |
this.pDataInput22.setLabelText(celda22);
|
201 |
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)); |
202 |
|
203 |
} |
204 |
|
205 |
/**
|
206 |
* Indica si los campos de texto admiten valores
|
207 |
* decimales o no.
|
208 |
* @param dec
|
209 |
*/
|
210 |
public void setDecimalValues(boolean dec){ |
211 |
this.pDataInput11.setDecimal(dec);
|
212 |
this.pDataInput12.setDecimal(dec);
|
213 |
this.pDataInput21.setDecimal(dec);
|
214 |
this.pDataInput22.setDecimal(dec);
|
215 |
} |
216 |
|
217 |
|
218 |
/**
|
219 |
* Indica si los campos de texto admiten cadenas de
|
220 |
* de caracteres.
|
221 |
* @param car
|
222 |
*/
|
223 |
public void setCaracterValues(boolean car){ |
224 |
this.pDataInput11.setCaracter(car);
|
225 |
this.pDataInput12.setCaracter(car);
|
226 |
this.pDataInput21.setCaracter(car);
|
227 |
this.pDataInput22.setCaracter(car);
|
228 |
} |
229 |
|
230 |
|
231 |
/**
|
232 |
* Devuelve los valores del panel por orden de izquierda a derecha
|
233 |
* y de arriba a bajo.
|
234 |
* @return
|
235 |
*/
|
236 |
public String[] getValues(){ |
237 |
String[] values = {this.pDataInput11.getValue(), |
238 |
this.pDataInput12.getValue(),
|
239 |
this.pDataInput21.getValue(),
|
240 |
this.pDataInput22.getValue()
|
241 |
}; |
242 |
return values;
|
243 |
} |
244 |
|
245 |
/**
|
246 |
* Asigna los valores del panel por orden de izquierda a derecha
|
247 |
* y de arriba a bajo.
|
248 |
* @return
|
249 |
*/
|
250 |
public void setValues(String[] values){ |
251 |
this.pDataInput11.setValue(values[0]); |
252 |
this.pDataInput12.setValue(values[1]); |
253 |
this.pDataInput21.setValue(values[2]); |
254 |
this.pDataInput22.setValue(values[3]); |
255 |
} |
256 |
} |