root / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / coorddatainput / CoordDataInputContainer.java @ 13136
History | View | Annotate | Download (7.83 KB)
1 | 11186 | nacho | /* 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 | 12282 | bsanchez | import java.awt.BorderLayout; |
22 | 11186 | nacho | import java.awt.GridBagConstraints; |
23 | import java.awt.GridBagLayout; |
||
24 | |||
25 | 11415 | bsanchez | import javax.swing.ImageIcon; |
26 | 11186 | nacho | import javax.swing.JLabel; |
27 | import javax.swing.JPanel; |
||
28 | |||
29 | import org.gvsig.gui.beans.datainput.DataInputContainer; |
||
30 | |||
31 | 11445 | bsanchez | public class CoordDataInputContainer extends JPanel { |
32 | 11186 | nacho | private static final long serialVersionUID = 3336324382874763427L; |
33 | 12282 | bsanchez | private String pathToImages = "images/"; |
34 | |||
35 | private JPanel pCoord = null; |
||
36 | private JLabel lTitulo1 = null; |
||
37 | private JLabel lTitulo2 = null; |
||
38 | 11186 | nacho | private DataInputContainer pDataInput11 = null; |
39 | private DataInputContainer pDataInput12 = null; |
||
40 | private DataInputContainer pDataInput21 = null; |
||
41 | private DataInputContainer pDataInput22 = null; |
||
42 | |||
43 | 12282 | bsanchez | private String tituloPanel = "Title"; |
44 | |||
45 | 11186 | nacho | /**
|
46 | * This is the default constructor
|
||
47 | */
|
||
48 | 12282 | bsanchez | public CoordDataInputContainer() {
|
49 | 11186 | nacho | initialize(); |
50 | } |
||
51 | |||
52 | /**
|
||
53 | * This method initializes this
|
||
54 | 12282 | bsanchez | *
|
55 | 11186 | nacho | * @return void
|
56 | */
|
||
57 | private void initialize() { |
||
58 | 12282 | bsanchez | setLayout(new BorderLayout()); |
59 | add(getPCoord(), BorderLayout.CENTER);
|
||
60 | 11186 | nacho | } |
61 | |||
62 | /**
|
||
63 | 12282 | bsanchez | * This method initializes jPanel
|
64 | *
|
||
65 | * @return javax.swing.JPanel
|
||
66 | 11186 | nacho | */
|
67 | private JPanel getPCoord() { |
||
68 | if (pCoord == null) { |
||
69 | 12282 | bsanchez | |
70 | GridBagConstraints gridBagConstraints0 = new GridBagConstraints(); |
||
71 | gridBagConstraints0.gridx = 0;
|
||
72 | gridBagConstraints0.gridy = 0;
|
||
73 | 12284 | bsanchez | gridBagConstraints0.insets = new java.awt.Insets(5, 5, 2, 2); |
74 | 12282 | bsanchez | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
75 | gridBagConstraints1.gridx = 0;
|
||
76 | gridBagConstraints1.gridy = 1;
|
||
77 | 12284 | bsanchez | gridBagConstraints1.insets = new java.awt.Insets(2, 5, 5, 2); |
78 | 12282 | bsanchez | |
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 | 12284 | bsanchez | gridBagConstraints11.insets = new java.awt.Insets(5, 2, 2, 2); |
85 | 12282 | bsanchez | 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 | 12284 | bsanchez | gridBagConstraints12.insets = new java.awt.Insets(5, 2, 2, 5); |
91 | 12282 | bsanchez | 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 | 12284 | bsanchez | gridBagConstraints21.insets = new java.awt.Insets(2, 2, 5, 2); |
97 | 12282 | bsanchez | 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 | 12284 | bsanchez | gridBagConstraints22.insets = new java.awt.Insets(2, 2, 5, 5); |
103 | 12282 | bsanchez | |
104 | 11186 | nacho | 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 | 12282 | bsanchez | |
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 | 11186 | nacho | } |
115 | return pCoord;
|
||
116 | } |
||
117 | |||
118 | private JLabel getLTitulo1(){ |
||
119 | if (lTitulo1 == null){ |
||
120 | 12282 | bsanchez | lTitulo1 = new JLabel(new ImageIcon(getClass().getResource(pathToImages + "upleft.png"))); |
121 | 11186 | nacho | } |
122 | return lTitulo1;
|
||
123 | } |
||
124 | |||
125 | private JLabel getLTitulo2(){ |
||
126 | if (lTitulo2 == null){ |
||
127 | 12282 | bsanchez | lTitulo2 = new JLabel(new ImageIcon(getClass().getResource(pathToImages + "downright.png"))); |
128 | 11186 | nacho | } |
129 | return lTitulo2;
|
||
130 | } |
||
131 | |||
132 | /**
|
||
133 | 12282 | bsanchez | * This method initializes jPanel
|
134 | *
|
||
135 | * @return javax.swing.JPanel
|
||
136 | 11186 | nacho | */
|
137 | public DataInputContainer getPDataInput11() {
|
||
138 | if (pDataInput11 == null) { |
||
139 | 12282 | bsanchez | pDataInput11 = new DataInputContainer();
|
140 | pDataInput11.setLabelText("X:");
|
||
141 | 11186 | nacho | } |
142 | return pDataInput11;
|
||
143 | } |
||
144 | |||
145 | /**
|
||
146 | 12282 | bsanchez | * This method initializes jPanel1
|
147 | *
|
||
148 | * @return javax.swing.JPanel
|
||
149 | 11186 | nacho | */
|
150 | public DataInputContainer getPDataInput12() {
|
||
151 | if (pDataInput12 == null) { |
||
152 | 12282 | bsanchez | pDataInput12 = new DataInputContainer();
|
153 | pDataInput12.setLabelText("Y:");
|
||
154 | 11186 | nacho | } |
155 | return pDataInput12;
|
||
156 | } |
||
157 | |||
158 | /**
|
||
159 | 12282 | bsanchez | * This method initializes jPanel2
|
160 | *
|
||
161 | * @return javax.swing.JPanel
|
||
162 | 11186 | nacho | */
|
163 | public DataInputContainer getPDataInput21() {
|
||
164 | if (pDataInput21 == null) { |
||
165 | 12282 | bsanchez | pDataInput21 = new DataInputContainer();
|
166 | pDataInput21.setLabelText("X:");
|
||
167 | 11186 | nacho | } |
168 | return pDataInput21;
|
||
169 | } |
||
170 | |||
171 | /**
|
||
172 | 12282 | bsanchez | * This method initializes jPanel3
|
173 | *
|
||
174 | * @return javax.swing.JPanel
|
||
175 | 11186 | nacho | */
|
176 | public DataInputContainer getPDataInput22() {
|
||
177 | if (pDataInput22 == null) { |
||
178 | 12282 | bsanchez | pDataInput22 = new DataInputContainer();
|
179 | pDataInput22.setLabelText("Y:");
|
||
180 | 11186 | nacho | } |
181 | return pDataInput22;
|
||
182 | } |
||
183 | 12282 | bsanchez | |
184 | 11186 | nacho | /**
|
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 | 12282 | bsanchez | |
203 | 11186 | nacho | } |
204 | 12282 | bsanchez | |
205 | 11186 | nacho | /**
|
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 | 12282 | bsanchez | |
217 | |||
218 | 11186 | nacho | /**
|
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 | 12282 | bsanchez | |
230 | |||
231 | 11186 | nacho | /**
|
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 | 12282 | bsanchez | |
245 | 11186 | nacho | /**
|
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 | } |