svn-gvsig-desktop / tags / v1_0_2_Build_905 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / panels / MappingFieldsToAnotation.java @ 10767
History | View | Annotate | Download (10.2 KB)
1 | 6117 | jaume | package com.iver.cit.gvsig.gui.panels; |
---|---|---|---|
2 | |||
3 | import java.sql.Types; |
||
4 | |||
5 | 8765 | jjdelcerro | import javax.swing.ButtonGroup; |
6 | import javax.swing.JButton; |
||
7 | import javax.swing.JComboBox; |
||
8 | import javax.swing.JLabel; |
||
9 | 6117 | jaume | import javax.swing.JPanel; |
10 | 8765 | jjdelcerro | import javax.swing.JRadioButton; |
11 | import javax.swing.JTextField; |
||
12 | 6117 | jaume | |
13 | import com.hardcode.gdbms.engine.data.driver.DriverException; |
||
14 | import com.iver.andami.PluginServices; |
||
15 | 6877 | cesar | import com.iver.andami.ui.mdiManager.IWindow; |
16 | 6880 | cesar | import com.iver.andami.ui.mdiManager.WindowInfo; |
17 | 6117 | jaume | import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation; |
18 | import com.iver.cit.gvsig.fmap.layers.MappingAnnotation; |
||
19 | import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
||
20 | |||
21 | 6877 | cesar | public class MappingFieldsToAnotation extends JPanel implements IWindow{ |
22 | 6117 | jaume | |
23 | private JComboBox cmbText = null; |
||
24 | private JComboBox cmbAngle = null; |
||
25 | private JLabel jLabel = null; |
||
26 | private JLabel jLabel1 = null; |
||
27 | private JLabel jLabel2 = null; |
||
28 | private JComboBox cmbColor = null; |
||
29 | private JLabel jLabel3 = null; |
||
30 | private JComboBox cmbHeight = null; |
||
31 | private JLabel jLabel4 = null; |
||
32 | private JComboBox cmbFont = null; |
||
33 | private JButton bOk = null; |
||
34 | private JButton bCancel = null; |
||
35 | private SelectableDataSource sds=null; |
||
36 | private FLyrAnnotation la;
|
||
37 | private int[] mapText; |
||
38 | private int[] mapAngle; |
||
39 | private int[] mapColor; |
||
40 | private int[] mapHeight; |
||
41 | private int[] mapFont; |
||
42 | private JPanel jPanel = null; |
||
43 | private JLabel jLabel5 = null; |
||
44 | private JTextField txtName = null; |
||
45 | //private JCheckBox chbPixels = null;
|
||
46 | private JRadioButton rbMapUnits = null; |
||
47 | private JRadioButton rbPixels = null; |
||
48 | private boolean isOk=false; |
||
49 | /**
|
||
50 | * This is the default constructor
|
||
51 | */
|
||
52 | public MappingFieldsToAnotation(FLyrAnnotation la) {
|
||
53 | super();
|
||
54 | this.la=la;
|
||
55 | try {
|
||
56 | this.sds=la.getRecordset();
|
||
57 | initialize(); |
||
58 | } catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
||
59 | // TODO Auto-generated catch block
|
||
60 | e.printStackTrace(); |
||
61 | } |
||
62 | |||
63 | } |
||
64 | |||
65 | /**
|
||
66 | * This method initializes this
|
||
67 | *
|
||
68 | * @return void
|
||
69 | */
|
||
70 | private void initialize() { |
||
71 | jLabel4 = new JLabel(); |
||
72 | jLabel4.setBounds(new java.awt.Rectangle(15,259,166,20)); |
||
73 | jLabel4.setText("fuente");
|
||
74 | jLabel3 = new JLabel(); |
||
75 | jLabel3.setBounds(new java.awt.Rectangle(15,197,166,20)); |
||
76 | jLabel3.setText("alto");
|
||
77 | jLabel2 = new JLabel(); |
||
78 | jLabel2.setBounds(new java.awt.Rectangle(15,135,166,20)); |
||
79 | jLabel2.setText("color");
|
||
80 | jLabel1 = new JLabel(); |
||
81 | jLabel1.setBounds(new java.awt.Rectangle(15,73,166,20)); |
||
82 | jLabel1.setText("angulo");
|
||
83 | jLabel = new JLabel(); |
||
84 | jLabel.setBounds(new java.awt.Rectangle(15,11,166,20)); |
||
85 | jLabel.setText("texto");
|
||
86 | this.setLayout(null); |
||
87 | this.setSize(544, 368); |
||
88 | this.add(getCmbText(), null); |
||
89 | this.add(getCmbAngle(), null); |
||
90 | this.add(jLabel, null); |
||
91 | this.add(jLabel1, null); |
||
92 | this.add(jLabel2, null); |
||
93 | this.add(getCmbColor(), null); |
||
94 | this.add(jLabel3, null); |
||
95 | this.add(getCmbHeight(), null); |
||
96 | this.add(jLabel4, null); |
||
97 | this.add(getCmbFont(), null); |
||
98 | this.add(getBOk(), null); |
||
99 | this.add(getBCancel(), null); |
||
100 | this.add(getJPanel(), null); |
||
101 | } |
||
102 | |||
103 | 6880 | cesar | public WindowInfo getWindowInfo() {
|
104 | WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
||
105 | 6117 | jaume | m_viewinfo.setTitle(PluginServices.getText(this,
|
106 | "indexar_campos"));
|
||
107 | |||
108 | return m_viewinfo;
|
||
109 | } |
||
110 | |||
111 | /**
|
||
112 | * This method initializes cmbOrigin
|
||
113 | *
|
||
114 | * @return javax.swing.JComboBox
|
||
115 | */
|
||
116 | private JComboBox getCmbText() { |
||
117 | if (cmbText == null) { |
||
118 | cmbText = new JComboBox(); |
||
119 | try {
|
||
120 | mapText=new int[sds.getFieldCount()]; |
||
121 | int num=-1; |
||
122 | for (int i = 0; i < sds.getFieldCount(); i++) { |
||
123 | cmbText.addItem(sds.getFieldName(i)); |
||
124 | num++; |
||
125 | mapText[i]=num; |
||
126 | } |
||
127 | //cmbText.addItem("- Defaulf -");
|
||
128 | } catch (DriverException e) {
|
||
129 | e.printStackTrace(); |
||
130 | } |
||
131 | cmbText.setBounds(new java.awt.Rectangle(15,42,166,20)); |
||
132 | |||
133 | } |
||
134 | return cmbText;
|
||
135 | } |
||
136 | |||
137 | /**
|
||
138 | * This method initializes cmbEnd
|
||
139 | *
|
||
140 | * @return javax.swing.JComboBox
|
||
141 | */
|
||
142 | private JComboBox getCmbAngle() { |
||
143 | if (cmbAngle == null) { |
||
144 | cmbAngle = new JComboBox(); |
||
145 | try {
|
||
146 | mapAngle=new int[sds.getFieldCount()]; |
||
147 | int num=-1; |
||
148 | for (int i = 0; i < sds.getFieldCount(); i++) { |
||
149 | if (sds.getFieldType(i) == Types.DOUBLE){ |
||
150 | cmbAngle.addItem(sds.getFieldName(i)); |
||
151 | num++; |
||
152 | mapAngle[i]=num; |
||
153 | } |
||
154 | } |
||
155 | cmbAngle.addItem("- Default -");
|
||
156 | cmbAngle.setSelectedItem("- Default -");
|
||
157 | } catch (DriverException e) {
|
||
158 | e.printStackTrace(); |
||
159 | } |
||
160 | cmbAngle.setBounds(new java.awt.Rectangle(15,104,166,20)); |
||
161 | } |
||
162 | return cmbAngle;
|
||
163 | } |
||
164 | |||
165 | /**
|
||
166 | * This method initializes cmbColor
|
||
167 | *
|
||
168 | * @return javax.swing.JComboBox
|
||
169 | */
|
||
170 | private JComboBox getCmbColor() { |
||
171 | if (cmbColor == null) { |
||
172 | cmbColor = new JComboBox(); |
||
173 | cmbColor.setBounds(new java.awt.Rectangle(15,166,166,20)); |
||
174 | try {
|
||
175 | mapColor=new int[sds.getFieldCount()]; |
||
176 | int num=-1; |
||
177 | for (int i = 0; i < sds.getFieldCount(); i++) { |
||
178 | if (sds.getFieldType(i) == Types.DOUBLE){ |
||
179 | cmbColor.addItem(sds.getFieldName(i)); |
||
180 | num++; |
||
181 | mapColor[i]=num; |
||
182 | } |
||
183 | } |
||
184 | cmbColor.addItem("- Default -");
|
||
185 | cmbColor.setSelectedItem("- Default -");
|
||
186 | } catch (DriverException e) {
|
||
187 | e.printStackTrace(); |
||
188 | } |
||
189 | } |
||
190 | return cmbColor;
|
||
191 | } |
||
192 | |||
193 | /**
|
||
194 | * This method initializes cmbHeight
|
||
195 | *
|
||
196 | * @return javax.swing.JComboBox
|
||
197 | */
|
||
198 | private JComboBox getCmbHeight() { |
||
199 | if (cmbHeight == null) { |
||
200 | cmbHeight = new JComboBox(); |
||
201 | try {
|
||
202 | mapHeight=new int[sds.getFieldCount()]; |
||
203 | int num=-1; |
||
204 | for (int i = 0; i < sds.getFieldCount(); i++) { |
||
205 | if (sds.getFieldType(i) == Types.DOUBLE){ |
||
206 | cmbHeight.addItem(sds.getFieldName(i)); |
||
207 | num++; |
||
208 | mapHeight[i]=num; |
||
209 | } |
||
210 | } |
||
211 | cmbHeight.addItem("- Default -");
|
||
212 | cmbHeight.setSelectedItem("- Default -");
|
||
213 | } catch (DriverException e) {
|
||
214 | e.printStackTrace(); |
||
215 | } |
||
216 | cmbHeight.setBounds(new java.awt.Rectangle(15,228,166,20)); |
||
217 | } |
||
218 | return cmbHeight;
|
||
219 | } |
||
220 | |||
221 | /**
|
||
222 | * This method initializes cmbFont
|
||
223 | *
|
||
224 | * @return javax.swing.JComboBox
|
||
225 | */
|
||
226 | private JComboBox getCmbFont() { |
||
227 | if (cmbFont == null) { |
||
228 | cmbFont = new JComboBox(); |
||
229 | try {
|
||
230 | mapFont=new int[sds.getFieldCount()]; |
||
231 | int num=-1; |
||
232 | for (int i = 0; i < sds.getFieldCount(); i++) { |
||
233 | if (sds.getFieldType(i) == Types.VARCHAR){ |
||
234 | cmbFont.addItem(sds.getFieldName(i)); |
||
235 | num++; |
||
236 | mapFont[i]=num; |
||
237 | } |
||
238 | } |
||
239 | cmbFont.addItem("- Default -");
|
||
240 | cmbFont.setSelectedItem("- Default -");
|
||
241 | } catch (DriverException e) {
|
||
242 | e.printStackTrace(); |
||
243 | } |
||
244 | cmbFont.setBounds(new java.awt.Rectangle(15,290,166,20)); |
||
245 | } |
||
246 | return cmbFont;
|
||
247 | } |
||
248 | |||
249 | /**
|
||
250 | * This method initializes bOk
|
||
251 | *
|
||
252 | * @return javax.swing.JButton
|
||
253 | */
|
||
254 | private JButton getBOk() { |
||
255 | if (bOk == null) { |
||
256 | bOk = new JButton(); |
||
257 | bOk.setBounds(new java.awt.Rectangle(119,326,92,24)); |
||
258 | bOk.setText("Aceptar");
|
||
259 | bOk.addActionListener(new java.awt.event.ActionListener() {
|
||
260 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
261 | MappingAnnotation mapping=new MappingAnnotation();
|
||
262 | if (getCmbText().getSelectedItem().equals("")) |
||
263 | mapping.setColumnText(-1);
|
||
264 | else
|
||
265 | mapping.setColumnText(mapText[getCmbText().getSelectedIndex()]); |
||
266 | if (!getCmbAngle().getSelectedItem().equals("- Default -")) |
||
267 | mapping.setColumnRotate(mapAngle[getCmbAngle().getSelectedIndex()]); |
||
268 | if (!getCmbColor().getSelectedItem().equals("- Default -")) |
||
269 | mapping.setColumnColor(mapColor[getCmbColor().getSelectedIndex()]); |
||
270 | if (!getCmbHeight().getSelectedItem().equals("- Default -")) |
||
271 | mapping.setColumnHeight(mapHeight[getCmbHeight().getSelectedIndex()]); |
||
272 | if (!getCmbFont().getSelectedItem().equals("- Default -")) |
||
273 | mapping.setColumnTypeFont(mapFont[getCmbFont().getSelectedIndex()]); |
||
274 | //Falta el estilo, si es necesario.
|
||
275 | la.setInPixels(rbPixels.isSelected()); |
||
276 | la.setMapping(mapping); |
||
277 | la.setName(getTxtName().getText()); |
||
278 | isOk=true;
|
||
279 | 6880 | cesar | PluginServices.getMDIManager().closeWindow(MappingFieldsToAnotation.this); |
280 | 6117 | jaume | } |
281 | }); |
||
282 | } |
||
283 | return bOk;
|
||
284 | } |
||
285 | |||
286 | /**
|
||
287 | * This method initializes bCancel
|
||
288 | *
|
||
289 | * @return javax.swing.JButton
|
||
290 | */
|
||
291 | private JButton getBCancel() { |
||
292 | if (bCancel == null) { |
||
293 | bCancel = new JButton(); |
||
294 | bCancel.setBounds(new java.awt.Rectangle(330,325,93,25)); |
||
295 | bCancel.setText("cancelar");
|
||
296 | bCancel.addActionListener(new java.awt.event.ActionListener() {
|
||
297 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
298 | isOk=false;
|
||
299 | 6880 | cesar | PluginServices.getMDIManager().closeWindow(MappingFieldsToAnotation.this); |
300 | 6117 | jaume | } |
301 | }); |
||
302 | } |
||
303 | return bCancel;
|
||
304 | } |
||
305 | |||
306 | /**
|
||
307 | * This method initializes jPanel
|
||
308 | *
|
||
309 | * @return javax.swing.JPanel
|
||
310 | */
|
||
311 | private JPanel getJPanel() { |
||
312 | if (jPanel == null) { |
||
313 | jLabel5 = new JLabel(); |
||
314 | jLabel5.setBounds(new java.awt.Rectangle(15,10,228,22)); |
||
315 | jLabel5.setText("nombre");
|
||
316 | jPanel = new JPanel(); |
||
317 | jPanel.setLayout(null);
|
||
318 | jPanel.setBounds(new java.awt.Rectangle(234,14,251,141)); |
||
319 | jPanel.add(jLabel5, null);
|
||
320 | jPanel.add(getTxtName(), null);
|
||
321 | //jPanel.add(getChbPixels(), null);
|
||
322 | jPanel.add(getRbMapUnits(), null);
|
||
323 | jPanel.add(getRbPixels(), null);
|
||
324 | ButtonGroup bg=new ButtonGroup(); |
||
325 | bg.add(getRbMapUnits()); |
||
326 | bg.add(getRbPixels()); |
||
327 | } |
||
328 | return jPanel;
|
||
329 | } |
||
330 | |||
331 | /**
|
||
332 | * This method initializes txtName
|
||
333 | *
|
||
334 | * @return javax.swing.JTextField
|
||
335 | */
|
||
336 | private JTextField getTxtName() { |
||
337 | if (txtName == null) { |
||
338 | txtName = new JTextField(); |
||
339 | //txtName.setText(la.get.getName());
|
||
340 | txtName.setBounds(new java.awt.Rectangle(15,42,227,22)); |
||
341 | } |
||
342 | return txtName;
|
||
343 | } |
||
344 | |||
345 | /**
|
||
346 | * This method initializes chbPixels
|
||
347 | *
|
||
348 | * @return javax.swing.JCheckBox
|
||
349 | */
|
||
350 | /*private JCheckBox getChbPixels() {
|
||
351 | if (chbPixels == null) {
|
||
352 | chbPixels = new JCheckBox();
|
||
353 | chbPixels.setBounds(new java.awt.Rectangle(15,138,226,25));
|
||
354 | chbPixels.setText("pixels");
|
||
355 | }
|
||
356 | return chbPixels;
|
||
357 | }
|
||
358 | */
|
||
359 | /**
|
||
360 | * This method initializes rbMapUnits
|
||
361 | *
|
||
362 | * @return javax.swing.JRadioButton
|
||
363 | */
|
||
364 | private JRadioButton getRbMapUnits() { |
||
365 | if (rbMapUnits == null) { |
||
366 | rbMapUnits = new JRadioButton(); |
||
367 | rbMapUnits.setBounds(new java.awt.Rectangle(15,74,167,22)); |
||
368 | rbMapUnits.setText("unidades_mapa");
|
||
369 | } |
||
370 | return rbMapUnits;
|
||
371 | } |
||
372 | |||
373 | /**
|
||
374 | * This method initializes rbPixels
|
||
375 | *
|
||
376 | * @return javax.swing.JRadioButton
|
||
377 | */
|
||
378 | private JRadioButton getRbPixels() { |
||
379 | if (rbPixels == null) { |
||
380 | rbPixels = new JRadioButton(); |
||
381 | rbPixels.setBounds(new java.awt.Rectangle(15,106,167,22)); |
||
382 | rbPixels.setText("pixels");
|
||
383 | rbPixels.setSelected(true);
|
||
384 | } |
||
385 | return rbPixels;
|
||
386 | } |
||
387 | |||
388 | public boolean isOk() { |
||
389 | return isOk;
|
||
390 | } |
||
391 | |||
392 | } // @jve:decl-index=0:visual-constraint="-150,10" |